ItemModels: remove deprecated functions

Change-Id: Id3430493a62b11977f64e146f7668ca30935b959
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Christian Ehrlicher 2020-06-05 21:44:10 +02:00
parent 50ccd35fbd
commit e0fc998e87
7 changed files with 2 additions and 139 deletions

View File

@ -410,26 +410,6 @@ QModelIndex QPersistentModelIndex::sibling(int row, int column) const
return QModelIndex();
}
#if QT_DEPRECATED_SINCE(5, 8)
/*!
\obsolete
Use QAbstractItemModel::index() instead.
Returns the child of the model index that is stored in the given \a row
and \a column.
\sa parent(), sibling()
*/
QModelIndex QPersistentModelIndex::child(int row, int column) const
{
if (d)
return d->index.model()->index(row, column, d->index);
return QModelIndex();
}
#endif
/*!
Returns the data for the given \a role for the item referred to by the
index.
@ -517,8 +497,7 @@ Q_GLOBAL_STATIC(QEmptyItemModel, qEmptyModel)
QAbstractItemModelPrivate::QAbstractItemModelPrivate()
: QObjectPrivate(),
supportedDragActions(-1)
: QObjectPrivate()
{
}
@ -1148,22 +1127,6 @@ void QAbstractItemModel::resetInternalData()
\since 5.11
*/
/*!
\fn QModelIndex QModelIndex::child(int row, int column) const
\obsolete
Use QAbstractItemModel::index() instead.
Returns the child of the model index that is stored in the given \a row and
\a column.
\note This function does not work for an invalid model index which is often
used as the root index.
\sa parent(), sibling()
*/
/*!
\fn QVariant QModelIndex::data(int role) const
@ -1885,7 +1848,6 @@ bool QAbstractItemModel::setData(const QModelIndex &index, const QVariant &value
return false;
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
/*!
\since 6.0
Removes the data stored in all the roles for the given \a index.
@ -1900,7 +1862,6 @@ bool QAbstractItemModel::clearItemData(const QModelIndex &index)
Q_UNUSED(index);
return false;
}
#endif
/*!
\fn QVariant QAbstractItemModel::data(const QModelIndex &index, int role) const = 0
@ -2107,33 +2068,9 @@ Qt::DropActions QAbstractItemModel::supportedDropActions() const
*/
Qt::DropActions QAbstractItemModel::supportedDragActions() const
{
Q_D(const QAbstractItemModel);
if (int(d->supportedDragActions) != -1)
return d->supportedDragActions;
return supportedDropActions();
}
/*!
\internal
*/
void QAbstractItemModel::doSetSupportedDragActions(Qt::DropActions actions)
{
Q_D(QAbstractItemModel);
d->supportedDragActions = actions;
}
/*!
\since 4.2
\obsolete
\fn void QAbstractItemModel::setSupportedDragActions(Qt::DropActions actions)
This function is obsolete. Reimplement supportedDragActions() instead.
Sets the supported drag \a actions for the items in the model.
\sa supportedDragActions(), {Using drag and drop with item views}
*/
/*!
\note The base class implementation of this function does nothing and
returns \c{false}.
@ -3232,28 +3169,6 @@ void QAbstractItemModel::endMoveColumns()
emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
}
/*!
\fn void QAbstractItemModel::reset()
\obsolete
Resets the model to its original state in any attached views.
This function emits the signals modelAboutToBeReset() and modelReset().
\note Use beginResetModel() and endResetModel() instead whenever possible.
Use this method only if there is no way to call beginResetModel() before invalidating the model.
Otherwise it could lead to unexpected behaviour, especially when used with proxy models.
For example, in this code both signals modelAboutToBeReset() and modelReset()
are emitted \e after the data changes:
\snippet code/src_corelib_kernel_qabstractitemmodel.cpp 10
Instead you should use:
\snippet code/src_corelib_kernel_qabstractitemmodel.cpp 11
*/
/*!
Begins a model reset operation.
@ -3297,11 +3212,7 @@ void QAbstractItemModel::endResetModel()
{
Q_D(QAbstractItemModel);
d->invalidatePersistentIndexes();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
resetInternalData();
#else
QMetaObject::invokeMethod(this, "resetInternalData");
#endif
emit modelReset(QPrivateSignal());
}

View File

@ -68,9 +68,6 @@ public:
inline QModelIndex sibling(int row, int column) const;
inline QModelIndex siblingAtColumn(int column) const;
inline QModelIndex siblingAtRow(int row) const;
#if QT_DEPRECATED_SINCE(5, 8)
QT_DEPRECATED_X("Use QAbstractItemModel::index") inline QModelIndex child(int row, int column) const;
#endif
inline QVariant data(int role = Qt::DisplayRole) const;
inline Qt::ItemFlags flags() const;
Q_DECL_CONSTEXPR inline const QAbstractItemModel *model() const noexcept { return m; }
@ -134,9 +131,6 @@ public:
quintptr internalId() const;
QModelIndex parent() const;
QModelIndex sibling(int row, int column) const;
#if QT_DEPRECATED_SINCE(5, 8)
QT_DEPRECATED_X("Use QAbstractItemModel::index") QModelIndex child(int row, int column) const;
#endif
QVariant data(int role = Qt::DisplayRole) const;
Qt::ItemFlags flags() const;
const QAbstractItemModel *model() const;
@ -199,9 +193,7 @@ public:
virtual QMap<int, QVariant> itemData(const QModelIndex &index) const;
virtual bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual bool clearItemData(const QModelIndex &index);
#endif
virtual QStringList mimeTypes() const;
virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
@ -210,12 +202,7 @@ public:
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent);
virtual Qt::DropActions supportedDropActions() const;
virtual Qt::DropActions supportedDragActions() const;
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED void setSupportedDragActions(Qt::DropActions actions)
{ doSetSupportedDragActions(actions); }
#endif
virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
virtual bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
@ -301,10 +288,7 @@ public Q_SLOTS:
virtual void revert();
protected Q_SLOTS:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual
#endif
void resetInternalData();
virtual void resetInternalData();
protected:
QAbstractItemModel(QAbstractItemModelPrivate &dd, QObject *parent = nullptr);
@ -333,15 +317,6 @@ protected:
bool beginMoveColumns(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn);
void endMoveColumns();
#if QT_DEPRECATED_SINCE(5,0)
QT_DEPRECATED void reset()
{
beginResetModel();
endResetModel();
}
#endif
void beginResetModel();
void endResetModel();
@ -350,8 +325,6 @@ protected:
QModelIndexList persistentIndexList() const;
private:
void doSetSupportedDragActions(Qt::DropActions actions);
Q_DECLARE_PRIVATE(QAbstractItemModel)
Q_DISABLE_COPY(QAbstractItemModel)
};
@ -444,11 +417,6 @@ inline QModelIndex QModelIndex::siblingAtColumn(int acolumn) const
inline QModelIndex QModelIndex::siblingAtRow(int arow) const
{ return m ? (r == arow) ? *this : m->sibling(arow, c, *this) : QModelIndex(); }
#if QT_DEPRECATED_SINCE(5, 8)
inline QModelIndex QModelIndex::child(int arow, int acolumn) const
{ return m ? m->index(arow, acolumn, *this) : QModelIndex(); }
#endif
inline QVariant QModelIndex::data(int arole) const
{ return m ? m->data(*this, arole) : QVariant(); }

View File

@ -147,8 +147,6 @@ public:
void insertMultiAtEnd(const QModelIndex& key, QPersistentModelIndexData *data);
} persistent;
Qt::DropActions supportedDragActions;
static const QHash<int,QByteArray> &defaultRoleNames();
static bool isVariantLessThan(const QVariant &left, const QVariant &right,
Qt::CaseSensitivity cs = Qt::CaseSensitive, bool isLocaleAware = false);

View File

@ -303,7 +303,6 @@ bool QAbstractProxyModel::setHeaderData(int section, Qt::Orientation orientation
return d->model->setHeaderData(sourceSection, orientation, value, role);
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
/*!
\reimp
\since 6.0
@ -313,7 +312,6 @@ bool QAbstractProxyModel::clearItemData(const QModelIndex &index)
Q_D(QAbstractProxyModel);
return d->model->clearItemData(mapToSource(index));
}
#endif
/*!
\reimp

View File

@ -78,9 +78,7 @@ public:
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
bool setItemData(const QModelIndex& index, const QMap<int, QVariant> &roles) override;
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool clearItemData(const QModelIndex &index) override;
#endif
QModelIndex buddy(const QModelIndex &index) const override;
bool canFetchMore(const QModelIndex &parent) const override;

View File

@ -2850,14 +2850,6 @@ bool QStandardItemModel::hasChildren(const QModelIndex &parent) const
return item ? item->hasChildren() : false;
}
/*!
\reimp
*/
QModelIndex QStandardItemModel::sibling(int row, int column, const QModelIndex &idx) const
{
return QAbstractItemModel::sibling(row, column, idx);
}
/*!
\reimp
*/

View File

@ -329,8 +329,6 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
// Qt 6: Remove
QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;