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

activitywidget.h « gui « src - github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5f33ba0b6efa252a6db45b76501b3a9d84975f9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
 * 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
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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 ACTIVITYWIDGET_H
#define ACTIVITYWIDGET_H

#include <QDialog>
#include <QDateTime>
#include <QLocale>
#include <QAbstractListModel>
#include <chrono>

#include "progressdispatcher.h"
#include "owncloudgui.h"
#include "account.h"
#include "activitydata.h"

#include "models/models.h"

#include "ui_activitywidget.h"

class QPushButton;
class QProgressIndicator;

namespace OCC {

class Account;
class AccountStatusPtr;
class ProtocolWidget;
class IssuesWidget;
class JsonApiJob;
class NotificationWidget;
class ActivityListModel;

namespace Ui {
    class ActivityWidget;
}
class Application;

/**
 * @brief The ActivityWidget class
 * @ingroup gui
 *
 * The list widget to display the activities, contained in the
 * subsequent ActivitySettings widget.
 */

class ActivityWidget : public QWidget
{
    Q_OBJECT
public:
    explicit ActivityWidget(QWidget *parent = nullptr);
    ~ActivityWidget() override;
    void storeActivityList(QTextStream &ts);

    /**
     * Adjusts the activity tab's and some widgets' visibility
     *
     * Based on whether activities are enabled and whether notifications are
     * available.
     */
    void checkActivityTabVisibility();

public slots:
    void slotRefreshActivities(AccountStatePtr ptr);
    void slotRefreshNotifications(AccountStatePtr ptr);
    void slotRemoveAccount(AccountStatePtr ptr);
    void slotAccountActivityStatus(AccountStatePtr ast, int statusCode);
    void slotRequestCleanupAndBlacklist(const Activity &blacklistActivity);

signals:
    void guiLog(const QString &, const QString &);
    void dataChanged();
    void hideActivityTab(bool);
    void newNotification();

private slots:
    void slotBuildNotificationDisplay(const ActivityList &list);
    void slotSendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb);
    void endNotificationRequest(NotificationWidget *widget, bool success);
    void scheduleWidgetToRemove(NotificationWidget *widget, int milliseconds = 100);
    void slotCheckToCleanWidgets();

private:
    void slotItemContextMenu();
    void showLabels();
    QString timeString(QDateTime dt, QLocale::FormatType format) const;
    Ui::ActivityWidget *_ui;
    QPushButton *_copyBtn;

    QSet<QString> _accountsWithoutActivities;
    QMap<Activity::Identifier, NotificationWidget *> _widgetForNotifId;
    QElapsedTimer _guiLogTimer;
    QSet<Activity::Identifier> _guiLoggedNotifications;
    ActivityList _blacklistedNotifications;

    QHash<NotificationWidget *, QDateTime> _widgetsToRemove;
    QTimer _removeTimer;

    // number of currently running notification requests. If non zero,
    // no query for notifications is started.
    int _notificationRequestsRunning;

    ActivityListModel *_model;
    SignalledQSortFilterProxyModel *_sortModel;
    QVBoxLayout *_notificationsLayout;
};


/**
 * @brief The ActivitySettings class
 * @ingroup gui
 *
 * Implements a tab for the settings dialog, displaying the three activity
 * lists.
 */
class ActivitySettings : public QWidget
{
    Q_OBJECT
public:
    explicit ActivitySettings(QWidget *parent = nullptr);
    ~ActivitySettings() override;

public slots:
    void slotRefresh(AccountStatePtr ptr);
    void slotRemoveAccount(AccountStatePtr ptr);

    void setNotificationRefreshInterval(std::chrono::milliseconds interval);

    void slotShowIssuesTab();

private slots:
    void setActivityTabHidden(bool hidden);
    void slotRegularNotificationCheck();
    void slotShowIssueItemCount(int cnt);
    void slotShowActivityTab();

signals:
    void guiLog(const QString &, const QString &);

private:
    bool event(QEvent *e) override;

    QTabWidget *_tab;
    int _activityTabId;
    int _protocolTabId;
    int _syncIssueTabId;

    ActivityWidget *_activityWidget;
    ProtocolWidget *_protocolWidget;
    IssuesWidget *_issuesWidget;
    QProgressIndicator *_progressIndicator;
    QTimer _notificationCheckTimer;
    QHash<AccountStatePtr, QElapsedTimer> _timeSinceLastCheck;
};
}
#endif // ActivityWIDGET_H