diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-11-17 14:03:37 +0000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-17 14:03:37 +0000 |
commit | 0c3f13d128f366b036a77dfd2d195cbcac8547ba (patch) | |
tree | 02586f27258dfd9103796f7cc8236b9895e52322 /qt-ui/modeldelegates.cpp | |
parent | 1739042f3431e5b399db0cf49106c98478436a2f (diff) | |
download | subsurface-0c3f13d128f366b036a77dfd2d195cbcac8547ba.tar.gz |
Add the ability to modify the cylinder use in the UI
Thanks to Tomaz for writing a first draft of the delegate.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/modeldelegates.cpp')
-rw-r--r-- | qt-ui/modeldelegates.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 7079173c4..85be9ba62 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -277,6 +277,32 @@ QWidget *TankInfoDelegate::createEditor(QWidget *parent, const QStyleOptionViewI return delegate; } +TankUseDelegate::TankUseDelegate(QObject *parent) +{ + +} + +QWidget *TankUseDelegate::createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const +{ + QComboBox *comboBox = new QComboBox(parent); + for (int i = 0; i < NUM_GAS_USE; i++) + comboBox->addItem(QString(cylinderuse_text[i])); + return comboBox; +} + +void TankUseDelegate::setEditorData(QWidget * editor, const QModelIndex & index) const +{ + QComboBox *comboBox = qobject_cast<QComboBox*>(editor); + QString indexString = index.data().toString(); + comboBox->setCurrentIndex(cylinderuse_from_text(indexString.toUtf8().data())); +} + +void TankUseDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const +{ + QComboBox *comboBox = qobject_cast<QComboBox*>(editor); + model->setData(index, comboBox->currentIndex()); +} + struct RevertWeightData { QString type; int weight; |