Merged in ValentinaZhuravska/valentina/feature (pull request #73)

Fixed problems in DialogDetail

--HG--
branch : develop
This commit is contained in:
Roman Telezhinskyi 2015-11-11 21:50:54 +02:00
commit ae1195df21
2 changed files with 91 additions and 33 deletions

View File

@ -117,16 +117,7 @@ void DialogDetail::ChosenObject(quint32 id, const SceneObject &type)
EnableObjectGUI(true);
}
if (CreateDetail().ContourPoints(data).size() < 3)
{
ValidObjects(false);
}
else
{
ValidObjects(true);
}
ValidObjects(DetailIsValid());
this->show();
}
}
@ -180,6 +171,23 @@ void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &t
return;
}
bool canAddNewPoint = false;
if(ui.listWidget->count() == 0)
{
canAddNewPoint = true;
}
else
{
const QString previousItemName = ui.listWidget->item(ui.listWidget->count()-1)->text();
if(QString::compare(previousItemName, name) != 0)
{
canAddNewPoint = true;
}
}
if(canAddNewPoint)
{
QListWidgetItem *item = new QListWidgetItem(name);
item->setFont(QFont("Times", 12, QFont::Bold));
VNodeDetail node(id, typeTool, typeNode, mx, my, reverse);
@ -206,6 +214,7 @@ void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &t
ui.doubleSpinBoxBiasX->blockSignals(false);
ui.doubleSpinBoxBiasY->blockSignals(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
VDetail DialogDetail::CreateDetail() const
@ -403,8 +412,55 @@ void DialogDetail::DeleteItem()
}
delete ui.listWidget->item(ui.listWidget->currentRow());
if (CreateDetail().ContourPoints(data).size() < 3 )
ValidObjects(DetailIsValid());
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogDetail::DetailIsValid() const
{
ValidObjects(false);
if (ui.listWidget->count() < 3)
{
return false;
}
else
{
if (FirstPointEqualLast())
{
return false;
}
else
{
for (int i=0, sz = ui.listWidget->count()-1; i<sz; ++i)
{
const QString previousRow = ui.listWidget->item(i)->text();
const QString nextRow = ui.listWidget->item(i+1)->text();
if (QString::compare(previousRow, nextRow) == 0)
{
return false;
}
}
}
}
return true;
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogDetail::FirstPointEqualLast() const
{
if (ui.listWidget->count() > 1)
{
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)
{
return true;
}
else
{
return false;
}
}
return false;
}

View File

@ -74,6 +74,8 @@ private:
/** @brief closed keep option about equdistant (closed or not) */
bool closed;
bool flagWidth;
bool DetailIsValid() const;
bool FirstPointEqualLast() const;
void NewItem(quint32 id, const Tool &typeTool, const NodeDetail &typeNode,
qreal mx = 0, qreal my = 0, bool reverse = false);