Line 0
Link Here
|
|
|
1 |
diff --git a/src/gui/activitylistmodel.cpp b/src/gui/activitylistmodel.cpp |
2 |
index d4f993b55..d74e8597b 100644 |
3 |
--- src/gui/activitylistmodel.cpp |
4 |
+++ src/gui/activitylistmodel.cpp |
5 |
@@ -150,16 +150,12 @@ int ActivityListModel::rowCount(const QModelIndex &) const |
6 |
return _finalList.count(); |
7 |
} |
8 |
|
9 |
-// current strategy: Fetch 100 items per Account |
10 |
-// ATTENTION: This method is const and thus it is not possible to modify |
11 |
-// the _activityLists hash or so. Doesn't make it easier... |
12 |
bool ActivityListModel::canFetchMore(const QModelIndex &) const |
13 |
{ |
14 |
- if (_activityLists.count() == 0) |
15 |
- return true; |
16 |
- |
17 |
+ // We need to be connected to be able to fetch more |
18 |
if (_accountState && _accountState->isConnected()) { |
19 |
- if (_activityLists.count() == 0 && !_currentlyFetching) { |
20 |
+ // If the fetching is reported to be done or we are currently fetching we can't fetch more |
21 |
+ if (!_doneFetching && !_currentlyFetching) { |
22 |
return true; |
23 |
} |
24 |
} |
25 |
@@ -177,8 +173,8 @@ void ActivityListModel::startFetchJob() |
26 |
this, &ActivityListModel::slotActivitiesReceived); |
27 |
|
28 |
QUrlQuery params; |
29 |
- params.addQueryItem(QLatin1String("page"), QLatin1String("0")); |
30 |
- params.addQueryItem(QLatin1String("pagesize"), QLatin1String("100")); |
31 |
+ params.addQueryItem(QLatin1String("start"), QString::number(_currentItem)); |
32 |
+ params.addQueryItem(QLatin1String("count"), QString::number(100)); |
33 |
job->addQueryParams(params); |
34 |
|
35 |
_currentlyFetching = true; |
36 |
@@ -192,10 +188,16 @@ void ActivityListModel::slotActivitiesReceived(const QJsonDocument &json, int st |
37 |
|
38 |
ActivityList list; |
39 |
auto ast = _accountState; |
40 |
- if (!ast) |
41 |
+ if (!ast) { |
42 |
return; |
43 |
+ } |
44 |
|
45 |
- _currentlyFetching = 0; |
46 |
+ if (activities.size() == 0) { |
47 |
+ _doneFetching = true; |
48 |
+ } |
49 |
+ |
50 |
+ _currentlyFetching = false; |
51 |
+ _currentItem += activities.size(); |
52 |
|
53 |
foreach (auto activ, activities) { |
54 |
auto json = activ.toObject(); |
55 |
@@ -212,7 +214,7 @@ void ActivityListModel::slotActivitiesReceived(const QJsonDocument &json, int st |
56 |
list.append(a); |
57 |
} |
58 |
|
59 |
- _activityLists = list; |
60 |
+ _activityLists.append(list); |
61 |
|
62 |
emit activityJobStatusCode(statusCode); |
63 |
|
64 |
@@ -234,6 +236,7 @@ void ActivityListModel::addNotificationToActivityList(Activity activity) { |
65 |
void ActivityListModel::removeActivityFromActivityList(int row) { |
66 |
Activity activity = _finalList.at(row); |
67 |
removeActivityFromActivityList(activity); |
68 |
+ combineActivityLists(); |
69 |
} |
70 |
|
71 |
void ActivityListModel::addSyncFileItemToActivityList(Activity activity) { |
72 |
@@ -297,10 +300,10 @@ bool ActivityListModel::canFetchActivities() const { |
73 |
|
74 |
void ActivityListModel::fetchMore(const QModelIndex &) |
75 |
{ |
76 |
- _activityLists = ActivityList(); |
77 |
if (canFetchActivities()) { |
78 |
startFetchJob(); |
79 |
} else { |
80 |
+ _doneFetching = true; |
81 |
combineActivityLists(); |
82 |
} |
83 |
} |
84 |
@@ -308,9 +311,13 @@ void ActivityListModel::fetchMore(const QModelIndex &) |
85 |
void ActivityListModel::slotRefreshActivity() |
86 |
{ |
87 |
_activityLists.clear(); |
88 |
+ _doneFetching = false; |
89 |
+ _currentItem = 0; |
90 |
+ |
91 |
if (canFetchActivities()) { |
92 |
startFetchJob(); |
93 |
} else { |
94 |
+ _doneFetching = true; |
95 |
combineActivityLists(); |
96 |
} |
97 |
} |
98 |
@@ -320,5 +327,7 @@ void ActivityListModel::slotRemoveAccount() |
99 |
_finalList.clear(); |
100 |
_activityLists.clear(); |
101 |
_currentlyFetching = false; |
102 |
+ _doneFetching = false; |
103 |
+ _currentItem = 0; |
104 |
} |
105 |
} |
106 |
diff --git a/src/gui/activitylistmodel.h b/src/gui/activitylistmodel.h |
107 |
index 9b66da135..0c7606a0c 100644 |
108 |
--- src/gui/activitylistmodel.h |
109 |
+++ src/gui/activitylistmodel.h |
110 |
@@ -75,7 +75,9 @@ private slots: |
111 |
ActivityList _notificationErrorsLists; |
112 |
ActivityList _finalList; |
113 |
AccountState *_accountState; |
114 |
- bool _currentlyFetching = true; |
115 |
+ bool _currentlyFetching = false; |
116 |
+ bool _doneFetching = false; |
117 |
+ int _currentItem = 0; |
118 |
}; |
119 |
} |
120 |
#endif // ACTIVITYLISTMODEL_H |