tageditor/gui/tagfieldedit.h

131 lines
4.0 KiB
C
Raw Normal View History

2015-04-22 19:33:53 +02:00
#ifndef QTGUI_TAGFIELDLINEEDIT_H
#define QTGUI_TAGFIELDLINEEDIT_H
2015-09-06 20:20:00 +02:00
#include "./previousvaluehandling.h"
2015-04-22 19:33:53 +02:00
#include <c++utilities/application/global.h>
#include <QPair>
#include <QWidget>
2016-07-11 21:34:05 +02:00
QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
QT_FORWARD_DECLARE_CLASS(QLabel)
2015-04-22 19:33:53 +02:00
2018-03-06 23:10:13 +01:00
namespace TagParser {
2015-04-22 19:33:53 +02:00
class TagValue;
2016-07-11 21:34:05 +02:00
class Tag;
DECLARE_ENUM_CLASS(KnownField, unsigned int);
DECLARE_ENUM_CLASS(TagDataType, unsigned int);
DECLARE_ENUM_CLASS(TagTextEncoding, unsigned int);
2018-03-07 01:18:01 +01:00
} // namespace TagParser
2015-04-22 19:33:53 +02:00
namespace Widgets {
class ButtonOverlay;
class ClearLineEdit;
class ClearComboBox;
class ClearSpinBox;
class ClearPlainTextEdit;
class IconButton;
2018-03-07 01:18:01 +01:00
} // namespace Widgets
2015-04-22 19:33:53 +02:00
namespace QtGui {
class PicturePreviewSelection;
2018-03-07 01:18:01 +01:00
class TagFieldEdit : public QWidget {
2015-04-22 19:33:53 +02:00
Q_OBJECT
public:
2018-03-06 23:10:13 +01:00
explicit TagFieldEdit(const QList<TagParser::Tag *> &tags, TagParser::KnownField field, QWidget *parent = nullptr);
2015-04-22 19:33:53 +02:00
2018-03-06 23:10:13 +01:00
const QList<TagParser::Tag *> &tags() const;
TagParser::KnownField field() const;
2018-03-07 01:18:01 +01:00
void setTagField(const QList<TagParser::Tag *> &tags, TagParser::KnownField field,
PreviousValueHandling previousValueHandling = PreviousValueHandling::Clear, bool preventUiUpdate = false);
2018-03-06 23:10:13 +01:00
TagParser::TagValue value(TagParser::TagTextEncoding encoding, bool includeDescription) const;
bool setValue(const TagParser::TagValue &value, PreviousValueHandling previousValueHandling = PreviousValueHandling::Clear);
2015-04-22 19:33:53 +02:00
bool hasDescription() const;
2018-03-06 23:10:13 +01:00
bool canApply(TagParser::KnownField field) const;
2019-05-28 23:59:38 +02:00
bool isLocked() const;
void setLocked(bool locked);
void toggleLocked();
2015-04-22 19:33:53 +02:00
public slots:
void clear();
void apply();
void restore();
void setCoverButtonsHidden(bool hideCoverButtons);
2015-04-22 19:33:53 +02:00
signals:
void returnPressed();
protected:
2019-06-01 12:45:12 +02:00
bool eventFilter(QObject *obj, QEvent *event) override;
2015-04-22 19:33:53 +02:00
private slots:
void handleRestoreButtonClicked();
void handleRestoreButtonDestroyed(QObject *obj = nullptr);
2019-05-28 23:59:38 +02:00
void handleLockButtonDestroyed(QObject *obj = nullptr);
2015-04-22 19:33:53 +02:00
private:
2018-03-06 23:10:13 +01:00
TagParser::TagDataType determineDataType();
2015-04-22 19:33:53 +02:00
void setupUi();
Widgets::ClearLineEdit *setupLineEdit();
Widgets::ClearPlainTextEdit *setupPlainTextEdit();
Widgets::ClearComboBox *setupGenreComboBox();
Widgets::ClearSpinBox *setupSpinBox();
QPair<Widgets::ClearSpinBox *, Widgets::ClearSpinBox *> &setupPositionInSetSpinBoxes();
PicturePreviewSelection *setupPictureSelection();
QWidget *setupFileSelection();
Widgets::ClearLineEdit *setupDescriptionLineEdit();
QLabel *setupTypeNotSupportedLabel();
void updateValue(PreviousValueHandling previousValueHandling = PreviousValueHandling::Clear);
2018-03-06 23:10:13 +01:00
void updateValue(TagParser::Tag *tag, PreviousValueHandling previousValueHandling = PreviousValueHandling::Clear);
2018-03-07 01:18:01 +01:00
void updateValue(
const TagParser::TagValue &value, PreviousValueHandling previousValueHandling = PreviousValueHandling::Clear, bool resetRestoreButton = true);
2015-04-22 19:33:53 +02:00
Widgets::IconButton *setupRestoreButton();
2019-05-28 23:59:38 +02:00
Widgets::IconButton *setupLockButton();
2015-04-22 19:33:53 +02:00
void showRestoreButton();
void applyAutoCorrection(QString &textValue);
void concretizePreviousValueHandling(PreviousValueHandling &previousValueHandling);
QVBoxLayout *m_layout;
2018-03-06 23:10:13 +01:00
const QList<TagParser::Tag *> *m_tags;
TagParser::KnownField m_field;
TagParser::TagDataType m_dataType;
2015-04-22 19:33:53 +02:00
QList<QWidget *> m_widgets;
Widgets::ClearLineEdit *m_lineEdit;
Widgets::ClearComboBox *m_comboBox;
QPair<Widgets::ClearSpinBox *, Widgets::ClearSpinBox *> m_spinBoxes;
PicturePreviewSelection *m_pictureSelection;
Widgets::ClearPlainTextEdit *m_plainTextEdit;
Widgets::ClearLineEdit *m_descriptionLineEdit;
Widgets::IconButton *m_restoreButton;
2019-05-28 23:59:38 +02:00
Widgets::IconButton *m_lockButton;
bool m_isLocked;
2015-04-22 19:33:53 +02:00
};
2018-03-06 23:10:13 +01:00
inline const QList<TagParser::Tag *> &TagFieldEdit::tags() const
2015-04-22 19:33:53 +02:00
{
return *m_tags;
}
2018-03-06 23:10:13 +01:00
inline TagParser::KnownField TagFieldEdit::field() const
2015-04-22 19:33:53 +02:00
{
return m_field;
}
2019-05-28 23:59:38 +02:00
inline bool TagFieldEdit::isLocked() const
{
return m_isLocked;
}
inline void TagFieldEdit::toggleLocked()
{
setLocked(!isLocked());
}
2018-03-07 01:18:01 +01:00
} // namespace QtGui
2015-04-22 19:33:53 +02:00
#endif // QTGUI_TAGFIELDLINEEDIT_H