Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 3f100d45 authored by Johan Ouwerkerk's avatar Johan Ouwerkerk Committed by Bhushan Shah

Minor code cleanups in src/model

parent a64db237
......@@ -208,17 +208,16 @@ namespace model
void SimpleAccountListModel::removed(const QString &account)
{
int accountIndex = m_index.indexOf(account);
if (accountIndex >= 0) {
qCDebug(logger) << "Removing (old) account from the model at position:" << accountIndex;
beginRemoveRows(QModelIndex(), accountIndex, accountIndex);
m_index.remove(accountIndex);
m_accounts.remove(account);
endRemoveRows();
} else {
if (accountIndex < 0) {
qCDebug(logger) << "Unable to handle account removal: account not part of the model";
return;
}
qCDebug(logger) << "Removing (old) account from the model at position:" << accountIndex;
beginRemoveRows(QModelIndex(), accountIndex, accountIndex);
m_index.remove(accountIndex);
m_accounts.remove(account);
endRemoveRows();
}
bool SimpleAccountListModel::isNameStillAvailable(const QString &account) const
......@@ -253,12 +252,13 @@ namespace model
void AccountNameValidator::setAccounts(SimpleAccountListModel *accounts)
{
if (accounts) {
m_accounts = accounts;
Q_EMIT accountsChanged();
} else {
if (!accounts) {
qCDebug(logger) << "Ignoring new accounts model: not a valid object";
return;
}
m_accounts = accounts;
Q_EMIT accountsChanged();
}
SortedAccountsListModel::SortedAccountsListModel(QObject *parent) : QSortFilterProxyModel(parent)
......@@ -286,7 +286,7 @@ namespace model
QAbstractItemModel *source = sourceModel();
Q_ASSERT_X(source, Q_FUNC_INFO, "should have a source model at this point");
SimpleAccountListModel *model = qobject_cast<SimpleAccountListModel*>(source);
const SimpleAccountListModel *model = qobject_cast<const SimpleAccountListModel*>(source);
// useless junk: implement sorting as no-op: claim equality between left & right
if (!model) {
qCDebug(logger) << "Short-circuiting lessThan operator: source model is not an accounts list model!";
......
......@@ -112,7 +112,7 @@ namespace model
void accountsChanged(void);
private:
SimpleAccountListModel * m_accounts;
validators::NameValidator m_delegate;
const validators::NameValidator m_delegate;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment