KRFPM: remove compatibility for Qt < 5.5, given that 5.5 is required.

wilder
David Faure 9 years ago
parent 21e1b1e49e
commit 1b8ef1fd1c
  1. 57
      src/krecursivefilterproxymodel.cpp

@ -31,14 +31,7 @@
// to be cleared, even if only a part of it is dirty.
// Stephen Kelly, 30 April 2010.
inline static bool passRolesToDataChanged()
{
// runtime check to ensure a KF5 built against Qt < 5.5 keeps working when Qt is updated to 5.5 and above but KF5 is not rebuild
// TODO: remove once Qt 5.5 or above is required for frameworks
static const bool passRoles = QT_VERSION >= 0x050500 // no runtime check required when we built against Qt 5.5 or higher
|| KRecursiveFilterProxyModel::staticMetaObject.indexOfMethod("_q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)") != -1;
return passRoles;
}
// All this is temporary anyway, the long term solution is support in QSFPM: https://codereview.qt-project.org/151000
class KRecursiveFilterProxyModelPrivate
{
@ -65,21 +58,12 @@ public:
inline void invokeDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>())
{
Q_Q(KRecursiveFilterProxyModel);
bool success = false;
if (passRolesToDataChanged()) {
// required for Qt 5.5 and upwards, see commit f96baeb75fc in qtbase
static const QMetaMethod m = findMethod("_q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)");
success = m.invoke(q, Qt::DirectConnection,
Q_ARG(QModelIndex, topLeft),
Q_ARG(QModelIndex, bottomRight),
Q_ARG(QVector<int>, roles));
} else {
// backwards compatibility
static const QMetaMethod m = findMethod("_q_sourceDataChanged(QModelIndex,QModelIndex)");
success = m.invoke(q, Qt::DirectConnection,
Q_ARG(QModelIndex, topLeft),
Q_ARG(QModelIndex, bottomRight));
}
// required for Qt 5.5 and upwards, see commit f96baeb75fc in qtbase
static const QMetaMethod m = findMethod("_q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)");
bool success = m.invoke(q, Qt::DirectConnection,
Q_ARG(QModelIndex, topLeft),
Q_ARG(QModelIndex, bottomRight),
Q_ARG(QVector<int>, roles));
Q_UNUSED(success);
Q_ASSERT(success);
}
@ -320,13 +304,8 @@ void KRecursiveFilterProxyModel::setSourceModel(QAbstractItemModel *model)
{
// Standard disconnect of the previous source model, if present
if (sourceModel()) {
if (passRolesToDataChanged()) {
disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
this, SLOT(sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)));
} else {
disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(sourceDataChanged(QModelIndex,QModelIndex)));
}
disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
this, SLOT(sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)));
disconnect(sourceModel(), SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
this, SLOT(sourceRowsAboutToBeInserted(QModelIndex,int,int)));
@ -411,13 +390,8 @@ void KRecursiveFilterProxyModel::setSourceModel(QAbstractItemModel *model)
return;
}
if (passRolesToDataChanged()) {
disconnect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)));
} else {
disconnect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
}
disconnect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)));
disconnect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
this, SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int)));
@ -432,13 +406,8 @@ void KRecursiveFilterProxyModel::setSourceModel(QAbstractItemModel *model)
this, SLOT(_q_sourceRowsRemoved(QModelIndex,int,int)));
// Slots for manual invoking of QSortFilterProxyModel methods.
if (passRolesToDataChanged()) {
connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
this, SLOT(sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)));
} else {
connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(sourceDataChanged(QModelIndex,QModelIndex)));
}
connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
this, SLOT(sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)));
connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
this, SLOT(sourceRowsAboutToBeInserted(QModelIndex,int,int)));

Loading…
Cancel
Save