Move the DevicesSortProxyModel to interfaces/
This way it can be used by other parts of the project. It belongs with the DevicesModel. REVIEW: 124067
This commit is contained in:
parent
dee103d451
commit
a83bf73a4d
5 changed files with 16 additions and 6 deletions
|
@ -11,6 +11,7 @@ set(libkdeconnect_SRC
|
|||
dbusinterfaces.cpp
|
||||
devicesmodel.cpp
|
||||
notificationsmodel.cpp
|
||||
devicessortproxymodel.cpp
|
||||
# modeltest.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -27,9 +27,15 @@ DevicesSortProxyModel::DevicesSortProxyModel(DevicesModel* devicesModel)
|
|||
: QSortFilterProxyModel(devicesModel)
|
||||
{
|
||||
setSourceModel(devicesModel);
|
||||
setSortRole(DevicesModel::StatusModelRole);
|
||||
connect(devicesModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
|
||||
this, SLOT(sourceDataChanged(QModelIndex,QModelIndex)));
|
||||
}
|
||||
|
||||
void DevicesSortProxyModel::setSourceModel(QAbstractItemModel *devicesModel)
|
||||
{
|
||||
QSortFilterProxyModel::setSourceModel(devicesModel);
|
||||
if (devicesModel) {
|
||||
setSortRole(DevicesModel::StatusModelRole);
|
||||
connect(devicesModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(sourceDataChanged(QModelIndex,QModelIndex)));
|
||||
}
|
||||
sort(0);
|
||||
}
|
||||
|
|
@ -22,16 +22,18 @@
|
|||
#define DEVICESSORTPROXYMODEL_H
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
#include "interfaces/kdeconnectinterfaces_export.h"
|
||||
|
||||
class DevicesModel;
|
||||
|
||||
class DevicesSortProxyModel : public QSortFilterProxyModel
|
||||
class KDECONNECTINTERFACES_EXPORT DevicesSortProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DevicesSortProxyModel(DevicesModel* devicesModel);
|
||||
DevicesSortProxyModel(DevicesModel* devicesModel = Q_NULLPTR);
|
||||
virtual bool lessThan(const QModelIndex& left, const QModelIndex& right) const;
|
||||
virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
|
||||
virtual void setSourceModel(QAbstractItemModel *sourceModel);
|
||||
|
||||
public Q_SLOTS:
|
||||
void sourceDataChanged(QModelIndex,QModelIndex);
|
|
@ -9,7 +9,6 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}
|
|||
|
||||
set(kcm_SRCS
|
||||
kcm.cpp
|
||||
devicessortproxymodel.cpp
|
||||
)
|
||||
|
||||
ki18n_wrap_ui(kcm_SRCS kcm.ui)
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "responsewaiter.h"
|
||||
#include "processrunner.h"
|
||||
|
||||
#include "interfaces/devicessortproxymodel.h"
|
||||
#include "interfaces/devicesmodel.h"
|
||||
#include "interfaces/notificationsmodel.h"
|
||||
|
||||
|
@ -59,6 +60,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
|
|||
qmlRegisterType<NotificationsModel>(uri, 1, 0, "NotificationsModel");
|
||||
qmlRegisterType<DBusAsyncResponse>(uri, 1, 0, "DBusAsyncResponse");
|
||||
qmlRegisterType<ProcessRunner>(uri, 1, 0, "ProcessRunner");
|
||||
qmlRegisterType<DevicesSortProxyModel>(uri, 1, 0, "DevicesSortProxyModel");
|
||||
qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "DeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess"));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue