Don't show children in point combobox.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-06-20 21:32:35 +03:00
parent 9b49c5122c
commit 0c947f5f50
5 changed files with 72 additions and 156 deletions

View File

@ -157,7 +157,7 @@ void DialogCutArc::closeEvent(QCloseEvent *event)
*/
void DialogCutArc::setArcId(const quint32 &value)
{
setCurrentArcId(ui->comboBoxArc, value, ComboBoxCutArc::CutArc);
setCurrentArcId(ui->comboBoxArc, value, FillComboBox::NoChildren);
VisToolCutArc *path = qobject_cast<VisToolCutArc *>(vis);
SCASSERT(path != nullptr);

View File

@ -114,7 +114,7 @@ void DialogCutSpline::SetFormula(const QString &value)
*/
void DialogCutSpline::setSplineId(const quint32 &value)
{
setCurrentSplineId(ui->comboBoxSpline, value, ComboBoxCutSpline::CutSpline);
setCurrentSplineId(ui->comboBoxSpline, value, FillComboBox::NoChildren);
VisToolCutSpline *path = qobject_cast<VisToolCutSpline *>(vis);
SCASSERT(path != nullptr);

View File

@ -114,7 +114,7 @@ void DialogCutSplinePath::SetFormula(const QString &value)
*/
void DialogCutSplinePath::setSplinePathId(const quint32 &value)
{
setCurrentSplinePathId(ui->comboBoxSplinePath, value, ComboBoxCutSpline::CutSpline);
setCurrentSplinePathId(ui->comboBoxSplinePath, value, FillComboBox::NoChildren);
VisToolCutSplinePath *path = qobject_cast<VisToolCutSplinePath *>(vis);
SCASSERT(path != nullptr);

View File

@ -115,146 +115,27 @@ void DialogTool::showEvent(QShowEvent *event)
* @brief FillComboBoxPoints fill comboBox list of points
* @param box comboBox
*/
void DialogTool::FillComboBoxPoints(QComboBox *box) const
void DialogTool::FillComboBoxPoints(QComboBox *box, FillComboBox rule) const
{
SCASSERT(box != nullptr);
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
QMap<QString, quint32> list;
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::Point && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(i.key());
list[point->name()] = i.key();
}
}
}
FillList(box, list);
FillCombo<VPointF>(box, GOType::Point, rule);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut) const
void DialogTool::FillComboBoxArcs(QComboBox *box, FillComboBox rule) const
{
SCASSERT(box != nullptr);
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (cut == ComboBoxCutArc::CutArc)
{
if (i.key() != toolId + 1 && i.key() != toolId + 2)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(i.key());
list[arc->name()] = i.key();
}
}
}
else
{
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(i.key());
list[arc->name()] = i.key();
}
}
}
}
FillList(box, list);
FillCombo<VArc>(box, GOType::Arc, rule);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FillComboBoxSplines fill comboBox list of splines
* @param box comboBox
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
*/
void DialogTool::FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut) const
void DialogTool::FillComboBoxSplines(QComboBox *box, FillComboBox rule) const
{
SCASSERT(box != nullptr);
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (cut == ComboBoxCutSpline::CutSpline)
{
if (i.key() != toolId + 1 && i.key() != toolId + 2)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(i.key());
list[spl->name()] = i.key();
}
}
}
else
{
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(i.key());
list[spl->name()] = i.key();
}
}
}
}
FillList(box, list);
FillCombo<VSpline>(box, GOType::Spline, rule);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FillComboBoxSplinesPath
* @param box comboBox
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
*/
void DialogTool::FillComboBoxSplinesPath(QComboBox *box, ComboBoxCutSpline cut) const
void DialogTool::FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule) const
{
SCASSERT(box != nullptr);
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
QMap<QString, quint32> list;
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (cut == ComboBoxCutSpline::CutSpline)
{
if (i.key() != toolId + 1 && i.key() != toolId + 2)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(i.key());
list[splPath->name()] = i.key();
}
}
}
else
{
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(i.key());
list[splPath->name()] = i.key();
}
}
}
}
FillList(box, list);
FillCombo<VSplinePath>(box, GOType::SplinePath, rule);
}
//---------------------------------------------------------------------------------------------------------------------
@ -505,13 +386,13 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value) const
void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value, FillComboBox rule) const
{
SCASSERT(box != nullptr);
box->blockSignals(true);
FillComboBoxPoints(box);
FillComboBoxPoints(box, rule);
ChangeCurrentData(box, value);
box->blockSignals(false);
@ -520,28 +401,22 @@ void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value) const
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setCurrentSplineId set current spline id in combobox
* @param box combobox
* @param value spline id
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
*/
void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut) const
void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, FillComboBox rule) const
{
SCASSERT(box != nullptr);
FillComboBoxSplines(box, cut);
FillComboBoxSplines(box, rule);
ChangeCurrentData(box, value);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setCurrentArcId
* @param box combobox
* @param value arc id
* @param cut if set to ComboMode::CutArc don't show id+1 and id+2
*/
void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, ComboBoxCutArc cut) const
void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, FillComboBox rule) const
{
SCASSERT(box != nullptr);
FillComboBoxArcs(box, cut);
FillComboBoxArcs(box, rule);
ChangeCurrentData(box, value);
}
@ -552,10 +427,10 @@ void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, ComboBoxC
* @param value splinePath id
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
*/
void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut) const
void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value, FillComboBox rule) const
{
SCASSERT(box != nullptr);
FillComboBoxSplinesPath(box, cut);
FillComboBoxSplinesPath(box, rule);
ChangeCurrentData(box, value);
}
@ -922,3 +797,41 @@ void DialogTool::SetAssociatedTool(VAbstractTool *tool)
this->associatedTool=tool;
SetToolId(tool->getId());
}
//---------------------------------------------------------------------------------------------------------------------
template <typename GObject>
void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule) const
{
SCASSERT(box != nullptr);
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (rule == FillComboBox::NoChildren)
{
if (i.key() != toolId + 1 && i.key() != toolId + 2)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == gType && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<GObject> arc = data->GeometricObject<GObject>(i.key());
list[arc->name()] = i.key();
}
}
}
else
{
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == gType && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<GObject> arc = data->GeometricObject<GObject>(i.key());
list[arc->name()] = i.key();
}
}
}
}
FillList(box, list);
}

View File

@ -53,8 +53,7 @@ class VContainer;
class QPlainTextEdit;
class VAbstractTool;
enum class ComboBoxCutSpline : char { CutSpline, NoCutSpline };
enum class ComboBoxCutArc : char { CutArc, NoCutArc};
enum class FillComboBox : char { Whole, NoChildren};
/**
* @brief The DialogTool class parent for all dialog of tools.
@ -185,11 +184,10 @@ protected:
virtual void closeEvent ( QCloseEvent * event );
virtual void showEvent( QShowEvent *event );
void FillComboBoxPoints(QComboBox *box)const;
void FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc)const;
void FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const;
void FillComboBoxSplinesPath(QComboBox *box,
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const;
void FillComboBoxPoints(QComboBox *box, FillComboBox rule = FillComboBox::Whole)const;
void FillComboBoxArcs(QComboBox *box, FillComboBox rule = FillComboBox::Whole)const;
void FillComboBoxSplines(QComboBox *box, FillComboBox rule = FillComboBox::Whole)const;
void FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule = FillComboBox::Whole)const;
void FillComboBoxCurves(QComboBox *box)const;
void FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon> &stylesPics) const;
void FillComboBoxLineColors(QComboBox *box)const;
@ -202,13 +200,15 @@ protected:
void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer);
qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix,
bool checkZero = true);
void setCurrentPointId(QComboBox *box, const quint32 &value) const;
void setCurrentPointId(QComboBox *box, const quint32 &value,
FillComboBox rule = FillComboBox::NoChildren) const;
void setCurrentSplineId(QComboBox *box, const quint32 &value,
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const;
FillComboBox rule = FillComboBox::NoChildren) const;
void setCurrentArcId(QComboBox *box, const quint32 &value,
ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc) const;
FillComboBox rule = FillComboBox::NoChildren) const;
void setCurrentSplinePathId(QComboBox *box, const quint32 &value,
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const;
FillComboBox rule = FillComboBox::NoChildren) const;
void setCurrentCurveId(QComboBox *box, const quint32 &value) const;
quint32 getCurrentObjectId(QComboBox *box) const;
@ -308,7 +308,10 @@ protected:
void MoveCursorToEnd(QPlainTextEdit *plainTextEdit);
bool eventFilter(QObject *object, QEvent *event);
private:
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
template <typename GObject>
void FillCombo(QComboBox *box, GOType gType, FillComboBox rule = FillComboBox::Whole) const;
};
//---------------------------------------------------------------------------------------------------------------------