Fixed issue #47.

--HG--
branch : develop
This commit is contained in:
dismine 2014-01-17 23:41:27 +02:00
parent 8f5cfb7050
commit 44b33ab1cb
5 changed files with 36 additions and 65 deletions

View File

@ -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()

View File

@ -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)
/**

View File

@ -14,7 +14,7 @@
<string>Increments</string>
</property>
<property name="windowIcon">
<iconset resource="../icon.qrc">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<property name="locale">
@ -27,7 +27,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>4</number>
</property>
<widget class="QWidget" name="tabStandard">
<attribute name="title">
@ -329,19 +329,6 @@
</widget>
</widget>
</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>
</widget>
<tabstops>
@ -353,43 +340,9 @@
<tabstop>tableWidgetLines</tabstop>
<tabstop>tableWidgetSplines</tabstop>
<tabstop>tableWidgetArcs</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../icon.qrc"/>
<include location="../../share/resources/icon.qrc"/>
</resources>
<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>
<connections/>
</ui>

View File

@ -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<QDoubleSpinBox*>(editor);
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(editor);
Q_ASSERT(spinBox != 0);
spinBox->setValue(value);
}
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();
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<QDoubleSpinBox*>(sender());
Q_ASSERT(spinBox != 0);
qreal value = spinBox->value();
if(qFuzzyCompare ( lastValue, value ) == false)
{
lastValue = value;
emit commitData(spinBox);
}
emit closeEditor(spinBox);
}

View File

@ -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