diff --git a/sources/templateeditor.cpp b/sources/templateeditor.cpp
index e6a42a9a2..02b7b058f 100644
--- a/sources/templateeditor.cpp
+++ b/sources/templateeditor.cpp
@@ -46,7 +46,11 @@ bool TemplateEditor::edit(QETProject *project, const QString &template_name) {
xml_doc.appendChild(xml_doc.importNode(xml_tb_template, true));
template_name_edit_ -> setText(template_name);
template_name_edit_ -> setReadOnly(true);
- template_xml_edit_ -> setPlainText(xml_doc.toString(4));
+
+ QString xml_str = xml_doc.toString(4);
+ xml_str.replace(QRegExp("^]*>"), "");
+ xml_str.replace(QRegExp(""), "");
+ template_xml_edit_ -> setPlainText(" " + xml_str.trimmed());
// stores the parent project and template name, in order to write/save the template later
template_name_ = template_name;
@@ -91,7 +95,7 @@ void TemplateEditor::save() {
}
QDomDocument xml_doc;
- bool parsing = xml_doc.setContent(template_xml_edit_ -> toPlainText());
+ bool parsing = xml_doc.setContent(getXmlString());
if (!parsing) {
QMessageBox::critical(
this,
@@ -122,6 +126,9 @@ void TemplateEditor::quit() {
void TemplateEditor::build() {
parent_project_label_ = new QLabel();
updateProjectLabel();
+ static_xml_1_ = new QLabel("");
+ static_xml_3_ = new QLabel("");
template_name_edit_ = new QLineEdit();
template_xml_edit_ = new QTextEdit();
template_xml_edit_ -> setAcceptRichText(false);
@@ -141,10 +148,16 @@ void TemplateEditor::build() {
h_layout0 -> addWidget(save_button_);
h_layout0 -> addWidget(quit_button_);
+ QHBoxLayout *h_layout1 = new QHBoxLayout();
+ h_layout1 -> addWidget(static_xml_1_);
+ h_layout1 -> addWidget(template_name_edit_);
+ h_layout1 -> addWidget(static_xml_2_);
+
QVBoxLayout *v_layout0 = new QVBoxLayout();
v_layout0 -> addWidget(parent_project_label_);
- v_layout0 -> addWidget(template_name_edit_);
+ v_layout0 -> addLayout(h_layout1);
v_layout0 -> addWidget(template_xml_edit_);
+ v_layout0 -> addWidget(static_xml_3_);
v_layout0 -> addLayout(h_layout0);
setLayout(v_layout0);
@@ -168,3 +181,12 @@ void TemplateEditor::updateProjectLabel() {
QString(tr("Projet parent : %1")).arg(parent_project_title)
);
}
+
+/**
+ @return the XML description provided by the user, as a string.
+*/
+QString TemplateEditor::getXmlString() const {
+ QString xml_str = QString("%2");
+ xml_str = xml_str.arg(Qt::escape(template_name_edit_ -> text())).arg(template_xml_edit_ -> toPlainText());
+ return(xml_str);
+}
diff --git a/sources/templateeditor.h b/sources/templateeditor.h
index 10c755317..1781666f2 100644
--- a/sources/templateeditor.h
+++ b/sources/templateeditor.h
@@ -45,10 +45,14 @@ class TemplateEditor : public QWidget {
private:
void build();
void updateProjectLabel();
+ QString getXmlString() const;
// attributes
private:
QLabel *parent_project_label_;
+ QLabel *static_xml_1_;
+ QLabel *static_xml_2_;
+ QLabel *static_xml_3_;
QLineEdit *template_name_edit_;
QTextEdit *template_xml_edit_;
QPushButton *validate_button_;