2016-03-11 13:37:45 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2016-10-25 12:00:07 +03:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2016-03-11 13:37:45 +03:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ACTIVITYLISTMODEL_H
|
|
|
|
#define ACTIVITYLISTMODEL_H
|
|
|
|
|
|
|
|
#include <QtCore>
|
|
|
|
|
|
|
|
#include "activitydata.h"
|
|
|
|
|
2017-04-26 13:15:33 +03:00
|
|
|
class QJsonDocument;
|
|
|
|
|
2016-03-11 13:37:45 +03:00
|
|
|
namespace OCC {
|
|
|
|
|
2017-05-09 15:24:11 +03:00
|
|
|
Q_DECLARE_LOGGING_CATEGORY(lcActivity)
|
|
|
|
|
2016-03-11 13:37:45 +03:00
|
|
|
class AccountState;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The ActivityListModel
|
|
|
|
* @ingroup gui
|
|
|
|
*
|
|
|
|
* Simple list model to provide the list view with data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class ActivityListModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-11-11 12:56:22 +03:00
|
|
|
explicit ActivityListModel(AccountState *accountState, QWidget *parent = nullptr);
|
2016-03-11 13:37:45 +03:00
|
|
|
|
2018-11-11 13:09:29 +03:00
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
2016-03-11 13:37:45 +03:00
|
|
|
|
2018-11-11 13:09:29 +03:00
|
|
|
bool canFetchMore(const QModelIndex &) const override;
|
|
|
|
void fetchMore(const QModelIndex &) override;
|
2016-03-11 13:37:45 +03:00
|
|
|
|
|
|
|
ActivityList activityList() { return _finalList; }
|
2018-07-18 00:56:31 +03:00
|
|
|
ActivityList errorsList() { return _notificationErrorsLists; }
|
2018-05-14 21:21:30 +03:00
|
|
|
void addNotificationToActivityList(Activity activity);
|
|
|
|
void addErrorToActivityList(Activity activity);
|
2018-08-24 10:17:47 +03:00
|
|
|
void addSyncFileItemToActivityList(Activity activity);
|
2018-07-18 00:56:31 +03:00
|
|
|
void removeActivityFromActivityList(int row);
|
|
|
|
void removeActivityFromActivityList(Activity activity);
|
2016-03-11 13:37:45 +03:00
|
|
|
|
|
|
|
public slots:
|
2018-03-27 18:19:22 +03:00
|
|
|
void slotRefreshActivity();
|
|
|
|
void slotRemoveAccount();
|
2016-03-11 13:37:45 +03:00
|
|
|
|
|
|
|
private slots:
|
2017-04-26 13:15:33 +03:00
|
|
|
void slotActivitiesReceived(const QJsonDocument &json, int statusCode);
|
2016-03-11 13:37:45 +03:00
|
|
|
|
|
|
|
signals:
|
2018-03-27 18:19:22 +03:00
|
|
|
void activityJobStatusCode(int statusCode);
|
2016-03-11 13:37:45 +03:00
|
|
|
|
|
|
|
private:
|
2018-03-27 18:19:22 +03:00
|
|
|
void startFetchJob();
|
2016-03-11 13:37:45 +03:00
|
|
|
void combineActivityLists();
|
|
|
|
|
2018-03-27 18:19:22 +03:00
|
|
|
ActivityList _activityLists;
|
2018-08-24 10:17:47 +03:00
|
|
|
ActivityList _syncFileItemLists;
|
2018-03-27 18:19:22 +03:00
|
|
|
ActivityList _notificationLists;
|
2018-05-14 21:21:30 +03:00
|
|
|
ActivityList _notificationErrorsLists;
|
2016-03-11 13:37:45 +03:00
|
|
|
ActivityList _finalList;
|
2018-03-27 18:19:22 +03:00
|
|
|
AccountState *_accountState;
|
|
|
|
bool _currentlyFetching = true;
|
2016-03-11 13:37:45 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // ACTIVITYLISTMODEL_H
|