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 {
14  struct Icon
15  {
16  int mValue;
17  QIcon mIcon;
18  QString mName;
19  };
20 
22  {
23  public:
24 
25  typedef std::vector<Icon> IconList;
26  typedef std::vector<std::pair<int, QString> > ValueList;
27 
28  protected:
29 
31  {
35  };
36 
39 
40  private:
41 
42  std::vector <std::pair <int, QPixmap> > mPixmaps;
43  QSize mIconSize;
46 
47  std::string mSettingKey;
48 
49  public:
50  DataDisplayDelegate (const ValueList & values, const IconList & icons,
51  CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document& document,
52  const std::string& pageName, const std::string& settingName, QObject *parent);
53 
55 
56  virtual void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
57 
58  virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
59 
61  void setIconSize (const QSize& icon);
62 
64  void setTextLeftOffset (int offset);
65 
66  private:
67 
69  void updateDisplayMode (const std::string &);
70 
72  void paintIcon (QPainter *painter, const QStyleOptionViewItem &option, int i) const;
73 
75  void buildPixmaps();
76 
77  virtual void settingChanged (const CSMPrefs::Setting *setting);
78  };
79 
81  {
82  protected:
83 
85 
86  public:
87 
88  virtual CommandDelegate *makeDelegate (CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document& document, QObject *parent) const;
90 
91  protected:
92 
93  void add (int enumValue, const QString& enumName, const QString& iconFilename);
94 
95  };
96 
97 }
98 
99 #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:43
Definition: datadisplaydelegate.hpp:33
QIcon mIcon
Definition: datadisplaydelegate.hpp:17
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:26
~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:30
DisplayMode mDisplayMode
Definition: datadisplaydelegate.hpp:37
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:45
Definition: datadisplaydelegate.hpp:32
QString mName
Definition: datadisplaydelegate.hpp:18
Definition: datadisplaydelegate.hpp:21
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:164
std::vector< std::pair< int, QPixmap > > mPixmaps
Definition: datadisplaydelegate.hpp:42
virtual void settingChanged(const CSMPrefs::Setting *setting)
Definition: datadisplaydelegate.cpp:136
int mHorizontalMargin
Definition: datadisplaydelegate.hpp:44
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:38
Definition: datadisplaydelegate.hpp:80
Integer value that represents an enum and is interacted with via a combobox.
Definition: enumdelegate.hpp:16
int mValue
Definition: datadisplaydelegate.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
DataDisplayDelegate::IconList mIcons
Definition: datadisplaydelegate.hpp:84
Definition: datadisplaydelegate.hpp:34
Definition: datadisplaydelegate.hpp:14
std::string mSettingKey
Definition: datadisplaydelegate.hpp:47
std::vector< Icon > IconList
Definition: datadisplaydelegate.hpp:25
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: datadisplaydelegate.cpp:51