Added getNeighbours functions to class Operation + moved UpdateMeshDensity to class...
[engrid.git] / vertexdelegate.h
blobf3f98e568a94355b6755eb8a43d83c4076ea39ea
1 #ifndef VERTEXDELEGATE_H
2 #define VERTEXDELEGATE_H
4 #include <QItemDelegate>
5 #include <QTableWidgetItem>
7 //Thanks to jpnurmi from qt@irc.freenode.net for this class ;)
8 class TriStateTableWidgetItem : public QTableWidgetItem
10 public:
11 TriStateTableWidgetItem() : QTableWidgetItem()
13 QTableWidgetItem::setCheckState(Qt::Checked);
14 setData(Qt::CheckStateRole,Qt::Checked);
16 void setData(int role, const QVariant& value)
18 QVariant tmp = value;
19 if (role == Qt::CheckStateRole)
21 if (data(role) == Qt::Unchecked && value == Qt::Checked)
22 tmp = Qt::PartiallyChecked;
23 else if (data(role) == Qt::PartiallyChecked && value == Qt::Checked)
24 tmp = Qt::Checked;
25 else
26 tmp = Qt::Unchecked;
28 QTableWidgetItem::setData(role, tmp);
30 void setCheckState(Qt::CheckState S){
31 QTableWidgetItem::setData(Qt::CheckStateRole, S);
35 class VertexDelegate : public QItemDelegate
37 Q_OBJECT
39 public:
40 VertexDelegate(int durationColumn, QList<QString> list, QObject *parent = 0);
42 void paint(QPainter *painter, const QStyleOptionViewItem &option,
43 const QModelIndex &index) const;
44 QWidget *createEditor(QWidget *parent,
45 const QStyleOptionViewItem &option,
46 const QModelIndex &index) const;
47 void setEditorData(QWidget *editor, const QModelIndex &index) const;
48 void setModelData(QWidget *editor, QAbstractItemModel *model,
49 const QModelIndex &index) const;
51 private slots:
52 void commitAndCloseEditor();
54 private:
55 QList<QString> list;
56 int durationColumn;
59 #endif