Find neighbor node for undo deletion tool.

--HG--
branch : develop
This commit is contained in:
dismine 2014-10-29 11:14:36 +02:00
parent dd6eb522f8
commit 205cca7eec
6 changed files with 49 additions and 12 deletions

View File

@ -150,18 +150,13 @@ void DialogHistory::UpdateHistory()
void DialogHistory::FillTable()
{
ui->tableWidget->clear();
const QVector<VToolRecord> *history = doc->getHistory();
SCASSERT(history != nullptr);
QVector<VToolRecord> history = doc->getLocalHistory();
qint32 currentRow = -1;
qint32 count = 0;
ui->tableWidget->setRowCount(history->size());//Make row count max possible number
for (qint32 i = 0; i< history->size(); ++i)
ui->tableWidget->setRowCount(history.size());//Make row count max possible number
for (qint32 i = 0; i< history.size(); ++i)
{
const VToolRecord tool = history->at(i);
if (tool.getNameDraw() != doc->GetNameActivPP())
{
continue;
}
const VToolRecord tool = history.at(i);
const QString historyRecord = Record(tool);
if (historyRecord.isEmpty() ==false)
{
@ -417,7 +412,7 @@ void DialogHistory::InitialTable()
*/
void DialogHistory::ShowPoint()
{
QVector<VToolRecord> *history = doc->getHistory();
const QVector<VToolRecord> *history = doc->getHistory();
if (history->size()>0)
{
QTableWidgetItem *item = ui->tableWidget->item(0, 1);

View File

@ -33,10 +33,29 @@
//---------------------------------------------------------------------------------------------------------------------
DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), cursor(doc->getCursor())
: VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), cursor(NULL_ID)
{
setText(tr("Delete tool"));
nodeId = id;
QVector<VToolRecord> history = doc->getLocalHistory();
for (qint32 i = 0; i< history.size(); ++i)
{
const VToolRecord tool = history.at(i);
if (nodeId == tool.getId())
{
if (i == 0)
{
cursor = NULL_ID;
}
else
{
const VToolRecord tool = history.at(i-1);
cursor = tool.getId();
}
}
}
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
@ -57,7 +76,7 @@ DelTool::~DelTool()
//---------------------------------------------------------------------------------------------------------------------
void DelTool::undo()
{
if (cursor <= 0)
if (cursor == NULL_ID)
{
parentNode.appendChild(xml);
}

View File

@ -2754,3 +2754,20 @@ QRectF VPattern::ToolBoundingRect(const QRectF &rec, const quint32 &id) const
}
return recTool;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VToolRecord> VPattern::getLocalHistory()
{
QVector<VToolRecord> historyPP;
for (qint32 i = 0; i< history.size(); ++i)
{
const VToolRecord tool = history.at(i);
if (tool.getNameDraw() != GetNameActivPP())
{
continue;
}
historyPP.append(tool);
}
return historyPP;
}

View File

@ -72,6 +72,7 @@ public:
QHash<quint32, VDataTool*>* getTools();
VDataTool* getTool(const quint32 &id);
QVector<VToolRecord> *getHistory();
QVector<VToolRecord> getLocalHistory();
quint32 getCursor() const;
void setCursor(const quint32 &value);
void setCurrentData();

View File

@ -71,3 +71,7 @@ VToolRecord &VToolRecord::operator=(const VToolRecord &record)
VToolRecord::VToolRecord(const VToolRecord &record)
:id(record.getId()), typeTool(record.getTypeTool()), nameDraw(record.getNameDraw())
{}
//---------------------------------------------------------------------------------------------------------------------
VToolRecord::~VToolRecord()
{}

View File

@ -50,6 +50,7 @@ public:
void setTypeTool(const Tool &value);
QString getNameDraw() const;
void setNameDraw(const QString &value);
~VToolRecord();
private:
/** @brief id tool id. */
quint32 id;