Delete the last point from detail when the first point equals the last point
--HG-- branch : feature
This commit is contained in:
parent
4c41e04d49
commit
d27a64b819
|
@ -78,6 +78,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -117,7 +118,7 @@ void DialogDetail::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
EnableObjectGUI(true);
|
EnableObjectGUI(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CreateDetail().ContourPoints(data).size() < 3)
|
if (not DetailIsValid())
|
||||||
{
|
{
|
||||||
ValidObjects(false);
|
ValidObjects(false);
|
||||||
}
|
}
|
||||||
|
@ -420,9 +421,67 @@ void DialogDetail::DeleteItem()
|
||||||
EnableObjectGUI(false);
|
EnableObjectGUI(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete ui.listWidget->item( ui.listWidget->currentRow() );
|
int rowNumber = ui.listWidget->currentRow();
|
||||||
if (CreateDetail().ContourPoints(data).size() < 3 )
|
|
||||||
|
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);
|
ValidObjects(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogDetail::DetailIsValid()
|
||||||
|
{
|
||||||
|
if (ui.listWidget->count() < 3)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (ui.listWidget->count() == 3)
|
||||||
|
{
|
||||||
|
if (FirstPointEqualLast())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogDetail::FirstPointEqualLast()
|
||||||
|
{
|
||||||
|
QString firstDetailPoint = ui.listWidget->item(0)->text();
|
||||||
|
QString lastDetailPoint = ui.listWidget->item(ui.listWidget->count()-1)->text();
|
||||||
|
|
||||||
|
if (QString::compare(firstDetailPoint, lastDetailPoint) == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogDetail::DeleteLastPoint()
|
||||||
|
{
|
||||||
|
if (ui.listWidget->count() > 3)
|
||||||
|
{
|
||||||
|
if (FirstPointEqualLast())
|
||||||
|
{
|
||||||
|
delete ui.listWidget->item(ui.listWidget->count()-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ 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
|
||||||
|
@ -74,6 +75,8 @@ private:
|
||||||
/** @brief closed keep option about equdistant (closed or not) */
|
/** @brief closed keep option about equdistant (closed or not) */
|
||||||
bool closed;
|
bool closed;
|
||||||
bool flagWidth;
|
bool flagWidth;
|
||||||
|
bool DetailIsValid();
|
||||||
|
bool FirstPointEqualLast();
|
||||||
|
|
||||||
void NewItem(quint32 id, const Tool &typeTool, const NodeDetail &typeNode,
|
void NewItem(quint32 id, const Tool &typeTool, const NodeDetail &typeNode,
|
||||||
qreal mx = 0, qreal my = 0, bool reverse = false);
|
qreal mx = 0, qreal my = 0, bool reverse = false);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user