parent
8f5cfb7050
commit
44b33ab1cb
|
@ -62,8 +62,6 @@ DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget
|
||||||
connect(this->doc, &VDomDocument::FullUpdateFromFile, this,
|
connect(this->doc, &VDomDocument::FullUpdateFromFile, this,
|
||||||
&DialogIncrements::FullUpdateFromFile);
|
&DialogIncrements::FullUpdateFromFile);
|
||||||
|
|
||||||
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
|
||||||
connect(bOk, &QPushButton::clicked, this, &DialogIncrements::DialogAccepted);
|
|
||||||
ui->tabWidget->setCurrentIndex(0);
|
ui->tabWidget->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,8 +282,8 @@ void DialogIncrements::FullUpdateFromFile()
|
||||||
InitialStandardTable();
|
InitialStandardTable();
|
||||||
FillStandardTable();
|
FillStandardTable();
|
||||||
|
|
||||||
ui->tableWidgetIncrement->clear();
|
ui->tableWidgetIncrement->clearContents();
|
||||||
InitialIncrementTable();
|
//InitialIncrementTable();
|
||||||
FillIncrementTable();
|
FillIncrementTable();
|
||||||
|
|
||||||
ui->tableWidgetLines->clear();
|
ui->tableWidgetLines->clear();
|
||||||
|
@ -306,9 +304,9 @@ void DialogIncrements::FullUpdateFromFile()
|
||||||
|
|
||||||
void DialogIncrements::clickedToolButtonAdd()
|
void DialogIncrements::clickedToolButtonAdd()
|
||||||
{
|
{
|
||||||
|
ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason);
|
||||||
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
|
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
|
||||||
&DialogIncrements::cellChanged);
|
&DialogIncrements::cellChanged);
|
||||||
ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason);
|
|
||||||
qint32 currentRow = ui->tableWidgetIncrement->rowCount();
|
qint32 currentRow = ui->tableWidgetIncrement->rowCount();
|
||||||
ui->tableWidgetIncrement->insertRow( currentRow );
|
ui->tableWidgetIncrement->insertRow( currentRow );
|
||||||
|
|
||||||
|
@ -316,7 +314,7 @@ void DialogIncrements::clickedToolButtonAdd()
|
||||||
QString name;
|
QString name;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
name = QString(tr("Name %1")).arg(num);
|
name = QString(tr("Name_%1")).arg(num);
|
||||||
num++;
|
num++;
|
||||||
} while (data->IncrementTableContains(name));
|
} while (data->IncrementTableContains(name));
|
||||||
|
|
||||||
|
@ -554,9 +552,10 @@ void DialogIncrements::InitialArcsTable()
|
||||||
ui->tableWidgetArcs->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length")));
|
ui->tableWidgetArcs->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogIncrements::DialogAccepted()
|
void DialogIncrements::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
emit DialogClosed(QDialog::Accepted);
|
emit DialogClosed(QDialog::Accepted);
|
||||||
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogIncrements::~DialogIncrements()
|
DialogIncrements::~DialogIncrements()
|
||||||
|
|
|
@ -71,10 +71,6 @@ public slots:
|
||||||
* @brief FullUpdateFromFile update information in tables form file
|
* @brief FullUpdateFromFile update information in tables form file
|
||||||
*/
|
*/
|
||||||
void FullUpdateFromFile();
|
void FullUpdateFromFile();
|
||||||
/**
|
|
||||||
* @brief DialogAccepted save data and emit signal about closed dialog.
|
|
||||||
*/
|
|
||||||
virtual void DialogAccepted();
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief FullUpdateTree signal update data for dom document
|
* @brief FullUpdateTree signal update data for dom document
|
||||||
|
@ -84,6 +80,8 @@ signals:
|
||||||
* @brief haveLiteChange signal show sign of change
|
* @brief haveLiteChange signal show sign of change
|
||||||
*/
|
*/
|
||||||
void haveLiteChange();
|
void haveLiteChange();
|
||||||
|
protected:
|
||||||
|
virtual void closeEvent ( QCloseEvent * event );
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogIncrements)
|
Q_DISABLE_COPY(DialogIncrements)
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<string>Increments</string>
|
<string>Increments</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowIcon">
|
||||||
<iconset resource="../icon.qrc">
|
<iconset resource="../../share/resources/icon.qrc">
|
||||||
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="locale">
|
<property name="locale">
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
<enum>QTabWidget::North</enum>
|
<enum>QTabWidget::North</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>4</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tabStandard">
|
<widget class="QWidget" name="tabStandard">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -329,19 +329,6 @@
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
<property name="centerButtons">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
@ -353,43 +340,9 @@
|
||||||
<tabstop>tableWidgetLines</tabstop>
|
<tabstop>tableWidgetLines</tabstop>
|
||||||
<tabstop>tableWidgetSplines</tabstop>
|
<tabstop>tableWidgetSplines</tabstop>
|
||||||
<tabstop>tableWidgetArcs</tabstop>
|
<tabstop>tableWidgetArcs</tabstop>
|
||||||
<tabstop>buttonBox</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../icon.qrc"/>
|
<include location="../../share/resources/icon.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>DialogIncrements</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>DialogIncrements</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -43,8 +43,10 @@ QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOption
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(index);
|
Q_UNUSED(index);
|
||||||
QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
|
QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
|
||||||
|
Q_ASSERT(editor != 0);
|
||||||
editor->setMinimum(-10000.0);
|
editor->setMinimum(-10000.0);
|
||||||
editor->setMaximum(10000.0);
|
editor->setMaximum(10000.0);
|
||||||
|
connect(editor, &QDoubleSpinBox::editingFinished, this, &DoubleSpinBoxDelegate::commitAndCloseEditor);
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,13 +54,15 @@ void DoubleSpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &in
|
||||||
{
|
{
|
||||||
qreal value = index.model()->data(index, Qt::EditRole).toDouble();
|
qreal value = index.model()->data(index, Qt::EditRole).toDouble();
|
||||||
|
|
||||||
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
|
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(editor);
|
||||||
|
Q_ASSERT(spinBox != 0);
|
||||||
spinBox->setValue(value);
|
spinBox->setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
|
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(editor);
|
||||||
|
Q_ASSERT(spinBox != 0);
|
||||||
spinBox->interpretText();
|
spinBox->interpretText();
|
||||||
qreal value = spinBox->value();
|
qreal value = spinBox->value();
|
||||||
|
|
||||||
|
@ -71,3 +75,16 @@ void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOp
|
||||||
Q_UNUSED(index)
|
Q_UNUSED(index)
|
||||||
editor->setGeometry(option.rect);
|
editor->setGeometry(option.rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DoubleSpinBoxDelegate::commitAndCloseEditor()
|
||||||
|
{
|
||||||
|
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender());
|
||||||
|
Q_ASSERT(spinBox != 0);
|
||||||
|
qreal value = spinBox->value();
|
||||||
|
if(qFuzzyCompare ( lastValue, value ) == false)
|
||||||
|
{
|
||||||
|
lastValue = value;
|
||||||
|
emit commitData(spinBox);
|
||||||
|
}
|
||||||
|
emit closeEditor(spinBox);
|
||||||
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
* @brief DoubleSpinBoxDelegate
|
* @brief DoubleSpinBoxDelegate
|
||||||
* @param parent
|
* @param parent
|
||||||
*/
|
*/
|
||||||
DoubleSpinBoxDelegate(QObject *parent = 0): QItemDelegate(parent){}
|
DoubleSpinBoxDelegate(QObject *parent = 0): QItemDelegate(parent), lastValue(-10001.0){}
|
||||||
/**
|
/**
|
||||||
* @brief createEditor
|
* @brief createEditor
|
||||||
* @param parent
|
* @param parent
|
||||||
|
@ -71,6 +71,10 @@ public:
|
||||||
* @param index
|
* @param index
|
||||||
*/
|
*/
|
||||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||||
|
public slots:
|
||||||
|
void commitAndCloseEditor();
|
||||||
|
private:
|
||||||
|
qreal lastValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user