X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fignorelistmodel.cpp;h=d08a280d18df392008c5992bbc8eefa83425028c;hp=3d137b3983fe373db928fa4467f011b5d4dbd68a;hb=673ded0d543cbdc2cf6e746b6bee7c1d21af8f90;hpb=cc6e7c08709c4e761e2fd9c2e322751015497003 diff --git a/src/qtui/settingspages/ignorelistmodel.cpp b/src/qtui/settingspages/ignorelistmodel.cpp index 3d137b39..d08a280d 100644 --- a/src/qtui/settingspages/ignorelistmodel.cpp +++ b/src/qtui/settingspages/ignorelistmodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2019 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -144,7 +144,6 @@ bool IgnoreListModel::newIgnoreRule(const IgnoreListManager::IgnoreListItem& ite if (manager.contains(item.contents())) return false; beginInsertRows(QModelIndex(), rowCount(), rowCount()); - // manager.addIgnoreListItem(item); manager.addIgnoreListItem(item.type(), item.contents(), item.isRegEx(), item.strictness(), item.scope(), item.scopeRule(), item.isEnabled()); endInsertRows(); return true; @@ -216,47 +215,41 @@ QModelIndex IgnoreListModel::index(int row, int column, const QModelIndex& paren const IgnoreListManager& IgnoreListModel::ignoreListManager() const { - if (_configChanged) - return _clonedIgnoreListManager; - else - return *Client::ignoreListManager(); + return _clonedIgnoreListManager ? *_clonedIgnoreListManager : *Client::ignoreListManager(); } IgnoreListManager& IgnoreListModel::ignoreListManager() { - if (_configChanged) - return _clonedIgnoreListManager; - else - return *Client::ignoreListManager(); + return _clonedIgnoreListManager ? *_clonedIgnoreListManager : *Client::ignoreListManager(); } IgnoreListManager& IgnoreListModel::cloneIgnoreListManager() { - if (!_configChanged) { - _clonedIgnoreListManager = *Client::ignoreListManager(); - _configChanged = true; + if (!_clonedIgnoreListManager) { + _clonedIgnoreListManager = std::make_unique(); + _clonedIgnoreListManager->fromVariantMap(Client::ignoreListManager()->toVariantMap()); emit configChanged(true); } - return _clonedIgnoreListManager; + return *_clonedIgnoreListManager; } void IgnoreListModel::revert() { - if (!_configChanged) + if (!_clonedIgnoreListManager) return; - _configChanged = false; - emit configChanged(false); beginResetModel(); + _clonedIgnoreListManager.reset(); endResetModel(); + emit configChanged(false); } void IgnoreListModel::commit() { - if (!_configChanged) + if (!_clonedIgnoreListManager) return; - Client::ignoreListManager()->requestUpdate(_clonedIgnoreListManager.toVariantMap()); + Client::ignoreListManager()->requestUpdate(_clonedIgnoreListManager->toVariantMap()); revert(); } @@ -279,10 +272,9 @@ void IgnoreListModel::clientConnected() void IgnoreListModel::clientDisconnected() { - // clear - _clonedIgnoreListManager = ClientIgnoreListManager(); _modelReady = false; beginResetModel(); + _clonedIgnoreListManager.reset(); endResetModel(); emit modelReady(false); }