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

activitydata.h « tray « gui « src - github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9c035e2a32216f45c9f98d05c3b7237fe78474f6 (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
169
170
171
172
173
/*
 * 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 ACTIVITYDATA_H
#define ACTIVITYDATA_H

#include <QtCore>
#include <QIcon>
#include <QJsonObject>

#include "syncfileitem.h"
#include "folder.h"
#include "account.h"

namespace OCC {
/**
 * @brief The ActivityLink class describes actions of an activity
 *
 * These are part of notifications which are mapped into activities.
 */

class ActivityLink
{
    Q_GADGET
    
    Q_PROPERTY(QString imageSource MEMBER _imageSource)
    Q_PROPERTY(QString imageSourceHovered MEMBER _imageSourceHovered)
    Q_PROPERTY(QString label MEMBER _label)
    Q_PROPERTY(QString link MEMBER _link)
    Q_PROPERTY(QByteArray verb MEMBER _verb)
    Q_PROPERTY(bool primary MEMBER _primary)

public:
    static ActivityLink createFomJsonObject(const QJsonObject &obj);

public:
    QString _imageSource;
    QString _imageSourceHovered;
    QString _label;
    QString _link;
    QByteArray _verb;
    bool _primary;
};

/**
 * @brief The PreviewData class describes the data about a file's preview.
 */

class PreviewData
{
    Q_GADGET

    Q_PROPERTY(QString source MEMBER _source)
    Q_PROPERTY(QString link MEMBER _link)
    Q_PROPERTY(QString mimeType MEMBER _mimeType)
    Q_PROPERTY(int fileId MEMBER _fileId)
    Q_PROPERTY(QString view MEMBER _view)
    Q_PROPERTY(bool isMimeTypeIcon MEMBER _isMimeTypeIcon)
    Q_PROPERTY(QString filename MEMBER _filename)

public:
    QString _source;
    QString _link;
    QString _mimeType;
    int _fileId;
    QString _view;
    bool _isMimeTypeIcon;
    QString _filename;
};

/* ==================================================================== */
/**
 * @brief Activity Structure
 * @ingroup gui
 *
 * contains all the information describing a single activity.
 */

class Activity
{
public:
    using Identifier = QPair<qlonglong, QString>;

    enum Type {
        ActivityType,
        NotificationType,
        SyncResultType,
        SyncFileItemType
    };

    static Activity fromActivityJson(const QJsonObject json, const AccountPtr account);

    struct RichSubjectParameter {
        QString type;    // Required
        QString id;      // Required
        QString name;    // Required
        QString path;    // Required (for files only)
        QUrl link;    // Optional (files only)
    };

    struct TalkNotificationData {
        QString conversationToken;
        QString messageId;
        QString messageSent;
    };

    Type _type;
    qlonglong _id;
    QString _fileAction;
    int _objectId;
    TalkNotificationData _talkNotificationData;
    QString _objectType;
    QString _objectName;
    QString _subject;
    QString _subjectRich;
    QHash<QString, RichSubjectParameter> _subjectRichParameters;
    QString _subjectDisplay;
    QString _message;
    QString _folder;
    QString _file;
    QString _renamedFile;
    QUrl _link;
    QDateTime _dateTime;
    qint64 _expireAtMsecs = -1;
    QString _accName;
    QString _darkIcon;
    QString _lightIcon;
    bool _isCurrentUserFileActivity = false;
    QVector<PreviewData> _previews;

    // Stores information about the error
    int _status;

    QVector<ActivityLink> _links;
    /**
     * @brief Sort operator to sort the list youngest first.
     * @param val
     * @return
     */


    Identifier ident() const;
};

bool operator==(const Activity &rhs, const Activity &lhs);
bool operator<(const Activity &rhs, const Activity &lhs);

/* ==================================================================== */
/**
 * @brief The ActivityList
 * @ingroup gui
 *
 * A QList based list of Activities
 */
using ActivityList = QList<Activity>;
}

Q_DECLARE_METATYPE(OCC::Activity::Type)
Q_DECLARE_METATYPE(OCC::ActivityLink)
Q_DECLARE_METATYPE(OCC::PreviewData)

#endif // ACTIVITYDATA_H