Refactoring.

--HG--
branch : feature
This commit is contained in:
dismine 2014-03-04 19:13:10 +02:00
parent e30d1fe9dd
commit 2610487fe5
4 changed files with 32 additions and 30 deletions

View File

@ -85,33 +85,26 @@ void DialogAlongLine::ChoosedObject(quint32 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
const VPointF *point = data->GeometricObject<const VPointF *>(id);
if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
if (ChoosedPoint(id, ui->comboBoxFirstPoint, tr("Select second point of line")))
{
number++;
emit ToolTip(tr("Select second point of line"));
return;
}
}
if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
if (ChoosedPoint(id, ui->comboBoxSecondPoint, ""))
{
number = 0;
emit ToolTip("");
}
if (isInitialized == false)
{
this->show();
}
}
}
}
}
void DialogAlongLine::DialogAccepted()

View File

@ -102,33 +102,26 @@ void DialogNormal::ChoosedObject(quint32 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
const VPointF *point = data->GeometricObject<const VPointF *>(id);
if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
if (ChoosedPoint(id, ui->comboBoxFirstPoint, tr("Select second point of line")))
{
number++;
emit ToolTip(tr("Select second point of line"));
return;
}
}
if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
if (ChoosedPoint(id, ui->comboBoxSecondPoint, ""))
{
number = 0;
emit ToolTip("");
}
if (isInitialized == false)
{
this->show();
}
}
}
}
}
void DialogNormal::DialogAccepted()

View File

@ -384,6 +384,21 @@ quint32 DialogTool::getCurrentObjectId(QComboBox *box) const
}
}
bool DialogTool::ChoosedPoint(const quint32 &id, QComboBox *box, const QString &toolTip)
{
Q_CHECK_PTR(box);
const VPointF *point = data->GeometricObject<const VPointF *>(id);
Q_CHECK_PTR(point);
const qint32 index = box->findText(point->name());
if ( index != -1 )
{ // -1 for not found
box->setCurrentIndex(index);
emit ToolTip(toolTip);
return true;
}
return false;
}
void DialogTool::FillList(QComboBox *box, const QMap<QString, quint32> &list) const
{
Q_CHECK_PTR(box);

View File

@ -398,6 +398,7 @@ protected:
* @return id or -1 if combobox is empty
*/
quint32 getCurrentObjectId(QComboBox *box) const;
bool ChoosedPoint(const quint32 &id, QComboBox *box, const QString &toolTip);
private:
/**
* @brief FillList fill combobox list