tageditor/application/targetlevelmodel.h

41 lines
1.4 KiB
C
Raw Permalink Normal View History

2016-05-26 02:15:41 +02:00
#ifndef TARGETLEVELMODEL_H
#define TARGETLEVELMODEL_H
#include <qtutilities/models/checklistmodel.h>
#include <QAbstractListModel>
#include <QList>
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 TagTargetLevel : unsigned char;
2016-05-26 02:15:41 +02:00
}
2019-07-07 12:00:16 +02:00
#undef TAGEDITOR_ENUM_CLASS
2016-05-26 02:15:41 +02:00
namespace Settings {
2019-06-10 22:49:46 +02:00
class TargetLevelModel : public QtUtilities::ChecklistModel {
2016-05-26 02:15:41 +02:00
Q_OBJECT
public:
2018-03-11 18:58:50 +01:00
enum class DefaultSelection { None, MostUsefulTargets };
2016-05-26 02:15:41 +02:00
2018-03-06 23:10:13 +01:00
static const char *fieldName(TagParser::TagTargetLevel targetLevel);
static QString translatedFieldName(TagParser::TagTargetLevel targetLevel);
2019-06-10 22:49:46 +02:00
static QtUtilities::ChecklistItem mkItem(TagParser::TagTargetLevel targetLevel, Qt::CheckState checkState = Qt::Checked);
2016-05-26 02:15:41 +02:00
explicit TargetLevelModel(QObject *parent = nullptr, DefaultSelection defaultSelection = DefaultSelection::None);
2019-06-10 22:49:46 +02:00
explicit TargetLevelModel(const QList<QtUtilities::ChecklistItem> &items, QObject *parent = nullptr);
2016-05-26 02:15:41 +02:00
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
virtual QString labelForId(const QVariant &id) const override;
2016-05-26 02:15:41 +02:00
};
2019-06-10 22:49:46 +02:00
inline QtUtilities::ChecklistItem TargetLevelModel::mkItem(TagParser::TagTargetLevel field, Qt::CheckState checkState)
2016-05-26 02:15:41 +02:00
{
2019-06-10 22:49:46 +02:00
return QtUtilities::ChecklistItem(static_cast<int>(field), translatedFieldName(field), checkState);
2016-05-26 02:15:41 +02:00
}
2018-03-11 18:58:50 +01:00
} // namespace Settings
2016-05-26 02:15:41 +02:00
#endif // TARGETLEVELMODEL_H