2015-04-22 19:33:53 +02:00
|
|
|
#ifndef ATTACHMENTSMODEL_H
|
|
|
|
#define ATTACHMENTSMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
|
2018-03-06 23:10:13 +01:00
|
|
|
namespace TagParser {
|
2015-04-22 19:33:53 +02:00
|
|
|
class AbstractAttachment;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace QtGui {
|
|
|
|
|
2018-03-07 01:18:01 +01:00
|
|
|
class AttachmentItem {
|
2015-04-22 19:33:53 +02:00
|
|
|
public:
|
2018-03-06 23:10:13 +01:00
|
|
|
AttachmentItem(TagParser::AbstractAttachment *attachment, bool activated = true, const QString &location = QString());
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2018-03-06 23:10:13 +01:00
|
|
|
TagParser::AbstractAttachment *attachment();
|
|
|
|
const TagParser::AbstractAttachment *attachment() const;
|
2015-04-22 19:33:53 +02:00
|
|
|
const QString &name() const;
|
|
|
|
void setName(const QString &name);
|
|
|
|
const QString &description() const;
|
|
|
|
void setDescription(const QString &description);
|
|
|
|
const QString &mimeType() const;
|
|
|
|
void setMimeType(const QString &mimeType);
|
|
|
|
const QString &size() const;
|
|
|
|
const QString &location() const;
|
|
|
|
bool isActivated() const;
|
|
|
|
void setActivated(bool isActivated);
|
|
|
|
|
|
|
|
void revert();
|
|
|
|
void submit();
|
|
|
|
|
|
|
|
private:
|
2018-03-06 23:10:13 +01:00
|
|
|
TagParser::AbstractAttachment *m_attachment;
|
2015-04-22 19:33:53 +02:00
|
|
|
QString m_name;
|
|
|
|
QString m_description;
|
|
|
|
QString m_mimeType;
|
|
|
|
QString m_size;
|
|
|
|
QString m_location;
|
|
|
|
bool m_activated;
|
|
|
|
};
|
|
|
|
|
2018-03-07 01:18:01 +01:00
|
|
|
class AttachmentsModel : public QAbstractTableModel {
|
2015-04-22 19:33:53 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
AttachmentsModel(QObject *parent = nullptr);
|
2019-06-01 12:45:12 +02:00
|
|
|
~AttachmentsModel() override;
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2019-06-01 12:45:12 +02:00
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2019-06-01 12:45:12 +02:00
|
|
|
void revert() override;
|
|
|
|
bool submit() override;
|
2015-04-22 19:33:53 +02:00
|
|
|
void repealSelection();
|
|
|
|
|
2018-03-06 23:10:13 +01:00
|
|
|
TagParser::AbstractAttachment *attachment(const QModelIndex &index);
|
|
|
|
void addAttachment(int row, TagParser::AbstractAttachment *attachment, bool activated = true, const QString &location = QString());
|
|
|
|
void setAttachments(const QList<TagParser::AbstractAttachment *> &attachments, bool activated = true, const QString &location = QString());
|
2015-04-22 19:33:53 +02:00
|
|
|
void removeAttachments(int firstRow, int lastRow);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<AttachmentItem> m_attachments;
|
|
|
|
};
|
|
|
|
|
2018-03-07 01:18:01 +01:00
|
|
|
} // namespace QtGui
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
#endif // ATTACHMENTSMODEL_H
|