ActivityWidget: Detect new items in the list to refetch the activities.

On refresh, remove the activity list object from the models list.
This commit is contained in:
Klaas Freitag 2015-11-17 14:46:13 +01:00
parent 1cdf0e8597
commit c9ef4d5fa0
2 changed files with 4 additions and 4 deletions

View File

@ -204,13 +204,14 @@ void ActivityListModel::fetchMore(const QModelIndex &)
QList<AccountStatePtr> accounts = AccountManager::instance()->accounts();
foreach (AccountStatePtr asp, accounts) {
bool newItem = false;
// if the account is not yet managed, add an empty list.
if( !_activityLists.contains(asp.data()) ) {
_activityLists[asp.data()] = ActivityList();
newItem = true;
}
ActivityList activities = _activityLists[asp.data()];
if( activities.count() == 0 ) {
if( newItem ) {
startFetchJob(asp.data());
}
}
@ -220,7 +221,7 @@ void ActivityListModel::slotRefreshActivity(AccountState *ast)
{
if(ast && _activityLists.contains(ast)) {
qDebug() << "**** Refreshing Activity list for" << ast->account()->displayName();
_activityLists[ast].clear();
_activityLists.remove(ast);
}
startFetchJob(ast);
}

View File

@ -76,7 +76,6 @@ public:
*/
class ActivityList:public QList<Activity>
{
// explicit ActivityList();
public:
void setAccountName( const QString& name );
QString accountName() const;