From 233e1f7cbc2d29a8fde994a9c1995917e65d423a Mon Sep 17 00:00:00 2001 From: dismine Date: Fri, 4 Oct 2013 14:32:42 +0300 Subject: [PATCH] Replaced Qmap on to Qhash. Better performance. --HG-- branch : develop --- container/vcontainer.cpp | 77 ++++++++++++++++++------------------ container/vcontainer.h | 70 ++++++++++++++++---------------- dialogs/dialogarc.cpp | 4 +- dialogs/dialogincrements.cpp | 35 ++++++++++------ dialogs/dialogtool.cpp | 8 ++-- dialogs/dialogtool.h | 2 +- geometry/varc.cpp | 4 +- geometry/varc.h | 6 +-- geometry/vspline.cpp | 6 +-- geometry/vspline.h | 10 ++--- geometry/vsplinepath.cpp | 4 +- geometry/vsplinepath.h | 6 +-- mainwindow.cpp | 4 +- tools/vtooldetail.cpp | 4 +- xml/vdomdocument.cpp | 16 ++++---- xml/vdomdocument.h | 8 ++-- 16 files changed, 136 insertions(+), 128 deletions(-) diff --git a/container/vcontainer.cpp b/container/vcontainer.cpp index 8f20e2036..65292950e 100644 --- a/container/vcontainer.cpp +++ b/container/vcontainer.cpp @@ -26,15 +26,15 @@ qint64 VContainer::_id = 0; -VContainer::VContainer():base(QMap()), points(QMap()), - modelingPoints(QMap()), - standartTable(QMap()), incrementTable(QMap()), - lengthLines(QMap()), lineAngles(QMap()), splines(QMap()), - modelingSplines(QMap()), - lengthSplines(QMap()), arcs(QMap()), modelingArcs(QMap()), - lengthArcs(QMap()), - splinePaths(QMap()), modelingSplinePaths(QMap()), - details(QMap()){ +VContainer::VContainer():base(QHash()), points(QHash()), + modelingPoints(QHash()), + standartTable(QHash()), incrementTable(QHash()), + lengthLines(QHash()), lineAngles(QHash()), splines(QHash()), + modelingSplines(QHash()), + lengthSplines(QHash()), arcs(QHash()), modelingArcs(QHash()), + lengthArcs(QHash()), + splinePaths(QHash()), modelingSplinePaths(QHash()), + details(QHash()){ SetSize(500); SetGrowth(1760); CreateManTableIGroup (); @@ -45,15 +45,15 @@ VContainer &VContainer::operator =(const VContainer &data){ return *this; } -VContainer::VContainer(const VContainer &data):base(QMap()), points(QMap()), - modelingPoints(QMap()), - standartTable(QMap()), incrementTable(QMap()), - lengthLines(QMap()), lineAngles(QMap()), splines(QMap()), - modelingSplines(QMap()), - lengthSplines(QMap()), arcs(QMap()), modelingArcs(QMap()), - lengthArcs(QMap()), - splinePaths(QMap()), modelingSplinePaths(QMap()), - details(QMap()){ +VContainer::VContainer(const VContainer &data):base(QHash()), points(QHash()), + modelingPoints(QHash()), + standartTable(QHash()), incrementTable(QHash()), + lengthLines(QHash()), lineAngles(QHash()), splines(QHash()), + modelingSplines(QHash()), + lengthSplines(QHash()), arcs(QHash()), modelingArcs(QHash()), + lengthArcs(QHash()), + splinePaths(QHash()), modelingSplinePaths(QHash()), + details(QHash()){ setData(data); } @@ -77,7 +77,7 @@ void VContainer::setData(const VContainer &data){ } template -val VContainer::GetObject(const QMap &obj, key id){ +val VContainer::GetObject(const QHash &obj, key id){ if(obj.contains(id)){ return obj.value(id); } else { @@ -85,7 +85,6 @@ val VContainer::GetObject(const QMap &obj, key id){ } } - VPointF VContainer::GetPoint(qint64 id) const{ return GetObject(points, id); } @@ -377,7 +376,7 @@ QVector VContainer::CheckLoops(const QVector &points) const{ } void VContainer::PrepareDetails(QVector &list) const{ - QMapIterator iDetail(details); + QHashIterator iDetail(details); while (iDetail.hasNext()) { iDetail.next(); list.append(new VItem(ContourPath(iDetail.key()), list.size())); @@ -389,7 +388,7 @@ void VContainer::RemoveIncrementTableRow(const QString& name){ } template -void VContainer::UpdateObject(QMap &obj, const qint64 &id, const val& point){ +void VContainer::UpdateObject(QHash &obj, const qint64 &id, const val& point){ Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); obj[id] = point; UpdateId(id); @@ -567,67 +566,67 @@ qreal VContainer::FindVar(const QString &name, bool *ok)const{ return 0; } -const QMap *VContainer::DataPoints() const{ +const QHash *VContainer::DataPoints() const{ return &points; } -const QMap *VContainer::DataModelingPoints() const{ +const QHash *VContainer::DataModelingPoints() const{ return &modelingPoints; } -const QMap *VContainer::DataSplines() const{ +const QHash *VContainer::DataSplines() const{ return &splines; } -const QMap *VContainer::DataModelingSplines() const{ +const QHash *VContainer::DataModelingSplines() const{ return &modelingSplines; } -const QMap *VContainer::DataArcs() const{ +const QHash *VContainer::DataArcs() const{ return &arcs; } -const QMap *VContainer::DataModelingArcs() const{ +const QHash *VContainer::DataModelingArcs() const{ return &modelingArcs; } -const QMap *VContainer::DataBase() const{ +const QHash *VContainer::DataBase() const{ return &base; } -const QMap *VContainer::DataStandartTable() const{ +const QHash *VContainer::DataStandartTable() const{ return &standartTable; } -const QMap *VContainer::DataIncrementTable() const{ +const QHash *VContainer::DataIncrementTable() const{ return &incrementTable; } -const QMap *VContainer::DataLengthLines() const{ +const QHash *VContainer::DataLengthLines() const{ return &lengthLines; } -const QMap *VContainer::DataLengthSplines() const{ +const QHash *VContainer::DataLengthSplines() const{ return &lengthSplines; } -const QMap *VContainer::DataLengthArcs() const{ +const QHash *VContainer::DataLengthArcs() const{ return &lengthArcs; } -const QMap *VContainer::DataLineAngles() const{ +const QHash *VContainer::DataLineAngles() const{ return &lineAngles; } -const QMap *VContainer::DataSplinePaths() const{ +const QHash *VContainer::DataSplinePaths() const{ return &splinePaths; } -const QMap *VContainer::DataModelingSplinePaths() const{ +const QHash *VContainer::DataModelingSplinePaths() const{ return &modelingSplinePaths; } -const QMap *VContainer::DataDetails() const{ +const QHash *VContainer::DataDetails() const{ return &details; } @@ -648,7 +647,7 @@ void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId } template -qint64 VContainer::AddObject(QMap &obj, const val& value){ +qint64 VContainer::AddObject(QHash &obj, const val& value){ qint64 id = getNextId(); obj[id] = value; return id; diff --git a/container/vcontainer.h b/container/vcontainer.h index fce8a378a..c7582b89d 100644 --- a/container/vcontainer.h +++ b/container/vcontainer.h @@ -122,22 +122,22 @@ public: bool IncrementTableContains(const QString& name); static qint64 getNextId(); void RemoveIncrementTableRow(const QString& name); - const QMap *DataPoints() const; - const QMap *DataModelingPoints() const; - const QMap *DataSplines() const; - const QMap *DataModelingSplines() const; - const QMap *DataArcs() const; - const QMap *DataModelingArcs() const; - const QMap *DataBase() const; - const QMap *DataStandartTable() const; - const QMap *DataIncrementTable() const; - const QMap *DataLengthLines() const; - const QMap *DataLengthSplines() const; - const QMap *DataLengthArcs() const; - const QMap *DataLineAngles() const; - const QMap *DataSplinePaths() const; - const QMap *DataModelingSplinePaths() const; - const QMap *DataDetails() const; + const QHash *DataPoints() const; + const QHash *DataModelingPoints() const; + const QHash *DataSplines() const; + const QHash *DataModelingSplines() const; + const QHash *DataArcs() const; + const QHash *DataModelingArcs() const; + const QHash *DataBase() const; + const QHash *DataStandartTable() const; + const QHash *DataIncrementTable() const; + const QHash *DataLengthLines() const; + const QHash *DataLengthSplines() const; + const QHash *DataLengthArcs() const; + const QHash *DataLineAngles() const; + const QHash *DataSplinePaths() const; + const QHash *DataModelingSplinePaths() const; + const QHash *DataDetails() const; static void UpdateId(qint64 newId); QPainterPath ContourPath(qint64 idDetail) const; QPainterPath Equidistant(QVector points, const Detail::Equidistant &eqv, @@ -149,26 +149,26 @@ public: void PrepareDetails(QVector & list)const; private: static qint64 _id; - QMap base; - QMap points; - QMap modelingPoints; - QMap standartTable; - QMap incrementTable; - QMap lengthLines; - QMap lineAngles; - QMap splines; - QMap modelingSplines; - QMap lengthSplines; - QMap arcs; - QMap modelingArcs; - QMap lengthArcs; - QMap splinePaths; - QMap modelingSplinePaths; - QMap details; - template static val GetObject(const QMap &obj, key id); - template static void UpdateObject(QMap &obj, const qint64 &id, + QHash base; + QHash points; + QHash modelingPoints; + QHash standartTable; + QHash incrementTable; + QHash lengthLines; + QHash lineAngles; + QHash splines; + QHash modelingSplines; + QHash lengthSplines; + QHash arcs; + QHash modelingArcs; + QHash lengthArcs; + QHash splinePaths; + QHash modelingSplinePaths; + QHash details; + template static val GetObject(const QHash &obj, key id); + template static void UpdateObject(QHash &obj, const qint64 &id, const val& point); - template static qint64 AddObject(QMap &obj, const val& value); + template static qint64 AddObject(QHash &obj, const val& value); void CreateManTableIGroup (); QVector GetReversePoint(const QVector &points)const; qreal GetLengthContour(const QVector &contour, const QVector &newPoints)const; diff --git a/dialogs/dialogarc.cpp b/dialogs/dialogarc.cpp index cb547949a..7f77b419c 100644 --- a/dialogs/dialogarc.cpp +++ b/dialogs/dialogarc.cpp @@ -209,8 +209,8 @@ void DialogArc::ShowLineArcs(){ disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); ui->listWidget->clear(); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); - const QMap *lineArcsTable = data->DataLineAngles(); - QMapIterator i(*lineArcsTable); + const QHash *lineArcsTable = data->DataLineAngles(); + QHashIterator i(*lineArcsTable); while (i.hasNext()) { i.next(); QListWidgetItem *item = new QListWidgetItem(i.key()); diff --git a/dialogs/dialogincrements.cpp b/dialogs/dialogincrements.cpp index dea7a04d2..f26012fd1 100644 --- a/dialogs/dialogincrements.cpp +++ b/dialogs/dialogincrements.cpp @@ -55,9 +55,9 @@ DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget } void DialogIncrements::FillStandartTable(){ - const QMap *standartTable = data->DataStandartTable(); + const QHash *standartTable = data->DataStandartTable(); qint32 currentRow = -1; - QMapIterator i(*standartTable); + QHashIterator i(*standartTable); ui->tableWidgetStandart->setRowCount ( standartTable->size() ); while (i.hasNext()) { i.next(); @@ -95,22 +95,31 @@ void DialogIncrements::FillStandartTable(){ } void DialogIncrements::FillIncrementTable(){ - const QMap *incrementTable = data->DataIncrementTable(); - qint32 currentRow = -1; - QMapIterator i(*incrementTable); + const QHash *incrementTable = data->DataIncrementTable(); + QHashIterator i(*incrementTable); + QMap map; + //Sorting QHash by id while (i.hasNext()) { i.next(); VIncrementTableRow cell = i.value(); + map.insert(cell.getId(), i.key()); + } + + qint32 currentRow = -1; + QMapIterator iMap(map); + while (iMap.hasNext()) { + iMap.next(); + VIncrementTableRow cell = incrementTable->value(iMap.value()); currentRow++; ui->tableWidgetIncrement->setRowCount ( incrementTable->size() ); - QTableWidgetItem *item = new QTableWidgetItem(QString(i.key())); + QTableWidgetItem *item = new QTableWidgetItem(iMap.value()); item->setTextAlignment(Qt::AlignHCenter); item->setFont(QFont("Times", 12, QFont::Bold)); item->setData(Qt::UserRole, cell.getId()); ui->tableWidgetIncrement->setItem(currentRow, 0, item); - item = new QTableWidgetItem(QString().setNum(data->GetValueIncrementTableRow(i.key()))); + item = new QTableWidgetItem(QString().setNum(data->GetValueIncrementTableRow(iMap.value()))); item->setTextAlignment(Qt::AlignHCenter); // set the item non-editable (view only), and non-selectable Qt::ItemFlags flags = item->flags(); @@ -143,9 +152,9 @@ void DialogIncrements::FillIncrementTable(){ } void DialogIncrements::FillLengthLines(){ - const QMap *linesTable = data->DataLengthLines(); + const QHash *linesTable = data->DataLengthLines(); qint32 currentRow = -1; - QMapIterator i(*linesTable); + QHashIterator i(*linesTable); while (i.hasNext()) { i.next(); qreal length = i.value(); @@ -167,9 +176,9 @@ void DialogIncrements::FillLengthLines(){ } void DialogIncrements::FillLengthSplines(){ - const QMap *splinesTable = data->DataLengthSplines(); + const QHash *splinesTable = data->DataLengthSplines(); qint32 currentRow = -1; - QMapIterator i(*splinesTable); + QHashIterator i(*splinesTable); while (i.hasNext()) { i.next(); qreal length = i.value(); @@ -191,9 +200,9 @@ void DialogIncrements::FillLengthSplines(){ } void DialogIncrements::FillLengthArcs(){ - const QMap *arcsTable = data->DataLengthArcs(); + const QHash *arcsTable = data->DataLengthArcs(); qint32 currentRow = -1; - QMapIterator i(*arcsTable); + QHashIterator i(*arcsTable); while (i.hasNext()) { i.next(); qreal length = i.value(); diff --git a/dialogs/dialogtool.cpp b/dialogs/dialogtool.cpp index 2c9db774e..f5641e33c 100644 --- a/dialogs/dialogtool.cpp +++ b/dialogs/dialogtool.cpp @@ -58,8 +58,8 @@ void DialogTool::showEvent(QShowEvent *event){ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{ box->clear(); if(mode == Draw::Calculation){ - const QMap *points = data->DataPoints(); - QMapIterator i(*points); + const QHash *points = data->DataPoints(); + QHashIterator i(*points); while (i.hasNext()) { i.next(); if(i.key() != id){ @@ -373,12 +373,12 @@ bool DialogTool::CheckObject(const qint64 &id){ } template -void DialogTool::ShowVariable(const QMap *var){ +void DialogTool::ShowVariable(const QHash *var){ Q_CHECK_PTR(listWidget); disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); listWidget->clear(); connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); - QMapIterator i(*var); + QHashIterator i(*var); while (i.hasNext()) { i.next(); QListWidgetItem *item = new QListWidgetItem(i.key()); diff --git a/dialogs/dialogtool.h b/dialogs/dialogtool.h index a6168934b..e48d68aa9 100644 --- a/dialogs/dialogtool.h +++ b/dialogs/dialogtool.h @@ -92,7 +92,7 @@ protected: void FillComboBoxTypeLine(QComboBox *box) const; virtual void CheckState(); QString GetTypeLine(const QComboBox *box)const; - template void ShowVariable(const QMap *var); + template void ShowVariable(const QHash *var); void SetupTypeLine(QComboBox *box, const QString &value); void ChangeCurrentText(QComboBox *box, const QString &value); void ChangeCurrentData(QComboBox *box, const qint64 &value) const; diff --git a/geometry/varc.cpp b/geometry/varc.cpp index 3ab6180c9..214a39a51 100644 --- a/geometry/varc.cpp +++ b/geometry/varc.cpp @@ -26,7 +26,7 @@ VArc::VArc () : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius center(0), points(0), mode(Draw::Calculation), idObject(0){ } -VArc::VArc (const QMap *points, qint64 center, qreal radius, QString formulaRadius, +VArc::VArc (const QHash *points, qint64 center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Draws mode, qint64 idObject) : f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius), center(center), points(points), mode(mode), idObject(idObject){ @@ -108,7 +108,7 @@ QPointF VArc::GetP2 () const{ return centerP2.p2(); } -const QMap *VArc::GetDataPoints() const{ +const QHash *VArc::GetDataPoints() const{ return points; } diff --git a/geometry/varc.h b/geometry/varc.h index d0f0b1285..349083a44 100644 --- a/geometry/varc.h +++ b/geometry/varc.h @@ -40,7 +40,7 @@ public: * @param f1 початковий кут в градусах. * @param f2 кінцевий кут в градусах. */ - VArc (const QMap *points, qint64 center, qreal radius, QString formulaRadius, + VArc (const QHash *points, qint64 center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2 , QString formulaF2, Draw::Draws mode = Draw::Calculation, qint64 idObject = 0); VArc(const VArc &arc); @@ -84,7 +84,7 @@ public: * @return точку кінця дуги. */ QPointF GetP2 () const; - const QMap *GetDataPoints() const; + const QHash *GetDataPoints() const; /** * @brief GetPath будує шлях по даній дузі. * @return повертає шлях. @@ -119,7 +119,7 @@ private: * @brief center центральна точка дуги. */ qint64 center; - const QMap *points; + const QHash *points; Draw::Draws mode; qint64 idObject; }; diff --git a/geometry/vspline.cpp b/geometry/vspline.cpp index 69f6ff495..ee19f4a18 100644 --- a/geometry/vspline.cpp +++ b/geometry/vspline.cpp @@ -32,14 +32,14 @@ VSpline::VSpline ( const VSpline & spline ):p1(spline.GetP1 ()), p2(spline.GetP2 mode(spline.getMode()), idObject(spline.getIdObject()){ } -VSpline::VSpline (const QMap *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2, +VSpline::VSpline (const QHash *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2 , qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve), points(points), mode(mode), idObject(idObject){ ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve ); } -VSpline::VSpline (const QMap *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4, +VSpline::VSpline (const QHash *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4, qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(points), mode(mode), idObject(idObject){ ModifiSpl ( p1, p2, p3, p4, kCurve); @@ -190,7 +190,7 @@ qreal VSpline::GetKcurve() const{ return kCurve; } -const QMap *VSpline::GetDataPoints() const{ +const QHash *VSpline::GetDataPoints() const{ return points; } diff --git a/geometry/vspline.h b/geometry/vspline.h index 6c7cf59c0..79ee52fe4 100644 --- a/geometry/vspline.h +++ b/geometry/vspline.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include "container/vpointf.h" /** @@ -50,7 +50,7 @@ public: * @param kAsm1 коефіцієнт довжини першої напрямної. * @param kAsm2 коефіцієнт довжини другої напрямної. */ - VSpline (const QMap *points, qint64 p1, qint64 p4, qreal angle1, + VSpline (const QHash *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode = Draw::Calculation, qint64 idObject = 0); /** @@ -60,7 +60,7 @@ public: * @param p3 друга контролююча точка сплайну. * @param p4 кінцева точка сплайну. */ - VSpline (const QMap *points, qint64 p1, QPointF p2, QPointF p3, + VSpline (const QHash *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4, qreal kCurve, Draw::Draws mode = Draw::Calculation, qint64 idObject = 0); /** @@ -136,7 +136,7 @@ public: qreal GetKasm1() const; qreal GetKasm2() const; qreal GetKcurve() const; - const QMap *GetDataPoints() const; + const QHash *GetDataPoints() const; /** * @brief CrossingSplLine перевіряє перетин сплайну з лінією. * @param line лінія з якою перевіряється перетин. @@ -224,7 +224,7 @@ private: qreal kAsm1; qreal kAsm2; qreal kCurve; - const QMap *points; + const QHash *points; Draw::Draws mode; qint64 idObject; /** diff --git a/geometry/vsplinepath.cpp b/geometry/vsplinepath.cpp index 8e3823ee3..a4dd5c176 100644 --- a/geometry/vsplinepath.cpp +++ b/geometry/vsplinepath.cpp @@ -26,7 +26,7 @@ VSplinePath::VSplinePath(): path(QVector()), kCurve(1), mode(Draw: idObject(0){ } -VSplinePath::VSplinePath(const QMap *points, qreal kCurve, Draw::Draws mode, qint64 idObject): path(QVector()), +VSplinePath::VSplinePath(const QHash *points, qreal kCurve, Draw::Draws mode, qint64 idObject): path(QVector()), kCurve(kCurve), mode(mode), points(points), idObject(idObject){ } @@ -108,7 +108,7 @@ qreal VSplinePath::GetLength() const{ return length; } -const QMap *VSplinePath::GetDataPoints() const{ +const QHash *VSplinePath::GetDataPoints() const{ return points; } diff --git a/geometry/vsplinepath.h b/geometry/vsplinepath.h index c6d6330f9..1036154dd 100644 --- a/geometry/vsplinepath.h +++ b/geometry/vsplinepath.h @@ -45,7 +45,7 @@ public: /** * @brief VSplinePath конструктор по замовчуванню. */ - VSplinePath(const QMap *points, qreal kCurve = 1, + VSplinePath(const QHash *points, qreal kCurve = 1, Draw::Draws mode = Draw::Calculation, qint64 idObject = 0); VSplinePath(const VSplinePath& splPath); /** @@ -60,7 +60,7 @@ public: QVector GetPathPoints() const; QVector GetSplinePath() const; qreal GetLength() const; - const QMap *GetDataPoints() const; + const QHash *GetDataPoints() const; void UpdatePoint(qint32 indexSpline, SplinePoint::Position pos, VSplinePoint point); VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const; /** @@ -85,7 +85,7 @@ protected: QVector path; qreal kCurve; Draw::Draws mode; - const QMap *points; + const QHash *points; qint64 idObject; }; diff --git a/mainwindow.cpp b/mainwindow.cpp index 65cdfb791..ca34966ea 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -150,7 +150,7 @@ void MainWindow::ActionNewDraw(){ VToolSinglePoint *spoint = new VToolSinglePoint(doc, data, id, Tool::FromGui); sceneDraw->addItem(spoint); connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem); - QMap* tools = doc->getTools(); + QHash* tools = doc->getTools(); tools->insert(id, spoint); VDrawTool::AddRecord(id, Tool::SinglePointTool, doc); SetEnableTool(true); @@ -214,7 +214,7 @@ void MainWindow::SetToolButton(bool checked, Tool::Tools t, const QString &curso template void MainWindow::AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool, const qint64 &idDetail){ - QMap* tools = doc->getTools(); + QHash* tools = doc->getTools(); VToolDetail *det = qobject_cast(tools->value(idDetail)); Q_CHECK_PTR(det); det->AddTool(tool, id, typeTool); diff --git a/tools/vtooldetail.cpp b/tools/vtooldetail.cpp index 06b9d8da7..0f4041dc3 100644 --- a/tools/vtooldetail.cpp +++ b/tools/vtooldetail.cpp @@ -30,7 +30,7 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, :VAbstractTool(doc, data, id), QGraphicsPathItem(parent), dialogDetail(QSharedPointer()), sceneDetails(scene){ VDetail detail = data->GetDetail(id); - QMap* tools = doc->getTools(); + QHash* tools = doc->getTools(); Q_CHECK_PTR(tools); for(qint32 i = 0; i< detail.CountNode(); ++i){ switch(detail[i].getTypeTool()){ @@ -248,7 +248,7 @@ void VToolDetail::Create(const qint64 _id, VDetail &newDetail, VMainGraphicsScen scene->addItem(detail); connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(detail, &VToolDetail::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - QMap* tools = doc->getTools(); + QHash* tools = doc->getTools(); tools->insert(id, detail); } } diff --git a/xml/vdomdocument.cpp b/xml/vdomdocument.cpp index 151a6b522..ad6d916a1 100644 --- a/xml/vdomdocument.cpp +++ b/xml/vdomdocument.cpp @@ -36,22 +36,22 @@ VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode) : QDomDocument(), - map(QMap()), nameActivDraw(QString()), data(data), - tools(QMap()), history(QVector()), cursor(0), + map(QHash()), nameActivDraw(QString()), data(data), + tools(QHash()), history(QVector()), cursor(0), comboBoxDraws(comboBoxDraws), mode(mode){ } VDomDocument::VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode) : - QDomDocument(name), map(QMap()), nameActivDraw(QString()), data(data), - tools(QMap()), history(QVector()), cursor(0), + QDomDocument(name), map(QHash()), nameActivDraw(QString()), data(data), + tools(QHash()), history(QVector()), cursor(0), comboBoxDraws(comboBoxDraws), mode(mode){ } VDomDocument::VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode) : - QDomDocument(doctype), map(QMap()), nameActivDraw(QString()), data(data), - tools(QMap()), history(QVector()), cursor(0), + QDomDocument(doctype), map(QHash()), nameActivDraw(QString()), data(data), + tools(QHash()), history(QVector()), cursor(0), comboBoxDraws(comboBoxDraws), mode(mode){ } @@ -296,7 +296,7 @@ void VDomDocument::Parse(Document::Documents parse, VMainGraphicsScene *sceneDra } } -QMap *VDomDocument::getTools(){ +QHash *VDomDocument::getTools(){ return &tools; } @@ -1035,7 +1035,7 @@ void VDomDocument::setCurrentData(){ } void VDomDocument::GarbageCollector(){ - QMapIterator t(tools); + QHashIterator t(tools); while (t.hasNext()) { t.next(); VDataTool *tool = t.value(); diff --git a/xml/vdomdocument.h b/xml/vdomdocument.h index 192bee821..2a28d6d88 100644 --- a/xml/vdomdocument.h +++ b/xml/vdomdocument.h @@ -23,7 +23,7 @@ #define VDOMDOCUMENT_H #include -#include +#include #include #include "widgets/vmaingraphicsscene.h" #include "tools/vdatatool.h" @@ -58,7 +58,7 @@ public: bool appendDraw(const QString& name); void SetNameDraw(const QString& name); void Parse(Document::Documents parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail); - QMap* getTools(); + QHash* getTools(); QVector *getHistory(); qint64 getCursor() const; void setCursor(const qint64 &value); @@ -81,10 +81,10 @@ public slots: void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable); private: Q_DISABLE_COPY(VDomDocument) - QMap map; + QHash map; QString nameActivDraw; VContainer *data; - QMap tools; + QHash tools; QVector history; qint64 cursor; QComboBox *comboBoxDraws;