2014-05-16 14:51:39 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file dialogpatternxmledit.cpp
|
|
|
|
** @author Patrick Proy <patrick(at)proy.org>
|
|
|
|
** @date 14 5, 2014
|
|
|
|
**
|
|
|
|
** @brief Code file for the XML editor dialog
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2013 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** 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.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** 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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "dialogpatternxmledit.h"
|
|
|
|
#include "ui_dialogpatternxmledit.h"
|
|
|
|
|
|
|
|
|
|
|
|
const short int DialogPatternXmlEdit::ChangeTypeDelete=1;
|
|
|
|
const short int DialogPatternXmlEdit::ChangeTypeAdd=2;
|
|
|
|
const short int DialogPatternXmlEdit::ChangeTypeModify=3;
|
|
|
|
|
2014-05-16 17:13:45 +02:00
|
|
|
DialogPatternXmlEdit::DialogPatternXmlEdit(QWidget *parent,VPattern *xmldoc):QDialog(parent),
|
|
|
|
ui(new Ui::DialogPatternXmlEdit)
|
2014-05-16 14:51:39 +02:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
xmlmodel = new VXMLTreeView();
|
2014-05-16 17:13:45 +02:00
|
|
|
currentNodeEdited=nullptr;
|
2014-05-16 14:51:39 +02:00
|
|
|
treeChange=false;
|
2014-05-16 17:13:45 +02:00
|
|
|
this->changeStackRoot = this->changeStackLast =nullptr ;
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
doc=xmldoc;
|
|
|
|
root = doc->documentElement();
|
|
|
|
// disable edit trigers :
|
|
|
|
//ui->treeView_main->editTriggers(QTreeView::NoEditTriggers);
|
|
|
|
ui->treeView_main->setEditTriggers(QTreeView::NoEditTriggers);
|
|
|
|
|
|
|
|
ui->treeView_main->setWindowTitle("XML");
|
|
|
|
|
|
|
|
|
|
|
|
rootNode = (QStandardItem*) xmlmodel->invisibleRootItem();
|
|
|
|
|
|
|
|
qint16 drawnum=xmldoc->elementsByTagName("draw").size();
|
2014-05-16 16:49:58 +02:00
|
|
|
rootBases = new VXMLTreeElement*[drawnum+1];
|
2014-05-16 14:51:39 +02:00
|
|
|
rootBasesNum=1;
|
2014-05-16 16:49:58 +02:00
|
|
|
rootBases[0]=new VXMLTreeElement("Valentina",VXMLTreeElement::TypeRoot,root,false);
|
2014-05-16 14:51:39 +02:00
|
|
|
// TODO : OOM exception.
|
|
|
|
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement* standard_base = new VXMLTreeElement("Valentina",VXMLTreeElement::TypeRoot,root,false);
|
2014-05-16 14:51:39 +02:00
|
|
|
ui->comboBox_Base_Selection->addItem(tr("All drawings"),QVariant(0));
|
|
|
|
|
|
|
|
//rootBases[0]=(QDomNode) doc->DocumentNode;
|
|
|
|
rootNode->appendRow(standard_base);
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
ReadNodes(root,standard_base,xmlmodel,false);
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
ui->treeView_main->setModel(xmlmodel);
|
|
|
|
|
|
|
|
//ui->treeView_main->expandAll();
|
|
|
|
|
|
|
|
// connectors
|
2014-05-16 17:13:45 +02:00
|
|
|
connect(ui->comboBox_Base_Selection,static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
this,&DialogPatternXmlEdit::BaseSelectionChanged);
|
2014-05-16 16:49:58 +02:00
|
|
|
connect(ui->treeView_main,&QTreeView::clicked,this,&DialogPatternXmlEdit::ElementClicked);
|
|
|
|
connect(ui->lineEdit_Name,&QLineEdit::textEdited,this,&DialogPatternXmlEdit::NameTextEdited);
|
|
|
|
connect(ui->lineEdit_Value,&QLineEdit::textEdited,this,&DialogPatternXmlEdit::ValueTextEdited);
|
|
|
|
connect(ui->pushButton_Set_Values,&QPushButton::clicked,this,&DialogPatternXmlEdit::ButtonSetClicked);
|
|
|
|
connect(ui->pushButton_Cancel_Values,&QPushButton::clicked,this,&DialogPatternXmlEdit::ButtonCancelClicked);
|
2014-05-16 17:13:45 +02:00
|
|
|
connect(ui->pushButton_Remove_attribute,&QPushButton::clicked,
|
|
|
|
this,&DialogPatternXmlEdit::ButtonDeleteAttributeClicked);
|
2014-05-16 16:49:58 +02:00
|
|
|
connect(ui->pushButton_Add_son,&QPushButton::clicked,this,&DialogPatternXmlEdit::ButtonAddSonClicked);
|
|
|
|
connect(ui->pushButton_Add_attribute,&QPushButton::clicked,this,&DialogPatternXmlEdit::ButtonAddAttributeClicked);
|
|
|
|
connect(ui->pushButton_Apply_Changes,&QPushButton::clicked,this,&DialogPatternXmlEdit::ButtonApplyChangesClicked);
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
DialogPatternXmlEdit::ChangesStackElement* DialogPatternXmlEdit::CreateStackElement(short int typechange)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
ChangesStackElement* tmp;
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
tmp= new ChangesStackElement;
|
2014-05-16 14:51:39 +02:00
|
|
|
//if (tmp==0) TODO
|
|
|
|
tmp->type=typechange;
|
|
|
|
tmp->changedText=tmp->changedValue=false;
|
|
|
|
|
2014-05-16 17:13:45 +02:00
|
|
|
if (changeStackLast==nullptr )
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
changeStackLast=changeStackRoot=tmp;
|
2014-05-16 16:49:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
changeStackLast->next=tmp;
|
|
|
|
changeStackLast=changeStackLast->next;
|
|
|
|
}
|
2014-05-16 17:13:45 +02:00
|
|
|
changeStackLast->newValue=changeStackLast->newText=nullptr;
|
|
|
|
changeStackLast->next=nullptr;
|
2014-05-16 14:51:39 +02:00
|
|
|
return changeStackLast;
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::ButtonApplyChangesClicked()
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
QString Changes="";
|
|
|
|
ChangesStackElement* currentChange;
|
2014-05-16 17:13:45 +02:00
|
|
|
if (this->changeStackRoot==nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
|
|
|
Changes="No Changes";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
currentChange=this->changeStackRoot;
|
2014-05-16 16:49:58 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (currentChange->type == DialogPatternXmlEdit::ChangeTypeAdd)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
Changes += QString("Added type %1 : ").arg(currentChange->element->getelementType());
|
|
|
|
Changes += currentChange->element->gettreeNodeName();
|
|
|
|
Changes += "/";
|
|
|
|
Changes += (currentChange->element->gettreeNodeValueSet()) ?
|
|
|
|
currentChange->element->gettreeNodeValue(): QString(tr("<no value>"));
|
|
|
|
Changes += "\n";
|
2014-05-16 16:49:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (currentChange->type == DialogPatternXmlEdit::ChangeTypeModify)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
Changes += QString("Modified type %1 : ").arg(currentChange->element->getelementType());
|
|
|
|
Changes += (currentChange->changedText) ? *currentChange->newText : QString(tr("Unchanged"));
|
|
|
|
Changes += "/";
|
|
|
|
Changes += (currentChange->changedValue) ? *currentChange->newValue: QString(tr("Unchanged"));
|
|
|
|
Changes += "\n";
|
2014-05-16 16:49:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (currentChange->type == DialogPatternXmlEdit::ChangeTypeDelete)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
Changes += QString("Deleted type %1 : ").arg(currentChange->element->getelementType());
|
|
|
|
Changes += currentChange->element->gettreeNodeName();
|
|
|
|
Changes += "/";
|
|
|
|
Changes += (currentChange->element->gettreeNodeValueSet()) ?
|
|
|
|
currentChange->element->gettreeNodeValue(): QString(tr("<no value>"));
|
|
|
|
Changes += "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
currentChange=currentChange->next;
|
2014-05-16 17:13:45 +02:00
|
|
|
} while (currentChange != nullptr);
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
|
|
|
QMessageBox::information(this, "Changes (not REALLY applied for now)", Changes);
|
|
|
|
// TODO : clear stack and apply
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::ButtonCancelClicked()
|
|
|
|
{
|
|
|
|
this->ClearEditData();
|
|
|
|
if (this->currentNodeEditedStatus==DialogPatternXmlEdit::ChangeTypeDelete)
|
|
|
|
{
|
|
|
|
if (this->currentNodeEdited->getelementType() == VXMLTreeElement::TypeAttr)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
// Attribute previously deleted -> resore
|
2014-05-16 16:49:58 +02:00
|
|
|
QFont textfont=currentNodeEdited->font();
|
2014-05-16 14:51:39 +02:00
|
|
|
textfont.setStrikeOut(false);
|
2014-05-16 16:49:58 +02:00
|
|
|
this->currentNodeEdited->setFont(textfont);
|
|
|
|
this->RemoveChangeStackElement(this->currentNodeEditedStack);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
QMessageBox::information(this, "Not Implemented", "Not Implemented");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::RemoveChangeStackElement(ChangesStackElement* elmt)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
ChangesStackElement* index = this->changeStackRoot;
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
if (changeStackRoot == elmt)
|
|
|
|
{
|
2014-05-16 17:13:45 +02:00
|
|
|
if (elmt->newText != nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
|
|
|
delete elmt->newText;
|
|
|
|
}
|
2014-05-16 17:13:45 +02:00
|
|
|
if (elmt->newValue != nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
|
|
|
delete elmt->newValue;
|
|
|
|
}
|
2014-05-16 14:51:39 +02:00
|
|
|
this->changeStackRoot = elmt->next;
|
2014-05-16 16:49:58 +02:00
|
|
|
if (this->changeStackLast == elmt)
|
|
|
|
{
|
|
|
|
this->changeStackLast= elmt->next;
|
|
|
|
}
|
|
|
|
delete elmt;
|
2014-05-16 14:51:39 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-05-16 17:13:45 +02:00
|
|
|
while (index->next!=nullptr) {
|
2014-05-16 16:49:58 +02:00
|
|
|
if (index->next == elmt)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
index=index->next;
|
|
|
|
}
|
2014-05-16 17:13:45 +02:00
|
|
|
if (index->next == nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
// TODO : debug error here
|
|
|
|
return;
|
|
|
|
}
|
2014-05-16 17:13:45 +02:00
|
|
|
if (index->next->newText != nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
|
|
|
delete index->next->newText;
|
|
|
|
}
|
2014-05-16 17:13:45 +02:00
|
|
|
if (index->next->newValue != nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
|
|
|
delete index->next->newValue;
|
|
|
|
}
|
2014-05-16 14:51:39 +02:00
|
|
|
index->next=index->next->next;
|
2014-05-16 16:49:58 +02:00
|
|
|
if (this->changeStackLast == elmt)
|
|
|
|
{
|
|
|
|
this->changeStackLast= index;
|
|
|
|
}
|
|
|
|
delete elmt;
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::ButtonDeleteAttributeClicked()
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
ChangesStackElement* newstack;
|
|
|
|
|
|
|
|
// TODO : maybe assert functions here
|
2014-05-16 17:13:45 +02:00
|
|
|
if (this->currentNodeEdited == nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this->currentNodeEdited->getelementType() != VXMLTreeElement::TypeAttr)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeDelete);
|
2014-05-16 16:49:58 +02:00
|
|
|
newstack->element= this->currentNodeEdited;
|
2014-05-16 14:51:39 +02:00
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
QFont textfont=currentNodeEdited->font();
|
2014-05-16 14:51:39 +02:00
|
|
|
textfont.setStrikeOut(true);
|
2014-05-16 16:49:58 +02:00
|
|
|
this->currentNodeEdited->setFont(textfont);
|
2014-05-16 14:51:39 +02:00
|
|
|
// Activate changes
|
|
|
|
this->treeChange=true;
|
|
|
|
ui->pushButton_Apply_Changes->setEnabled(true);
|
|
|
|
// clear dialog
|
2014-05-16 16:49:58 +02:00
|
|
|
this->ClearEditData();
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::ButtonAddSonClicked()
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
ChangesStackElement* newstack;
|
2014-05-16 16:49:58 +02:00
|
|
|
bool ok;
|
2014-05-16 14:51:39 +02:00
|
|
|
//clear_edit_data();
|
|
|
|
// TODO : maybe assert functions here
|
2014-05-16 17:13:45 +02:00
|
|
|
if (this->currentNodeEdited == nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this->currentNodeEdited->getelementType() != VXMLTreeElement::TypeNode)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
QString name = QInputDialog::getText(this, tr("Node Name"),
|
|
|
|
tr("Name:"), QLineEdit::Normal,
|
|
|
|
"", &ok);
|
2014-05-16 16:49:58 +02:00
|
|
|
if (ok==false)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-05-16 14:51:39 +02:00
|
|
|
QString value = QInputDialog::getText(this, tr("Node Value (may be empty)"),
|
|
|
|
tr("Value:"), QLineEdit::Normal,
|
|
|
|
"", &ok);
|
2014-05-16 16:49:58 +02:00
|
|
|
if (ok==false)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
// create element tree but do not add attribute in DOM (will be done in apply).
|
|
|
|
QDomNode empty;
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement* tElement = new VXMLTreeElement(
|
2014-05-16 14:51:39 +02:00
|
|
|
name,
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement::TypeNode,
|
2014-05-16 14:51:39 +02:00
|
|
|
empty,true);
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
if (!value.isEmpty())
|
|
|
|
{
|
|
|
|
tElement->setTreeNodeValue(value);
|
|
|
|
}
|
|
|
|
currentNodeEdited->appendRow(tElement);
|
2014-05-16 14:51:39 +02:00
|
|
|
xmlmodel->appendchain(tElement);
|
2014-05-16 16:49:58 +02:00
|
|
|
QFont textfont=currentNodeEdited->font();
|
2014-05-16 14:51:39 +02:00
|
|
|
textfont.setBold(true);
|
|
|
|
tElement->setFont(textfont);
|
|
|
|
|
|
|
|
// Add to change stack
|
|
|
|
newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeAdd);
|
|
|
|
newstack->element=tElement;
|
|
|
|
newstack->newText=new QString(name); newstack->changedText=true;
|
2014-05-16 16:49:58 +02:00
|
|
|
if (value.isEmpty())
|
|
|
|
{
|
|
|
|
newstack->changedValue=true;newstack->newValue=new QString(value);
|
|
|
|
}
|
2014-05-16 14:51:39 +02:00
|
|
|
// Activate changes
|
|
|
|
treeChange=true;
|
|
|
|
ui->pushButton_Apply_Changes->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::ButtonAddAttributeClicked()
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
ChangesStackElement* newstack;
|
|
|
|
bool ok;
|
|
|
|
QDomNode empty; // empty QNode to pas to create function : maybe a better way to do this ?
|
|
|
|
|
|
|
|
// TODO : maybe assert functions here
|
2014-05-16 17:13:45 +02:00
|
|
|
if (this->currentNodeEdited == nullptr)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this->currentNodeEdited->getelementType() != VXMLTreeElement::TypeNode)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
QString name = QInputDialog::getText(this, tr("Attribute Name"),
|
|
|
|
tr("Name:"), QLineEdit::Normal,
|
|
|
|
"", &ok);
|
2014-05-16 16:49:58 +02:00
|
|
|
if (ok==false)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-05-16 14:51:39 +02:00
|
|
|
QString value = QInputDialog::getText(this, tr("Attribute Value"),
|
|
|
|
tr("Value:"), QLineEdit::Normal,
|
|
|
|
"", &ok);
|
2014-05-16 16:49:58 +02:00
|
|
|
if (ok==false)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
// create element tree but do not add attribute in DOM (will be done in apply).
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement* tElement = new VXMLTreeElement(
|
2014-05-16 14:51:39 +02:00
|
|
|
name,
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement::TypeAttr,
|
2014-05-16 14:51:39 +02:00
|
|
|
empty,true);
|
|
|
|
|
|
|
|
tElement->setTreeNodeValue(value);
|
2014-05-16 16:49:58 +02:00
|
|
|
currentNodeEdited->appendRow(tElement);
|
2014-05-16 14:51:39 +02:00
|
|
|
xmlmodel->appendchain(tElement);
|
2014-05-16 16:49:58 +02:00
|
|
|
QFont textfont=currentNodeEdited->font();
|
2014-05-16 14:51:39 +02:00
|
|
|
textfont.setBold(true);
|
|
|
|
tElement->setFont(textfont);
|
|
|
|
// Add to change stack
|
|
|
|
newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeAdd);
|
|
|
|
newstack->element= tElement;
|
2014-05-16 16:49:58 +02:00
|
|
|
newstack->type=VXMLTreeElement::TypeAttr;
|
2014-05-16 14:51:39 +02:00
|
|
|
newstack->newText=new QString(name);
|
|
|
|
newstack->newValue=new QString(value);
|
|
|
|
// Activate changes
|
|
|
|
treeChange=true;
|
|
|
|
ui->pushButton_Apply_Changes->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::ButtonSetClicked()
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
QString name,value;
|
|
|
|
ChangesStackElement* newstack;
|
|
|
|
|
|
|
|
// TODO : check if a change has already been done
|
2014-05-16 17:13:45 +02:00
|
|
|
if (this->currentNodeEdited == nullptr) return;
|
2014-05-16 14:51:39 +02:00
|
|
|
name=ui->lineEdit_Name->text();
|
|
|
|
value=ui->lineEdit_Value->text();
|
|
|
|
bool nameedit,valueedit;
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
nameedit = (name != currentNodeEdited->gettreeNodeName()) ? true : false;
|
|
|
|
valueedit= (value != currentNodeEdited->gettreeNodeValue()) ? true : false;
|
2014-05-16 14:51:39 +02:00
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
if ( nameedit == true || valueedit == true )
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeModify);
|
2014-05-16 16:49:58 +02:00
|
|
|
newstack->element= this->currentNodeEdited;
|
2014-05-16 14:51:39 +02:00
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
if (nameedit == true)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
newstack->changedText=true;
|
|
|
|
newstack->newText=new QString(name);
|
2014-05-16 16:49:58 +02:00
|
|
|
currentNodeEdited->setTreeNodeName(name);
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
2014-05-16 16:49:58 +02:00
|
|
|
if (valueedit == true)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
newstack->changedValue=true;
|
|
|
|
newstack->newValue= new QString(value);
|
2014-05-16 16:49:58 +02:00
|
|
|
currentNodeEdited->setTreeNodeValue(value);
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
QFont textfont=currentNodeEdited->font();
|
2014-05-16 14:51:39 +02:00
|
|
|
textfont.setBold(true);
|
2014-05-16 16:49:58 +02:00
|
|
|
currentNodeEdited->setFont(textfont);
|
2014-05-16 14:51:39 +02:00
|
|
|
treeChange=true;
|
|
|
|
ui->pushButton_Apply_Changes->setEnabled(true);
|
2014-05-16 16:49:58 +02:00
|
|
|
ClearEditData();
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::NameTextEdited(QString newtext)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
//QMessageBox::information(this, "nameTextEdited", QString("%1").arg(newtext));
|
|
|
|
ui->pushButton_Set_Values->setEnabled(true);
|
|
|
|
ui->pushButton_Cancel_Values->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::ValueTextEdited(QString newtext)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
//QMessageBox::information(this, "valueTextEdited", QString("%1").arg(newtext));
|
|
|
|
ui->pushButton_Set_Values->setEnabled(true);
|
|
|
|
ui->pushButton_Cancel_Values->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::ClearEditData()
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
ui->lineEdit_Name->setText("");
|
|
|
|
ui->lineEdit_Value->setText("");
|
|
|
|
ui->lineEdit_Name->setEnabled(false);
|
|
|
|
ui->lineEdit_Value->setEnabled(false);
|
|
|
|
|
|
|
|
ui->label_type_value->setText(tr("No selection"));
|
|
|
|
ui->pushButton_Set_Values->setEnabled(false);
|
|
|
|
ui->pushButton_Add_attribute->setEnabled(false);
|
|
|
|
ui->pushButton_Add_son->setEnabled(false);
|
|
|
|
ui->pushButton_Remove_attribute->setEnabled(false);
|
|
|
|
ui->pushButton_Cancel_Values->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::ClearStack()
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
ChangesStackElement * tmp;
|
2014-05-16 17:13:45 +02:00
|
|
|
while (changeStackRoot != nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
2014-05-16 17:13:45 +02:00
|
|
|
if (changeStackRoot->newText != nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
|
|
|
delete changeStackRoot->newText;
|
|
|
|
}
|
2014-05-16 17:13:45 +02:00
|
|
|
if (changeStackRoot->newValue != nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
|
|
|
delete changeStackRoot->newValue;
|
|
|
|
}
|
2014-05-16 14:51:39 +02:00
|
|
|
tmp=changeStackRoot;
|
|
|
|
changeStackRoot=changeStackRoot->next;
|
2014-05-16 16:49:58 +02:00
|
|
|
delete tmp;
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
2014-05-16 17:13:45 +02:00
|
|
|
changeStackLast=nullptr;
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::BaseSelectionChanged(int value)
|
2014-05-16 14:51:39 +02:00
|
|
|
{
|
|
|
|
QDomNode newbase;
|
|
|
|
|
|
|
|
int index;
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
if (this->treeChange == true)
|
|
|
|
{//Changes have been made : warn ?
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
2014-05-16 16:49:58 +02:00
|
|
|
ClearStack();
|
2014-05-16 14:51:39 +02:00
|
|
|
ui->pushButton_Apply_Changes->setEnabled(false);
|
|
|
|
|
|
|
|
index = ui->comboBox_Base_Selection->itemData(value).toInt(); //.convert(QVariant::Int);
|
|
|
|
Q_ASSERT(value < rootBasesNum);
|
|
|
|
// QMessageBox::information(this, "test", QString("%1:%2").arg(value).arg(index));
|
|
|
|
|
|
|
|
// Clear all tree info and nodes
|
|
|
|
// TODO : Check
|
2014-05-16 16:49:58 +02:00
|
|
|
while (rootNode->rowCount() > 0)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
rootNode->removeRow(0);
|
|
|
|
}
|
2014-05-16 16:49:58 +02:00
|
|
|
xmlmodel->ClearTree();
|
2014-05-16 14:51:39 +02:00
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement* standard_base = new VXMLTreeElement(
|
2014-05-16 14:51:39 +02:00
|
|
|
rootBases[index]->gettreeNodeName(),
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement::TypeRoot,
|
2014-05-16 14:51:39 +02:00
|
|
|
rootBases[index]->getDocNode(),
|
|
|
|
false);
|
|
|
|
rootNode->appendRow(standard_base);
|
2014-05-16 16:49:58 +02:00
|
|
|
ReadNodes(rootBases[index]->getDocNode(),standard_base,xmlmodel,true);
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
ui->treeView_main->setModel(xmlmodel);
|
2014-05-16 16:49:58 +02:00
|
|
|
this->ClearEditData();
|
2014-05-16 14:51:39 +02:00
|
|
|
// TODO : warn if changes ?
|
2014-05-16 16:49:58 +02:00
|
|
|
this->ClearStack();
|
2014-05-16 14:51:39 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::ElementClicked ( const QModelIndex & index )
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
// Get item (function returns parent of clicked item)
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement *item = (VXMLTreeElement *)index.internalPointer();
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
// Get child specified by index row/column
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement * item2 = (VXMLTreeElement *) item->child(index.row(),index.column());
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
// Clear all data and disable buttons
|
2014-05-16 16:49:58 +02:00
|
|
|
this->ClearEditData();
|
2014-05-16 14:51:39 +02:00
|
|
|
// Check status of element in change stack
|
2014-05-16 16:49:58 +02:00
|
|
|
this->currentNodeEdited=item2;
|
|
|
|
this->currentNodeEditedStatus=0;
|
2014-05-16 14:51:39 +02:00
|
|
|
DialogPatternXmlEdit::ChangesStackElement * local = this->changeStackRoot;
|
2014-05-16 17:13:45 +02:00
|
|
|
while (local != nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
|
|
|
if (local->element == item2)
|
|
|
|
{
|
|
|
|
this->currentNodeEditedStatus=local->type;
|
|
|
|
this->currentNodeEditedStack=local;
|
|
|
|
if (local->type == DialogPatternXmlEdit::ChangeTypeDelete)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
// Node is deleted, only enable cancel button
|
|
|
|
ui->pushButton_Cancel_Values->setEnabled(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
local=local->next;
|
|
|
|
}
|
|
|
|
// Fill the dialog and Activate the line edit
|
2014-05-16 16:49:58 +02:00
|
|
|
if (item2->getelementType() != VXMLTreeElement::TypeRoot)
|
|
|
|
{
|
|
|
|
ui->lineEdit_Name->setText(currentNodeEdited->gettreeNodeName());
|
2014-05-16 14:51:39 +02:00
|
|
|
ui->lineEdit_Name->setEnabled(true);
|
|
|
|
// Fill value
|
2014-05-16 16:49:58 +02:00
|
|
|
ui->lineEdit_Value->setText(currentNodeEdited->gettreeNodeValue());
|
2014-05-16 14:51:39 +02:00
|
|
|
ui->lineEdit_Value->setEnabled(true);
|
|
|
|
}
|
2014-05-16 16:49:58 +02:00
|
|
|
if (item2->getelementType() == VXMLTreeElement::TypeRoot)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
ui->label_type_value->setText(tr("Root node"));;
|
|
|
|
ui->pushButton_Add_son->setEnabled(true);
|
2014-05-16 16:49:58 +02:00
|
|
|
}
|
|
|
|
else if (item2->getelementType() == VXMLTreeElement::TypeNode)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
ui->label_type_value->setText(tr("Node"));
|
|
|
|
ui->pushButton_Add_attribute->setEnabled(true);
|
|
|
|
ui->pushButton_Add_son->setEnabled(true);
|
2014-05-16 16:49:58 +02:00
|
|
|
}
|
|
|
|
else if (item2->getelementType() == VXMLTreeElement::TypeAttr)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
ui->label_type_value->setText(tr("Attribute"));
|
|
|
|
ui->pushButton_Remove_attribute->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogPatternXmlEdit::~DialogPatternXmlEdit()
|
|
|
|
{
|
|
|
|
//xmlmodel->clearTree();
|
|
|
|
delete ui;
|
2014-05-16 16:49:58 +02:00
|
|
|
ChangesStackElement * tmp;
|
2014-05-16 17:13:45 +02:00
|
|
|
while (changeStackRoot != nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
tmp=changeStackRoot->next;
|
2014-05-16 16:49:58 +02:00
|
|
|
delete changeStackRoot;
|
2014-05-16 14:51:39 +02:00
|
|
|
changeStackRoot=tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void DialogPatternXmlEdit::ReadNodes(QDomNode dNode, VXMLTreeElement* root,VXMLTreeView* xmlmodel, bool refresh)
|
2014-05-16 14:51:39 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
QDomNode tNode,tNode2;
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement* tElement,*tElement2;
|
2014-05-16 14:51:39 +02:00
|
|
|
int totalOfChilds = dNode.childNodes().size();
|
2014-05-16 16:49:58 +02:00
|
|
|
if (totalOfChilds == 0)
|
|
|
|
{
|
|
|
|
return; // empty xml
|
|
|
|
}
|
|
|
|
for (int i=0;i<totalOfChilds;i++)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
tNode = dNode.childNodes().at(i);
|
2014-05-16 16:49:58 +02:00
|
|
|
if (tNode.nodeType() != QDomNode::CommentNode)
|
|
|
|
{
|
|
|
|
tElement = new VXMLTreeElement(tNode.nodeName(),VXMLTreeElement::TypeNode,tNode,false);
|
2014-05-16 14:51:39 +02:00
|
|
|
xmlmodel->appendchain(tElement);
|
|
|
|
root->appendRow(tElement);
|
2014-05-16 16:49:58 +02:00
|
|
|
if (tNode.nodeName() == "draw")
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
for (int i = 0; i < tNode.attributes().size(); i++)
|
|
|
|
{
|
|
|
|
if ((tNode.attributes().item(i).nodeName() == "name")
|
2014-05-16 16:49:58 +02:00
|
|
|
&& (refresh == false))
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
ui->comboBox_Base_Selection->addItem(tNode.attributes().item(i).nodeValue(),
|
|
|
|
QVariant(rootBasesNum));
|
2014-05-16 16:49:58 +02:00
|
|
|
rootBases[rootBasesNum]=new VXMLTreeElement(
|
2014-05-16 14:51:39 +02:00
|
|
|
QString("Drawing %1").arg(tNode.attributes().item(i).nodeValue()),
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement::TypeRoot,tNode,false);;
|
2014-05-16 14:51:39 +02:00
|
|
|
rootBasesNum++;
|
|
|
|
//QStandardItem* rootNode = (QStandardItem*) rootBases[rootBasesNum]->invisibleRootItem();
|
|
|
|
//rootNode->appendRow(tElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
tElement=xmlmodel->getCurrent()->elmt;
|
|
|
|
tNode=tElement->getDocNode();
|
2014-05-16 16:49:58 +02:00
|
|
|
if (tElement->getelementType() == VXMLTreeElement::TypeNode)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
totalOfChilds = tNode.childNodes().size();
|
2014-05-16 16:49:58 +02:00
|
|
|
for (int i=0;i<totalOfChilds;i++)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
tNode2 = tNode.childNodes().at(i);
|
2014-05-16 16:49:58 +02:00
|
|
|
if (tNode2.nodeType() != QDomNode::CommentNode)
|
|
|
|
{
|
|
|
|
tElement2 = new VXMLTreeElement(tNode2.nodeName(),VXMLTreeElement::TypeNode,tNode2,false);
|
2014-05-16 14:51:39 +02:00
|
|
|
xmlmodel->appendchain(tElement2);
|
|
|
|
tElement->appendRow(tElement2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
if (tNode.nodeType() == QDomNode::TextNode)
|
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
tElement->setTreeNodeValue(tNode.nodeValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < tNode.attributes().size(); i++)
|
|
|
|
{
|
2014-05-16 16:49:58 +02:00
|
|
|
tElement2 = new VXMLTreeElement(
|
2014-05-16 14:51:39 +02:00
|
|
|
tNode.attributes().item(i).nodeName(),
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement::TypeAttr,
|
2014-05-16 14:51:39 +02:00
|
|
|
tNode,false);
|
|
|
|
tElement2->setTreeNodeValue(tNode.attributes().item(i).nodeValue());
|
|
|
|
tElement->appendRow(tElement2);
|
|
|
|
xmlmodel->appendchain(tElement2);
|
|
|
|
}
|
|
|
|
}
|
2014-05-16 16:49:58 +02:00
|
|
|
xmlmodel->SetCurrent(xmlmodel->getCurrent()->next);
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
|
|
|
while (xmlmodel->getCurrent() != 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// vXMLTreeView Code -----------------------------------------------------------------
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeView::VXMLTreeView(QObject *parent) : QStandardItemModel(parent)
|
2014-05-16 14:51:39 +02:00
|
|
|
{
|
2014-05-16 17:13:45 +02:00
|
|
|
current=last=items=nullptr;
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void VXMLTreeView::ClearTree() {
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
// TODO check if treeitems are deleted with the delete row command of QDom
|
|
|
|
|
|
|
|
//clear the chain link
|
|
|
|
TreeElementchain * tmp;
|
2014-05-16 17:13:45 +02:00
|
|
|
while (items != nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
2014-05-16 14:51:39 +02:00
|
|
|
tmp=items;
|
|
|
|
items=items->next;
|
2014-05-16 16:49:58 +02:00
|
|
|
delete tmp;
|
2014-05-16 14:51:39 +02:00
|
|
|
}
|
|
|
|
// reset chain counters
|
2014-05-16 17:13:45 +02:00
|
|
|
current=last=items=nullptr;
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeView::~VXMLTreeView()
|
2014-05-16 14:51:39 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void VXMLTreeView::appendchain(VXMLTreeElement* elmt)
|
2014-05-16 14:51:39 +02:00
|
|
|
{
|
2014-05-16 17:13:45 +02:00
|
|
|
if (last == nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{ // first element
|
|
|
|
current = new TreeElementchain;
|
2014-05-16 17:13:45 +02:00
|
|
|
if (current == nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
2014-05-16 17:13:45 +02:00
|
|
|
Q_ASSERT(current != nullptr);
|
2014-05-16 14:51:39 +02:00
|
|
|
// TODO : throw exception
|
|
|
|
}
|
|
|
|
current->elmt=elmt;
|
2014-05-16 17:13:45 +02:00
|
|
|
current->next=nullptr;
|
2014-05-16 14:51:39 +02:00
|
|
|
last=items=current;
|
|
|
|
return;
|
|
|
|
}
|
2014-05-16 16:49:58 +02:00
|
|
|
TreeElementchain* temp= new TreeElementchain;
|
2014-05-16 17:13:45 +02:00
|
|
|
if (temp == nullptr)
|
2014-05-16 16:49:58 +02:00
|
|
|
{
|
2014-05-16 17:13:45 +02:00
|
|
|
Q_ASSERT(temp != nullptr);
|
2014-05-16 14:51:39 +02:00
|
|
|
// TODO : throw exception
|
|
|
|
}
|
|
|
|
temp->elmt=elmt;
|
2014-05-16 17:13:45 +02:00
|
|
|
temp->next=nullptr;
|
2014-05-16 14:51:39 +02:00
|
|
|
last->next=temp;
|
|
|
|
last=temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// vXMLTreeElement code -----------------------------------------------------------------
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
const short int VXMLTreeElement::TypeNode=1;
|
|
|
|
const short int VXMLTreeElement::TypeAttr=2;
|
|
|
|
const short int VXMLTreeElement::TypeRoot=3;
|
2014-05-16 14:51:39 +02:00
|
|
|
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement::VXMLTreeElement(QString name, int nodetype, QDomNode source,bool editor): QStandardItem(name)
|
2014-05-16 14:51:39 +02:00
|
|
|
{
|
|
|
|
this->elementType=nodetype;
|
|
|
|
this->DocNode=source;
|
|
|
|
this->addedNode=editor;
|
2014-05-16 16:49:58 +02:00
|
|
|
if (!editor)
|
|
|
|
{
|
|
|
|
this->DocNode=source;
|
|
|
|
}
|
2014-05-16 14:51:39 +02:00
|
|
|
this->treeNodeName=name;
|
|
|
|
this->treeNodeValue="<empty>"; // TODO : translation ?
|
|
|
|
this->treeNodeValueSet=false,
|
|
|
|
this->setText(this->displayText());
|
2014-05-16 16:49:58 +02:00
|
|
|
switch (this->elementType)
|
|
|
|
{
|
|
|
|
case VXMLTreeElement::TypeAttr:
|
2014-05-16 14:51:39 +02:00
|
|
|
this->setBackground(BACKGROUND_COLOR_ATTRIBUTE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
VXMLTreeElement::~VXMLTreeElement()
|
2014-05-16 14:51:39 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2014-05-16 16:49:58 +02:00
|
|
|
|
|
|
|
void VXMLTreeElement::setTreeNodeValue(QString value)
|
2014-05-16 14:51:39 +02:00
|
|
|
{
|
|
|
|
this->treeNodeValue=value;
|
|
|
|
this->treeNodeValueSet=true;
|
|
|
|
this->setText(this->displayText());
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
void VXMLTreeElement::setTreeNodeName(QString value)
|
2014-05-16 14:51:39 +02:00
|
|
|
{
|
|
|
|
this->treeNodeName=value;
|
|
|
|
this->setText(this->displayText());
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
QString VXMLTreeElement::displayText()
|
2014-05-16 14:51:39 +02:00
|
|
|
{
|
2014-05-16 16:49:58 +02:00
|
|
|
if (this->elementType == VXMLTreeElement::TypeRoot)
|
2014-05-16 14:51:39 +02:00
|
|
|
return this->treeNodeName;
|
|
|
|
return QString("%1 : %2").arg((this->treeNodeName)).arg(this->treeNodeValue);
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:49:58 +02:00
|
|
|
QString VXMLTreeElement::gettreeNodeValue() {
|
2014-05-16 14:51:39 +02:00
|
|
|
// Only return value if it's really set.
|
|
|
|
if (this->treeNodeValueSet)
|
|
|
|
return this->treeNodeValue;
|
|
|
|
else
|
|
|
|
return "";
|
|
|
|
}
|
2014-05-16 16:49:58 +02:00
|
|
|
|