|
@@ -6,6 +6,8 @@
|
|
|
#include <QButtonGroup>
|
|
|
#include <QDebug>
|
|
|
|
|
|
+#include <QComboBox>
|
|
|
+
|
|
|
SchemeBar::SchemeBar(const QString &lLabel, const QString &rLabel, const QStringList &vlist, QWidget *parent)
|
|
|
: QDialog(parent), leftLabel(lLabel), rightLabel(rLabel), barValueList(vlist)
|
|
|
{
|
|
@@ -44,3 +46,35 @@ void SchemeBar::barClicked(QAbstractButton *btn)
|
|
|
emit setValue(btn->property("number").toString());
|
|
|
this->close();
|
|
|
}
|
|
|
+
|
|
|
+EXDataTableComboDelegate::EXDataTableComboDelegate(QObject *parent) : QStyledItemDelegate(parent) { }
|
|
|
+
|
|
|
+QWidget *EXDataTableComboDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & /* option */,
|
|
|
+ const QModelIndex & /* index */) const
|
|
|
+{
|
|
|
+ QComboBox *w = new QComboBox(parent);
|
|
|
+
|
|
|
+ w->addItems({ "9", "5", "4", "3", "1" });
|
|
|
+
|
|
|
+ return w;
|
|
|
+}
|
|
|
+
|
|
|
+void EXDataTableComboDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
|
|
+{
|
|
|
+ QString value = index.model()->data(index, Qt::EditRole).toString();
|
|
|
+ QComboBox *comboBox = static_cast<QComboBox *>(editor);
|
|
|
+ comboBox->setCurrentText(value);
|
|
|
+}
|
|
|
+
|
|
|
+void EXDataTableComboDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
|
|
+{
|
|
|
+ QComboBox *spinBox = static_cast<QComboBox *>(editor);
|
|
|
+ QString value = spinBox->currentText();
|
|
|
+ model->setData(index, value, Qt::EditRole);
|
|
|
+}
|
|
|
+
|
|
|
+void EXDataTableComboDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
|
|
|
+ const QModelIndex & /*index*/) const
|
|
|
+{
|
|
|
+ editor->setGeometry(option.rect);
|
|
|
+}
|