2017-12-19 08:36:09 -05:00
|
|
|
#ifndef ENTRYATTACHMENTSWIDGET_H
|
|
|
|
#define ENTRYATTACHMENTSWIDGET_H
|
|
|
|
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QWidget>
|
|
|
|
|
2018-03-31 16:01:30 -04:00
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class EntryAttachmentsWidget;
|
2017-12-19 08:36:09 -05:00
|
|
|
}
|
|
|
|
|
2017-12-25 11:07:02 -05:00
|
|
|
class QByteArray;
|
2017-12-19 08:36:09 -05:00
|
|
|
class EntryAttachments;
|
|
|
|
class EntryAttachmentsModel;
|
|
|
|
|
|
|
|
class EntryAttachmentsWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
|
|
|
|
Q_PROPERTY(bool isButtonsVisible READ isButtonsVisible WRITE setButtonsVisible NOTIFY buttonsVisibleChanged)
|
|
|
|
public:
|
|
|
|
explicit EntryAttachmentsWidget(QWidget* parent = nullptr);
|
|
|
|
~EntryAttachmentsWidget();
|
|
|
|
|
|
|
|
const EntryAttachments* entryAttachments() const;
|
|
|
|
bool isReadOnly() const;
|
|
|
|
bool isButtonsVisible() const;
|
|
|
|
|
2017-12-25 11:07:02 -05:00
|
|
|
QByteArray getAttachment(const QString& name);
|
|
|
|
void setAttachment(const QString& name, const QByteArray& value);
|
|
|
|
void removeAttachment(const QString& name);
|
|
|
|
|
2017-12-19 08:36:09 -05:00
|
|
|
public slots:
|
|
|
|
void setEntryAttachments(const EntryAttachments* attachments);
|
|
|
|
void clearAttachments();
|
|
|
|
void setReadOnly(bool readOnly);
|
|
|
|
void setButtonsVisible(bool isButtonsVisible);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void errorOccurred(const QString& error);
|
|
|
|
void readOnlyChanged(bool readOnly);
|
|
|
|
void buttonsVisibleChanged(bool isButtonsVisible);
|
2018-03-10 22:31:43 -05:00
|
|
|
void widgetUpdated();
|
2017-12-19 08:36:09 -05:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void insertAttachments();
|
|
|
|
void removeSelectedAttachments();
|
|
|
|
void saveSelectedAttachments();
|
|
|
|
void openAttachment(const QModelIndex& index);
|
|
|
|
void openSelectedAttachments();
|
|
|
|
void updateButtonsEnabled();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool insertAttachments(const QStringList& fileNames, QString& errorMessage);
|
|
|
|
bool openAttachment(const QModelIndex& index, QString& errorMessage);
|
|
|
|
|
|
|
|
bool eventFilter(QObject* watched, QEvent* event) override;
|
|
|
|
|
|
|
|
QScopedPointer<Ui::EntryAttachmentsWidget> m_ui;
|
|
|
|
QPointer<EntryAttachments> m_entryAttachments;
|
|
|
|
QPointer<EntryAttachmentsModel> m_attachmentsModel;
|
|
|
|
bool m_readOnly;
|
|
|
|
bool m_buttonsVisible;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ENTRYATTACHMENTSWIDGET_H
|