diff --git a/src/dialogs/dialogincrements.cpp b/src/dialogs/dialogincrements.cpp
index efea8fb2f..6fbc5dd10 100644
--- a/src/dialogs/dialogincrements.cpp
+++ b/src/dialogs/dialogincrements.cpp
@@ -62,8 +62,6 @@ DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget
connect(this->doc, &VDomDocument::FullUpdateFromFile, this,
&DialogIncrements::FullUpdateFromFile);
- bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
- connect(bOk, &QPushButton::clicked, this, &DialogIncrements::DialogAccepted);
ui->tabWidget->setCurrentIndex(0);
}
@@ -284,8 +282,8 @@ void DialogIncrements::FullUpdateFromFile()
InitialStandardTable();
FillStandardTable();
- ui->tableWidgetIncrement->clear();
- InitialIncrementTable();
+ ui->tableWidgetIncrement->clearContents();
+ //InitialIncrementTable();
FillIncrementTable();
ui->tableWidgetLines->clear();
@@ -306,9 +304,9 @@ void DialogIncrements::FullUpdateFromFile()
void DialogIncrements::clickedToolButtonAdd()
{
+ ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason);
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged);
- ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason);
qint32 currentRow = ui->tableWidgetIncrement->rowCount();
ui->tableWidgetIncrement->insertRow( currentRow );
@@ -316,7 +314,7 @@ void DialogIncrements::clickedToolButtonAdd()
QString name;
do
{
- name = QString(tr("Name %1")).arg(num);
+ name = QString(tr("Name_%1")).arg(num);
num++;
} while (data->IncrementTableContains(name));
@@ -554,9 +552,10 @@ void DialogIncrements::InitialArcsTable()
ui->tableWidgetArcs->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length")));
}
-void DialogIncrements::DialogAccepted()
+void DialogIncrements::closeEvent(QCloseEvent *event)
{
emit DialogClosed(QDialog::Accepted);
+ event->accept();
}
DialogIncrements::~DialogIncrements()
diff --git a/src/dialogs/dialogincrements.h b/src/dialogs/dialogincrements.h
index 72ed3eb37..169964849 100644
--- a/src/dialogs/dialogincrements.h
+++ b/src/dialogs/dialogincrements.h
@@ -71,10 +71,6 @@ public slots:
* @brief FullUpdateFromFile update information in tables form file
*/
void FullUpdateFromFile();
- /**
- * @brief DialogAccepted save data and emit signal about closed dialog.
- */
- virtual void DialogAccepted();
signals:
/**
* @brief FullUpdateTree signal update data for dom document
@@ -84,6 +80,8 @@ signals:
* @brief haveLiteChange signal show sign of change
*/
void haveLiteChange();
+protected:
+ virtual void closeEvent ( QCloseEvent * event );
private:
Q_DISABLE_COPY(DialogIncrements)
/**
diff --git a/src/dialogs/dialogincrements.ui b/src/dialogs/dialogincrements.ui
index ffbf6a398..cd4871012 100644
--- a/src/dialogs/dialogincrements.ui
+++ b/src/dialogs/dialogincrements.ui
@@ -14,7 +14,7 @@
Increments
-
+
:/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png
@@ -27,7 +27,7 @@
QTabWidget::North
- 1
+ 4
@@ -329,19 +329,6 @@
- -
-
-
- Qt::Horizontal
-
-
- QDialogButtonBox::Ok
-
-
- false
-
-
-
@@ -353,43 +340,9 @@
tableWidgetLines
tableWidgetSplines
tableWidgetArcs
- buttonBox
-
+
-
-
- buttonBox
- accepted()
- DialogIncrements
- accept()
-
-
- 248
- 254
-
-
- 157
- 274
-
-
-
-
- buttonBox
- rejected()
- DialogIncrements
- reject()
-
-
- 316
- 260
-
-
- 286
- 274
-
-
-
-
+
diff --git a/src/widgets/doubledelegate.cpp b/src/widgets/doubledelegate.cpp
index 36e865905..aadb1114f 100644
--- a/src/widgets/doubledelegate.cpp
+++ b/src/widgets/doubledelegate.cpp
@@ -43,8 +43,10 @@ QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOption
Q_UNUSED(option);
Q_UNUSED(index);
QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
+ Q_ASSERT(editor != 0);
editor->setMinimum(-10000.0);
editor->setMaximum(10000.0);
+ connect(editor, &QDoubleSpinBox::editingFinished, this, &DoubleSpinBoxDelegate::commitAndCloseEditor);
return editor;
}
@@ -52,13 +54,15 @@ void DoubleSpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &in
{
qreal value = index.model()->data(index, Qt::EditRole).toDouble();
- QDoubleSpinBox *spinBox = static_cast(editor);
+ QDoubleSpinBox *spinBox = qobject_cast(editor);
+ Q_ASSERT(spinBox != 0);
spinBox->setValue(value);
}
void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
- QDoubleSpinBox *spinBox = static_cast(editor);
+ QDoubleSpinBox *spinBox = qobject_cast(editor);
+ Q_ASSERT(spinBox != 0);
spinBox->interpretText();
qreal value = spinBox->value();
@@ -71,3 +75,16 @@ void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOp
Q_UNUSED(index)
editor->setGeometry(option.rect);
}
+
+void DoubleSpinBoxDelegate::commitAndCloseEditor()
+{
+ QDoubleSpinBox *spinBox = qobject_cast(sender());
+ Q_ASSERT(spinBox != 0);
+ qreal value = spinBox->value();
+ if(qFuzzyCompare ( lastValue, value ) == false)
+ {
+ lastValue = value;
+ emit commitData(spinBox);
+ }
+ emit closeEditor(spinBox);
+}
diff --git a/src/widgets/doubledelegate.h b/src/widgets/doubledelegate.h
index c69a53e29..8542b04f2 100644
--- a/src/widgets/doubledelegate.h
+++ b/src/widgets/doubledelegate.h
@@ -42,7 +42,7 @@ public:
* @brief DoubleSpinBoxDelegate
* @param parent
*/
- DoubleSpinBoxDelegate(QObject *parent = 0): QItemDelegate(parent){}
+ DoubleSpinBoxDelegate(QObject *parent = 0): QItemDelegate(parent), lastValue(-10001.0){}
/**
* @brief createEditor
* @param parent
@@ -71,6 +71,10 @@ public:
* @param index
*/
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
+public slots:
+ void commitAndCloseEditor();
+private:
+ qreal lastValue;
};
#endif