X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fignorelistmodel.cpp;h=4b5b443c45c3452fd012c1d45473dde858161594;hp=3d14ddc98b92d87ec70454b3ed8989eb95eb1392;hb=HEAD;hpb=a95ad2de573027f9bee36db972bcae4195168d0c diff --git a/src/qtui/settingspages/ignorelistmodel.cpp b/src/qtui/settingspages/ignorelistmodel.cpp index 3d14ddc9..4b5b443c 100644 --- a/src/qtui/settingspages/ignorelistmodel.cpp +++ b/src/qtui/settingspages/ignorelistmodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2020 by the Quassel Project * + * Copyright (C) 2005-2022 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); }