refactored IgnoredController
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "controllers/ignores/IgnoreModel.hpp"
|
||||
#include "util/PersistSignalVector.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
@@ -12,22 +13,7 @@ void IgnoreController::initialize(Settings &, Paths &)
|
||||
assert(!this->initialized_);
|
||||
this->initialized_ = true;
|
||||
|
||||
for (const IgnorePhrase &phrase : this->ignoresSetting_.getValue())
|
||||
{
|
||||
this->phrases.append(phrase);
|
||||
}
|
||||
|
||||
this->phrases.delayedItemsChanged.connect([this] { //
|
||||
this->ignoresSetting_.setValue(this->phrases.raw());
|
||||
});
|
||||
}
|
||||
|
||||
IgnoreModel *IgnoreController::createModel(QObject *parent)
|
||||
{
|
||||
IgnoreModel *model = new IgnoreModel(parent);
|
||||
model->initialize(&this->phrases);
|
||||
|
||||
return model;
|
||||
persist(this->phrases, "/ignore/phrases");
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -21,13 +21,8 @@ public:
|
||||
|
||||
SignalVector<IgnorePhrase> phrases;
|
||||
|
||||
IgnoreModel *createModel(QObject *parent);
|
||||
|
||||
private:
|
||||
bool initialized_ = false;
|
||||
|
||||
ChatterinoSetting<std::vector<IgnorePhrase>> ignoresSetting_ = {
|
||||
"/ignore/phrases"};
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class IgnoreController;
|
||||
|
||||
class IgnoreModel : public SignalVectorModel<IgnorePhrase>
|
||||
{
|
||||
public:
|
||||
explicit IgnoreModel(QObject *parent);
|
||||
|
||||
protected:
|
||||
@@ -21,8 +20,6 @@ protected:
|
||||
// turns a row in the model into a vector item
|
||||
virtual void getRowFromItem(const IgnorePhrase &item,
|
||||
std::vector<QStandardItem *> &row) override;
|
||||
|
||||
friend class IgnoreController;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user