-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
attachmenteditormodel.h
50 lines (37 loc) · 1.54 KB
/
attachmenteditormodel.h
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
// SPDX-FileCopyrightText: 2021 kaniini <https://git.pleroma.social/kaniini>
// SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "timeline/post.h"
class QTimer;
class AbstractAccount;
class AttachmentEditorModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
explicit AttachmentEditorModel(QObject *parent, AbstractAccount *account);
enum ExtraRole { PreviewRole = Qt::UserRole + 1, DescriptionRole, FocalXRole, FocalYRole };
[[nodiscard]] int count() const;
Q_INVOKABLE [[nodiscard]] int rowCount(const QModelIndex &parent = {}) const override;
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
[[nodiscard]] const QList<Attachment *> &attachments() const;
void copyFromOther(AttachmentEditorModel *other);
public Q_SLOTS:
QNetworkReply *append(const QString &fileName);
QNetworkReply *appendData(QVariant data);
void appendExisting(Attachment *attachment);
void removeAttachment(int row);
void setDescription(int row, const QString &description);
void setFocusPoint(int row, double x, double y);
bool isLocalFile(const QString &fileName);
Q_SIGNALS:
void postChanged();
void countChanged();
private:
QList<Attachment *> m_attachments;
QHash<QString, QTimer *> m_updateTimers;
AbstractAccount *m_account = nullptr;
QTemporaryDir m_saveDir;
};