Find neighbor node for undo deletion tool.
--HG-- branch : develop
This commit is contained in:
parent
dd6eb522f8
commit
205cca7eec
|
@ -150,18 +150,13 @@ void DialogHistory::UpdateHistory()
|
||||||
void DialogHistory::FillTable()
|
void DialogHistory::FillTable()
|
||||||
{
|
{
|
||||||
ui->tableWidget->clear();
|
ui->tableWidget->clear();
|
||||||
const QVector<VToolRecord> *history = doc->getHistory();
|
QVector<VToolRecord> history = doc->getLocalHistory();
|
||||||
SCASSERT(history != nullptr);
|
|
||||||
qint32 currentRow = -1;
|
qint32 currentRow = -1;
|
||||||
qint32 count = 0;
|
qint32 count = 0;
|
||||||
ui->tableWidget->setRowCount(history->size());//Make row count max possible number
|
ui->tableWidget->setRowCount(history.size());//Make row count max possible number
|
||||||
for (qint32 i = 0; i< history->size(); ++i)
|
for (qint32 i = 0; i< history.size(); ++i)
|
||||||
{
|
{
|
||||||
const VToolRecord tool = history->at(i);
|
const VToolRecord tool = history.at(i);
|
||||||
if (tool.getNameDraw() != doc->GetNameActivPP())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const QString historyRecord = Record(tool);
|
const QString historyRecord = Record(tool);
|
||||||
if (historyRecord.isEmpty() ==false)
|
if (historyRecord.isEmpty() ==false)
|
||||||
{
|
{
|
||||||
|
@ -417,7 +412,7 @@ void DialogHistory::InitialTable()
|
||||||
*/
|
*/
|
||||||
void DialogHistory::ShowPoint()
|
void DialogHistory::ShowPoint()
|
||||||
{
|
{
|
||||||
QVector<VToolRecord> *history = doc->getHistory();
|
const QVector<VToolRecord> *history = doc->getHistory();
|
||||||
if (history->size()>0)
|
if (history->size()>0)
|
||||||
{
|
{
|
||||||
QTableWidgetItem *item = ui->tableWidget->item(0, 1);
|
QTableWidgetItem *item = ui->tableWidget->item(0, 1);
|
||||||
|
|
|
@ -33,10 +33,29 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent)
|
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"));
|
setText(tr("Delete tool"));
|
||||||
nodeId = id;
|
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));
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
|
@ -57,7 +76,7 @@ DelTool::~DelTool()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DelTool::undo()
|
void DelTool::undo()
|
||||||
{
|
{
|
||||||
if (cursor <= 0)
|
if (cursor == NULL_ID)
|
||||||
{
|
{
|
||||||
parentNode.appendChild(xml);
|
parentNode.appendChild(xml);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2754,3 +2754,20 @@ QRectF VPattern::ToolBoundingRect(const QRectF &rec, const quint32 &id) const
|
||||||
}
|
}
|
||||||
return recTool;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ public:
|
||||||
QHash<quint32, VDataTool*>* getTools();
|
QHash<quint32, VDataTool*>* getTools();
|
||||||
VDataTool* getTool(const quint32 &id);
|
VDataTool* getTool(const quint32 &id);
|
||||||
QVector<VToolRecord> *getHistory();
|
QVector<VToolRecord> *getHistory();
|
||||||
|
QVector<VToolRecord> getLocalHistory();
|
||||||
quint32 getCursor() const;
|
quint32 getCursor() const;
|
||||||
void setCursor(const quint32 &value);
|
void setCursor(const quint32 &value);
|
||||||
void setCurrentData();
|
void setCurrentData();
|
||||||
|
|
|
@ -71,3 +71,7 @@ VToolRecord &VToolRecord::operator=(const VToolRecord &record)
|
||||||
VToolRecord::VToolRecord(const VToolRecord &record)
|
VToolRecord::VToolRecord(const VToolRecord &record)
|
||||||
:id(record.getId()), typeTool(record.getTypeTool()), nameDraw(record.getNameDraw())
|
:id(record.getId()), typeTool(record.getTypeTool()), nameDraw(record.getNameDraw())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VToolRecord::~VToolRecord()
|
||||||
|
{}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
void setTypeTool(const Tool &value);
|
void setTypeTool(const Tool &value);
|
||||||
QString getNameDraw() const;
|
QString getNameDraw() const;
|
||||||
void setNameDraw(const QString &value);
|
void setNameDraw(const QString &value);
|
||||||
|
~VToolRecord();
|
||||||
private:
|
private:
|
||||||
/** @brief id tool id. */
|
/** @brief id tool id. */
|
||||||
quint32 id;
|
quint32 id;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user