diff options
| author | Christoph Berg <myon@debian.org> | 2018-12-19 23:01:50 +0100 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2018-12-19 23:01:50 +0100 |
| commit | 5c60c77adff9a54fd5f94f9915b22ccd8c4c5a3b (patch) | |
| tree | 410fa358a5f73260a579b4d669730f319a4d2609 /models/DecodeHighlightingModel.hpp | |
| parent | 6c82050de806dcdafaed0077400a6c3396a4a159 (diff) | |
| parent | e0737c56c1e384e05064a0c6e1ac46979371041b (diff) | |
Update upstream source from tag 'upstream/2.0.0+repack'
Update to upstream version '2.0.0+repack'
with Debian dir 55dbb3a6a7eb189e187dd79f732623ca0b56116d
Diffstat (limited to 'models/DecodeHighlightingModel.hpp')
| -rw-r--r-- | models/DecodeHighlightingModel.hpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/models/DecodeHighlightingModel.hpp b/models/DecodeHighlightingModel.hpp new file mode 100644 index 00000000..afb66276 --- /dev/null +++ b/models/DecodeHighlightingModel.hpp @@ -0,0 +1,79 @@ +#ifndef DECODE_HIGHLIGHTING_MODEL_HPP_ +#define DECODE_HIGHLIGHTING_MODEL_HPP_ + +#include <QAbstractListModel> +#include <QBrush> +#include <QList> + +#include "qt_helpers.hpp" +#include "pimpl_h.hpp" + +class QObject; +class QFont; +class QDataStream; +class QDebug; + +class DecodeHighlightingModel final + : public QAbstractListModel +{ + Q_OBJECT +public: + enum class Highlight : char {CQ, MyCall, Tx, DXCC, DXCCBand, Grid, GridBand, Call, CallBand + , Continent, ContinentBand, CQZone, CQZoneBand, ITUZone, ITUZoneBand + , LotW}; + Q_ENUM (Highlight) + static QString highlight_name (Highlight h); + + struct HighlightInfo final + { + Highlight type_; + bool enabled_; + QBrush foreground_; + QBrush background_; + }; + using HighlightItems = QList<HighlightInfo>; + + explicit DecodeHighlightingModel (QObject * parent = 0); + ~DecodeHighlightingModel(); + + // access to raw items nd default items + static HighlightItems const& default_items (); + HighlightItems const& items () const; + void items (HighlightItems const&); + + void set_font (QFont const&); + + enum DefaultRoles {TypeRole = Qt::UserRole, EnabledDefaultRole, ForegroundDefaultRole, BackgroundDefaultRole}; + +private: + // implement the QAbstractListModel interface + int rowCount (QModelIndex const& parent = QModelIndex()) const override; + QVariant data (QModelIndex const&, int role) const override; + QVariant headerData (int section, Qt::Orientation, int role = Qt::DisplayRole) const override; + Qt::ItemFlags flags (QModelIndex const&) const override; + bool setData (QModelIndex const& index, QVariant const& value, int role) override; + Qt::DropActions supportedDropActions () const override; + bool insertRows (int row, int count, QModelIndex const& parent = QModelIndex {}) override; + bool removeRows (int row, int count, QModelIndex const& parent = QModelIndex {}) override; + QMap<int, QVariant> itemData (QModelIndex const&) const override; + + class impl; + pimpl<impl> m_; +}; + +bool operator == (DecodeHighlightingModel::HighlightInfo const&, DecodeHighlightingModel::HighlightInfo const&); + +QDataStream& operator << (QDataStream&, DecodeHighlightingModel::HighlightInfo const&); +QDataStream& operator >> (QDataStream&, DecodeHighlightingModel::HighlightInfo&); + +#if !defined (QT_NO_DEBUG_STREAM) +QDebug operator << (QDebug, DecodeHighlightingModel::HighlightInfo const&); +#endif + +ENUM_QDATASTREAM_OPS_DECL (DecodeHighlightingModel, Highlight); +ENUM_CONVERSION_OPS_DECL (DecodeHighlightingModel, Highlight); + +Q_DECLARE_METATYPE (DecodeHighlightingModel::HighlightInfo); +Q_DECLARE_METATYPE (DecodeHighlightingModel::HighlightItems); + +#endif |
