mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
d6bee060af
commit
fc4243eef0
3 changed files with 33 additions and 0 deletions
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue