OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
datadisplaydelegate.hpp
Go to the documentation of this file.
1 #ifndef DATADISPLAYDELEGATE_HPP
2 #define DATADISPLAYDELEGATE_HPP
3 
4 #include <QTextOption>
5 #include "enumdelegate.hpp"
6 
7 namespace CSMPrefs
8 {
9  class Setting;
10 }
11 
12 namespace CSVWorld
13 {
15  {
16  public:
17 
18  typedef std::vector < std::pair < int, QIcon > > IconList;
19  typedef std::vector<std::pair<int, QString> > ValueList;
20 
21  protected:
22 
24  {
28  };
29 
32 
33  private:
34 
35  std::vector <std::pair <int, QPixmap> > mPixmaps;
36  QSize mIconSize;
39 
40  std::string mSettingKey;
41 
42  public:
43  DataDisplayDelegate (const ValueList & values, const IconList & icons,
44  CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document& document,
45  const std::string& pageName, const std::string& settingName, QObject *parent);
46 
48 
49  virtual void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
50 
51  virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
52 
54  void setIconSize (const QSize& icon);
55 
57  void setTextLeftOffset (int offset);
58 
59  private:
60 
62  void updateDisplayMode (const std::string &);
63 
65  void paintIcon (QPainter *painter, const QStyleOptionViewItem &option, int i) const;
66 
68  void buildPixmaps();
69 
70  virtual void settingChanged (const CSMPrefs::Setting *setting);
71  };
72 
74  {
75  protected:
76 
78 
79  public:
80 
81  virtual CommandDelegate *makeDelegate (CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document& document, QObject *parent) const;
83 
84  protected:
85 
86  void add (int enumValue, const QString& enumName, const QString& iconFilename);
87 
88  };
89 
90 }
91 
92 #endif // DATADISPLAYDELEGATE_HPP
void updateDisplayMode(const std::string &)
update the display mode based on a passed string
Definition: datadisplaydelegate.cpp:120
QSize mIconSize
Definition: datadisplaydelegate.hpp:36
Definition: datadisplaydelegate.hpp:26
void setTextLeftOffset(int offset)
offset the horizontal position of the text from the right edge of the icon. Default is 8 pixels...
Definition: datadisplaydelegate.cpp:46
std::vector< std::pair< int, QString > > ValueList
Definition: datadisplaydelegate.hpp:19
~DataDisplayDelegate()
Definition: datadisplaydelegate.cpp:132
Definition: enumdelegate.hpp:55
void buildPixmaps()
rebuild the list of pixmaps from the provided icons (called when icon size is changed) ...
Definition: datadisplaydelegate.cpp:26
DisplayMode
Definition: datadisplaydelegate.hpp:23
DisplayMode mDisplayMode
Definition: datadisplaydelegate.hpp:30
void setIconSize(const QSize &icon)
pass a QSize defining height / width of icon. Default is QSize (16,16).
Definition: datadisplaydelegate.cpp:40
void add(int enumValue, const QString &enumName, const QString &iconFilename)
Definition: datadisplaydelegate.cpp:143
int mTextLeftOffset
Definition: datadisplaydelegate.hpp:38
Definition: datadisplaydelegate.hpp:25
Definition: datadisplaydelegate.hpp:14
virtual CommandDelegate * makeDelegate(CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document &document, QObject *parent) const
The ownership of the returned CommandDelegate is transferred to the caller.
Definition: datadisplaydelegate.cpp:150
std::vector< std::pair< int, QPixmap > > mPixmaps
Definition: datadisplaydelegate.hpp:35
virtual void settingChanged(const CSMPrefs::Setting *setting)
Definition: datadisplaydelegate.cpp:136
int mHorizontalMargin
Definition: datadisplaydelegate.hpp:37
Definition: commanddispatcher.hpp:20
Definition: util.hpp:99
Definition: setting.hpp:22
void paintIcon(QPainter *painter, const QStyleOptionViewItem &option, int i) const
custom paint function for painting the icon. Mode_IconAndText and Mode_Icon only. ...
Definition: datadisplaydelegate.cpp:94
Definition: document.hpp:57
IconList mIcons
Definition: datadisplaydelegate.hpp:31
Definition: datadisplaydelegate.hpp:73
Integer value that represents an enum and is interacted with via a combobox.
Definition: enumdelegate.hpp:16
DataDisplayDelegate(const ValueList &values, const IconList &icons, CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document &document, const std::string &pageName, const std::string &settingName, QObject *parent)
Definition: datadisplaydelegate.cpp:8
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: datadisplaydelegate.cpp:75
std::vector< std::pair< int, QIcon > > IconList
Definition: datadisplaydelegate.hpp:18
DataDisplayDelegate::IconList mIcons
Definition: datadisplaydelegate.hpp:77
Definition: datadisplaydelegate.hpp:27
std::string mSettingKey
Definition: datadisplaydelegate.hpp:40
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: datadisplaydelegate.cpp:51