2016-05-26 02:15:41 +02:00
|
|
|
#ifndef KNOWNFIELDMODEL_H
|
|
|
|
#define KNOWNFIELDMODEL_H
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2017-04-27 22:10:55 +02:00
|
|
|
#if defined(TAGEDITOR_GUI_QTWIDGETS) || defined(TAGEDITOR_GUI_QTQUICK)
|
2018-03-07 01:18:01 +01:00
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QList>
|
|
|
|
#include <qtutilities/models/checklistmodel.h>
|
2016-07-27 18:31:42 +02:00
|
|
|
#else
|
2018-03-07 01:18:01 +01:00
|
|
|
#include <c++utilities/application/global.h>
|
|
|
|
#define Q_OBJECT
|
2016-07-27 18:31:42 +02:00
|
|
|
#endif
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2019-07-07 12:00:16 +02:00
|
|
|
#define TAGEDITOR_ENUM_CLASS enum class
|
2018-03-06 23:10:13 +01:00
|
|
|
namespace TagParser {
|
2019-07-07 12:00:16 +02:00
|
|
|
TAGEDITOR_ENUM_CLASS KnownField : unsigned int;
|
2015-04-22 19:33:53 +02:00
|
|
|
}
|
2019-07-07 12:00:16 +02:00
|
|
|
#undef TAGEDITOR_ENUM_CLASS
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
namespace Settings {
|
|
|
|
|
2016-07-27 18:31:42 +02:00
|
|
|
class KnownFieldModel
|
2017-04-27 22:10:55 +02:00
|
|
|
#if defined(TAGEDITOR_GUI_QTWIDGETS) || defined(TAGEDITOR_GUI_QTQUICK)
|
2019-06-10 22:49:46 +02:00
|
|
|
: public QtUtilities::ChecklistModel
|
2016-07-27 18:31:42 +02:00
|
|
|
#endif
|
2015-04-22 19:33:53 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-03-07 01:18:01 +01:00
|
|
|
enum class DefaultSelection { None, CommonFields };
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2018-03-06 23:10:13 +01:00
|
|
|
static const char *fieldName(TagParser::KnownField field);
|
2016-07-27 18:31:42 +02:00
|
|
|
|
2017-04-27 22:10:55 +02:00
|
|
|
#if defined(TAGEDITOR_GUI_QTWIDGETS) || defined(TAGEDITOR_GUI_QTQUICK)
|
2018-03-06 23:10:13 +01:00
|
|
|
static QString translatedFieldName(TagParser::KnownField field);
|
2019-06-10 22:49:46 +02:00
|
|
|
static QtUtilities::ChecklistItem mkItem(TagParser::KnownField field, Qt::CheckState checkState = Qt::Checked);
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
explicit KnownFieldModel(QObject *parent = nullptr, DefaultSelection defaultSelection = DefaultSelection::None);
|
2019-06-10 22:49:46 +02:00
|
|
|
explicit KnownFieldModel(const QList<QtUtilities::ChecklistItem> &items, QObject *parent = nullptr);
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2018-11-15 21:32:49 +01:00
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
|
|
QString labelForId(const QVariant &id) const override;
|
2016-07-27 18:31:42 +02:00
|
|
|
#endif
|
2015-04-22 19:33:53 +02:00
|
|
|
};
|
|
|
|
|
2017-04-27 22:10:55 +02:00
|
|
|
#if defined(TAGEDITOR_GUI_QTWIDGETS) || defined(TAGEDITOR_GUI_QTQUICK)
|
2019-06-10 22:49:46 +02:00
|
|
|
inline QtUtilities::ChecklistItem KnownFieldModel::mkItem(TagParser::KnownField field, Qt::CheckState checkState)
|
2016-03-23 22:02:43 +01:00
|
|
|
{
|
2019-06-10 22:49:46 +02:00
|
|
|
return QtUtilities::ChecklistItem(static_cast<int>(field), translatedFieldName(field), checkState);
|
2016-03-23 22:02:43 +01:00
|
|
|
}
|
2016-07-27 18:31:42 +02:00
|
|
|
#endif
|
2016-03-23 22:02:43 +01:00
|
|
|
|
2018-03-07 01:18:01 +01:00
|
|
|
} // namespace Settings
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2016-05-26 02:15:41 +02:00
|
|
|
#endif // KNOWNFIELDMODEL_H
|