Fixed DetailIsValid() method
--HG-- branch : feature
This commit is contained in:
parent
d27a64b819
commit
e323afc4e6
|
@ -78,7 +78,6 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
|
|||
connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NamePointChanged);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (not DetailIsValid())
|
||||
{
|
||||
ValidObjects(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ValidObjects(true);
|
||||
|
||||
}
|
||||
|
||||
ValidObjects(DetailIsValid());
|
||||
this->show();
|
||||
}
|
||||
}
|
||||
|
@ -189,8 +179,8 @@ void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &t
|
|||
}
|
||||
else
|
||||
{
|
||||
QString lastItemName = ui.listWidget->item(ui.listWidget->count()-1)->text();
|
||||
if(QString::compare(lastItemName, name) != 0)
|
||||
QString previousItemName = ui.listWidget->item(ui.listWidget->count()-1)->text();
|
||||
if(QString::compare(previousItemName, name) != 0)
|
||||
{
|
||||
canAddNewPoint = true;
|
||||
}
|
||||
|
@ -421,24 +411,8 @@ void DialogDetail::DeleteItem()
|
|||
EnableObjectGUI(false);
|
||||
}
|
||||
|
||||
int rowNumber = ui.listWidget->currentRow();
|
||||
|
||||
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);
|
||||
}
|
||||
delete ui.listWidget->item(ui.listWidget->currentRow());
|
||||
ValidObjects(DetailIsValid());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -448,12 +422,25 @@ bool DialogDetail::DetailIsValid()
|
|||
{
|
||||
return false;
|
||||
}
|
||||
else if (ui.listWidget->count() == 3)
|
||||
else
|
||||
{
|
||||
if (FirstPointEqualLast())
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -461,8 +448,8 @@ bool DialogDetail::DetailIsValid()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogDetail::FirstPointEqualLast()
|
||||
{
|
||||
QString firstDetailPoint = ui.listWidget->item(0)->text();
|
||||
QString lastDetailPoint = ui.listWidget->item(ui.listWidget->count()-1)->text();
|
||||
const QString firstDetailPoint = ui.listWidget->item(0)->text();
|
||||
const QString lastDetailPoint = ui.listWidget->item(ui.listWidget->count()-1)->text();
|
||||
|
||||
if (QString::compare(firstDetailPoint, lastDetailPoint) == 0)
|
||||
{
|
||||
|
@ -473,15 +460,3 @@ bool DialogDetail::FirstPointEqualLast()
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogDetail::DeleteLastPoint()
|
||||
{
|
||||
if (ui.listWidget->count() > 3)
|
||||
{
|
||||
if (FirstPointEqualLast())
|
||||
{
|
||||
delete ui.listWidget->item(ui.listWidget->count()-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ public slots:
|
|||
void ClickedReverse(bool checked);
|
||||
void ObjectChanged(int row);
|
||||
void DeleteItem();
|
||||
void DeleteLastPoint();
|
||||
protected:
|
||||
/**
|
||||
* @brief SaveData Put dialog data in local variables
|
||||
|
|
Loading…
Reference in New Issue
Block a user