QGIM: reimplement remaining virtuals
Opens up the option to provide optimized reimplementations of e.g. mime type handling or sorting, without having to worry about compatibility implications when adding new overrides. Also override QObject::event/eventFilter, for the same reason. Change-Id: I843cfc449770e780fa3dbc2bd9629939f847a26e Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
This commit is contained in:
parent
1bb601cc2e
commit
a92c78784f
@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||||
|
|
||||||
#include "qgenericitemmodel.h"
|
#include "qgenericitemmodel.h"
|
||||||
|
#include <QtCore/qsize.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -762,6 +763,153 @@ bool QGenericItemModel::moveRows(const QModelIndex &sourceParent, int sourceRow,
|
|||||||
destinationParent, destinationRow);
|
destinationParent, destinationRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
bool QGenericItemModel::canFetchMore(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::canFetchMore(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
void QGenericItemModel::fetchMore(const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
QAbstractItemModel::fetchMore(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
bool QGenericItemModel::hasChildren(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::hasChildren(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
QModelIndex QGenericItemModel::buddy(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::buddy(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
bool QGenericItemModel::canDropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||||
|
int row, int column, const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::canDropMimeData(data, action, row, column, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
bool QGenericItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||||
|
int row, int column, const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::dropMimeData(data, action, row, column, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
QMimeData *QGenericItemModel::mimeData(const QModelIndexList &indexes) const
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::mimeData(indexes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
QStringList QGenericItemModel::mimeTypes() const
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::mimeTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
QModelIndexList QGenericItemModel::match(const QModelIndex &start, int role, const QVariant &value,
|
||||||
|
int hits, Qt::MatchFlags flags) const
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::match(start, role, value, hits, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
void QGenericItemModel::multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const
|
||||||
|
{
|
||||||
|
QAbstractItemModel::multiData(index, roleDataSpan);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
QHash<int, QByteArray> QGenericItemModel::roleNames() const
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::roleNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
void QGenericItemModel::sort(int column, Qt::SortOrder order)
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::sort(column, order);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
QSize QGenericItemModel::span(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::span(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
Qt::DropActions QGenericItemModel::supportedDragActions() const
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::supportedDragActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
Qt::DropActions QGenericItemModel::supportedDropActions() const
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::supportedDropActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
void QGenericItemModel::resetInternalData()
|
||||||
|
{
|
||||||
|
QAbstractItemModel::resetInternalData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
bool QGenericItemModel::event(QEvent *event)
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\reimp
|
||||||
|
*/
|
||||||
|
bool QGenericItemModel::eventFilter(QObject *object, QEvent *event)
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::eventFilter(object, event);
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#include "moc_qgenericitemmodel.cpp"
|
#include "moc_qgenericitemmodel.cpp"
|
||||||
|
@ -75,6 +75,33 @@ public:
|
|||||||
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count,
|
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count,
|
||||||
const QModelIndex &destParent, int destRow) override;
|
const QModelIndex &destParent, int destRow) override;
|
||||||
|
|
||||||
|
bool canFetchMore(const QModelIndex &parent) const override;
|
||||||
|
void fetchMore(const QModelIndex &parent) override;
|
||||||
|
|
||||||
|
bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
|
QModelIndex buddy(const QModelIndex &index) const override;
|
||||||
|
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
|
||||||
|
const QModelIndex &parent) const override;
|
||||||
|
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
|
||||||
|
const QModelIndex &parent) override;
|
||||||
|
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||||
|
QStringList mimeTypes() const override;
|
||||||
|
QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits,
|
||||||
|
Qt::MatchFlags flags) const override;
|
||||||
|
void multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const override;
|
||||||
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
|
||||||
|
QSize span(const QModelIndex &index) const override;
|
||||||
|
Qt::DropActions supportedDragActions() const override;
|
||||||
|
Qt::DropActions supportedDropActions() const override;
|
||||||
|
|
||||||
|
protected Q_SLOTS:
|
||||||
|
void resetInternalData() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool event(QEvent *) override;
|
||||||
|
bool eventFilter(QObject *, QEvent *) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY_MOVE(QGenericItemModel)
|
Q_DISABLE_COPY_MOVE(QGenericItemModel)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user