summaryrefslogtreecommitdiffstats
path: root/qt-ui/modeldelegates.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-05-22 14:11:49 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-05-22 14:11:49 -0300
commitfc4243eef08b1b90241bdf048506826180d9d853 (patch)
tree8819f79f615d97b5d17e72a8641f74a0d490e407 /qt-ui/modeldelegates.cpp
parentd6bee060afaaf54b731c1e27b130089ebb5a9e40 (diff)
downloadsubsurface-fc4243eef08b1b90241bdf048506826180d9d853.tar.gz
Added a Delegate for editing Cylinders
Now when you edit 'Type', a drop-down list will appear and will enable you to choose from it's contents. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/modeldelegates.cpp')
-rw-r--r--qt-ui/modeldelegates.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp
index be47198e2..0164deedc 100644
--- a/qt-ui/modeldelegates.cpp
+++ b/qt-ui/modeldelegates.cpp
@@ -9,6 +9,7 @@
#include <QSortFilterProxyModel>
#include <QStyle>
#include <QStyleOption>
+#include <QComboBox>
StarWidgetsDelegate::StarWidgetsDelegate(QWidget* parent):
QStyledItemDelegate(parent),
@@ -47,3 +48,25 @@ QSize StarWidgetsDelegate::sizeHint(const QStyleOptionViewItem& option, const QM
{
return QSize(IMG_SIZE * TOTALSTARS + SPACING * (TOTALSTARS-1), IMG_SIZE);
}
+
+QWidget* TankInfoDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
+{
+ QComboBox *comboDelegate = new QComboBox(parent);
+ TankInfoModel *model = new TankInfoModel;
+ QString data = index.model()->data(index, Qt::DisplayRole).toString();
+ qDebug() << "Tentando pegar " << data;
+ comboDelegate->setModel(model);
+ int i;
+ for(i = 0; i < model->rowCount(); i++){
+ if (model->data(model->index(i,0), Qt::DisplayRole).toString() == data){
+ break;
+ }
+ }
+ if (i != model->rowCount())
+ comboDelegate->setCurrentIndex(i);
+ return comboDelegate;
+}
+
+TankInfoDelegate::TankInfoDelegate(QObject* parent): QStyledItemDelegate(parent)
+{
+}