X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fflatproxymodel.cpp;h=8af502491631cb03db727c4cce9b6b7adee444c5;hp=0894f89c2fd88c59d7086a1dc7d66f772588d94b;hb=e2188dc438be6f3eb0d9cdf47d28821aefe9835e;hpb=694f9bfbf7f1af19108461c7e00d133e55082bce diff --git a/src/uisupport/flatproxymodel.cpp b/src/uisupport/flatproxymodel.cpp index 0894f89c..8af50249 100644 --- a/src/uisupport/flatproxymodel.cpp +++ b/src/uisupport/flatproxymodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 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 "flatproxymodel.h" @@ -24,8 +24,7 @@ #include FlatProxyModel::FlatProxyModel(QObject *parent) - : QAbstractProxyModel(parent), - _rootSourceItem(0) + : QAbstractProxyModel(parent) { } @@ -96,7 +95,7 @@ QItemSelection FlatProxyModel::mapSelectionFromSource(const QItemSelection &sour QModelIndex currentParent = currentRange.topLeft().parent(); Q_ASSERT(currentParent == currentRange.bottomRight().parent()); - SourceItem *parentItem = 0; + SourceItem *parentItem = nullptr; if (!itemLookup.contains(currentParent)) { parentItem = sourceToInternal(currentParent); itemLookup[currentParent] = parentItem; @@ -178,9 +177,9 @@ QItemSelection FlatProxyModel::mapSelectionToSource(const QItemSelection &proxyS for (int i = 0; i < proxySelection.count(); i++) { const QItemSelectionRange &range = proxySelection[i]; - SourceItem *topLeftItem = 0; - SourceItem *bottomRightItem = 0; - SourceItem *currentItem = static_cast(range.topLeft().internalPointer()); + SourceItem *topLeftItem = nullptr; + SourceItem *bottomRightItem = nullptr; + auto *currentItem = static_cast(range.topLeft().internalPointer()); int row = range.topLeft().row(); int left = range.topLeft().column(); int right = range.bottomRight().column(); @@ -195,8 +194,8 @@ QItemSelection FlatProxyModel::mapSelectionToSource(const QItemSelection &proxyS else { Q_ASSERT(topLeftItem && bottomRightItem); sourceSelection << QItemSelectionRange(mapToSource(createIndex(topLeftItem->pos(), left, topLeftItem)), mapToSource(createIndex(bottomRightItem->pos(), right, bottomRightItem))); - topLeftItem = 0; - bottomRightItem = 0; + topLeftItem = nullptr; + bottomRightItem = nullptr; } // update loop vars @@ -204,8 +203,9 @@ QItemSelection FlatProxyModel::mapSelectionToSource(const QItemSelection &proxyS row++; } - Q_ASSERT(topLeftItem && bottomRightItem); // there should be one range left. - sourceSelection << QItemSelectionRange(mapToSource(createIndex(topLeftItem->pos(), left, topLeftItem)), mapToSource(createIndex(bottomRightItem->pos(), right, bottomRightItem))); + if (topLeftItem && bottomRightItem) { // there should be one range left. + sourceSelection << QItemSelectionRange(mapToSource(createIndex(topLeftItem->pos(), left, topLeftItem)), mapToSource(createIndex(bottomRightItem->pos(), right, bottomRightItem))); + } } return sourceSelection; @@ -215,7 +215,7 @@ QItemSelection FlatProxyModel::mapSelectionToSource(const QItemSelection &proxyS void FlatProxyModel::setSourceModel(QAbstractItemModel *sourceModel) { if (QAbstractProxyModel::sourceModel()) { - disconnect(QAbstractProxyModel::sourceModel(), 0, this, 0); + disconnect(QAbstractProxyModel::sourceModel(), nullptr, this, nullptr); } QAbstractProxyModel::setSourceModel(sourceModel); @@ -270,7 +270,7 @@ void FlatProxyModel::insertSubTree(const QModelIndex &source_idx, bool emitInser SourceItem *lastItem = insertSubTreeHelper(newSubTree, newSubTree, source_idx); Q_ASSERT(lastItem); - Q_ASSERT(lastItem->next() == 0); + Q_ASSERT(lastItem->next() == nullptr); if (emitInsert) beginInsertRows(QModelIndex(), newSubTree->pos(), lastItem->pos()); @@ -309,7 +309,7 @@ void FlatProxyModel::insertSubTree(const QModelIndex &source_idx, bool emitInser FlatProxyModel::SourceItem *FlatProxyModel::insertSubTreeHelper(SourceItem *parentItem, SourceItem *lastItem_, const QModelIndex &source_idx) { SourceItem *lastItem = lastItem_; - SourceItem *newItem = 0; + SourceItem *newItem = nullptr; for (int row = 0; row < sourceModel()->rowCount(source_idx); row++) { newItem = new SourceItem(row, parentItem); newItem->setPos(lastItem->pos() + 1); @@ -524,7 +524,7 @@ void FlatProxyModel::on_rowsAboutToBeInserted(const QModelIndex &parent, int sta SourceItem *nextItem = prevItem->next(); - SourceItem *newItem = 0; + SourceItem *newItem = nullptr; int newPos = prevItem->pos() + 1; for (int row = start; row <= end; row++) { newItem = new SourceItem(row, sourceItem); @@ -682,9 +682,7 @@ void FlatProxyModel::checkChildCount(const QModelIndex &index, const SourceItem // SourceItem // ======================================== FlatProxyModel::SourceItem::SourceItem(int row, SourceItem *parent) - : _parent(parent), - _pos(-1), - _next(0) + : _parent(parent) { if (parent) { parent->_childs.insert(row, this);