Added node delete
Added undo change button --HG-- branch : XML Editor
This commit is contained in:
parent
e1c3f418e5
commit
99818c3d28
|
@ -53,11 +53,9 @@ DialogPatternXmlEdit::DialogPatternXmlEdit(QWidget *parent, VPattern *xmldoc)
|
||||||
|
|
||||||
ui->treeView_main->setWindowTitle("XML");
|
ui->treeView_main->setWindowTitle("XML");
|
||||||
|
|
||||||
//TODO warning: use of old-style cast [-Wold-style-cast]
|
rootNode = xmlmodel->invisibleRootItem();
|
||||||
rootNode = (QStandardItem*) xmlmodel->invisibleRootItem();
|
|
||||||
|
|
||||||
//TODO warning: conversion to 'qint16 {aka short int}' from 'int' may alter its value [-Wconversion]
|
int drawnum=xmldoc->elementsByTagName("draw").size();
|
||||||
qint16 drawnum=xmldoc->elementsByTagName("draw").size();
|
|
||||||
rootBases = new VXMLTreeElement*[drawnum+1];
|
rootBases = new VXMLTreeElement*[drawnum+1];
|
||||||
rootBasesNum=1;
|
rootBasesNum=1;
|
||||||
rootBases[0]=new VXMLTreeElement("Valentina", VXMLTreeElement::TypeRoot, root, false);
|
rootBases[0]=new VXMLTreeElement("Valentina", VXMLTreeElement::TypeRoot, root, false);
|
||||||
|
@ -87,10 +85,133 @@ DialogPatternXmlEdit::DialogPatternXmlEdit(QWidget *parent, VPattern *xmldoc)
|
||||||
connect(ui->pushButton_Remove_attribute, &QPushButton::clicked,
|
connect(ui->pushButton_Remove_attribute, &QPushButton::clicked,
|
||||||
this, &DialogPatternXmlEdit::ButtonDeleteAttributeClicked);
|
this, &DialogPatternXmlEdit::ButtonDeleteAttributeClicked);
|
||||||
connect(ui->pushButton_Add_son, &QPushButton::clicked, this, &DialogPatternXmlEdit::ButtonAddSonClicked);
|
connect(ui->pushButton_Add_son, &QPushButton::clicked, this, &DialogPatternXmlEdit::ButtonAddSonClicked);
|
||||||
connect(ui->pushButton_Add_attribute, &QPushButton::clicked, this,
|
connect(ui->pushButton_Add_attribute, &QPushButton::clicked,
|
||||||
&DialogPatternXmlEdit::ButtonAddAttributeClicked);
|
this, &DialogPatternXmlEdit::ButtonAddAttributeClicked);
|
||||||
connect(ui->pushButton_Apply_Changes, &QPushButton::clicked, this,
|
connect(ui->pushButton_Apply_Changes, &QPushButton::clicked,
|
||||||
&DialogPatternXmlEdit::ButtonApplyChangesClicked);
|
this, &DialogPatternXmlEdit::ButtonApplyChangesClicked);
|
||||||
|
connect(ui->pushButton_Undo_Last_Change, &QPushButton::clicked, this, &DialogPatternXmlEdit::ButtonUndoLastChange);
|
||||||
|
connect(ui->pushButton_Remove_Node, &QPushButton::clicked, this, &DialogPatternXmlEdit::ButtonDeleteNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogPatternXmlEdit::ButtonDeleteNode()
|
||||||
|
{
|
||||||
|
ChangesStackElement* newstack;
|
||||||
|
|
||||||
|
// TODO : maybe assert functions here
|
||||||
|
if (this->currentNodeEdited == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this->currentNodeEdited->GetelementType() != VXMLTreeElement::TypeNode)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->currentNodeEditedStatus != 0)
|
||||||
|
{
|
||||||
|
if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeDelete)
|
||||||
|
{ // Change already done ??? ignore...
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeAdd)
|
||||||
|
{ // Attribute was previously added, just undo the change
|
||||||
|
if ( this->UndoChange(this->currentNodeEditedStack) == false )
|
||||||
|
{ // Error in undo... warn user
|
||||||
|
QMessageBox::warning(this, tr("No changes"), tr("Cannot delete previously created node"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this->ClearEditData();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeModify)
|
||||||
|
{ // Node was edited : remove change then continue to delete node
|
||||||
|
this->UndoChange(this->currentNodeEditedStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modify display
|
||||||
|
QFont textfont=currentNodeEdited->font();
|
||||||
|
textfont.setStrikeOut(true);
|
||||||
|
this->currentNodeEdited->setFont(textfont);
|
||||||
|
//
|
||||||
|
this->DeleteNodeAndSons(this->currentNodeEdited, true);
|
||||||
|
// Create change
|
||||||
|
newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeDelete);
|
||||||
|
newstack->element= this->currentNodeEdited;
|
||||||
|
// Activate changes
|
||||||
|
this->treeChange=true;
|
||||||
|
ui->pushButton_Apply_Changes->setEnabled(true);
|
||||||
|
ui->pushButton_Undo_Last_Change->setEnabled(true);
|
||||||
|
// clear dialog
|
||||||
|
this->ClearEditData();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogPatternXmlEdit::DeleteNodeAndSons(VXMLTreeElement * currentNode, bool onlydeactivate)
|
||||||
|
{
|
||||||
|
|
||||||
|
QList<VXMLTreeElement*> stack;
|
||||||
|
VXMLTreeElement * currentNodeStack;
|
||||||
|
stack << currentNode;
|
||||||
|
while (stack.isEmpty() == false)
|
||||||
|
{
|
||||||
|
//pop first element
|
||||||
|
currentNodeStack=stack.takeFirst();
|
||||||
|
if (onlydeactivate==true)
|
||||||
|
{
|
||||||
|
currentNodeStack->SetSetlectable(false);
|
||||||
|
QFont textfont=currentNodeStack->font();
|
||||||
|
textfont.setStrikeOut(true);
|
||||||
|
currentNodeStack->setFont(textfont);
|
||||||
|
}
|
||||||
|
// clear all changes made in son node and not on current or it will loop
|
||||||
|
if (currentNodeStack != currentNode)
|
||||||
|
{
|
||||||
|
ChangesStackElement * local = this->changeStackRoot;
|
||||||
|
while (local != nullptr)
|
||||||
|
{
|
||||||
|
if (local->element == currentNodeStack)
|
||||||
|
{
|
||||||
|
this->UndoChange(local);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
local=local->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add sons to stack
|
||||||
|
int index=currentNodeStack->rowCount();
|
||||||
|
while (index > 0)
|
||||||
|
{
|
||||||
|
stack << static_cast<VXMLTreeElement *> (currentNodeStack->child(index-1));
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
//stack.removeFirst();
|
||||||
|
}
|
||||||
|
currentNode->SetSetlectable(true);
|
||||||
|
|
||||||
|
if (onlydeactivate==false)
|
||||||
|
{ // Remove node from parent
|
||||||
|
// Get parent node
|
||||||
|
QStandardItem * parent= currentNode->parent();
|
||||||
|
int index=parent->rowCount();
|
||||||
|
while (index >= 0)
|
||||||
|
{
|
||||||
|
if (static_cast<VXMLTreeElement *> (parent->child(index)) == currentNode)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
if (index < 0)
|
||||||
|
{
|
||||||
|
Q_ASSERT(index==0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
parent->removeRow(index);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -113,14 +234,136 @@ DialogPatternXmlEdit::ChangesStackElement* DialogPatternXmlEdit::CreateStackElem
|
||||||
changeStackLast=changeStackLast->next;
|
changeStackLast=changeStackLast->next;
|
||||||
}
|
}
|
||||||
changeStackLast->newValue=changeStackLast->newText=nullptr;
|
changeStackLast->newValue=changeStackLast->newText=nullptr;
|
||||||
|
changeStackLast->oldValue=changeStackLast->oldText=nullptr;
|
||||||
changeStackLast->next=nullptr;
|
changeStackLast->next=nullptr;
|
||||||
return changeStackLast;
|
return changeStackLast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogPatternXmlEdit::UndoChange(DialogPatternXmlEdit::ChangesStackElement* current)
|
||||||
|
{
|
||||||
|
Q_ASSERT(current != nullptr);
|
||||||
|
|
||||||
|
VXMLTreeElement * currentNode = current->element;
|
||||||
|
|
||||||
|
if (current->type == DialogPatternXmlEdit::ChangeTypeDelete)
|
||||||
|
{
|
||||||
|
if (currentNode->GetelementType()==VXMLTreeElement::TypeAttr)
|
||||||
|
{
|
||||||
|
// Attribute previously deleted -> restore
|
||||||
|
QFont textfont=currentNode->font();
|
||||||
|
textfont.setStrikeOut(false);
|
||||||
|
currentNode->setFont(textfont);
|
||||||
|
this->RemoveChangeStackElement(current);
|
||||||
|
}
|
||||||
|
else if (currentNode->GetelementType()==VXMLTreeElement::TypeNode)
|
||||||
|
{
|
||||||
|
QList<VXMLTreeElement*> stack;
|
||||||
|
stack << currentNode;
|
||||||
|
while (stack.isEmpty() == false)
|
||||||
|
{
|
||||||
|
currentNode=stack.takeFirst();
|
||||||
|
currentNode->SetSetlectable(true);
|
||||||
|
QFont textfont=currentNode->font();
|
||||||
|
textfont.setStrikeOut(false);
|
||||||
|
currentNode->setFont(textfont);
|
||||||
|
|
||||||
|
int index=currentNode->rowCount();
|
||||||
|
while (index > 0)
|
||||||
|
{
|
||||||
|
stack << static_cast<VXMLTreeElement *> (currentNode->child(index-1));
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->RemoveChangeStackElement(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (current->type == DialogPatternXmlEdit::ChangeTypeAdd)
|
||||||
|
{
|
||||||
|
if (currentNode->GetelementType()==VXMLTreeElement::TypeAttr)
|
||||||
|
{
|
||||||
|
// Get parent node
|
||||||
|
VXMLTreeElement * parent= static_cast<VXMLTreeElement *> (currentNode->parent());
|
||||||
|
int index=parent->rowCount();
|
||||||
|
while (index >= 0)
|
||||||
|
{
|
||||||
|
if (static_cast<VXMLTreeElement *> (parent->child(index)) == currentNode)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
if (index < 0)
|
||||||
|
{
|
||||||
|
Q_ASSERT(index==0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
parent->removeRow(index);
|
||||||
|
this->RemoveChangeStackElement(current);
|
||||||
|
}
|
||||||
|
else if (currentNode->GetelementType()==VXMLTreeElement::TypeNode)
|
||||||
|
{
|
||||||
|
if (this->DeleteNodeAndSons(currentNode, false) == false)
|
||||||
|
{
|
||||||
|
// TODO : error message.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this->RemoveChangeStackElement(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (current->type == DialogPatternXmlEdit::ChangeTypeModify)
|
||||||
|
{
|
||||||
|
if (current->changedText == true)
|
||||||
|
{
|
||||||
|
currentNode->SetTreeNodeName(*current->oldText);
|
||||||
|
}
|
||||||
|
if (current->changedValue == true)
|
||||||
|
{
|
||||||
|
currentNode->SetTreeNodeValue(*current->oldValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
QFont textfont=currentNode->font();
|
||||||
|
textfont.setBold(false);
|
||||||
|
currentNode->setFont(textfont);
|
||||||
|
this->RemoveChangeStackElement(current);
|
||||||
|
}
|
||||||
|
// Check if last change was undone
|
||||||
|
if (this->changeStackLast == nullptr)
|
||||||
|
{
|
||||||
|
this->treeChange=false;
|
||||||
|
ui->pushButton_Apply_Changes->setEnabled(false);
|
||||||
|
ui->pushButton_Undo_Last_Change->setEnabled(false);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogPatternXmlEdit::ButtonUndoLastChange()
|
||||||
|
{
|
||||||
|
ChangesStackElement* current=this->changeStackLast;
|
||||||
|
|
||||||
|
if (current == nullptr)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, tr("No changes"), tr("No changes left"));
|
||||||
|
this->ui->pushButton_Undo_Last_Change->setEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this->UndoChange(current) == false)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, tr("No changes"), tr("Cannot undo change"));
|
||||||
|
}
|
||||||
|
this->ClearEditData();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPatternXmlEdit::ButtonApplyChangesClicked()
|
void DialogPatternXmlEdit::ButtonApplyChangesClicked()
|
||||||
{
|
{
|
||||||
QString Changes="";
|
QString Changes="";
|
||||||
|
QStringList stringtype;
|
||||||
|
stringtype << "node" << "attribute" << "root";
|
||||||
|
QString nodetype;
|
||||||
ChangesStackElement* currentChange;
|
ChangesStackElement* currentChange;
|
||||||
if (this->changeStackRoot==nullptr)
|
if (this->changeStackRoot==nullptr)
|
||||||
{
|
{
|
||||||
|
@ -131,20 +374,21 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked()
|
||||||
currentChange=this->changeStackRoot;
|
currentChange=this->changeStackRoot;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
nodetype=stringtype.at(currentChange->element->GetelementType()-1);
|
||||||
if (currentChange->type == DialogPatternXmlEdit::ChangeTypeAdd)
|
if (currentChange->type == DialogPatternXmlEdit::ChangeTypeAdd)
|
||||||
{
|
{
|
||||||
Changes += QString("Added type %1 : ").arg(currentChange->element->getelementType());
|
Changes += QString("Added type %1 : ").arg(nodetype);
|
||||||
Changes += currentChange->element->gettreeNodeName();
|
Changes += currentChange->element->GettreeNodeName();
|
||||||
Changes += "/";
|
Changes += "/";
|
||||||
Changes += (currentChange->element->gettreeNodeValueSet()) ?
|
Changes += (currentChange->element->GettreeNodeValueSet()) ?
|
||||||
currentChange->element->gettreeNodeValue(): QString(tr("<no value>"));
|
currentChange->element->GettreeNodeValue(): QString(tr("<no value>"));
|
||||||
Changes += "\n";
|
Changes += "\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (currentChange->type == DialogPatternXmlEdit::ChangeTypeModify)
|
if (currentChange->type == DialogPatternXmlEdit::ChangeTypeModify)
|
||||||
{
|
{
|
||||||
Changes += QString("Modified type %1 : ").arg(currentChange->element->getelementType());
|
Changes += QString("Modified type %1 : ").arg(nodetype);
|
||||||
Changes += (currentChange->changedText) ? *currentChange->newText : QString(tr("Unchanged"));
|
Changes += (currentChange->changedText) ? *currentChange->newText : QString(tr("Unchanged"));
|
||||||
Changes += "/";
|
Changes += "/";
|
||||||
Changes += (currentChange->changedValue) ? *currentChange->newValue: QString(tr("Unchanged"));
|
Changes += (currentChange->changedValue) ? *currentChange->newValue: QString(tr("Unchanged"));
|
||||||
|
@ -154,11 +398,11 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked()
|
||||||
{
|
{
|
||||||
if (currentChange->type == DialogPatternXmlEdit::ChangeTypeDelete)
|
if (currentChange->type == DialogPatternXmlEdit::ChangeTypeDelete)
|
||||||
{
|
{
|
||||||
Changes += QString("Deleted type %1 : ").arg(currentChange->element->getelementType());
|
Changes += QString("Deleted type %1 : ").arg(nodetype);
|
||||||
Changes += currentChange->element->gettreeNodeName();
|
Changes += currentChange->element->GettreeNodeName();
|
||||||
Changes += "/";
|
Changes += "/";
|
||||||
Changes += (currentChange->element->gettreeNodeValueSet()) ?
|
Changes += (currentChange->element->GettreeNodeValueSet()) ?
|
||||||
currentChange->element->gettreeNodeValue(): QString(tr("<no value>"));
|
currentChange->element->GettreeNodeValue(): QString(tr("<no value>"));
|
||||||
Changes += "\n";
|
Changes += "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,17 +420,9 @@ void DialogPatternXmlEdit::ButtonCancelClicked()
|
||||||
this->ClearEditData();
|
this->ClearEditData();
|
||||||
if (this->currentNodeEditedStatus==DialogPatternXmlEdit::ChangeTypeDelete)
|
if (this->currentNodeEditedStatus==DialogPatternXmlEdit::ChangeTypeDelete)
|
||||||
{
|
{
|
||||||
if (this->currentNodeEdited->getelementType() == VXMLTreeElement::TypeAttr)
|
if (this->UndoChange(this->currentNodeEditedStack) == false)
|
||||||
{
|
{
|
||||||
// Attribute previously deleted -> resore
|
QMessageBox::warning(this, "Error", "Cannot undo");
|
||||||
QFont textfont=currentNodeEdited->font();
|
|
||||||
textfont.setStrikeOut(false);
|
|
||||||
this->currentNodeEdited->setFont(textfont);
|
|
||||||
this->RemoveChangeStackElement(this->currentNodeEditedStack);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QMessageBox::information(this, "Not Implemented", "Not Implemented");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,6 +442,14 @@ void DialogPatternXmlEdit::RemoveChangeStackElement(ChangesStackElement* elmt)
|
||||||
{
|
{
|
||||||
delete elmt->newValue;
|
delete elmt->newValue;
|
||||||
}
|
}
|
||||||
|
if (elmt->oldText != nullptr)
|
||||||
|
{
|
||||||
|
delete elmt->oldText;
|
||||||
|
}
|
||||||
|
if (elmt->oldValue != nullptr)
|
||||||
|
{
|
||||||
|
delete elmt->oldValue;
|
||||||
|
}
|
||||||
this->changeStackRoot = elmt->next;
|
this->changeStackRoot = elmt->next;
|
||||||
if (this->changeStackLast == elmt)
|
if (this->changeStackLast == elmt)
|
||||||
{
|
{
|
||||||
|
@ -224,7 +468,7 @@ void DialogPatternXmlEdit::RemoveChangeStackElement(ChangesStackElement* elmt)
|
||||||
}
|
}
|
||||||
if (index->next == nullptr)
|
if (index->next == nullptr)
|
||||||
{
|
{
|
||||||
// TODO : debug error here
|
Q_ASSERT(index->next != nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (index->next->newText != nullptr)
|
if (index->next->newText != nullptr)
|
||||||
|
@ -235,6 +479,14 @@ void DialogPatternXmlEdit::RemoveChangeStackElement(ChangesStackElement* elmt)
|
||||||
{
|
{
|
||||||
delete index->next->newValue;
|
delete index->next->newValue;
|
||||||
}
|
}
|
||||||
|
if (index->next->oldText != nullptr)
|
||||||
|
{
|
||||||
|
delete index->next->oldText;
|
||||||
|
}
|
||||||
|
if (index->next->oldValue != nullptr)
|
||||||
|
{
|
||||||
|
delete index->next->oldValue;
|
||||||
|
}
|
||||||
index->next=index->next->next;
|
index->next=index->next->next;
|
||||||
if (this->changeStackLast == elmt)
|
if (this->changeStackLast == elmt)
|
||||||
{
|
{
|
||||||
|
@ -253,11 +505,32 @@ void DialogPatternXmlEdit::ButtonDeleteAttributeClicked()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this->currentNodeEdited->getelementType() != VXMLTreeElement::TypeAttr)
|
if (this->currentNodeEdited->GetelementType() != VXMLTreeElement::TypeAttr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->currentNodeEditedStatus != 0)
|
||||||
|
{
|
||||||
|
if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeDelete)
|
||||||
|
{ // Change already done ??? ignore...
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeAdd)
|
||||||
|
{ // Attribute was previously added, just undo the change
|
||||||
|
if ( this->UndoChange(this->currentNodeEditedStack) == false )
|
||||||
|
{ // Error in undo... warn user
|
||||||
|
QMessageBox::warning(this, tr("No changes"), tr("Cannot delete previously created attribute"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this->ClearEditData();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeModify)
|
||||||
|
{ // Node was edited : remove change then continue to delete node
|
||||||
|
this->UndoChange(this->currentNodeEditedStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeDelete);
|
newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeDelete);
|
||||||
newstack->element= this->currentNodeEdited;
|
newstack->element= this->currentNodeEdited;
|
||||||
|
|
||||||
|
@ -267,6 +540,7 @@ void DialogPatternXmlEdit::ButtonDeleteAttributeClicked()
|
||||||
// Activate changes
|
// Activate changes
|
||||||
this->treeChange=true;
|
this->treeChange=true;
|
||||||
ui->pushButton_Apply_Changes->setEnabled(true);
|
ui->pushButton_Apply_Changes->setEnabled(true);
|
||||||
|
ui->pushButton_Undo_Last_Change->setEnabled(true);
|
||||||
// clear dialog
|
// clear dialog
|
||||||
this->ClearEditData();
|
this->ClearEditData();
|
||||||
}
|
}
|
||||||
|
@ -282,7 +556,7 @@ void DialogPatternXmlEdit::ButtonAddSonClicked()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this->currentNodeEdited->getelementType() != VXMLTreeElement::TypeNode)
|
if (this->currentNodeEdited->GetelementType() != VXMLTreeElement::TypeNode)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -309,7 +583,7 @@ void DialogPatternXmlEdit::ButtonAddSonClicked()
|
||||||
|
|
||||||
if (value.isEmpty() == false)
|
if (value.isEmpty() == false)
|
||||||
{
|
{
|
||||||
tElement->setTreeNodeValue(value);
|
tElement->SetTreeNodeValue(value);
|
||||||
}
|
}
|
||||||
currentNodeEdited->appendRow(tElement);
|
currentNodeEdited->appendRow(tElement);
|
||||||
xmlmodel->appendchain(tElement);
|
xmlmodel->appendchain(tElement);
|
||||||
|
@ -328,6 +602,7 @@ void DialogPatternXmlEdit::ButtonAddSonClicked()
|
||||||
// Activate changes
|
// Activate changes
|
||||||
treeChange=true;
|
treeChange=true;
|
||||||
ui->pushButton_Apply_Changes->setEnabled(true);
|
ui->pushButton_Apply_Changes->setEnabled(true);
|
||||||
|
ui->pushButton_Undo_Last_Change->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -342,7 +617,7 @@ void DialogPatternXmlEdit::ButtonAddAttributeClicked()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this->currentNodeEdited->getelementType() != VXMLTreeElement::TypeNode)
|
if (this->currentNodeEdited->GetelementType() != VXMLTreeElement::TypeNode)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -365,7 +640,7 @@ void DialogPatternXmlEdit::ButtonAddAttributeClicked()
|
||||||
// create element tree but do not add attribute in DOM (will be done in apply).
|
// create element tree but do not add attribute in DOM (will be done in apply).
|
||||||
VXMLTreeElement* tElement = new VXMLTreeElement(name, VXMLTreeElement::TypeAttr, empty, true);
|
VXMLTreeElement* tElement = new VXMLTreeElement(name, VXMLTreeElement::TypeAttr, empty, true);
|
||||||
|
|
||||||
tElement->setTreeNodeValue(value);
|
tElement->SetTreeNodeValue(value);
|
||||||
currentNodeEdited->appendRow(tElement);
|
currentNodeEdited->appendRow(tElement);
|
||||||
xmlmodel->appendchain(tElement);
|
xmlmodel->appendchain(tElement);
|
||||||
QFont textfont=currentNodeEdited->font();
|
QFont textfont=currentNodeEdited->font();
|
||||||
|
@ -380,6 +655,7 @@ void DialogPatternXmlEdit::ButtonAddAttributeClicked()
|
||||||
// Activate changes
|
// Activate changes
|
||||||
treeChange=true;
|
treeChange=true;
|
||||||
ui->pushButton_Apply_Changes->setEnabled(true);
|
ui->pushButton_Apply_Changes->setEnabled(true);
|
||||||
|
ui->pushButton_Undo_Last_Change->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -388,7 +664,6 @@ void DialogPatternXmlEdit::ButtonSetClicked()
|
||||||
QString name, value;
|
QString name, value;
|
||||||
ChangesStackElement* newstack;
|
ChangesStackElement* newstack;
|
||||||
|
|
||||||
// TODO : check if a change has already been done
|
|
||||||
if (this->currentNodeEdited == nullptr)
|
if (this->currentNodeEdited == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -397,10 +672,42 @@ void DialogPatternXmlEdit::ButtonSetClicked()
|
||||||
value=ui->lineEdit_Value->text();
|
value=ui->lineEdit_Value->text();
|
||||||
bool nameedit, valueedit;
|
bool nameedit, valueedit;
|
||||||
|
|
||||||
nameedit = (name != currentNodeEdited->gettreeNodeName()) ? true : false;
|
nameedit = (name != currentNodeEdited->GettreeNodeName()) ? true : false;
|
||||||
valueedit= (value != currentNodeEdited->gettreeNodeValue()) ? true : false;
|
valueedit= (value != currentNodeEdited->GettreeNodeValue()) ? true : false;
|
||||||
|
|
||||||
if ( nameedit == true || valueedit == true )
|
if ( nameedit == true || valueedit == true )
|
||||||
|
{
|
||||||
|
if (this->currentNodeEditedStatus != 0)
|
||||||
|
{ // If node was created or edited previously, rewrite
|
||||||
|
if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeDelete)
|
||||||
|
{ // You shouldn't be able to edit a deleted node...
|
||||||
|
Q_ASSERT(this->currentNodeEditedStatus != DialogPatternXmlEdit::ChangeTypeDelete);
|
||||||
|
ClearEditData();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
newstack=this->currentNodeEditedStack;
|
||||||
|
if (nameedit == true)
|
||||||
|
{
|
||||||
|
newstack->changedText=true;
|
||||||
|
*newstack->newText=name;
|
||||||
|
currentNodeEdited->SetTreeNodeName(name);
|
||||||
|
}
|
||||||
|
if (valueedit == true)
|
||||||
|
{
|
||||||
|
if (newstack->changedValue==true)
|
||||||
|
{
|
||||||
|
*newstack->newValue = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newstack->changedValue=true;
|
||||||
|
newstack->newValue= new QString(value);
|
||||||
|
newstack->oldValue= new QString(this->currentNodeEdited->GettreeNodeValue());
|
||||||
|
}
|
||||||
|
currentNodeEdited->SetTreeNodeValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeModify);
|
newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeModify);
|
||||||
newstack->element= this->currentNodeEdited;
|
newstack->element= this->currentNodeEdited;
|
||||||
|
@ -409,20 +716,23 @@ void DialogPatternXmlEdit::ButtonSetClicked()
|
||||||
{
|
{
|
||||||
newstack->changedText=true;
|
newstack->changedText=true;
|
||||||
newstack->newText=new QString(name);
|
newstack->newText=new QString(name);
|
||||||
currentNodeEdited->setTreeNodeName(name);
|
newstack->oldText=new QString(this->currentNodeEdited->GettreeNodeName());
|
||||||
|
currentNodeEdited->SetTreeNodeName(name);
|
||||||
}
|
}
|
||||||
if (valueedit == true)
|
if (valueedit == true)
|
||||||
{
|
{
|
||||||
newstack->changedValue=true;
|
newstack->changedValue=true;
|
||||||
newstack->newValue= new QString(value);
|
newstack->newValue= new QString(value);
|
||||||
currentNodeEdited->setTreeNodeValue(value);
|
newstack->oldValue= new QString(this->currentNodeEdited->GettreeNodeValue());
|
||||||
|
currentNodeEdited->SetTreeNodeValue(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont textfont=currentNodeEdited->font();
|
QFont textfont=currentNodeEdited->font();
|
||||||
textfont.setBold(true);
|
textfont.setBold(true);
|
||||||
currentNodeEdited->setFont(textfont);
|
currentNodeEdited->setFont(textfont);
|
||||||
treeChange=true;
|
treeChange=true;
|
||||||
ui->pushButton_Apply_Changes->setEnabled(true);
|
ui->pushButton_Apply_Changes->setEnabled(true);
|
||||||
|
ui->pushButton_Undo_Last_Change->setEnabled(true);
|
||||||
ClearEditData();
|
ClearEditData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,6 +767,7 @@ void DialogPatternXmlEdit::ClearEditData()
|
||||||
ui->pushButton_Add_son->setEnabled(false);
|
ui->pushButton_Add_son->setEnabled(false);
|
||||||
ui->pushButton_Remove_attribute->setEnabled(false);
|
ui->pushButton_Remove_attribute->setEnabled(false);
|
||||||
ui->pushButton_Cancel_Values->setEnabled(false);
|
ui->pushButton_Cancel_Values->setEnabled(false);
|
||||||
|
ui->pushButton_Remove_Node->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -490,7 +801,7 @@ void DialogPatternXmlEdit::BaseSelectionChanged(int value)
|
||||||
if (this->treeChange == true)
|
if (this->treeChange == true)
|
||||||
{//Changes have been made : warn ?
|
{//Changes have been made : warn ?
|
||||||
}
|
}
|
||||||
ClearStack();
|
this->ClearStack();
|
||||||
ui->pushButton_Apply_Changes->setEnabled(false);
|
ui->pushButton_Apply_Changes->setEnabled(false);
|
||||||
|
|
||||||
index = ui->comboBox_Base_Selection->itemData(value).toInt(); //.convert(QVariant::Int);
|
index = ui->comboBox_Base_Selection->itemData(value).toInt(); //.convert(QVariant::Int);
|
||||||
|
@ -503,15 +814,15 @@ void DialogPatternXmlEdit::BaseSelectionChanged(int value)
|
||||||
{
|
{
|
||||||
rootNode->removeRow(0);
|
rootNode->removeRow(0);
|
||||||
}
|
}
|
||||||
xmlmodel->ClearTree();
|
this->xmlmodel->ClearTree();
|
||||||
|
|
||||||
VXMLTreeElement* standard_base = new VXMLTreeElement(
|
VXMLTreeElement* standard_base = new VXMLTreeElement(
|
||||||
rootBases[index]->gettreeNodeName(),
|
rootBases[index]->GettreeNodeName(),
|
||||||
VXMLTreeElement::TypeRoot,
|
VXMLTreeElement::TypeRoot,
|
||||||
rootBases[index]->getDocNode(),
|
rootBases[index]->GetDocNode(),
|
||||||
false);
|
false);
|
||||||
rootNode->appendRow(standard_base);
|
rootNode->appendRow(standard_base);
|
||||||
ReadNodes(rootBases[index]->getDocNode(), standard_base, xmlmodel, true);
|
ReadNodes(rootBases[index]->GetDocNode(), standard_base, xmlmodel, true);
|
||||||
|
|
||||||
ui->treeView_main->setModel(xmlmodel);
|
ui->treeView_main->setModel(xmlmodel);
|
||||||
this->ClearEditData();
|
this->ClearEditData();
|
||||||
|
@ -534,10 +845,15 @@ void DialogPatternXmlEdit::ElementClicked ( const QModelIndex & index )
|
||||||
|
|
||||||
// Clear all data and disable buttons
|
// Clear all data and disable buttons
|
||||||
this->ClearEditData();
|
this->ClearEditData();
|
||||||
|
// Check if element is selectable at this time
|
||||||
|
if (item2->IsSelectable() == false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Check status of element in change stack
|
// Check status of element in change stack
|
||||||
this->currentNodeEdited=item2;
|
this->currentNodeEdited=item2;
|
||||||
this->currentNodeEditedStatus=0;
|
this->currentNodeEditedStatus=0;
|
||||||
DialogPatternXmlEdit::ChangesStackElement * local = this->changeStackRoot;
|
ChangesStackElement * local = this->changeStackRoot;
|
||||||
while (local != nullptr)
|
while (local != nullptr)
|
||||||
{
|
{
|
||||||
if (local->element == item2)
|
if (local->element == item2)
|
||||||
|
@ -554,26 +870,27 @@ void DialogPatternXmlEdit::ElementClicked ( const QModelIndex & index )
|
||||||
local=local->next;
|
local=local->next;
|
||||||
}
|
}
|
||||||
// Fill the dialog and Activate the line edit
|
// Fill the dialog and Activate the line edit
|
||||||
if (item2->getelementType() != VXMLTreeElement::TypeRoot)
|
if (item2->GetelementType() != VXMLTreeElement::TypeRoot)
|
||||||
{
|
{
|
||||||
ui->lineEdit_Name->setText(currentNodeEdited->gettreeNodeName());
|
ui->lineEdit_Name->setText(currentNodeEdited->GettreeNodeName());
|
||||||
ui->lineEdit_Name->setEnabled(true);
|
ui->lineEdit_Name->setEnabled(true);
|
||||||
// Fill value
|
// Fill value
|
||||||
ui->lineEdit_Value->setText(currentNodeEdited->gettreeNodeValue());
|
ui->lineEdit_Value->setText(currentNodeEdited->GettreeNodeValue());
|
||||||
ui->lineEdit_Value->setEnabled(true);
|
ui->lineEdit_Value->setEnabled(true);
|
||||||
}
|
}
|
||||||
if (item2->getelementType() == VXMLTreeElement::TypeRoot)
|
if (item2->GetelementType() == VXMLTreeElement::TypeRoot)
|
||||||
{
|
{
|
||||||
ui->label_type_value->setText(tr("Root node"));;
|
ui->label_type_value->setText(tr("Root node"));;
|
||||||
ui->pushButton_Add_son->setEnabled(true);
|
ui->pushButton_Add_son->setEnabled(true);
|
||||||
}
|
}
|
||||||
else if (item2->getelementType() == VXMLTreeElement::TypeNode)
|
else if (item2->GetelementType() == VXMLTreeElement::TypeNode)
|
||||||
{
|
{
|
||||||
ui->label_type_value->setText(tr("Node"));
|
ui->label_type_value->setText(tr("Node"));
|
||||||
ui->pushButton_Add_attribute->setEnabled(true);
|
ui->pushButton_Add_attribute->setEnabled(true);
|
||||||
ui->pushButton_Add_son->setEnabled(true);
|
ui->pushButton_Add_son->setEnabled(true);
|
||||||
|
ui->pushButton_Remove_Node->setEnabled(true);
|
||||||
}
|
}
|
||||||
else if (item2->getelementType() == VXMLTreeElement::TypeAttr)
|
else if (item2->GetelementType() == VXMLTreeElement::TypeAttr)
|
||||||
{
|
{
|
||||||
ui->label_type_value->setText(tr("Attribute"));
|
ui->label_type_value->setText(tr("Attribute"));
|
||||||
ui->pushButton_Remove_attribute->setEnabled(true);
|
ui->pushButton_Remove_attribute->setEnabled(true);
|
||||||
|
@ -583,15 +900,9 @@ void DialogPatternXmlEdit::ElementClicked ( const QModelIndex & index )
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogPatternXmlEdit::~DialogPatternXmlEdit()
|
DialogPatternXmlEdit::~DialogPatternXmlEdit()
|
||||||
{
|
{
|
||||||
//xmlmodel->clearTree();
|
this->ClearStack();
|
||||||
|
this->xmlmodel->ClearTree();
|
||||||
delete ui;
|
delete ui;
|
||||||
ChangesStackElement * tmp;
|
|
||||||
while (changeStackRoot != nullptr)
|
|
||||||
{
|
|
||||||
tmp=changeStackRoot->next;
|
|
||||||
delete changeStackRoot;
|
|
||||||
changeStackRoot=tmp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -637,8 +948,8 @@ void DialogPatternXmlEdit::ReadNodes(QDomNode dNode, VXMLTreeElement* root, VXML
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
tElement=xmlmodel->getCurrent()->elmt;
|
tElement=xmlmodel->getCurrent()->elmt;
|
||||||
tNode=tElement->getDocNode();
|
tNode=tElement->GetDocNode();
|
||||||
if (tElement->getelementType() == VXMLTreeElement::TypeNode)
|
if (tElement->GetelementType() == VXMLTreeElement::TypeNode)
|
||||||
{
|
{
|
||||||
totalOfChilds = tNode.childNodes().size();
|
totalOfChilds = tNode.childNodes().size();
|
||||||
for (int i=0;i<totalOfChilds;i++)
|
for (int i=0;i<totalOfChilds;i++)
|
||||||
|
@ -654,14 +965,14 @@ void DialogPatternXmlEdit::ReadNodes(QDomNode dNode, VXMLTreeElement* root, VXML
|
||||||
|
|
||||||
if (tNode.nodeType() == QDomNode::TextNode)
|
if (tNode.nodeType() == QDomNode::TextNode)
|
||||||
{
|
{
|
||||||
tElement->setTreeNodeValue(tNode.nodeValue());
|
tElement->SetTreeNodeValue(tNode.nodeValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < tNode.attributes().size(); i++)
|
for (int i = 0; i < tNode.attributes().size(); i++)
|
||||||
{
|
{
|
||||||
tElement2 = new VXMLTreeElement(tNode.attributes().item(i).nodeName(), VXMLTreeElement::TypeAttr,
|
tElement2 = new VXMLTreeElement(tNode.attributes().item(i).nodeName(), VXMLTreeElement::TypeAttr,
|
||||||
tNode, false);
|
tNode, false);
|
||||||
tElement2->setTreeNodeValue(tNode.attributes().item(i).nodeValue());
|
tElement2->SetTreeNodeValue(tNode.attributes().item(i).nodeValue());
|
||||||
tElement->appendRow(tElement2);
|
tElement->appendRow(tElement2);
|
||||||
xmlmodel->appendchain(tElement2);
|
xmlmodel->appendchain(tElement2);
|
||||||
}
|
}
|
||||||
|
@ -737,13 +1048,13 @@ const short int VXMLTreeElement::TypeRoot=3;
|
||||||
// ^
|
// ^
|
||||||
VXMLTreeElement::VXMLTreeElement(QString name, int nodetype, QDomNode source, bool editor)
|
VXMLTreeElement::VXMLTreeElement(QString name, int nodetype, QDomNode source, bool editor)
|
||||||
: QStandardItem(name), DocNode(source), addedNode(editor), elementType(nodetype), treeNodeValue("<empty>"),
|
: QStandardItem(name), DocNode(source), addedNode(editor), elementType(nodetype), treeNodeValue("<empty>"),
|
||||||
treeNodeValueSet(false), treeNodeName(name)
|
treeNodeValueSet(false), treeNodeName(name), selectable(true)
|
||||||
{
|
{
|
||||||
if (editor == false)
|
if (editor == false)
|
||||||
{
|
{
|
||||||
this->DocNode=source;
|
this->DocNode=source;
|
||||||
}
|
}
|
||||||
this->setText(this->displayText());
|
this->setText(this->DisplayText());
|
||||||
switch (this->elementType)
|
switch (this->elementType)
|
||||||
{
|
{
|
||||||
case VXMLTreeElement::TypeAttr:
|
case VXMLTreeElement::TypeAttr:
|
||||||
|
@ -759,22 +1070,22 @@ VXMLTreeElement::~VXMLTreeElement()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VXMLTreeElement::setTreeNodeValue(QString value)
|
void VXMLTreeElement::SetTreeNodeValue(QString value)
|
||||||
{
|
{
|
||||||
this->treeNodeValue=value;
|
this->treeNodeValue=value;
|
||||||
this->treeNodeValueSet=true;
|
this->treeNodeValueSet=true;
|
||||||
this->setText(this->displayText());
|
this->setText(this->DisplayText());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VXMLTreeElement::setTreeNodeName(QString value)
|
void VXMLTreeElement::SetTreeNodeName(QString value)
|
||||||
{
|
{
|
||||||
this->treeNodeName=value;
|
this->treeNodeName=value;
|
||||||
this->setText(this->displayText());
|
this->setText(this->DisplayText());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VXMLTreeElement::displayText()
|
QString VXMLTreeElement::DisplayText()
|
||||||
{
|
{
|
||||||
if (this->elementType == VXMLTreeElement::TypeRoot)
|
if (this->elementType == VXMLTreeElement::TypeRoot)
|
||||||
{
|
{
|
||||||
|
@ -784,7 +1095,7 @@ QString VXMLTreeElement::displayText()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VXMLTreeElement::gettreeNodeValue()
|
QString VXMLTreeElement::GettreeNodeValue()
|
||||||
{
|
{
|
||||||
// Only return value if it's really set.
|
// Only return value if it's really set.
|
||||||
if (this->treeNodeValueSet)
|
if (this->treeNodeValueSet)
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BACKGROUND_COLOR_ATTRIBUTE QBrush(Qt::GlobalColor::cyan)
|
#define BACKGROUND_COLOR_ATTRIBUTE QBrush(Qt::GlobalColor::cyan)
|
||||||
|
#define BACKGROUND_COLOR_INACTIVE_NODE QBrush(Qt::GlobalColor::gray)
|
||||||
class VXMLTreeElement : public QStandardItem
|
class VXMLTreeElement : public QStandardItem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -62,26 +63,28 @@ public:
|
||||||
* @brief setNodeValue : set value of node (content or attribute)
|
* @brief setNodeValue : set value of node (content or attribute)
|
||||||
* @param value : the value
|
* @param value : the value
|
||||||
*/
|
*/
|
||||||
void setTreeNodeValue(QString value);
|
void SetTreeNodeValue(QString value);
|
||||||
/**
|
/**
|
||||||
* @brief displayText : text to display
|
* @brief displayText : text to display
|
||||||
* @return text to display
|
* @return text to display
|
||||||
*/
|
*/
|
||||||
QString displayText();
|
QString DisplayText();
|
||||||
/**
|
/**
|
||||||
* @brief getDocNode
|
* @brief getDocNode
|
||||||
* @return current document node
|
* @return current document node
|
||||||
*/
|
*/
|
||||||
QDomNode getDocNode();
|
QDomNode GetDocNode();
|
||||||
QString gettreeNodeName();
|
QString GettreeNodeName();
|
||||||
QString gettreeNodeValue();
|
QString GettreeNodeValue();
|
||||||
bool gettreeNodeValueSet();
|
bool GettreeNodeValueSet();
|
||||||
void setTreeNodeName(QString value);
|
void SetTreeNodeName(QString value);
|
||||||
/**
|
/**
|
||||||
* @brief getelementType
|
* @brief getelementType
|
||||||
* @return elementType value
|
* @return elementType value
|
||||||
*/
|
*/
|
||||||
short int getelementType();
|
short int GetelementType();
|
||||||
|
bool IsSelectable();
|
||||||
|
void SetSetlectable(bool value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
@ -109,25 +112,39 @@ private:
|
||||||
* @brief nodeValue : Attribute or node value
|
* @brief nodeValue : Attribute or node value
|
||||||
*/
|
*/
|
||||||
QString treeNodeName;
|
QString treeNodeName;
|
||||||
|
/**
|
||||||
|
* @brief selectable : can item be selected to be changed (ex : false if father deleted).
|
||||||
|
*/
|
||||||
|
bool selectable;
|
||||||
Q_DISABLE_COPY(VXMLTreeElement)
|
Q_DISABLE_COPY(VXMLTreeElement)
|
||||||
};
|
};
|
||||||
|
|
||||||
inline short int VXMLTreeElement::getelementType()
|
inline bool VXMLTreeElement::IsSelectable()
|
||||||
|
{
|
||||||
|
return this->selectable;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void VXMLTreeElement::SetSetlectable(bool value)
|
||||||
|
{
|
||||||
|
this->selectable=value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline short int VXMLTreeElement::GetelementType()
|
||||||
{
|
{
|
||||||
return this->elementType;
|
return this->elementType;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QDomNode VXMLTreeElement::getDocNode()
|
inline QDomNode VXMLTreeElement::GetDocNode()
|
||||||
{
|
{
|
||||||
return this->DocNode;
|
return this->DocNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString VXMLTreeElement::gettreeNodeName()
|
inline QString VXMLTreeElement::GettreeNodeName()
|
||||||
{
|
{
|
||||||
return this->treeNodeName;
|
return this->treeNodeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VXMLTreeElement::gettreeNodeValueSet()
|
inline bool VXMLTreeElement::GettreeNodeValueSet()
|
||||||
{
|
{
|
||||||
return this->treeNodeValueSet;
|
return this->treeNodeValueSet;
|
||||||
}
|
}
|
||||||
|
@ -224,7 +241,8 @@ public:
|
||||||
void ButtonAddSonClicked();
|
void ButtonAddSonClicked();
|
||||||
void ButtonAddAttributeClicked();
|
void ButtonAddAttributeClicked();
|
||||||
void ButtonApplyChangesClicked();
|
void ButtonApplyChangesClicked();
|
||||||
|
void ButtonUndoLastChange();
|
||||||
|
void ButtonDeleteNode();
|
||||||
|
|
||||||
// Stack of changes definition
|
// Stack of changes definition
|
||||||
typedef struct ChangesStackElement
|
typedef struct ChangesStackElement
|
||||||
|
@ -232,8 +250,10 @@ public:
|
||||||
short int type;
|
short int type;
|
||||||
VXMLTreeElement *element;
|
VXMLTreeElement *element;
|
||||||
QString *newText;
|
QString *newText;
|
||||||
|
QString *oldText;
|
||||||
bool changedText;
|
bool changedText;
|
||||||
QString *newValue;
|
QString *newValue;
|
||||||
|
QString *oldValue;
|
||||||
bool changedValue;
|
bool changedValue;
|
||||||
ChangesStackElement* next;
|
ChangesStackElement* next;
|
||||||
} ChangesStackElement;
|
} ChangesStackElement;
|
||||||
|
@ -246,6 +266,19 @@ public:
|
||||||
VXMLTreeElement* currentNodeEdited;
|
VXMLTreeElement* currentNodeEdited;
|
||||||
short int currentNodeEditedStatus;
|
short int currentNodeEditedStatus;
|
||||||
ChangesStackElement* currentNodeEditedStack;
|
ChangesStackElement* currentNodeEditedStack;
|
||||||
|
/**
|
||||||
|
* @brief UndoChange : undo change in change stack element
|
||||||
|
* @param current : change to undo
|
||||||
|
* @return true if undo has been done, false on error
|
||||||
|
*/
|
||||||
|
bool UndoChange(ChangesStackElement* current);
|
||||||
|
/**
|
||||||
|
* @brief DeleteNodeAndSons : delete node and all it's attribute and sons below
|
||||||
|
* @param currentNode : node to delete
|
||||||
|
* @param onlydeactivate : if true, dont delete just deactivate sons and attributes
|
||||||
|
* @return false if changes couldn't be done
|
||||||
|
*/
|
||||||
|
bool DeleteNodeAndSons(VXMLTreeElement *currentNode, bool onlydeactivate);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void BaseSelectionChanged(int value);
|
void BaseSelectionChanged(int value);
|
||||||
|
|
|
@ -200,7 +200,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QPushButton" name="pushButton_Remove_attribute_2">
|
<widget class="QPushButton" name="pushButton_Remove_Node">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -272,12 +272,12 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QPushButton" name="pushButton_Cancel_Changes">
|
<widget class="QPushButton" name="pushButton_Undo_Last_Change">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Cancel changes</string>
|
<string>Undo last</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user