mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
refactored ModeratinActions
This commit is contained in:
parent
8ae9abb250
commit
df91ea44c4
4 changed files with 5 additions and 40 deletions
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
class ModerationActions;
|
||||
|
||||
class ModerationActionModel : public SignalVectorModel<ModerationAction>
|
||||
{
|
||||
public:
|
||||
|
@ -25,8 +23,6 @@ protected:
|
|||
std::vector<QStandardItem *> &row) override;
|
||||
|
||||
friend class HighlightController;
|
||||
|
||||
friend class ModerationActions;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -2,41 +2,18 @@
|
|||
|
||||
#include "Application.hpp"
|
||||
#include "controllers/moderationactions/ModerationActionModel.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "util/PersistSignalVector.hpp"
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
ModerationActions::ModerationActions()
|
||||
{
|
||||
}
|
||||
|
||||
void ModerationActions::initialize(Settings &settings, Paths &paths)
|
||||
{
|
||||
assert(!this->initialized_);
|
||||
this->initialized_ = true;
|
||||
|
||||
this->setting_ =
|
||||
std::make_unique<ChatterinoSetting<std::vector<ModerationAction>>>(
|
||||
"/moderation/actions");
|
||||
|
||||
for (auto &val : this->setting_->getValue())
|
||||
{
|
||||
this->items.insert(val);
|
||||
}
|
||||
|
||||
this->items.delayedItemsChanged.connect([this] { //
|
||||
this->setting_->setValue(this->items.raw());
|
||||
});
|
||||
}
|
||||
|
||||
ModerationActionModel *ModerationActions::createModel(QObject *parent)
|
||||
{
|
||||
ModerationActionModel *model = new ModerationActionModel(parent);
|
||||
model->initialize(&this->items);
|
||||
|
||||
return model;
|
||||
persist(this->items, "/moderation/actions");
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "common/Singleton.hpp"
|
||||
|
||||
#include "common/ChatterinoSetting.hpp"
|
||||
#include "common/SignalVector.hpp"
|
||||
#include "common/Singleton.hpp"
|
||||
#include "controllers/moderationactions/ModerationAction.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
@ -11,21 +9,14 @@ namespace chatterino {
|
|||
class Settings;
|
||||
class Paths;
|
||||
|
||||
class ModerationActionModel;
|
||||
|
||||
class ModerationActions final : public Singleton
|
||||
{
|
||||
public:
|
||||
ModerationActions();
|
||||
|
||||
virtual void initialize(Settings &settings, Paths &paths) override;
|
||||
|
||||
SignalVector<ModerationAction> items;
|
||||
|
||||
ModerationActionModel *createModel(QObject *parent);
|
||||
|
||||
private:
|
||||
std::unique_ptr<ChatterinoSetting<std::vector<ModerationAction>>> setting_;
|
||||
bool initialized_ = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -174,7 +174,8 @@ ModerationPage::ModerationPage()
|
|||
EditableModelView *view =
|
||||
modMode
|
||||
.emplace<EditableModelView>(
|
||||
app->moderationActions->createModel(nullptr))
|
||||
(new ModerationActionModel(nullptr))
|
||||
->initialized(&app->moderationActions->items))
|
||||
.getElement();
|
||||
|
||||
view->setTitles({"Actions"});
|
||||
|
|
Loading…
Reference in a new issue