Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorClaudio Cambra <claudio.cambra@gmail.com>2021-12-23 13:57:08 +0300
committerClaudio Cambra (Rebase PR Action) <claudio.cambra@gmail.com>2022-02-01 16:57:08 +0300
commitce5494b4ecf3ad094401d4796fdc75dfab7b1b12 (patch)
tree5533834b508fc8f59fe05a1f2d7c47dbbfba44ff /src/gui
parenta66bed5d0fa4a41334a74f39e3df5341863ede69 (diff)
Add testing for ActivityListModel
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/tray/activitylistmodel.cpp22
-rw-r--r--src/gui/tray/activitylistmodel.h4
2 files changed, 10 insertions, 16 deletions
diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp
index eacf36fd8..8120612a5 100644
--- a/src/gui/tray/activitylistmodel.cpp
+++ b/src/gui/tray/activitylistmodel.cpp
@@ -269,8 +269,12 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
return QVariant();
}
-int ActivityListModel::rowCount(const QModelIndex &) const
+int ActivityListModel::rowCount(const QModelIndex &parent) const
{
+ if(parent.isValid()) {
+ return 0;
+ }
+
return _finalList.count();
}
@@ -342,7 +346,6 @@ void ActivityListModel::activitiesReceived(const QJsonDocument &json, int status
a._icon = json.value(QStringLiteral("icon")).toString();
auto richSubjectData = json.value(QStringLiteral("subject_rich")).toArray();
- Q_ASSERT(richSubjectData.size() > 1);
if(richSubjectData.size() > 1) {
a._subjectRich = richSubjectData[0].toString();
@@ -621,14 +624,8 @@ void ActivityListModel::combineActivityLists()
}
beginResetModel();
- _finalList.clear();
+ _finalList = resultList;
endResetModel();
-
- if (resultList.count() > 0) {
- beginInsertRows(QModelIndex(), 0, resultList.count() - 1);
- _finalList = resultList;
- endInsertRows();
- }
}
bool ActivityListModel::canFetchActivities() const
@@ -638,11 +635,8 @@ bool ActivityListModel::canFetchActivities() const
void ActivityListModel::fetchMore(const QModelIndex &)
{
- if (canFetchActivities()) {
+ if (canFetchActivities() && !_currentlyFetching) {
startFetchJob();
- } else {
- _doneFetching = true;
- combineActivityLists();
}
}
@@ -672,4 +666,6 @@ void ActivityListModel::slotRemoveAccount()
_totalActivitiesFetched = 0;
_showMoreActivitiesAvailableEntry = false;
}
+
}
+
diff --git a/src/gui/tray/activitylistmodel.h b/src/gui/tray/activitylistmodel.h
index 07385e768..66de2e498 100644
--- a/src/gui/tray/activitylistmodel.h
+++ b/src/gui/tray/activitylistmodel.h
@@ -44,7 +44,6 @@ class ActivityListModel : public QAbstractListModel
public:
enum DataRole {
ActionIconRole = Qt::UserRole + 1,
- UserIconRole,
AccountRole,
ObjectTypeRole,
ActionsLinksRole,
@@ -59,7 +58,6 @@ public:
LinkRole,
PointInTimeRole,
AccountConnectedRole,
- SyncFileStatusRole,
DisplayActions,
ShareableRole,
};
@@ -90,6 +88,7 @@ public:
Q_INVOKABLE void triggerAction(int activityIndex, int actionIndex);
AccountState *accountState() const;
+ void setAccountState(AccountState *state);
public slots:
void slotRefreshActivity();
@@ -103,7 +102,6 @@ protected:
void activitiesReceived(const QJsonDocument &json, int statusCode);
QHash<int, QByteArray> roleNames() const override;
- void setAccountState(AccountState *state);
void setCurrentlyFetching(bool value);
bool currentlyFetching() const;
void setDoneFetching(bool value);