2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file vabstracttool.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2013-11-15 13:41:26 +01:00
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
2013-07-25 20:39:51 +02:00
|
|
|
#include "vabstracttool.h"
|
2014-04-17 19:18:26 +02:00
|
|
|
#include <QGraphicsView>
|
2015-02-26 21:18:52 +01:00
|
|
|
#include <QIcon>
|
2015-02-26 23:27:33 +01:00
|
|
|
#include <QStyle>
|
2014-06-14 08:37:25 +02:00
|
|
|
#include <QMessageBox>
|
2015-02-25 23:27:09 +01:00
|
|
|
#include <QtCore/qmath.h>
|
2015-02-26 22:34:33 +01:00
|
|
|
#include "../../libs/vpropertyexplorer/checkablemessagebox.h"
|
2014-06-14 08:37:25 +02:00
|
|
|
#include "../undocommands/deltool.h"
|
2014-09-25 17:44:06 +02:00
|
|
|
#include "../core/vapplication.h"
|
2015-05-07 14:31:53 +02:00
|
|
|
#include "../libs/vgeometry/vpointf.h"
|
2014-08-30 21:58:31 +02:00
|
|
|
#include "../undocommands/savetooloptions.h"
|
2015-06-15 14:50:59 +02:00
|
|
|
#include "../libs/vwidgets/vmaingraphicsview.h"
|
2015-06-15 15:24:57 +02:00
|
|
|
#include "../libs/vmisc/vsettings.h"
|
2013-07-25 20:39:51 +02:00
|
|
|
|
2013-10-29 18:46:58 +01:00
|
|
|
const QString VAbstractTool::AttrType = QStringLiteral("type");
|
|
|
|
const QString VAbstractTool::AttrMx = QStringLiteral("mx");
|
|
|
|
const QString VAbstractTool::AttrMy = QStringLiteral("my");
|
|
|
|
const QString VAbstractTool::AttrName = QStringLiteral("name");
|
|
|
|
const QString VAbstractTool::AttrX = QStringLiteral("x");
|
|
|
|
const QString VAbstractTool::AttrY = QStringLiteral("y");
|
|
|
|
const QString VAbstractTool::AttrTypeLine = QStringLiteral("typeLine");
|
|
|
|
const QString VAbstractTool::AttrLength = QStringLiteral("length");
|
|
|
|
const QString VAbstractTool::AttrBasePoint = QStringLiteral("basePoint");
|
|
|
|
const QString VAbstractTool::AttrFirstPoint = QStringLiteral("firstPoint");
|
2013-10-29 14:45:07 +01:00
|
|
|
const QString VAbstractTool::AttrSecondPoint = QStringLiteral("secondPoint");
|
2013-10-29 18:46:58 +01:00
|
|
|
const QString VAbstractTool::AttrThirdPoint = QStringLiteral("thirdPoint");
|
|
|
|
const QString VAbstractTool::AttrCenter = QStringLiteral("center");
|
|
|
|
const QString VAbstractTool::AttrRadius = QStringLiteral("radius");
|
|
|
|
const QString VAbstractTool::AttrAngle = QStringLiteral("angle");
|
|
|
|
const QString VAbstractTool::AttrAngle1 = QStringLiteral("angle1");
|
|
|
|
const QString VAbstractTool::AttrAngle2 = QStringLiteral("angle2");
|
|
|
|
const QString VAbstractTool::AttrP1Line = QStringLiteral("p1Line");
|
|
|
|
const QString VAbstractTool::AttrP2Line = QStringLiteral("p2Line");
|
|
|
|
const QString VAbstractTool::AttrP1Line1 = QStringLiteral("p1Line1");
|
|
|
|
const QString VAbstractTool::AttrP2Line1 = QStringLiteral("p2Line1");
|
|
|
|
const QString VAbstractTool::AttrP1Line2 = QStringLiteral("p1Line2");
|
|
|
|
const QString VAbstractTool::AttrP2Line2 = QStringLiteral("p2Line2");
|
|
|
|
const QString VAbstractTool::AttrPShoulder = QStringLiteral("pShoulder");
|
|
|
|
const QString VAbstractTool::AttrPoint1 = QStringLiteral("point1");
|
|
|
|
const QString VAbstractTool::AttrPoint4 = QStringLiteral("point4");
|
|
|
|
const QString VAbstractTool::AttrKAsm1 = QStringLiteral("kAsm1");
|
|
|
|
const QString VAbstractTool::AttrKAsm2 = QStringLiteral("kAsm2");
|
|
|
|
const QString VAbstractTool::AttrKCurve = QStringLiteral("kCurve");
|
|
|
|
const QString VAbstractTool::AttrPathPoint = QStringLiteral("pathPoint");
|
|
|
|
const QString VAbstractTool::AttrPSpline = QStringLiteral("pSpline");
|
|
|
|
const QString VAbstractTool::AttrAxisP1 = QStringLiteral("axisP1");
|
|
|
|
const QString VAbstractTool::AttrAxisP2 = QStringLiteral("axisP2");
|
2014-10-23 10:38:57 +02:00
|
|
|
const QString VAbstractTool::AttrCurve = QStringLiteral("curve");
|
2015-02-02 10:29:50 +01:00
|
|
|
const QString VAbstractTool::AttrLineColor = QStringLiteral("lineColor");
|
|
|
|
const QString VAbstractTool::AttrColor = QStringLiteral("color");
|
2015-05-27 12:48:21 +02:00
|
|
|
const QString VAbstractTool::AttrFirstArc = QStringLiteral("firstArc");
|
|
|
|
const QString VAbstractTool::AttrSecondArc = QStringLiteral("secondArc");
|
|
|
|
const QString VAbstractTool::AttrCrossPoint = QStringLiteral("crossPoint");
|
2015-05-30 12:02:20 +02:00
|
|
|
const QString VAbstractTool::AttrC1Center = QStringLiteral("c1Center");
|
|
|
|
const QString VAbstractTool::AttrC2Center = QStringLiteral("c2Center");
|
|
|
|
const QString VAbstractTool::AttrC1Radius = QStringLiteral("c1Radius");
|
|
|
|
const QString VAbstractTool::AttrC2Radius = QStringLiteral("c2Radius");
|
2015-06-05 15:43:41 +02:00
|
|
|
const QString VAbstractTool::AttrCCenter = QStringLiteral("cCenter");
|
|
|
|
const QString VAbstractTool::AttrTangent = QStringLiteral("tangent");
|
|
|
|
const QString VAbstractTool::AttrCRadius = QStringLiteral("cRadius");
|
2015-06-06 08:33:19 +02:00
|
|
|
const QString VAbstractTool::AttrArc = QStringLiteral("arc");
|
2014-02-25 19:03:17 +01:00
|
|
|
|
|
|
|
const QString VAbstractTool::TypeLineNone = QStringLiteral("none");
|
|
|
|
const QString VAbstractTool::TypeLineLine = QStringLiteral("hair");
|
2014-01-29 13:47:43 +01:00
|
|
|
const QString VAbstractTool::TypeLineDashLine = QStringLiteral("dashLine");
|
|
|
|
const QString VAbstractTool::TypeLineDotLine = QStringLiteral("dotLine");
|
|
|
|
const QString VAbstractTool::TypeLineDashDotLine = QStringLiteral("dashDotLine");
|
|
|
|
const QString VAbstractTool::TypeLineDashDotDotLine = QStringLiteral("dashDotDotLine");
|
2013-10-29 14:45:07 +01:00
|
|
|
|
2015-02-02 10:29:50 +01:00
|
|
|
const QString VAbstractTool::ColorBlack = QStringLiteral("black");
|
|
|
|
const QString VAbstractTool::ColorGreen = QStringLiteral("green");
|
|
|
|
const QString VAbstractTool::ColorBlue = QStringLiteral("blue");
|
|
|
|
const QString VAbstractTool::ColorDarkRed = QStringLiteral("darkRed");
|
|
|
|
const QString VAbstractTool::ColorDarkGreen = QStringLiteral("darkGreen");
|
2015-02-02 11:28:09 +01:00
|
|
|
const QString VAbstractTool::ColorDarkBlue = QStringLiteral("darkBlue");
|
|
|
|
const QString VAbstractTool::ColorYellow = QStringLiteral("yellow");
|
2015-02-02 10:29:50 +01:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief VAbstractTool container.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with data.
|
|
|
|
* @param id object id in container.
|
|
|
|
* @param parent parent object.
|
|
|
|
*/
|
2015-06-16 17:01:17 +02:00
|
|
|
VAbstractTool::VAbstractTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent)
|
2015-02-06 12:41:30 +01:00
|
|
|
:VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), vis(nullptr)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(doc != nullptr);
|
2015-06-16 17:01:17 +02:00
|
|
|
connect(this, &VAbstractTool::toolhaveChange, this->doc, &VAbstractPattern::haveLiteChange);
|
|
|
|
connect(this->doc, &VAbstractPattern::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile);
|
|
|
|
connect(this, &VAbstractTool::LiteUpdateTree, this->doc, &VAbstractPattern::LiteParseTree);
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
|
|
|
|
2014-09-03 15:52:16 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VAbstractTool::~VAbstractTool()
|
2014-09-04 15:42:16 +02:00
|
|
|
{}
|
2014-09-03 15:52:16 +02:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief DeleteTool full delete object form scene and file.
|
|
|
|
*/
|
2014-06-16 14:14:46 +02:00
|
|
|
void VAbstractTool::DeleteTool(bool ask)
|
2014-01-03 16:13:43 +01:00
|
|
|
{
|
2014-09-26 19:09:20 +02:00
|
|
|
if (_referens <= 1)
|
2014-01-03 16:13:43 +01:00
|
|
|
{
|
2014-09-26 19:09:20 +02:00
|
|
|
qApp->getSceneView()->itemClicked(nullptr);
|
|
|
|
if (ask)
|
2014-06-15 19:07:54 +02:00
|
|
|
{
|
2015-02-25 23:27:09 +01:00
|
|
|
if (ConfirmDeletion() == QMessageBox::No)
|
2014-09-26 19:09:20 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-06-15 19:07:54 +02:00
|
|
|
}
|
2014-09-26 19:09:20 +02:00
|
|
|
DelTool *delTool = new DelTool(doc, id);
|
2015-06-16 17:01:17 +02:00
|
|
|
connect(delTool, &DelTool::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
|
2014-09-26 19:09:20 +02:00
|
|
|
qApp->getUndoStack()->push(delTool);
|
2014-01-03 16:13:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-25 23:27:09 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VAbstractTool::ConfirmDeletion()
|
|
|
|
{
|
2015-06-18 10:49:25 +02:00
|
|
|
if (false == qApp->Settings()->GetConfirmItemDelete())
|
2015-02-26 22:34:33 +01:00
|
|
|
{
|
2015-02-25 23:27:09 +01:00
|
|
|
return QMessageBox::Yes;
|
2015-02-26 22:34:33 +01:00
|
|
|
}
|
2015-02-25 23:27:09 +01:00
|
|
|
|
|
|
|
Utils::CheckableMessageBox msgBox(qApp->getMainWindow());
|
|
|
|
msgBox.setWindowTitle(tr("Confirm deletion"));
|
|
|
|
msgBox.setText(tr("Do you really want to delete?"));
|
|
|
|
msgBox.setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);
|
|
|
|
msgBox.setDefaultButton(QDialogButtonBox::No);
|
2015-03-02 18:11:43 +01:00
|
|
|
msgBox.setIconPixmap(qApp->style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(32, 32) );
|
2015-02-25 23:27:09 +01:00
|
|
|
|
|
|
|
int dialogResult = msgBox.exec();
|
|
|
|
|
|
|
|
if (dialogResult == QDialog::Accepted)
|
2015-02-26 22:34:33 +01:00
|
|
|
{
|
2015-06-18 10:49:25 +02:00
|
|
|
qApp->Settings()->SetConfirmItemDelete(not msgBox.isChecked());
|
2015-02-26 22:34:33 +01:00
|
|
|
}
|
2015-02-25 23:27:09 +01:00
|
|
|
|
|
|
|
return dialogResult == QDialog::Accepted ? QMessageBox::Yes : QMessageBox::No;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief LineStyle return pen style for current line style.
|
|
|
|
* @return pen style.
|
|
|
|
*/
|
2015-01-29 16:47:02 +01:00
|
|
|
Qt::PenStyle VAbstractTool::LineStyleToPenStyle(const QString &typeLine)
|
2014-01-29 13:47:43 +01:00
|
|
|
{
|
2015-01-29 16:47:02 +01:00
|
|
|
const QStringList styles = StylesList();
|
2014-02-26 10:51:37 +01:00
|
|
|
switch (styles.indexOf(typeLine))
|
2014-01-29 13:47:43 +01:00
|
|
|
{
|
2014-02-26 10:51:37 +01:00
|
|
|
case 0: // TypeLineNone
|
2014-01-29 13:47:43 +01:00
|
|
|
return Qt::NoPen;
|
|
|
|
break;
|
2014-02-26 10:51:37 +01:00
|
|
|
case 1: // TypeLineLine
|
2014-01-29 13:47:43 +01:00
|
|
|
return Qt::SolidLine;
|
|
|
|
break;
|
2014-02-26 10:51:37 +01:00
|
|
|
case 2: // TypeLineDashLine
|
2014-01-29 13:47:43 +01:00
|
|
|
return Qt::DashLine;
|
|
|
|
break;
|
2014-02-26 10:51:37 +01:00
|
|
|
case 3: // TypeLineDotLine
|
2014-01-29 13:47:43 +01:00
|
|
|
return Qt::DotLine;
|
|
|
|
break;
|
2014-02-26 10:51:37 +01:00
|
|
|
case 4: // TypeLineDashDotLine
|
2014-01-29 13:47:43 +01:00
|
|
|
return Qt::DashDotLine;
|
|
|
|
break;
|
2014-02-26 10:51:37 +01:00
|
|
|
case 5: // TypeLineDashDotDotLine
|
2014-01-29 13:47:43 +01:00
|
|
|
return Qt::DashDotDotLine;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return Qt::SolidLine;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-08-30 21:58:31 +02:00
|
|
|
|
2015-01-29 16:47:02 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QMap<QString, QIcon> VAbstractTool::LineStylesPics()
|
|
|
|
{
|
|
|
|
QMap<QString, QIcon> map;
|
|
|
|
const QStringList styles = StylesList();
|
|
|
|
|
|
|
|
for (int i=0; i < styles.size(); ++i)
|
|
|
|
{
|
|
|
|
const Qt::PenStyle style = LineStyleToPenStyle(styles.at(i));
|
|
|
|
QPixmap pix(80, 14);
|
|
|
|
pix.fill(Qt::white);
|
|
|
|
|
|
|
|
QBrush brush(Qt::black);
|
|
|
|
QPen pen(brush, 2.5, style);
|
|
|
|
|
|
|
|
QPainter painter(&pix);
|
|
|
|
painter.setPen(pen);
|
|
|
|
painter.drawLine(2, 7, 78, 7);
|
|
|
|
|
|
|
|
map.insert(styles.at(i), QIcon(pix));
|
|
|
|
}
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2015-02-02 10:29:50 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
const QStringList VAbstractTool::Colors()
|
|
|
|
{
|
|
|
|
const QStringList colors = QStringList() << ColorBlack << ColorGreen << ColorBlue << ColorDarkRed << ColorDarkGreen
|
|
|
|
<< ColorDarkBlue << ColorYellow;
|
|
|
|
return colors;
|
|
|
|
}
|
|
|
|
|
2015-02-07 13:31:10 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QMap<QString, QString> VAbstractTool::ColorsList()
|
|
|
|
{
|
|
|
|
QMap<QString, QString> map;
|
|
|
|
|
|
|
|
const QStringList colorNames = Colors();
|
|
|
|
for (int i = 0; i < colorNames.size(); ++i)
|
|
|
|
{
|
|
|
|
QString name;
|
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case 0: // ColorBlack
|
|
|
|
name = tr("black");
|
|
|
|
break;
|
|
|
|
case 1: // ColorGreen
|
|
|
|
name = tr("green");
|
|
|
|
break;
|
|
|
|
case 2: // ColorBlue
|
|
|
|
name = tr("blue");
|
|
|
|
break;
|
|
|
|
case 3: // ColorDarkRed
|
|
|
|
name = tr("dark red");
|
|
|
|
break;
|
|
|
|
case 4: // ColorDarkGreen
|
|
|
|
name = tr("dark green");
|
|
|
|
break;
|
|
|
|
case 5: // ColorDarkBlue
|
|
|
|
name = tr("dark blue");
|
|
|
|
break;
|
|
|
|
case 6: // ColorYellow
|
|
|
|
name = tr("yellow");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
name = tr("black");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
map.insert(colorNames.at(i), name);
|
|
|
|
}
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2014-08-30 21:58:31 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-04-15 14:44:57 +02:00
|
|
|
// cppcheck-suppress unusedFunction
|
2014-08-28 13:05:58 +02:00
|
|
|
QMap<QString, quint32> VAbstractTool::PointsList() const
|
|
|
|
{
|
|
|
|
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() != id)
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2015-05-28 12:16:59 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VAbstractTool::ToolCreation(const Source &typeCreation)
|
|
|
|
{
|
|
|
|
if (typeCreation == Source::FromGui)
|
|
|
|
{
|
|
|
|
AddToFile();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RefreshDataInFile();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief Styles return list of all line styles.
|
|
|
|
* @return list of all line styles.
|
|
|
|
*/
|
2015-01-29 16:47:02 +01:00
|
|
|
const QStringList VAbstractTool::StylesList()
|
2014-01-29 13:47:43 +01:00
|
|
|
{
|
2015-02-02 10:29:50 +01:00
|
|
|
const QStringList styles = QStringList() << TypeLineNone << TypeLineLine << TypeLineDashLine << TypeLineDotLine
|
|
|
|
<< TypeLineDashDotLine << TypeLineDashDotDotLine;
|
2014-01-29 13:47:43 +01:00
|
|
|
return styles;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief AddRecord add record about tool in history.
|
|
|
|
* @param id object id in container
|
|
|
|
* @param toolType tool type
|
|
|
|
* @param doc dom document container
|
|
|
|
*/
|
2015-06-16 17:01:17 +02:00
|
|
|
void VAbstractTool::AddRecord(const quint32 id, const Tool &toolType, VAbstractPattern *doc)
|
2014-01-02 16:50:01 +01:00
|
|
|
{
|
|
|
|
QVector<VToolRecord> *history = doc->getHistory();
|
2014-07-29 17:23:18 +02:00
|
|
|
VToolRecord record = VToolRecord(id, toolType, doc->GetNameActivPP());
|
|
|
|
if (history->contains(record))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint32 cursor = doc->getCursor();
|
2014-01-02 16:50:01 +01:00
|
|
|
if (cursor <= 0)
|
|
|
|
{
|
2014-07-29 17:23:18 +02:00
|
|
|
history->append(record);
|
2014-01-02 16:50:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qint32 index = 0;
|
|
|
|
for (qint32 i = 0; i<history->size(); ++i)
|
|
|
|
{
|
|
|
|
VToolRecord rec = history->at(i);
|
|
|
|
if (rec.getId() == cursor)
|
|
|
|
{
|
|
|
|
index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-07-29 17:23:18 +02:00
|
|
|
history->insert(index+1, record);
|
2014-01-02 16:50:01 +01:00
|
|
|
}
|
|
|
|
}
|