COPASI API  4.16.103
CQComboDelegate.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2014 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 #ifndef CQComboDelegate_H
12 #define CQComboDelegate_H
13 
14 #include <QtGui/QItemDelegate>
15 
16 class CQComboDelegate : public QItemDelegate
17 {
18  Q_OBJECT
19 
20 public:
21  CQComboDelegate(const QStringList* pComboItems,
22  QObject *parent = NULL, bool commitOnSelect = true);
23 
24  virtual ~CQComboDelegate();
25 
26  virtual QWidget * createEditor(QWidget * parent,
27  const QStyleOptionViewItem & option,
28  const QModelIndex & index) const;
29 
30  virtual void setEditorData(QWidget * editor,
31  const QModelIndex & index) const;
32 
33  virtual void setModelData(QWidget * editor,
34  QAbstractItemModel * model,
35  const QModelIndex & index) const;
36 
37  virtual void updateEditorGeometry(QWidget * editor,
38  const QStyleOptionViewItem & option,
39  const QModelIndex & index) const;
40 
41  void setItems(int row, const QStringList* pComboItems);
42 
43  const QStringList *getItems(int row) const;
44 
45  bool isCommitOnSelect() const;
46  void setCommitOnSelect(bool commitOnSelect);
47 
48 protected slots:
49  void slotCurrentIndexChanged(int index);
50  void slotEditorDeleted(QObject * pObject);
51 
52 signals:
53  void currentIndexChanged(int, int);
54 
55 private:
56  const QStringList* mpComboItems;
57 
58  mutable QMap< QWidget * , QModelIndex > mEditorToIndex;
59  mutable QMap< int, const QStringList * > mRowToItems;
60 
62 };
63 
65 {
66 public:
67  CQIndexComboDelegate(const QStringList *pComboItems,
68  QObject *parent = NULL);
69 
70  virtual ~CQIndexComboDelegate();
71 
72  virtual void setModelData(QWidget * editor,
73  QAbstractItemModel * model,
74  const QModelIndex & index) const;
75 };
76 #endif //CQComboDelegate_H
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
CQComboDelegate(const QStringList *pComboItems, QObject *parent=NULL, bool commitOnSelect=true)
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const
const QStringList * mpComboItems
QMap< QWidget *, QModelIndex > mEditorToIndex
bool isCommitOnSelect() const
void currentIndexChanged(int, int)
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
const QStringList * getItems(int row) const
CQIndexComboDelegate(const QStringList *pComboItems, QObject *parent=NULL)
virtual ~CQComboDelegate()
QMap< int, const QStringList * > mRowToItems
void setCommitOnSelect(bool commitOnSelect)
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
void setItems(int row, const QStringList *pComboItems)
void slotEditorDeleted(QObject *pObject)
void slotCurrentIndexChanged(int index)