X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fignorelistmodel.cpp;h=d95db34fd4dacebba1e6386d00063e0783b03ccf;hp=99d6231bb14a02b582b9336eb9f634497171bcbc;hb=158443f71d48215eea8b47b836b61afd77654b78;hpb=694f9bfbf7f1af19108461c7e00d133e55082bce diff --git a/src/qtui/settingspages/ignorelistmodel.cpp b/src/qtui/settingspages/ignorelistmodel.cpp index 99d6231b..d95db34f 100644 --- a/src/qtui/settingspages/ignorelistmodel.cpp +++ b/src/qtui/settingspages/ignorelistmodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "ignorelistmodel.h" @@ -28,9 +28,7 @@ #include "signalproxy.h" IgnoreListModel::IgnoreListModel(QObject *parent) - : QAbstractItemModel(parent), - _configChanged(false), - _modelReady(false) + : QAbstractItemModel(parent) { // we need this signal for future connects to reset the data; connect(Client::instance(), SIGNAL(connected()), this, SLOT(clientConnected())); @@ -87,19 +85,20 @@ QVariant IgnoreListModel::data(const QModelIndex &index, int role) const case Qt::DisplayRole: switch (index.column()) { case 1: - if (ignoreListManager()[index.row()].type == IgnoreListManager::SenderIgnore) + if (ignoreListManager()[index.row()].type() == IgnoreListManager::SenderIgnore) return tr("By Sender"); else return tr("By Message"); } + // Intentional fallthrough case Qt::EditRole: switch (index.column()) { case 0: - return ignoreListManager()[index.row()].isActive; + return ignoreListManager()[index.row()].isEnabled(); case 1: - return ignoreListManager()[index.row()].type; + return ignoreListManager()[index.row()].type(); case 2: - return ignoreListManager()[index.row()].ignoreRule; + return ignoreListManager()[index.row()].contents(); default: return QVariant(); } @@ -123,17 +122,18 @@ bool IgnoreListModel::setData(const QModelIndex &index, const QVariant &value, i switch (index.column()) { case 0: - cloneIgnoreListManager()[index.row()].isActive = newValue.toBool(); + cloneIgnoreListManager()[index.row()].setIsEnabled(newValue.toBool()); return true; case 1: - cloneIgnoreListManager()[index.row()].type = (IgnoreListManager::IgnoreType)newValue.toInt(); + cloneIgnoreListManager()[index.row()].setType( + (IgnoreListManager::IgnoreType)newValue.toInt()); return true; case 2: if (ignoreListManager().contains(newValue.toString())) { return false; } else { - cloneIgnoreListManager()[index.row()].ignoreRule = newValue.toString(); + cloneIgnoreListManager()[index.row()].setContents(newValue.toString()); return true; } default: @@ -145,12 +145,12 @@ bool IgnoreListModel::setData(const QModelIndex &index, const QVariant &value, i bool IgnoreListModel::newIgnoreRule(const IgnoreListManager::IgnoreListItem &item) { IgnoreListManager &manager = cloneIgnoreListManager(); - if (manager.contains(item.ignoreRule)) + if (manager.contains(item.contents())) return false; beginInsertRows(QModelIndex(), rowCount(), rowCount()); // manager.addIgnoreListItem(item); - manager.addIgnoreListItem(item.type, item.ignoreRule, item.isRegEx, item.strictness, item.scope, - item.scopeRule, item.isActive); + manager.addIgnoreListItem(item.type(), item.contents(), item.isRegEx(), item.strictness(), + item.scope(), item.scopeRule(), item.isEnabled()); endInsertRows(); return true; } @@ -173,7 +173,8 @@ void IgnoreListModel::loadDefaults() IgnoreListManager::IgnoreList defaults = IgnoreListModel::defaults(); beginInsertRows(QModelIndex(), 0, defaults.count() - 1); foreach(IgnoreListManager::IgnoreListItem item, defaults) { - manager.addIgnoreListItem(item.ignoreRule, item.isRegEx, item.strictness, item.scope, item.scopeRule); + manager.addIgnoreListItem(item.contents(), item.isRegEx(), item.strictness(), item.scope(), + item.scopeRule()); } endInsertRows();*/ } @@ -262,7 +263,8 @@ void IgnoreListModel::revert() _configChanged = false; emit configChanged(false); - reset(); + beginResetModel(); + endResetModel(); } @@ -279,7 +281,8 @@ void IgnoreListModel::commit() void IgnoreListModel::initDone() { _modelReady = true; - reset(); + beginResetModel(); + endResetModel(); emit modelReady(true); } @@ -299,7 +302,8 @@ void IgnoreListModel::clientDisconnected() // clear _clonedIgnoreListManager = ClientIgnoreListManager(); _modelReady = false; - reset(); + beginResetModel(); + endResetModel(); emit modelReady(false); }