diff options
Diffstat (limited to 'src/corelib/itemmodels/qabstractitemmodel.cpp')
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.cpp | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index a9cfa3e7ca..60ac75133c 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** @@ -10,9 +10,9 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -23,8 +23,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ @@ -449,9 +449,10 @@ bool QPersistentModelIndex::isValid() const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QModelIndex &idx) { + QDebugStateSaver saver(dbg); dbg.nospace() << "QModelIndex(" << idx.row() << ',' << idx.column() << ',' << idx.internalPointer() << ',' << idx.model() << ')'; - return dbg.space(); + return dbg; } QDebug operator<<(QDebug dbg, const QPersistentModelIndex &idx) @@ -468,12 +469,12 @@ class QEmptyItemModel : public QAbstractItemModel { public: explicit QEmptyItemModel(QObject *parent = 0) : QAbstractItemModel(parent) {} - QModelIndex index(int, int, const QModelIndex &) const { return QModelIndex(); } - QModelIndex parent(const QModelIndex &) const { return QModelIndex(); } - int rowCount(const QModelIndex &) const { return 0; } - int columnCount(const QModelIndex &) const { return 0; } - bool hasChildren(const QModelIndex &) const { return false; } - QVariant data(const QModelIndex &, int) const { return QVariant(); } + QModelIndex index(int, int, const QModelIndex &) const Q_DECL_OVERRIDE { return QModelIndex(); } + QModelIndex parent(const QModelIndex &) const Q_DECL_OVERRIDE { return QModelIndex(); } + int rowCount(const QModelIndex &) const Q_DECL_OVERRIDE { return 0; } + int columnCount(const QModelIndex &) const Q_DECL_OVERRIDE { return 0; } + bool hasChildren(const QModelIndex &) const Q_DECL_OVERRIDE { return false; } + QVariant data(const QModelIndex &, int) const Q_DECL_OVERRIDE { return QVariant(); } }; Q_GLOBAL_STATIC(QEmptyItemModel, qEmptyModel) @@ -676,7 +677,7 @@ void QAbstractItemModelPrivate::itemsAboutToBeMoved(const QModelIndex &srcParent column value depending on the value of \a orientation. The indexes may also be moved to a different parent if \a parent differs from the existing parent for the index. */ -void QAbstractItemModelPrivate::movePersistentIndexes(QVector<QPersistentModelIndexData *> indexes, int change, const QModelIndex &parent, Qt::Orientation orientation) +void QAbstractItemModelPrivate::movePersistentIndexes(const QVector<QPersistentModelIndexData *> &indexes, int change, const QModelIndex &parent, Qt::Orientation orientation) { QVector<QPersistentModelIndexData *>::const_iterator it; const QVector<QPersistentModelIndexData *>::const_iterator begin = indexes.constBegin(); @@ -1264,11 +1265,6 @@ void QAbstractItemModel::resetInternalData() */ /*! - \fn QObject *QAbstractItemModel::parent() const - \internal -*/ - -/*! \fn QModelIndex QAbstractItemModel::parent(const QModelIndex &index) const = 0 Returns the parent of the model item with the given \a index. If the item @@ -3350,6 +3346,14 @@ QModelIndex QAbstractTableModel::parent(const QModelIndex &) const return QModelIndex(); } +/*! + \reimp +*/ +QModelIndex QAbstractTableModel::sibling(int row, int column, const QModelIndex &) const +{ + return index(row, column); +} + bool QAbstractTableModel::hasChildren(const QModelIndex &parent) const { if (parent.model() == this || !parent.isValid()) @@ -3493,6 +3497,14 @@ QModelIndex QAbstractListModel::parent(const QModelIndex & /* index */) const /*! \reimp +*/ +QModelIndex QAbstractListModel::sibling(int row, int column, const QModelIndex &) const +{ + return index(row, column); +} + +/*! + \reimp */ Qt::ItemFlags QAbstractListModel::flags(const QModelIndex &index) const { |