Fixed DetailIsValid() method

--HG--
branch : feature
This commit is contained in:
Valentina Zhuravska 2015-11-11 19:38:21 +02:00
parent d27a64b819
commit e323afc4e6
2 changed files with 22 additions and 48 deletions

View File

@ -78,7 +78,6 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NamePointChanged); connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NamePointChanged);
connect(ui.toolButtonDelete, &QToolButton::clicked, this, &DialogDetail::DeleteItem); connect(ui.toolButtonDelete, &QToolButton::clicked, this, &DialogDetail::DeleteItem);
connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &DialogDetail::DeleteLastPoint);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -118,16 +117,7 @@ void DialogDetail::ChosenObject(quint32 id, const SceneObject &type)
EnableObjectGUI(true); EnableObjectGUI(true);
} }
if (not DetailIsValid()) ValidObjects(DetailIsValid());
{
ValidObjects(false);
}
else
{
ValidObjects(true);
}
this->show(); this->show();
} }
} }
@ -189,8 +179,8 @@ void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &t
} }
else else
{ {
QString lastItemName = ui.listWidget->item(ui.listWidget->count()-1)->text(); QString previousItemName = ui.listWidget->item(ui.listWidget->count()-1)->text();
if(QString::compare(lastItemName, name) != 0) if(QString::compare(previousItemName, name) != 0)
{ {
canAddNewPoint = true; canAddNewPoint = true;
} }
@ -421,24 +411,8 @@ void DialogDetail::DeleteItem()
EnableObjectGUI(false); EnableObjectGUI(false);
} }
int rowNumber = ui.listWidget->currentRow(); delete ui.listWidget->item(ui.listWidget->currentRow());
ValidObjects(DetailIsValid());
if (rowNumber != 0 && rowNumber != ui.listWidget->count()-1)
{
QString previousRow = ui.listWidget->item(rowNumber-1)->text();
QString nextRow = ui.listWidget->item(rowNumber+1)->text();
if (QString::compare(previousRow, nextRow) == 0)
{
ValidObjects(false);
}
}
delete ui.listWidget->item(rowNumber);
if (not DetailIsValid())
{
ValidObjects(false);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -448,21 +422,34 @@ bool DialogDetail::DetailIsValid()
{ {
return false; return false;
} }
else if (ui.listWidget->count() == 3) else
{ {
if (FirstPointEqualLast()) if (FirstPointEqualLast())
{ {
return false; return false;
} }
} else
{
for (int i=0; i<ui.listWidget->count()-1; i++)
{
QString previousRow = ui.listWidget->item(i)->text();
QString nextRow = ui.listWidget->item(i+1)->text();
if (QString::compare(previousRow, nextRow) == 0)
{
return false;
}
}
}
}
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogDetail::FirstPointEqualLast() bool DialogDetail::FirstPointEqualLast()
{ {
QString firstDetailPoint = ui.listWidget->item(0)->text(); const QString firstDetailPoint = ui.listWidget->item(0)->text();
QString lastDetailPoint = ui.listWidget->item(ui.listWidget->count()-1)->text(); const QString lastDetailPoint = ui.listWidget->item(ui.listWidget->count()-1)->text();
if (QString::compare(firstDetailPoint, lastDetailPoint) == 0) if (QString::compare(firstDetailPoint, lastDetailPoint) == 0)
{ {
@ -473,15 +460,3 @@ bool DialogDetail::FirstPointEqualLast()
return false; return false;
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::DeleteLastPoint()
{
if (ui.listWidget->count() > 3)
{
if (FirstPointEqualLast())
{
delete ui.listWidget->item(ui.listWidget->count()-1);
}
}
}

View File

@ -54,7 +54,6 @@ public slots:
void ClickedReverse(bool checked); void ClickedReverse(bool checked);
void ObjectChanged(int row); void ObjectChanged(int row);
void DeleteItem(); void DeleteItem();
void DeleteLastPoint();
protected: protected:
/** /**
* @brief SaveData Put dialog data in local variables * @brief SaveData Put dialog data in local variables