Undo selection of last object if was selected twice.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-12-03 19:18:58 +02:00
parent 0a11ec59fb
commit c2da41bbf0
4 changed files with 110 additions and 40 deletions

View File

@ -127,6 +127,8 @@ void DialogPiecePath::ChosenObject(quint32 id, const SceneObject &type)
{
reverse = true;
}
if (id != GetLastId())
{
switch (type)
{
case SceneObject::Arc:
@ -148,6 +150,14 @@ void DialogPiecePath::ChosenObject(quint32 id, const SceneObject &type)
qDebug() << "Got wrong scene object. Ignore.";
break;
}
}
else
{
if (ui->listWidget->count() > 1)
{
delete GetItemById(id);
}
}
ValidObjects(PathIsValid());
@ -163,6 +173,8 @@ void DialogPiecePath::ChosenObject(quint32 id, const SceneObject &type)
emit ToolTip(tr("Select main path objects, <b>Shift</b> - reverse direction curve, "
"<b>Enter</b> - finish creation"));
if (not qApp->getCurrentScene()->items().contains(visPath))
{
visPath->VisualMode(NULL_ID);
}
else
@ -170,6 +182,11 @@ void DialogPiecePath::ChosenObject(quint32 id, const SceneObject &type)
visPath->RefreshGeometry();
}
}
else
{
visPath->RefreshGeometry();
}
}
}
}
@ -545,6 +562,22 @@ QListWidgetItem *DialogPiecePath::GetItemById(quint32 id)
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogPiecePath::GetLastId() const
{
const int count = ui->listWidget->count();
if (count > 0)
{
QListWidgetItem *item = ui->listWidget->item(count-1);
const VPieceNode node = qvariant_cast<VPieceNode>(item->data(Qt::UserRole));
return node.GetId();
}
else
{
return NULL_ID;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetCurrentSABefore(qreal value)
{

View File

@ -99,6 +99,8 @@ private:
QListWidgetItem *GetItemById(quint32 id);
quint32 GetLastId() const;
void SetCurrentSABefore(qreal value);
void SetCurrentSAAfter(qreal value);
};

View File

@ -202,6 +202,8 @@ void DialogSeamAllowance::ChosenObject(quint32 id, const SceneObject &type)
{
reverse = true;
}
if (id != GetLastId())
{
switch (type)
{
case SceneObject::Arc:
@ -223,6 +225,14 @@ void DialogSeamAllowance::ChosenObject(quint32 id, const SceneObject &type)
qDebug() << "Got wrong scene object. Ignore.";
break;
}
}
else
{
if (ui->listWidgetMainPath->count() > 1)
{
delete GetItemById(id);
}
}
ValidObjects(MainPathIsValid());
@ -238,6 +248,8 @@ void DialogSeamAllowance::ChosenObject(quint32 id, const SceneObject &type)
emit ToolTip(tr("Select main path objects clockwise, <b>Shift</b> - reverse direction curve, "
"<b>Enter</b> - finish creation"));
if (not qApp->getCurrentScene()->items().contains(visPath))
{
visPath->VisualMode(NULL_ID);
}
else
@ -245,6 +257,11 @@ void DialogSeamAllowance::ChosenObject(quint32 id, const SceneObject &type)
visPath->RefreshGeometry();
}
}
else
{
visPath->RefreshGeometry();
}
}
}
}
@ -925,6 +942,22 @@ QListWidgetItem *DialogSeamAllowance::GetItemById(quint32 id)
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogSeamAllowance::GetLastId() const
{
const int count = ui->listWidgetMainPath->count();
if (count > 0)
{
QListWidgetItem *item = ui->listWidgetMainPath->item(count-1);
const VPieceNode node = qvariant_cast<VPieceNode>(item->data(Qt::UserRole));
return node.GetId();
}
else
{
return NULL_ID;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetCurrentSABefore(qreal value)
{

View File

@ -105,6 +105,8 @@ private:
QListWidgetItem *GetItemById(quint32 id);
quint32 GetLastId() const;
void SetCurrentSABefore(qreal value);
void SetCurrentSAAfter(qreal value);
};