X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fuisupport%2Fflatproxymodel.cpp;h=d722c18f662cf684c1cb7eb95aa920f6efdb836a;hb=8582c2ad5708a1972c85bea1cf8d81ad3ece4814;hp=aef7b1b431184aa957aeccc08db6fdf3ceba9ca8;hpb=39328183a6a87c6eb10a9dbbffcd5d65bf154a1f;p=quassel.git diff --git a/src/uisupport/flatproxymodel.cpp b/src/uisupport/flatproxymodel.cpp index aef7b1b4..d722c18f 100644 --- a/src/uisupport/flatproxymodel.cpp +++ b/src/uisupport/flatproxymodel.cpp @@ -24,8 +24,7 @@ #include FlatProxyModel::FlatProxyModel(QObject *parent) - : QAbstractProxyModel(parent), - _rootSourceItem(nullptr) + : QAbstractProxyModel(parent) { } @@ -33,7 +32,7 @@ FlatProxyModel::FlatProxyModel(QObject *parent) QModelIndex FlatProxyModel::mapFromSource(const QModelIndex &sourceIndex) const { if (!sourceIndex.isValid()) - return QModelIndex(); + return {}; SourceItem *sourceItem = sourceToInternal(sourceIndex); Q_ASSERT(sourceItem); @@ -44,7 +43,7 @@ QModelIndex FlatProxyModel::mapFromSource(const QModelIndex &sourceIndex) const QModelIndex FlatProxyModel::mapToSource(const QModelIndex &proxyIndex) const { if (!proxyIndex.isValid()) - return QModelIndex(); + return {}; Q_ASSERT(proxyIndex.model() == this); Q_ASSERT(_rootSourceItem); @@ -64,7 +63,7 @@ QModelIndex FlatProxyModel::mapToSource(const QModelIndex &proxyIndex) const qWarning() << "FlatProxyModel::mapToSource(): couldn't find source index for" << proxyIndex; Q_ASSERT(false); - return QModelIndex(); // make compilers happy :) + return {}; // make compilers happy :) } @@ -180,7 +179,7 @@ QItemSelection FlatProxyModel::mapSelectionToSource(const QItemSelection &proxyS SourceItem *topLeftItem = nullptr; SourceItem *bottomRightItem = nullptr; - SourceItem *currentItem = static_cast(range.topLeft().internalPointer()); + auto *currentItem = static_cast(range.topLeft().internalPointer()); int row = range.topLeft().row(); int left = range.topLeft().column(); int right = range.bottomRight().column(); @@ -368,12 +367,12 @@ QModelIndex FlatProxyModel::index(int row, int column, const QModelIndex &parent { if (parent.isValid()) { qWarning() << "FlatProxyModel::index() called with valid parent:" << parent; - return QModelIndex(); + return {}; } if (!_rootSourceItem) { qWarning() << "FlatProxyModel::index() while model has no root Item"; - return QModelIndex(); + return {}; } SourceItem *item = _rootSourceItem; @@ -381,7 +380,7 @@ QModelIndex FlatProxyModel::index(int row, int column, const QModelIndex &parent item = item->findChild(row); if (!item) { qWarning() << "FlatProxyModel::index() no such row:" << row; - return QModelIndex(); + return {}; } } @@ -394,7 +393,7 @@ QModelIndex FlatProxyModel::parent(const QModelIndex &index) const { Q_UNUSED(index) // this is a flat model - return QModelIndex(); + return {}; } @@ -683,9 +682,7 @@ void FlatProxyModel::checkChildCount(const QModelIndex &index, const SourceItem // SourceItem // ======================================== FlatProxyModel::SourceItem::SourceItem(int row, SourceItem *parent) - : _parent(parent), - _pos(-1), - _next(nullptr) + : _parent(parent) { if (parent) { parent->_childs.insert(row, this);