--HG--
branch : XML Editor
This commit is contained in:
dismine 2014-05-16 20:00:13 +03:00
parent 1489dc6a1c
commit b28bd29092
8 changed files with 128 additions and 99 deletions

View File

@ -30,7 +30,8 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VIncrement::VIncrement() VIncrement::VIncrement()
:id(0), base(0), ksize(50.0), kheight(176.0), description(QString()){} :id(0), base(0), ksize(50.0), kheight(176.0), description(QString())
{}
VIncrement::VIncrement(quint32 id, qreal base, qreal ksize, qreal kheight, QString description) VIncrement::VIncrement(quint32 id, qreal base, qreal ksize, qreal kheight, QString description)
:id(id), base(base), ksize(ksize), kheight(kheight), description(description) :id(id), base(base), ksize(ksize), kheight(kheight), description(description)

View File

@ -30,6 +30,10 @@
#include "ui_dialogaboutapp.h" #include "ui_dialogaboutapp.h"
#include "../../version.h" #include "../../version.h"
#include <QDesktopServices>
#include <QMessageBox>
//---------------------------------------------------------------------------------------------------------------------
DialogAboutApp::DialogAboutApp(QWidget *parent) : DialogAboutApp::DialogAboutApp(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::DialogAboutApp) ui(new Ui::DialogAboutApp)
@ -50,16 +54,18 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) :
} }
//---------------------------------------------------------------------------------------------------------------------
DialogAboutApp::~DialogAboutApp() DialogAboutApp::~DialogAboutApp()
{ {
delete ui; delete ui;
} }
void DialogAboutApp::webButtonClicked() { //---------------------------------------------------------------------------------------------------------------------
if ( ! QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR))) { void DialogAboutApp::webButtonClicked()
QMessageBox::warning(this, {
tr("Warning"), if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false)
tr("Cannot open your default browser")); {
QMessageBox::warning(this, tr("Warning"), tr("Cannot open your default browser"));
} }
} }

View File

@ -31,8 +31,9 @@
#include <QDialog> #include <QDialog>
namespace Ui { namespace Ui
class DialogAboutApp; {
class DialogAboutApp;
} }
class DialogAboutApp : public QDialog class DialogAboutApp : public QDialog

View File

@ -26,24 +26,24 @@
** **
*************************************************************************/ *************************************************************************/
#include "dialogpatternxmledit.h" #include "dialogpatternxmledit.h"
#include "ui_dialogpatternxmledit.h" #include "ui_dialogpatternxmledit.h"
const short int DialogPatternXmlEdit::ChangeTypeDelete=1; const short int DialogPatternXmlEdit::ChangeTypeDelete=1;
const short int DialogPatternXmlEdit::ChangeTypeAdd=2; const short int DialogPatternXmlEdit::ChangeTypeAdd=2;
const short int DialogPatternXmlEdit::ChangeTypeModify=3; const short int DialogPatternXmlEdit::ChangeTypeModify=3;
DialogPatternXmlEdit::DialogPatternXmlEdit(QWidget *parent,VPattern *xmldoc):QDialog(parent),
ui(new Ui::DialogPatternXmlEdit) //---------------------------------------------------------------------------------------------------------------------
DialogPatternXmlEdit::DialogPatternXmlEdit(QWidget *parent, VPattern *xmldoc)
:QDialog(parent), ui(new Ui::DialogPatternXmlEdit)
{ {
ui->setupUi(this); ui->setupUi(this);
xmlmodel = new VXMLTreeView(); xmlmodel = new VXMLTreeView();
currentNodeEdited=nullptr; currentNodeEdited=nullptr;
treeChange=false; treeChange=false;
this->changeStackRoot = this->changeStackLast =nullptr ; this->changeStackRoot = this->changeStackLast = nullptr;
doc=xmldoc; doc=xmldoc;
root = doc->documentElement(); root = doc->documentElement();
@ -59,37 +59,40 @@ DialogPatternXmlEdit::DialogPatternXmlEdit(QWidget *parent,VPattern *xmldoc):QDi
qint16 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);
// TODO : OOM exception. // TODO : OOM exception.
VXMLTreeElement* standard_base = new VXMLTreeElement("Valentina",VXMLTreeElement::TypeRoot,root,false); VXMLTreeElement* standard_base = new VXMLTreeElement("Valentina", VXMLTreeElement::TypeRoot, root, false);
ui->comboBox_Base_Selection->addItem(tr("All drawings"),QVariant(0)); ui->comboBox_Base_Selection->addItem(tr("All drawings"), QVariant(0));
//rootBases[0]=(QDomNode) doc->DocumentNode; //rootBases[0]=(QDomNode) doc->DocumentNode;
rootNode->appendRow(standard_base); rootNode->appendRow(standard_base);
ReadNodes(root,standard_base,xmlmodel,false); ReadNodes(root, standard_base, xmlmodel, false);
ui->treeView_main->setModel(xmlmodel); ui->treeView_main->setModel(xmlmodel);
//ui->treeView_main->expandAll(); //ui->treeView_main->expandAll();
// connectors // connectors
connect(ui->comboBox_Base_Selection,static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), connect(ui->comboBox_Base_Selection, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,&DialogPatternXmlEdit::BaseSelectionChanged); this, &DialogPatternXmlEdit::BaseSelectionChanged);
connect(ui->treeView_main,&QTreeView::clicked,this,&DialogPatternXmlEdit::ElementClicked); connect(ui->treeView_main, &QTreeView::clicked, this, &DialogPatternXmlEdit::ElementClicked);
connect(ui->lineEdit_Name,&QLineEdit::textEdited,this,&DialogPatternXmlEdit::NameTextEdited); connect(ui->lineEdit_Name, &QLineEdit::textEdited, this, &DialogPatternXmlEdit::NameTextEdited);
connect(ui->lineEdit_Value,&QLineEdit::textEdited,this,&DialogPatternXmlEdit::ValueTextEdited); connect(ui->lineEdit_Value, &QLineEdit::textEdited, this, &DialogPatternXmlEdit::ValueTextEdited);
connect(ui->pushButton_Set_Values,&QPushButton::clicked,this,&DialogPatternXmlEdit::ButtonSetClicked); connect(ui->pushButton_Set_Values, &QPushButton::clicked, this, &DialogPatternXmlEdit::ButtonSetClicked);
connect(ui->pushButton_Cancel_Values,&QPushButton::clicked,this,&DialogPatternXmlEdit::ButtonCancelClicked); connect(ui->pushButton_Cancel_Values, &QPushButton::clicked, this, &DialogPatternXmlEdit::ButtonCancelClicked);
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,&DialogPatternXmlEdit::ButtonAddAttributeClicked); connect(ui->pushButton_Add_attribute, &QPushButton::clicked, this,
connect(ui->pushButton_Apply_Changes,&QPushButton::clicked,this,&DialogPatternXmlEdit::ButtonApplyChangesClicked); &DialogPatternXmlEdit::ButtonAddAttributeClicked);
connect(ui->pushButton_Apply_Changes, &QPushButton::clicked, this,
&DialogPatternXmlEdit::ButtonApplyChangesClicked);
} }
//---------------------------------------------------------------------------------------------------------------------
DialogPatternXmlEdit::ChangesStackElement* DialogPatternXmlEdit::CreateStackElement(short int typechange) DialogPatternXmlEdit::ChangesStackElement* DialogPatternXmlEdit::CreateStackElement(short int typechange)
{ {
ChangesStackElement* tmp; ChangesStackElement* tmp;
@ -113,6 +116,7 @@ DialogPatternXmlEdit::ChangesStackElement* DialogPatternXmlEdit::CreateStackElem
return changeStackLast; return changeStackLast;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::ButtonApplyChangesClicked() void DialogPatternXmlEdit::ButtonApplyChangesClicked()
{ {
QString Changes=""; QString Changes="";
@ -155,7 +159,7 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked()
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";
} }
} }
} }
currentChange=currentChange->next; currentChange=currentChange->next;
@ -165,6 +169,7 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked()
// TODO : clear stack and apply // TODO : clear stack and apply
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::ButtonCancelClicked() void DialogPatternXmlEdit::ButtonCancelClicked()
{ {
this->ClearEditData(); this->ClearEditData();
@ -185,6 +190,7 @@ void DialogPatternXmlEdit::ButtonCancelClicked()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::RemoveChangeStackElement(ChangesStackElement* elmt) void DialogPatternXmlEdit::RemoveChangeStackElement(ChangesStackElement* elmt)
{ {
ChangesStackElement* index = this->changeStackRoot; ChangesStackElement* index = this->changeStackRoot;
@ -207,7 +213,8 @@ void DialogPatternXmlEdit::RemoveChangeStackElement(ChangesStackElement* elmt)
delete elmt; delete elmt;
return; return;
} }
while (index->next!=nullptr) { while (index->next!=nullptr)
{
if (index->next == elmt) if (index->next == elmt)
{ {
break; break;
@ -235,6 +242,7 @@ void DialogPatternXmlEdit::RemoveChangeStackElement(ChangesStackElement* elmt)
delete elmt; delete elmt;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::ButtonDeleteAttributeClicked() void DialogPatternXmlEdit::ButtonDeleteAttributeClicked()
{ {
ChangesStackElement* newstack; ChangesStackElement* newstack;
@ -262,6 +270,7 @@ void DialogPatternXmlEdit::ButtonDeleteAttributeClicked()
this->ClearEditData(); this->ClearEditData();
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::ButtonAddSonClicked() void DialogPatternXmlEdit::ButtonAddSonClicked()
{ {
ChangesStackElement* newstack; ChangesStackElement* newstack;
@ -295,12 +304,9 @@ void DialogPatternXmlEdit::ButtonAddSonClicked()
// 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).
QDomNode empty; QDomNode empty;
VXMLTreeElement* tElement = new VXMLTreeElement( VXMLTreeElement* tElement = new VXMLTreeElement(name, VXMLTreeElement::TypeNode, empty, true);
name,
VXMLTreeElement::TypeNode,
empty,true);
if (!value.isEmpty()) if (value.isEmpty() == false)
{ {
tElement->setTreeNodeValue(value); tElement->setTreeNodeValue(value);
} }
@ -323,6 +329,7 @@ void DialogPatternXmlEdit::ButtonAddSonClicked()
ui->pushButton_Apply_Changes->setEnabled(true); ui->pushButton_Apply_Changes->setEnabled(true);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::ButtonAddAttributeClicked() void DialogPatternXmlEdit::ButtonAddAttributeClicked()
{ {
ChangesStackElement* newstack; ChangesStackElement* newstack;
@ -355,10 +362,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( VXMLTreeElement* tElement = new VXMLTreeElement(name, VXMLTreeElement::TypeAttr, empty, true);
name,
VXMLTreeElement::TypeAttr,
empty,true);
tElement->setTreeNodeValue(value); tElement->setTreeNodeValue(value);
currentNodeEdited->appendRow(tElement); currentNodeEdited->appendRow(tElement);
@ -377,16 +381,20 @@ void DialogPatternXmlEdit::ButtonAddAttributeClicked()
ui->pushButton_Apply_Changes->setEnabled(true); ui->pushButton_Apply_Changes->setEnabled(true);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::ButtonSetClicked() void DialogPatternXmlEdit::ButtonSetClicked()
{ {
QString name,value; QString name, value;
ChangesStackElement* newstack; ChangesStackElement* newstack;
// TODO : check if a change has already been done // TODO : check if a change has already been done
if (this->currentNodeEdited == nullptr) return; if (this->currentNodeEdited == nullptr)
{
return;
}
name=ui->lineEdit_Name->text(); name=ui->lineEdit_Name->text();
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;
@ -418,6 +426,7 @@ void DialogPatternXmlEdit::ButtonSetClicked()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::NameTextEdited(QString newtext) void DialogPatternXmlEdit::NameTextEdited(QString newtext)
{ {
//QMessageBox::information(this, "nameTextEdited", QString("%1").arg(newtext)); //QMessageBox::information(this, "nameTextEdited", QString("%1").arg(newtext));
@ -425,6 +434,7 @@ void DialogPatternXmlEdit::NameTextEdited(QString newtext)
ui->pushButton_Cancel_Values->setEnabled(true); ui->pushButton_Cancel_Values->setEnabled(true);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::ValueTextEdited(QString newtext) void DialogPatternXmlEdit::ValueTextEdited(QString newtext)
{ {
//QMessageBox::information(this, "valueTextEdited", QString("%1").arg(newtext)); //QMessageBox::information(this, "valueTextEdited", QString("%1").arg(newtext));
@ -432,6 +442,7 @@ void DialogPatternXmlEdit::ValueTextEdited(QString newtext)
ui->pushButton_Cancel_Values->setEnabled(true); ui->pushButton_Cancel_Values->setEnabled(true);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::ClearEditData() void DialogPatternXmlEdit::ClearEditData()
{ {
ui->lineEdit_Name->setText(""); ui->lineEdit_Name->setText("");
@ -447,6 +458,7 @@ void DialogPatternXmlEdit::ClearEditData()
ui->pushButton_Cancel_Values->setEnabled(false); ui->pushButton_Cancel_Values->setEnabled(false);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::ClearStack() void DialogPatternXmlEdit::ClearStack()
{ {
ChangesStackElement * tmp; ChangesStackElement * tmp;
@ -467,6 +479,7 @@ void DialogPatternXmlEdit::ClearStack()
changeStackLast=nullptr; changeStackLast=nullptr;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::BaseSelectionChanged(int value) void DialogPatternXmlEdit::BaseSelectionChanged(int value)
{ {
QDomNode newbase; QDomNode newbase;
@ -497,7 +510,7 @@ void DialogPatternXmlEdit::BaseSelectionChanged(int value)
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();
@ -506,6 +519,7 @@ void DialogPatternXmlEdit::BaseSelectionChanged(int value)
return; return;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::ElementClicked ( const QModelIndex & index ) void DialogPatternXmlEdit::ElementClicked ( const QModelIndex & index )
{ {
@ -513,7 +527,7 @@ void DialogPatternXmlEdit::ElementClicked ( const QModelIndex & index )
VXMLTreeElement *item = (VXMLTreeElement *)index.internalPointer(); VXMLTreeElement *item = (VXMLTreeElement *)index.internalPointer();
// Get child specified by index row/column // Get child specified by index row/column
VXMLTreeElement * item2 = (VXMLTreeElement *) item->child(index.row(),index.column()); VXMLTreeElement * item2 = (VXMLTreeElement *) item->child(index.row(), index.column());
// Clear all data and disable buttons // Clear all data and disable buttons
this->ClearEditData(); this->ClearEditData();
@ -550,7 +564,7 @@ void DialogPatternXmlEdit::ElementClicked ( const QModelIndex & index )
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);
@ -563,6 +577,7 @@ void DialogPatternXmlEdit::ElementClicked ( const QModelIndex & index )
} }
} }
//---------------------------------------------------------------------------------------------------------------------
DialogPatternXmlEdit::~DialogPatternXmlEdit() DialogPatternXmlEdit::~DialogPatternXmlEdit()
{ {
//xmlmodel->clearTree(); //xmlmodel->clearTree();
@ -576,11 +591,12 @@ DialogPatternXmlEdit::~DialogPatternXmlEdit()
} }
} }
void DialogPatternXmlEdit::ReadNodes(QDomNode dNode, VXMLTreeElement* root,VXMLTreeView* xmlmodel, bool refresh) //---------------------------------------------------------------------------------------------------------------------
void DialogPatternXmlEdit::ReadNodes(QDomNode dNode, VXMLTreeElement* root, VXMLTreeView* xmlmodel, bool refresh)
{ {
QDomNode tNode,tNode2; QDomNode tNode, tNode2;
VXMLTreeElement* tElement,*tElement2; VXMLTreeElement* tElement, *tElement2;
int totalOfChilds = dNode.childNodes().size(); int totalOfChilds = dNode.childNodes().size();
if (totalOfChilds == 0) if (totalOfChilds == 0)
{ {
@ -591,7 +607,7 @@ void DialogPatternXmlEdit::ReadNodes(QDomNode dNode, VXMLTreeElement* root,VXMLT
tNode = dNode.childNodes().at(i); tNode = dNode.childNodes().at(i);
if (tNode.nodeType() != QDomNode::CommentNode) if (tNode.nodeType() != QDomNode::CommentNode)
{ {
tElement = new VXMLTreeElement(tNode.nodeName(),VXMLTreeElement::TypeNode,tNode,false); tElement = new VXMLTreeElement(tNode.nodeName(), VXMLTreeElement::TypeNode, tNode, false);
xmlmodel->appendchain(tElement); xmlmodel->appendchain(tElement);
root->appendRow(tElement); root->appendRow(tElement);
if (tNode.nodeName() == "draw") if (tNode.nodeName() == "draw")
@ -605,7 +621,7 @@ void DialogPatternXmlEdit::ReadNodes(QDomNode dNode, VXMLTreeElement* root,VXMLT
QVariant(rootBasesNum)); QVariant(rootBasesNum));
rootBases[rootBasesNum]=new VXMLTreeElement( rootBases[rootBasesNum]=new VXMLTreeElement(
QString("Drawing %1").arg(tNode.attributes().item(i).nodeValue()), QString("Drawing %1").arg(tNode.attributes().item(i).nodeValue()),
VXMLTreeElement::TypeRoot,tNode,false);; VXMLTreeElement::TypeRoot, tNode, false);
rootBasesNum++; rootBasesNum++;
//QStandardItem* rootNode = (QStandardItem*) rootBases[rootBasesNum]->invisibleRootItem(); //QStandardItem* rootNode = (QStandardItem*) rootBases[rootBasesNum]->invisibleRootItem();
//rootNode->appendRow(tElement); //rootNode->appendRow(tElement);
@ -627,7 +643,7 @@ void DialogPatternXmlEdit::ReadNodes(QDomNode dNode, VXMLTreeElement* root,VXMLT
tNode2 = tNode.childNodes().at(i); tNode2 = tNode.childNodes().at(i);
if (tNode2.nodeType() != QDomNode::CommentNode) if (tNode2.nodeType() != QDomNode::CommentNode)
{ {
tElement2 = new VXMLTreeElement(tNode2.nodeName(),VXMLTreeElement::TypeNode,tNode2,false); tElement2 = new VXMLTreeElement(tNode2.nodeName(), VXMLTreeElement::TypeNode, tNode2, false);
xmlmodel->appendchain(tElement2); xmlmodel->appendchain(tElement2);
tElement->appendRow(tElement2); tElement->appendRow(tElement2);
} }
@ -640,10 +656,8 @@ void DialogPatternXmlEdit::ReadNodes(QDomNode dNode, VXMLTreeElement* root,VXMLT
for (int i = 0; i < tNode.attributes().size(); i++) for (int i = 0; i < tNode.attributes().size(); i++)
{ {
tElement2 = new VXMLTreeElement( tElement2 = new VXMLTreeElement(tNode.attributes().item(i).nodeName(), VXMLTreeElement::TypeAttr,
tNode.attributes().item(i).nodeName(), tNode, false);
VXMLTreeElement::TypeAttr,
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);
@ -655,13 +669,15 @@ void DialogPatternXmlEdit::ReadNodes(QDomNode dNode, VXMLTreeElement* root,VXMLT
return; return;
} }
// vXMLTreeView Code ----------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VXMLTreeView::VXMLTreeView(QObject *parent) : QStandardItemModel(parent) VXMLTreeView::VXMLTreeView(QObject *parent) : QStandardItemModel(parent)
{ {
current=last=items=nullptr; current=last=items=nullptr;
} }
void VXMLTreeView::ClearTree() { //---------------------------------------------------------------------------------------------------------------------
void VXMLTreeView::ClearTree()
{
// TODO check if treeitems are deleted with the delete row command of QDom // TODO check if treeitems are deleted with the delete row command of QDom
@ -675,14 +691,13 @@ void VXMLTreeView::ClearTree() {
} }
// reset chain counters // reset chain counters
current=last=items=nullptr; current=last=items=nullptr;
} }
//---------------------------------------------------------------------------------------------------------------------
VXMLTreeView::~VXMLTreeView() VXMLTreeView::~VXMLTreeView()
{ {}
}
//---------------------------------------------------------------------------------------------------------------------
void VXMLTreeView::appendchain(VXMLTreeElement* elmt) void VXMLTreeView::appendchain(VXMLTreeElement* elmt)
{ {
if (last == nullptr) if (last == nullptr)
@ -710,43 +725,40 @@ void VXMLTreeView::appendchain(VXMLTreeElement* elmt)
last=temp; last=temp;
} }
// vXMLTreeElement code -----------------------------------------------------------------
const short int VXMLTreeElement::TypeNode=1; const short int VXMLTreeElement::TypeNode=1;
const short int VXMLTreeElement::TypeAttr=2; const short int VXMLTreeElement::TypeAttr=2;
const short int VXMLTreeElement::TypeRoot=3; const short int VXMLTreeElement::TypeRoot=3;
//---------------------------------------------------------------------------------------------------------------------
VXMLTreeElement::VXMLTreeElement(QString name, int nodetype, QDomNode source,bool editor): QStandardItem(name) VXMLTreeElement::VXMLTreeElement(QString name, int nodetype, QDomNode source, bool editor)
: QStandardItem(name)
{ {
this->elementType=nodetype; this->elementType=nodetype;
this->DocNode=source; this->DocNode=source;
this->addedNode=editor; this->addedNode=editor;
if (!editor) if (editor == false)
{ {
this->DocNode=source; this->DocNode=source;
} }
this->treeNodeName=name; this->treeNodeName=name;
this->treeNodeValue="<empty>"; // TODO : translation ? this->treeNodeValue="<empty>"; // TODO : translation ?
this->treeNodeValueSet=false, this->treeNodeValueSet=false,
this->setText(this->displayText()); this->setText(this->displayText());
switch (this->elementType) switch (this->elementType)
{ {
case VXMLTreeElement::TypeAttr: case VXMLTreeElement::TypeAttr:
this->setBackground(BACKGROUND_COLOR_ATTRIBUTE); this->setBackground(BACKGROUND_COLOR_ATTRIBUTE);
break; break;
default: default:
break; break;
} }
} }
//---------------------------------------------------------------------------------------------------------------------
VXMLTreeElement::~VXMLTreeElement() VXMLTreeElement::~VXMLTreeElement()
{ {}
}
//---------------------------------------------------------------------------------------------------------------------
void VXMLTreeElement::setTreeNodeValue(QString value) void VXMLTreeElement::setTreeNodeValue(QString value)
{ {
this->treeNodeValue=value; this->treeNodeValue=value;
@ -754,24 +766,33 @@ void VXMLTreeElement::setTreeNodeValue(QString value)
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)
{
return this->treeNodeName; return this->treeNodeName;
}
return QString("%1 : %2").arg((this->treeNodeName)).arg(this->treeNodeValue); return QString("%1 : %2").arg((this->treeNodeName)).arg(this->treeNodeValue);
} }
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)
{
return this->treeNodeValue; return this->treeNodeValue;
}
else else
return ""; {
return QString();
}
} }

View File

@ -37,7 +37,6 @@
/** /**
* @brief The vXMLTreeElement class : node/attribute of xml pattern. Used by vXMLTreeView * @brief The vXMLTreeElement class : node/attribute of xml pattern. Used by vXMLTreeView
* *
**********************************************************************************************
*/ */
#define BACKGROUND_COLOR_ATTRIBUTE QBrush(Qt::GlobalColor::cyan) #define BACKGROUND_COLOR_ATTRIBUTE QBrush(Qt::GlobalColor::cyan)
@ -51,7 +50,7 @@ public:
* @param nodetype : node type (node, attribute, root) * @param nodetype : node type (node, attribute, root)
* @param source : the source dom node * @param source : the source dom node
*/ */
explicit VXMLTreeElement (QString name, int nodetype, QDomNode source,bool editor); explicit VXMLTreeElement (QString name, int nodetype, QDomNode source, bool editor);
explicit VXMLTreeElement (QString name, int nodetype); explicit VXMLTreeElement (QString name, int nodetype);
@ -146,7 +145,8 @@ public:
/** /**
* @brief The TreeElement struct : chained list of vXMLTreeElement * @brief The TreeElement struct : chained list of vXMLTreeElement
*/ */
typedef struct TreeElementchain { typedef struct TreeElementchain
{
VXMLTreeElement* elmt; VXMLTreeElement* elmt;
TreeElementchain* next; TreeElementchain* next;
} TreeElementchain; } TreeElementchain;
@ -197,8 +197,9 @@ inline VXMLTreeView::TreeElementchain * VXMLTreeView::GetItems()
//******************************************************************************************** //********************************************************************************************
namespace Ui { namespace Ui
class DialogPatternXmlEdit; {
class DialogPatternXmlEdit;
} }
/** /**
* @brief The DialogPatternXmlEdit class : ui dialog for XML editing of pattern * @brief The DialogPatternXmlEdit class : ui dialog for XML editing of pattern
@ -223,11 +224,12 @@ public:
void ButtonDeleteAttributeClicked(); void ButtonDeleteAttributeClicked();
void ButtonAddSonClicked(); void ButtonAddSonClicked();
void ButtonAddAttributeClicked(); void ButtonAddAttributeClicked();
void ButtonApplyChangesClicked() ; void ButtonApplyChangesClicked();
// Stack of changes definition // Stack of changes definition
typedef struct ChangesStackElement { typedef struct ChangesStackElement
{
short int type; short int type;
VXMLTreeElement *element; VXMLTreeElement *element;
QString *newText; QString *newText;
@ -277,6 +279,4 @@ private:
ChangesStackElement* changeStackLast; ChangesStackElement* changeStackLast;
}; };
#endif // DIALOGPATTERNXMLEDIT_H #endif // DIALOGPATTERNXMLEDIT_H

View File

@ -503,7 +503,7 @@ void MainWindow::ClosedDialogCutArc(int result)
void MainWindow::About() void MainWindow::About()
{ {
DialogAboutApp * about_dialog = new DialogAboutApp(this); DialogAboutApp * about_dialog = new DialogAboutApp(this);
about_dialog->setAttribute(Qt::WA_DeleteOnClose,true); about_dialog->setAttribute(Qt::WA_DeleteOnClose, true);
about_dialog->show(); about_dialog->show();
} }
@ -546,8 +546,8 @@ void MainWindow::PatternProperties()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::EditPatternCode() void MainWindow::EditPatternCode()
{ {
DialogPatternXmlEdit *Pattern = new DialogPatternXmlEdit (this,doc); DialogPatternXmlEdit *Pattern = new DialogPatternXmlEdit (this, doc);
Pattern->setAttribute(Qt::WA_DeleteOnClose,true); Pattern->setAttribute(Qt::WA_DeleteOnClose, true);
Pattern->show(); Pattern->show();
} }
@ -1367,7 +1367,7 @@ void MainWindow::CreateActions()
connect(ui->actionOptions, &QAction::triggered, this, &MainWindow::Options); connect(ui->actionOptions, &QAction::triggered, this, &MainWindow::Options);
connect(ui->actionPattern_properties, &QAction::triggered, this, &MainWindow::PatternProperties); connect(ui->actionPattern_properties, &QAction::triggered, this, &MainWindow::PatternProperties);
ui->actionPattern_properties->setEnabled(false); ui->actionPattern_properties->setEnabled(false);
connect(ui->actionEdit_pattern_code,&QAction::triggered,this,&MainWindow::EditPatternCode); connect(ui->actionEdit_pattern_code, &QAction::triggered, this, &MainWindow::EditPatternCode);
//ui->actionEdit_pattern_code->setEnabled(false); //ui->actionEdit_pattern_code->setEnabled(false);
//Actions for recent files loaded by a main window application. //Actions for recent files loaded by a main window application.

View File

@ -148,7 +148,7 @@ QString VApplication::pathToTables() const
return QApplication::applicationDirPath() + QStringLiteral("/tables/individual"); return QApplication::applicationDirPath() + QStringLiteral("/tables/individual");
#else #else
QDir dir(QApplication::applicationDirPath() + QStringLiteral("/tables/individual")); QDir dir(QApplication::applicationDirPath() + QStringLiteral("/tables/individual"));
if(dir.exist()) if (dir.exist())
{ {
return dir.absolutePath(); return dir.absolutePath();
} }
@ -168,7 +168,7 @@ QString VApplication::pathToTables() const
return QApplication::applicationDirPath() + QStringLiteral("/tables/standard"); return QApplication::applicationDirPath() + QStringLiteral("/tables/standard");
#else #else
QDir dir(QApplication::applicationDirPath() + QStringLiteral("/tables/standard")); QDir dir(QApplication::applicationDirPath() + QStringLiteral("/tables/standard"));
if(dir.exist()) if (dir.exist())
{ {
return dir.absolutePath(); return dir.absolutePath();
} }
@ -191,7 +191,7 @@ QString VApplication::translationsPath() const
return QApplication::applicationDirPath() + QStringLiteral("/translations"); return QApplication::applicationDirPath() + QStringLiteral("/translations");
#else #else
QDir dir(QApplication::applicationDirPath() + QStringLiteral("/translations")); QDir dir(QApplication::applicationDirPath() + QStringLiteral("/translations"));
if(dir.exist()) if (dir.exist())
{ {
return dir.absolutePath(); return dir.absolutePath();
} }

View File

@ -80,7 +80,7 @@ namespace qmu
static qreal Avg(const qreal*, int); // mean value static qreal Avg(const qreal*, int); // mean value
static qreal Min(const qreal*, int); // minimum static qreal Min(const qreal*, int); // minimum
static qreal Max(const qreal*, int); // maximum static qreal Max(const qreal*, int); // maximum
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**