mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 21:20:19 +00:00
Merge branch 'comboBoxDelegate' of https://github.com/tcanabrava/subsurface
This commit is contained in:
commit
9c3b512701
4 changed files with 33 additions and 0 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
#include "../statistics.h"
|
#include "../statistics.h"
|
||||||
#include "divelistview.h"
|
#include "divelistview.h"
|
||||||
|
#include "modeldelegates.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -81,6 +82,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
|
|
||||||
ui->cylinders->setColumnWidth( CylindersModel::REMOVE, 24);
|
ui->cylinders->setColumnWidth( CylindersModel::REMOVE, 24);
|
||||||
ui->cylinders->horizontalHeader()->setResizeMode (CylindersModel::REMOVE , QHeaderView::Fixed);
|
ui->cylinders->horizontalHeader()->setResizeMode (CylindersModel::REMOVE , QHeaderView::Fixed);
|
||||||
|
ui->cylinders->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
|
||||||
ui->weights->setColumnWidth( WeightModel::REMOVE, 24);
|
ui->weights->setColumnWidth( WeightModel::REMOVE, 24);
|
||||||
ui->cylinders->horizontalHeader()->setResizeMode (WeightModel::REMOVE , QHeaderView::Fixed);
|
ui->cylinders->horizontalHeader()->setResizeMode (WeightModel::REMOVE , QHeaderView::Fixed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
StarWidgetsDelegate::StarWidgetsDelegate(QWidget* parent):
|
StarWidgetsDelegate::StarWidgetsDelegate(QWidget* parent):
|
||||||
QStyledItemDelegate(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);
|
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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -12,4 +12,12 @@ public:
|
||||||
private:
|
private:
|
||||||
QWidget *parentWidget;
|
QWidget *parentWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TankInfoDelegate : public QStyledItemDelegate{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TankInfoDelegate(QObject* parent = 0);
|
||||||
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
BIN
trash.png
Normal file
BIN
trash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
Loading…
Reference in a new issue