diff options
| author | Christoph Berg <myon@debian.org> | 2018-12-19 22:58:32 +0100 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2018-12-19 22:58:32 +0100 |
| commit | e0737c56c1e384e05064a0c6e1ac46979371041b (patch) | |
| tree | a0123d694a2d36c43dabdf0a3907392fce11d457 /models/FontOverrideModel.hpp | |
| parent | b4aebf2d137b892f53503b13785ecae900062ff7 (diff) | |
New upstream version 2.0.0+repackupstream/2.0.0+repack
Diffstat (limited to 'models/FontOverrideModel.hpp')
| -rw-r--r-- | models/FontOverrideModel.hpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/models/FontOverrideModel.hpp b/models/FontOverrideModel.hpp new file mode 100644 index 00000000..2bff9aa8 --- /dev/null +++ b/models/FontOverrideModel.hpp @@ -0,0 +1,29 @@ +#ifndef FONT_OVERRIDE_MODEL_HPP_ +#define FONT_OVERRIDE_MODEL_HPP_ + +#include <QIdentityProxyModel> +#include <QFont> + +// fix up font display as header font changes don't currently work +// from views (I think fixed in Qt 5.11.1) +class FontOverrideModel final + : public QIdentityProxyModel +{ +public: + FontOverrideModel (QObject * parent = nullptr) : QIdentityProxyModel {parent} {} + void set_font (QFont const& font) {font_ = font;} + QVariant data (QModelIndex const& index, int role) const override + { + if (Qt::FontRole == role) return font_; + return QIdentityProxyModel::data (index, role); + } + QVariant headerData (int section, Qt::Orientation orientation, int role) const override + { + if (Qt::FontRole == role) return font_; + return QIdentityProxyModel::headerData (section, orientation, role); + } +private: + QFont font_; +}; + +#endif |
