DbDelegate Pile   version 0.0.1
DbDelegate pile.
dbdelegate.h
Go to the documentation of this file.
1 
10 #ifndef GUARD_DBDELEGATE_H_INCLUDE
11 #define GUARD_DBDELEGATE_H_INCLUDE
12 
13 #include <dbdelegate/dbdelegate-config.h>
14 #include <dbstruct/dbcolumn.h>
15 
16 #include <QStyledItemDelegate>
17 
18 QT_BEGIN_NAMESPACE
19 class QTableView;
20 class QAbstractItemModel;
21 class QCheckBox;
22 class QComboBox;
23 class QDateEdit;
24 class QDateTimeEdit;
25 class QDoubleSpinBox;
26 class QLineEdit;
27 class QSpinBox;
28 class QTimeEdit;
29 class QTextEdit;
30 QT_END_NAMESPACE
31 
32 class DbTaew;
33 class DbModel;
34 class DbModelCol;
35 
37 class DBDELEGATE_EXPORT DbDelegate : public QStyledItemDelegate {
38  Q_OBJECT
39 
40  DbColumn column_;
41 public:
42 
44  static bool
45  setAllDelegates (
46  QTableView * view);
47 
49  static bool
50  setAllDelegates (
51  DbTaew * table,
52  QTableView * view);
53 
55  static bool
56  resetAllDelegates (
57  QTableView * view);
58 
59  virtual const DbModel *
60  dbModelConst (
61  const QModelIndex &index) const;
62 
63  virtual DbModel *
64  dbModel (
65  const QModelIndex &index) const;
66 
67  virtual QVariant
68  getData (
69  const QModelIndex &index,
70  int role) const;
71 
72  virtual QModelIndex
73  mapIndex (
74  const QModelIndex & idx) const {
75  return idx;
76  }
77 
78 public:
79 
81  DbDelegate (
82  QObject *parent = NULL);
83 
85  virtual ~DbDelegate();
86 
88  virtual void
89  paint(
90  QPainter *painter,
91  const QStyleOptionViewItem &option,
92  const QModelIndex &index) const;
93 
95  virtual QSize
96  sizeHint(
97  const QStyleOptionViewItem &option,
98  const QModelIndex &index) const;
99 
101  virtual QWidget *
102  createEditor (
103  QWidget *parent,
104  const QStyleOptionViewItem &option,
105  const QModelIndex &index) const;
106 
108  virtual void
109  setEditorData (
110  QWidget *editor,
111  const QModelIndex &index) const;
112 
114  virtual void
115  setModelData (
116  QWidget *editor,
117  QAbstractItemModel *model,
118  const QModelIndex &index) const;
119 
121  virtual void
122  updateEditorGeometry (
123  QWidget *editor,
124  const QStyleOptionViewItem &option,
125  const QModelIndex &index) const;
126 
128  virtual QString
129  displayText (
130  const QVariant & value,
131  const QLocale &locale) const;
132 
133 
134 public:
135 
136  /* - - - - - - - - - - - - - - - - */
140 
142  static bool
143  setupControl (
144  const DbModelCol & col_data,
145  QCheckBox *control,
146  const QVariant & value);
147 
148  static bool
149  setupControl (
150  const DbModelCol & col_data,
151  QComboBox *control,
152  const QVariant & value);
153 
154  static bool
155  setupControl (
156  const DbModelCol & col_data,
157  QDateEdit *control,
158  const QVariant & value);
159 
160  static bool
161  setupControl (
162  const DbModelCol & col_data,
163  QDateTimeEdit *control,
164  const QVariant & value);
165 
166  static bool
167  setupControl (
168  const DbModelCol & col_data,
169  QDoubleSpinBox *control,
170  const QVariant & value);
171 
172  static bool
173  setupControl (
174  const DbModelCol & col_data,
175  QLineEdit *control,
176  const QVariant & value);
177 
178  static bool
179  setupControl (
180  const DbModelCol & col_data,
181  QSpinBox *control,
182  const QVariant & value);
183 
184  static bool
185  setupControl (
186  const DbModelCol & col_data,
187  QTimeEdit *control,
188  const QVariant & value);
189 
190  static bool
191  setupControl (
192  const DbModelCol & col_data,
193  QTextEdit *control,
194  const QVariant & value);
195 
197  /* - - - - - - - - - - - - - - - - */
198 
199 
200 protected:
201 
203  virtual void
204  initStyleOption (
205  QStyleOptionViewItem *option,
206  const QModelIndex &index) const;
207 
209  virtual bool
210  eventFilter (
211  QObject *object,
212  QEvent *event);
213 
215  virtual bool
216  editorEvent (
217  QEvent *event,
218  QAbstractItemModel *model,
219  const QStyleOptionViewItem &option,
220  const QModelIndex &index);
221 
222 private slots:
223 
224  void fucker (int i );
225 
226 };
227 
228 #endif // GUARD_DBDELEGATE_H_INCLUDE
Provides display and editing facilities for data items from a model.
Definition: dbdelegate.h:37