File indexing completed on 2024-05-19 08:54:58

0001 // SPDX-FileCopyrightText: 2021 kaniini <https://git.pleroma.social/kaniini>
0002 // SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu>
0003 // SPDX-License-Identifier: GPL-3.0-only
0004 
0005 #pragma once
0006 
0007 #include "post.h"
0008 
0009 class QTimer;
0010 class AbstractAccount;
0011 
0012 class AttachmentEditorModel : public QAbstractListModel
0013 {
0014     Q_OBJECT
0015     Q_PROPERTY(int count READ count NOTIFY countChanged)
0016 
0017 public:
0018     explicit AttachmentEditorModel(QObject *parent, AbstractAccount *account);
0019 
0020     enum ExtraRole { PreviewRole = Qt::UserRole + 1, DescriptionRole, FocalXRole, FocalYRole };
0021 
0022     int count() const;
0023 
0024     Q_INVOKABLE int rowCount(const QModelIndex &parent = {}) const override;
0025     QVariant data(const QModelIndex &index, int role) const override;
0026     QHash<int, QByteArray> roleNames() const override;
0027     const QList<Attachment *> &attachments() const;
0028 
0029 public Q_SLOTS:
0030     QNetworkReply *append(const QString &fileName);
0031     void appendExisting(Attachment *attachment);
0032     void removeAttachment(int row);
0033     void setDescription(int row, const QString &description);
0034     void setFocusPoint(int row, double x, double y);
0035 
0036 Q_SIGNALS:
0037     void postChanged();
0038     void countChanged();
0039 
0040 private:
0041     QList<Attachment *> m_attachments;
0042     QHash<QString, QTimer *> m_updateTimers;
0043     AbstractAccount *m_account;
0044 };