diff --git a/src/dialogs/dialogtool.cpp b/src/dialogs/dialogtool.cpp index 4816d7a5f..219dc2b29 100644 --- a/src/dialogs/dialogtool.cpp +++ b/src/dialogs/dialogtool.cpp @@ -66,9 +66,9 @@ void DialogTool::showEvent(QShowEvent *event) void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const { Q_ASSERT(box != 0); - box->clear(); const QHash *objs = data->DataGObjects(); QHashIterator i(*objs); + QMap list; while (i.hasNext()) { i.next(); @@ -78,18 +78,19 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const if (obj->getType() == GObject::Point && obj->getMode() == Draw::Calculation) { const VPointF *point = data->GeometricObject(i.key()); - box->addItem(point->name(), i.key()); + list[point->name()] = i.key(); } } } + FillList(box, list); } void DialogTool::FillComboBoxSplines(QComboBox *box, const qint64 &id, ComboMode::ComboBoxCutSpline cut) const { Q_ASSERT(box != 0); - box->clear(); const QHash *objs = data->DataGObjects(); QHashIterator i(*objs); + QMap list; while (i.hasNext()) { i.next(); @@ -101,7 +102,7 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, const qint64 &id, ComboMode if (obj->getType() == GObject::Spline && obj->getMode() == Draw::Calculation) { const VSpline *spl = data->GeometricObject(i.key()); - box->addItem(spl->name(), i.key()); + list[spl->name()] = i.key(); } } } @@ -113,19 +114,20 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, const qint64 &id, ComboMode if (obj->getType() == GObject::Spline && obj->getMode() == Draw::Calculation) { const VSpline *spl = data->GeometricObject(i.key()); - box->addItem(spl->name(), i.key()); + list[spl->name()] = i.key(); } } } } + FillList(box, list); } void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const qint64 &id, ComboMode::ComboBoxCutSpline cut) const { Q_ASSERT(box != 0); - box->clear(); const QHash *objs = data->DataGObjects(); QHashIterator i(*objs); + QMap list; while (i.hasNext()) { i.next(); @@ -137,7 +139,7 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const qint64 &id, Combo if (obj->getType() == GObject::SplinePath && obj->getMode() == Draw::Calculation) { const VSplinePath *splPath = data->GeometricObject(i.key()); - box->addItem(splPath->name(), i.key()); + list[splPath->name()] = i.key(); } } } @@ -149,11 +151,12 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const qint64 &id, Combo if (obj->getType() == GObject::SplinePath && obj->getMode() == Draw::Calculation) { const VSplinePath *splPath = data->GeometricObject(i.key()); - box->addItem(splPath->name(), i.key()); + list[splPath->name()] = i.key(); } } } } + FillList(box, list); } void DialogTool::FillComboBoxTypeLine(QComboBox *box) const @@ -322,6 +325,19 @@ qint64 DialogTool::getCurrentObjectId(QComboBox *box) const } } +void DialogTool::FillList(QComboBox *box, const QMap &list) const +{ + Q_ASSERT(box != 0); + box->clear(); + + QMapIterator iter(list); + while (iter.hasNext()) + { + iter.next(); + box->addItem(iter.key(), iter.value()); + } +} + void DialogTool::CheckState() { Q_ASSERT(bOk != 0); diff --git a/src/dialogs/dialogtool.h b/src/dialogs/dialogtool.h index f16318dea..ae8e7ac70 100644 --- a/src/dialogs/dialogtool.h +++ b/src/dialogs/dialogtool.h @@ -368,6 +368,8 @@ protected: * @return id or -1 if combobox is empty */ qint64 getCurrentObjectId(QComboBox *box) const; +private: + void FillList(QComboBox *box, const QMap &list)const; }; #endif // DIALOGTOOL_H