diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 45215d53e..713fca59f 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -54,7 +54,7 @@ #include #endif - +#include #include #include #include @@ -127,6 +127,7 @@ ownCloudGui::ownCloudGui(Application *parent) qmlRegisterType("com.nextcloud.desktopclient", 1, 0, "ShareeModel"); qmlRegisterType("com.nextcloud.desktopclient", 1, 0, "SortedShareModel"); qmlRegisterType("com.nextcloud.desktopclient", 1, 0, "SyncConflictsModel"); + qmlRegisterUncreatableType("com.nextcloud.desktopclient", 1, 0, "QAbstractItemModel", "QAbstractItemModel"); qmlRegisterUncreatableType("com.nextcloud.desktopclient", 1, 0, "UnifiedSearchResultsListModel", "UnifiedSearchResultsListModel"); qmlRegisterUncreatableType("com.nextcloud.desktopclient", 1, 0, "UserStatus", "Access to Status enum"); @@ -134,7 +135,6 @@ ownCloudGui::ownCloudGui(Application *parent) qRegisterMetaTypeStreamOperators(); - qRegisterMetaType("ActivityListModel*"); qRegisterMetaType("UnifiedSearchResultsListModel*"); qRegisterMetaType("UserStatus"); qRegisterMetaType("SharePtr"); diff --git a/src/gui/tray/ActivityList.qml b/src/gui/tray/ActivityList.qml index 0f690ca27..168afaaba 100644 --- a/src/gui/tray/ActivityList.qml +++ b/src/gui/tray/ActivityList.qml @@ -6,8 +6,8 @@ import com.nextcloud.desktopclient 1.0 as NC ScrollView { id: controlRoot - property alias model: sortedActivityList.activityListModel + property alias model: sortedActivityList.sourceModel property bool isFileActivityList: false property int iconSize: Style.trayListItemIconSize property int delegateHorizontalPadding: 0 @@ -53,7 +53,6 @@ ScrollView { model: NC.SortedActivityListModel { id: sortedActivityList - activityListModel: controlRoot.model } delegate: ActivityItem { diff --git a/src/gui/tray/sortedactivitylistmodel.cpp b/src/gui/tray/sortedactivitylistmodel.cpp index 4879143f2..3dced0982 100644 --- a/src/gui/tray/sortedactivitylistmodel.cpp +++ b/src/gui/tray/sortedactivitylistmodel.cpp @@ -21,37 +21,7 @@ namespace OCC { SortedActivityListModel::SortedActivityListModel(QObject *parent) : QSortFilterProxyModel(parent) { -} - -void SortedActivityListModel::sortModel() -{ - sort(0); -} - -ActivityListModel* SortedActivityListModel::activityListModel() const -{ - return dynamic_cast(sourceModel()); -} - -void SortedActivityListModel::setActivityListModel(ActivityListModel* activityListModel) -{ - if(const auto currentSetModel = sourceModel()) { - disconnect(currentSetModel, &ActivityListModel::rowsInserted, this, &SortedActivityListModel::sortModel); - disconnect(currentSetModel, &ActivityListModel::rowsMoved, this, &SortedActivityListModel::sortModel); - disconnect(currentSetModel, &ActivityListModel::rowsRemoved, this, &SortedActivityListModel::sortModel); - disconnect(currentSetModel, &ActivityListModel::dataChanged, this, &SortedActivityListModel::sortModel); - disconnect(currentSetModel, &ActivityListModel::modelReset, this, &SortedActivityListModel::sortModel); - } - - // Re-sort model when any changes take place - connect(activityListModel, &ActivityListModel::rowsInserted, this, &SortedActivityListModel::sortModel); - connect(activityListModel, &ActivityListModel::rowsMoved, this, &SortedActivityListModel::sortModel); - connect(activityListModel, &ActivityListModel::rowsRemoved, this, &SortedActivityListModel::sortModel); - connect(activityListModel, &ActivityListModel::dataChanged, this, &SortedActivityListModel::sortModel); - connect(activityListModel, &ActivityListModel::modelReset, this, &SortedActivityListModel::sortModel); - - setSourceModel(activityListModel); - Q_EMIT activityListModelChanged(); + sort(0, Qt::AscendingOrder); } bool SortedActivityListModel::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const diff --git a/src/gui/tray/sortedactivitylistmodel.h b/src/gui/tray/sortedactivitylistmodel.h index d3e8219c1..faf490d43 100644 --- a/src/gui/tray/sortedactivitylistmodel.h +++ b/src/gui/tray/sortedactivitylistmodel.h @@ -23,24 +23,12 @@ class ActivityListModel; class SortedActivityListModel : public QSortFilterProxyModel { Q_OBJECT - Q_PROPERTY(ActivityListModel* activityListModel READ activityListModel WRITE setActivityListModel NOTIFY activityListModelChanged) public: explicit SortedActivityListModel(QObject *parent = nullptr); - [[nodiscard]] ActivityListModel *activityListModel() const; - -signals: - void activityListModelChanged(); - -public slots: - void setActivityListModel(OCC::ActivityListModel *activityListModel); - protected: [[nodiscard]] bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override; - -private slots: - void sortModel(); }; }