Fix broken deletion of increment.

--HG--
branch : develop
This commit is contained in:
dismine 2014-08-04 17:35:57 +03:00
parent 7c52bf240f
commit c11e5d39dc
2 changed files with 16 additions and 6 deletions

View File

@ -355,6 +355,7 @@ void DialogIncrements::FullUpdateFromFile()
} }
ui->tableWidgetMeasurements->clearContents(); ui->tableWidgetMeasurements->clearContents();
FillMeasurements(); FillMeasurements();
ui->tableWidgetMeasurements->horizontalHeader()->setStretchLastSection(true);
if (qApp->patternType() == MeasurementsType::Individual) if (qApp->patternType() == MeasurementsType::Individual)
{ {
connect(ui->tableWidgetMeasurements, &QTableWidget::cellChanged, this, &DialogIncrements::MeasurementChanged); connect(ui->tableWidgetMeasurements, &QTableWidget::cellChanged, this, &DialogIncrements::MeasurementChanged);
@ -362,6 +363,7 @@ void DialogIncrements::FullUpdateFromFile()
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged); disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged);
ui->tableWidgetIncrement->clearContents(); ui->tableWidgetIncrement->clearContents();
ui->tableWidgetIncrement->horizontalHeader()->setStretchLastSection(true);
FillIncrements(); FillIncrements();
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged); connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged);
@ -590,22 +592,27 @@ void DialogIncrements::clickedToolButtonRemove()
{ {
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::IncrementChanged); &DialogIncrements::IncrementChanged);
QTableWidgetItem *item = ui->tableWidgetIncrement->currentItem(); QTableWidgetItem *item = ui->tableWidgetIncrement->currentItem();
qint32 row = item->row(); qint32 row = item->row();
QTableWidgetItem *itemName = ui->tableWidgetIncrement->item(row, 0); QTableWidgetItem *itemName = ui->tableWidgetIncrement->item(row, 0);
data->RemoveIncrement(itemName->text()); data->RemoveIncrement(itemName->text());
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
quint32 id = qvariant_cast<quint32>(itemName->data(Qt::UserRole));
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement()) if (domElement.isElement())
{ {
QDomNodeList list = doc->elementsByTagName(VPattern::TagIncrements); QDomNodeList list = doc->elementsByTagName(VPattern::TagIncrements);
list.at(0).removeChild(domElement); list.at(0).removeChild(domElement);
} }
ui->tableWidgetIncrement->removeRow(row); ui->tableWidgetIncrement->removeRow(row);
if (ui->tableWidgetIncrement->rowCount() == 0) if (ui->tableWidgetIncrement->rowCount() == 0)
{ {
ui->toolButtonRemove->setEnabled(false); ui->toolButtonRemove->setEnabled(false);
} }
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::IncrementChanged); &DialogIncrements::IncrementChanged);
emit haveLiteChange(); emit haveLiteChange();

View File

@ -39,7 +39,7 @@
<enum>QTabWidget::North</enum> <enum>QTabWidget::North</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tabStandard"> <widget class="QWidget" name="tabStandard">
<property name="sizePolicy"> <property name="sizePolicy">
@ -108,7 +108,7 @@
</size> </size>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="pagePersonalInformation"> <widget class="QWidget" name="pagePersonalInformation">
<property name="enabled"> <property name="enabled">
@ -398,10 +398,10 @@
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="horizontalHeaderDefaultSectionSize"> <attribute name="horizontalHeaderDefaultSectionSize">
<number>95</number> <number>120</number>
</attribute> </attribute>
<attribute name="horizontalHeaderMinimumSectionSize"> <attribute name="horizontalHeaderMinimumSectionSize">
<number>17</number> <number>70</number>
</attribute> </attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0"> <attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool> <bool>false</bool>
@ -416,7 +416,10 @@
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="verticalHeaderDefaultSectionSize"> <attribute name="verticalHeaderDefaultSectionSize">
<number>20</number> <number>25</number>
</attribute>
<attribute name="verticalHeaderMinimumSectionSize">
<number>8</number>
</attribute> </attribute>
<attribute name="verticalHeaderStretchLastSection"> <attribute name="verticalHeaderStretchLastSection">
<bool>false</bool> <bool>false</bool>