Path: blob/devel/ElmerGUI/Application/src/edfeditor.cpp
3203 views
/*****************************************************************************1* *2* Elmer, A Finite Element Software for Multiphysical Problems *3* *4* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *5* *6* This program is free software; you can redistribute it and/or *7* modify it under the terms of the GNU General Public License *8* as published by the Free Software Foundation; either version 2 *9* of the License, or (at your option) any later version. *10* *11* This program is distributed in the hope that it will be useful, *12* but WITHOUT ANY WARRANTY; without even the implied warranty of *13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *14* GNU General Public License for more details. *15* *16* You should have received a copy of the GNU General Public License *17* along with this program (in file fem/GPL-2); if not, write to the *18* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *19* Boston, MA 02110-1301, USA. *20* *21*****************************************************************************/2223/*****************************************************************************24* *25* ElmerGUI edfeditor *26* *27*****************************************************************************28* *29* Authors: Mikko Lyly, Juha Ruokolainen and Peter R�back *30* Email: [email protected] *31* Web: http://www.csc.fi/elmer *32* Address: CSC - IT Center for Science Ltd. *33* Keilaranta 14 *34* 02101 Espoo, Finland *35* *36* Original Date: 15 Mar 2008 *37* *38*****************************************************************************/3940#include <QtGui>41#include <iostream>42#include <QPushButton>43#include <QMainWindow>44#include <QMdiArea>45#include <QMdiSubWindow>46#include <QFileDialog>47#include <QMessageBox>4849#if WITH_QT650#define QRegExp QRegularExpression51#endif5253#include "edfeditor.h"54//#include "MainWindow.h"5556using namespace std;5758// ctor...59//----------------------------------------------------------------------------60EdfEditor::EdfEditor(QWidget *parent)61: QWidget(parent)62{63addIcon = QIcon::fromTheme("list-add");64removeIcon = QIcon::fromTheme("list-remove");65collapseIcon = QIcon::fromTheme("triangle-up");66expandIcon = QIcon::fromTheme("triangle-down");67openIcon = QIcon::fromTheme("document-open");68appendIcon = QIcon::fromTheme("tab-new"); // todo69saveAsIcon = QIcon::fromTheme("document-save");70applyIcon = QIcon::fromTheme("dialog-error-round");71previewIcon = QIcon::fromTheme("edit-find");7273lastActiveItem = NULL;74ctrlPressed = false;7576// Set up tree widget:77//--------------------78edfTree = new QTreeWidget;7980connect(edfTree, SIGNAL(itemClicked(QTreeWidgetItem*,int)),81this, SLOT(treeItemClicked(QTreeWidgetItem*,int)));8283edfTree->setColumnCount(3);84edfTree->setColumnWidth(0,200);85edfTree->setColumnWidth(1,200);86edfTree->setColumnWidth(2,200);8788edfTree->setAnimated(true);8990// Set internal drag'n drop mode on:91//----------------------------------92edfTree->setDragEnabled(true);93edfTree->setDragDropMode(QAbstractItemView::InternalMove);94edfTree->setDropIndicatorShown(true);95edfTree->setDragDropOverwriteMode(false);9697QStringList qsl;98qsl << "Tag" << "Attributes" << "Value";99edfTree->setHeaderLabels(qsl);100edfTree->setAlternatingRowColors(true);101102// Buttons:103//---------104addButton = new QPushButton(tr("&Add child"));105addButton->setIcon(addIcon);106connect(addButton, SIGNAL(clicked()), this, SLOT(addButtonClicked()));107108removeButton = new QPushButton(tr("&Remove item"));109removeButton->setIcon(removeIcon);110connect(removeButton, SIGNAL(clicked()), this, SLOT(removeButtonClicked()));111112expandCollapseAllButton = new QPushButton(tr("Collapse all"));113expandCollapseAllButton->setIcon(collapseIcon);114connect(expandCollapseAllButton, SIGNAL(clicked()),115this, SLOT(expandCollapseAllButtonClicked()));116117openButton = new QPushButton(tr("&Open"));118openButton->setIcon(openIcon);119connect(openButton, SIGNAL(clicked()), this, SLOT(openButtonClicked()));120121appendButton = new QPushButton(tr("&Append"));122appendButton->setIcon(appendIcon);123connect(appendButton, SIGNAL(clicked()), this, SLOT(appendButtonClicked()));124125previewButton = new QPushButton(tr("&Preview"));126previewButton->setIcon(previewIcon);127connect(previewButton, SIGNAL(clicked()), this, SLOT(previewButtonClicked()));128129saveAsButton = new QPushButton(tr("&Save as"));130saveAsButton->setIcon(saveAsIcon);131connect(saveAsButton, SIGNAL(clicked()), this, SLOT(saveAsButtonClicked()));132133applyButton = new QPushButton(tr("&Close"));134applyButton->setIcon(applyIcon);135connect(applyButton, SIGNAL(clicked()), this, SLOT(applyButtonClicked()));136137QHBoxLayout *buttonLayout = new QHBoxLayout;138buttonLayout->addWidget(addButton);139buttonLayout->addWidget(removeButton);140buttonLayout->addWidget(expandCollapseAllButton);141buttonLayout->addWidget(openButton);142buttonLayout->addWidget(appendButton);143buttonLayout->addWidget(previewButton);144buttonLayout->addWidget(saveAsButton);145buttonLayout->addWidget(applyButton);146147// Main layout:148//-------------149QVBoxLayout *mainLayout = new QVBoxLayout;150mainLayout->addWidget(edfTree);151mainLayout->addLayout(buttonLayout);152setLayout(mainLayout);153154setWindowTitle("Elmer Definitions File editor");155156setFocusPolicy(Qt::ClickFocus);157158expandCollapseAll = false;159160dynamicEditorSimulation = new DynamicEditor;161dynamicEditorConstants = new DynamicEditor;162dynamicEditorEquation = new DynamicEditor;163dynamicEditorSolver = new DynamicEditor;164dynamicEditorMaterial = new DynamicEditor;165dynamicEditorBodyForce = new DynamicEditor;166dynamicEditorBC = new DynamicEditor;167dynamicEditorIC = new DynamicEditor;168169setWindowIcon(QIcon(":/icons/Mesh3D.png"));170171172#ifdef __APPLE__DONTGO_HERE_TODO173defaultDir = ((MainWindow*)paernt->homePath ;174#else175defaultDir =176QCoreApplication::applicationDirPath() + "/../share/ElmerGUI";177178QString elmerGuiHome = QString(getenv("ELMERGUI_HOME"));179180if (!elmerGuiHome.isEmpty())181defaultDir = elmerGuiHome;182183defaultDir.replace('\\', '/');184#endif185186// Commented out as restoring defaultDir is not so useful187//defaultDir = ((MainWindow*) parent)->settings_value("defaultDir/edfEditor", defaultDir).toString();188189}190191192// dtor...193//----------------------------------------------------------------------------194EdfEditor::~EdfEditor()195{196197}198199// Min window size...200//----------------------------------------------------------------------------201QSize EdfEditor::minimumSizeHint() const202{203return QSize(64, 64);204}205206// Default window size...207//----------------------------------------------------------------------------208QSize EdfEditor::sizeHint() const209{210return QSize(720, 480);211}212213// preview panels214//-----------------------------------------------------------------------------215void EdfEditor::previewButtonClicked()216{217if(elmerDefs == NULL)218return;219220// always create a new instance:221QMainWindow *sandBox = new QMainWindow;222QMdiArea *mdiArea = new QMdiArea;223224sandBox->setCentralWidget(mdiArea);225sandBox->setWindowTitle(tr("Preview definitions"));226sandBox->show();227228if(dynamicEditorSimulation) delete dynamicEditorSimulation;229dynamicEditorSimulation = new DynamicEditor;230dynamicEditorSimulation->setupTabs(elmerDefs, "Simulation",1);231QMdiSubWindow *simulationSubWindow = new QMdiSubWindow;232simulationSubWindow->setWidget(dynamicEditorSimulation);233mdiArea->addSubWindow(simulationSubWindow);234simulationSubWindow->show();235236if(dynamicEditorConstants) delete dynamicEditorConstants;237dynamicEditorConstants = new DynamicEditor;238dynamicEditorConstants->setupTabs(elmerDefs, "Constants",1);239QMdiSubWindow *constantsSubWindow = new QMdiSubWindow;240constantsSubWindow->setWidget(dynamicEditorConstants);241mdiArea->addSubWindow(constantsSubWindow);242constantsSubWindow->show();243244if(dynamicEditorEquation) delete dynamicEditorEquation;245dynamicEditorEquation = new DynamicEditor;246dynamicEditorEquation->setupTabs(elmerDefs, "Equation",1);247QMdiSubWindow *equationSubWindow = new QMdiSubWindow;248equationSubWindow->setWidget(dynamicEditorEquation);249mdiArea->addSubWindow(equationSubWindow);250equationSubWindow->show();251252if(dynamicEditorSolver) delete dynamicEditorSolver;253dynamicEditorSolver = new DynamicEditor;254dynamicEditorSolver->setupTabs(elmerDefs, "Solver",1 );255QMdiSubWindow *solverSubWindow = new QMdiSubWindow;256solverSubWindow->setWidget(dynamicEditorSolver);257mdiArea->addSubWindow(solverSubWindow);258solverSubWindow->show();259260if(dynamicEditorMaterial) delete dynamicEditorMaterial;261dynamicEditorMaterial = new DynamicEditor;262dynamicEditorMaterial->setupTabs(elmerDefs, "Material",1 );263QMdiSubWindow *materialSubWindow = new QMdiSubWindow;264materialSubWindow->setWidget(dynamicEditorMaterial);265mdiArea->addSubWindow(materialSubWindow);266materialSubWindow->show();267268if(dynamicEditorBodyForce) delete dynamicEditorBodyForce;269dynamicEditorBodyForce = new DynamicEditor;270dynamicEditorBodyForce->setupTabs(elmerDefs, "BodyForce",1 );271QMdiSubWindow *bodyForceSubWindow = new QMdiSubWindow;272bodyForceSubWindow->setWidget(dynamicEditorBodyForce);273mdiArea->addSubWindow(bodyForceSubWindow);274bodyForceSubWindow->show();275276if(dynamicEditorIC) delete dynamicEditorIC;277dynamicEditorIC = new DynamicEditor;278dynamicEditorIC->setupTabs(elmerDefs, "InitialCondition",1 );279QMdiSubWindow *initialConditionSubWindow = new QMdiSubWindow;280initialConditionSubWindow->setWidget(dynamicEditorIC);281mdiArea->addSubWindow(initialConditionSubWindow);282initialConditionSubWindow->show();283284if(dynamicEditorBC) delete dynamicEditorBC;285dynamicEditorBC = new DynamicEditor;286dynamicEditorBC->setupTabs(elmerDefs, "BoundaryCondition",1 );287QMdiSubWindow *bcSubWindow = new QMdiSubWindow;288bcSubWindow->setWidget(dynamicEditorBC);289mdiArea->addSubWindow(bcSubWindow);290bcSubWindow->show();291292mdiArea->tileSubWindows();293//mdiArea->cascadeSubWindows();294295}296297298299// Add items from document to tree view...300//----------------------------------------------------------------------------301void EdfEditor::insertItemForElement(QDomElement element,302QTreeWidgetItem *parentItem)303{304if(element.isNull())305return;306307// set expanded308// if(parentItem != NULL)309// parentItem->setExpanded(true);310311// create new tree item312QTreeWidgetItem *newItem = new QTreeWidgetItem(parentItem);313314newItem->setText(0, element.tagName().trimmed());315newItem->setFlags(newItem->flags() | Qt::ItemIsEditable);316317// display attributes318QStringList list;319QDomNamedNodeMap attributeMap = element.attributes();320for(int index = 0; index < (int)attributeMap.length(); index++) {321QDomNode attribute = attributeMap.item(index);322list << attribute.nodeName() + "=\"" + attribute.nodeValue() + "\"";323}324newItem->setText(1, list.join(" "));325326// display value327if(element.firstChildElement().isNull())328newItem->setText(2, element.text().split("\n").join(" ").trimmed());329330// update hash331elementForItem.insert(newItem, element);332333// add item334edfTree->addTopLevelItem(newItem);335336if(!element.firstChildElement().isNull())337insertItemForElement(element.firstChildElement(), newItem);338339insertItemForElement(element.nextSiblingElement(), parentItem);340}341342// Construct tree view...343//----------------------------------------------------------------------------344void EdfEditor::setupEditor(QDomDocument *elmerDefs)345{346this->elmerDefs = elmerDefs;347348disconnect(edfTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)),349this, SLOT(updateElement(QTreeWidgetItem*, int)));350351// clear tree view & hash352edfTree->clear();353elementForItem.clear();354355// get root entry & recursively add items to the tree:356QDomElement root = elmerDefs->documentElement();357insertItemForElement(root, NULL);358edfTree->setCurrentItem(NULL);359360connect(edfTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)),361this, SLOT(updateElement(QTreeWidgetItem*, int)));362363edfTree->expandAll();364expandCollapseAllButton->setText("Collapse all");365expandCollapseAllButton->setIcon(collapseIcon);366expandCollapseAll = false;367368edfTree->setCurrentItem(NULL);369}370371// Tree view item has been edited: update document accordingly...372//----------------------------------------------------------------------------373void EdfEditor::updateElement(QTreeWidgetItem *item, int column)374{375// get element from hash376QDomElement element = elementForItem.value(item);377378if(element.isNull())379return;380381// set new tag382element.setTagName(item->text(0).trimmed());383384// delete old attributes385QDomNamedNodeMap oldAttributes = element.attributes();386for(int i = 0; i<(int)oldAttributes.length(); i++) {387QDomNode node = oldAttributes.item(i);388QString name = node.nodeName();389element.removeAttribute(name);390}391392// parse and set new attributes393QString pattern = "([a-zA-Z0-9]+)[ \t]*=[ \t]*[\"]([^\"]+)[\"]";394QRegExp expression(pattern);395QString qs = item->text(1).trimmed();396397#if WITH_QT6398QRegularExpressionMatch rem;399int index = qs.indexOf(expression, 0, &rem);400#else401int index = qs.indexOf(expression);402#endif403404QString parsedString = "";405if(index < 0)406parsedString = qs;407408while(index >= 0) {409#if WITH_QT6410QString currentMatch = rem.captured(0);411int length = currentMatch.length();412#else413int length = expression.matchedLength();414QString currentMatch = qs.mid(index, length);415#endif416417QStringList currentList = currentMatch.split("=");418QString name = currentList.at(0);419QString value = currentList.at(1);420421int firstPar = value.indexOf("\"", 0);422int secondPar = value.indexOf("\"", firstPar+1);423value = value.mid(firstPar+1, secondPar-firstPar-1);424425parsedString.append(name + "=\"" + value + "\" ");426427element.setAttribute(name.trimmed(), value.trimmed());428429#if WITH_QT6430index = qs.indexOf(expression, index + length, &rem);431#else432index = qs.indexOf(expression, index + length);433#endif434435}436437// update display with parsed attributes438item->setText(1, parsedString);439440// set new text (iff old element has no children)441if(element.firstChildElement().isNull()) {442443// remove old text node444QDomNodeList children = element.childNodes();445for(int i=0; i<(int)children.length(); i++) {446QDomNode node = children.at(i);447if(node.isText())448element.removeChild(node);449}450451// new text node452QDomText text = elmerDefs->createTextNode(item->text(2));453element.appendChild(text);454455} else {456457// clear value from tree view to avoid confusions:458item->setText(2, "");459}460461// no need to update hash462}463464// Add tree view item & document element...465//----------------------------------------------------------------------------466void EdfEditor::addButtonClicked()467{468QTreeWidgetItem *current = edfTree->currentItem();469470if(current == NULL)471return;472473QString newTag = "empty";474QString newAttribute = "attribute";475QString newAttributeValue = "empty";476QString newValue = "empty";477478// add item to tree view:479QTreeWidgetItem *newItem = new QTreeWidgetItem(current);480481newItem->setFlags(newItem->flags() | Qt::ItemIsEditable);482483newItem->setText(0, newTag);484newItem->setText(1, newAttribute + "=\"" + newAttributeValue + "\"");485newItem->setText(2, newValue);486current->addChild(newItem);487newItem->parent()->setExpanded(true);488489// clear the value field for current item (as it just became parent)490current->setText(2, "");491492// add to document493QDomElement newElement = elmerDefs->createElement(newTag);494newElement.setAttribute(newAttribute, newAttributeValue);495496QDomText newText = elmerDefs->createTextNode(newValue);497newElement.appendChild(newText);498499QDomElement parent = elementForItem.value(newItem->parent());500parent.appendChild(newElement);501502// update hash503elementForItem.insert(newItem, newElement);504505edfTree->setCurrentItem(newItem);506}507508// Remove item from tree view item & element from document...509//----------------------------------------------------------------------------510void EdfEditor::removeButtonClicked()511{512QTreeWidgetItem *currentItem = edfTree->currentItem();513514if(currentItem == NULL)515return;516517QTreeWidgetItem *parentItem = currentItem->parent();518QDomElement element = elementForItem.value(currentItem);519QDomElement parentElement = elementForItem.value(parentItem);520521parentItem->removeChild(currentItem);522parentElement.removeChild(element);523524// update hash525elementForItem.remove(currentItem);526527edfTree->setCurrentItem(NULL);528}529530// Save as...531//----------------------------------------------------------------------------532void EdfEditor::saveAsButtonClicked()533{534QString fileName;535536fileName = QFileDialog::getSaveFileName(this,537tr("Save definitions"), defaultDir, tr("EDF (*.xml)") );538539if(fileName.isEmpty())540return;541542const int indent = 3;543544QFile file;545file.setFileName(fileName);546file.open(QIODevice::WriteOnly);547QTextStream out(&file);548elmerDefs->save(out, indent);549550// Commented out as restoring defaultDir is not so useful551// QFileInfo info(file);552// defaultDir = info.dir().absolutePath();553}554555556// Expand/collapse tree view...557//----------------------------------------------------------------------------558void EdfEditor::expandCollapseAllButtonClicked()559{560if(expandCollapseAll) {561edfTree->expandAll();562expandCollapseAllButton->setText("Collapse all");563expandCollapseAllButton->setIcon(collapseIcon);564expandCollapseAll = false;565} else {566edfTree->collapseAll();567expandCollapseAllButton->setText("Expand all");568expandCollapseAllButton->setIcon(expandIcon);569expandCollapseAll = true;570}571}572573// Open...574//----------------------------------------------------------------------------575void EdfEditor::openButtonClicked()576{577QString fileName;578579fileName = QFileDialog::getOpenFileName(this,580tr("Open definitions"), defaultDir, tr("EDF (*.xml)") );581582if(fileName.isEmpty())583return;584585QFile file;586file.setFileName(fileName);587file.open(QIODevice::ReadOnly);588589QString errStr;590int errRow;591int errCol;592593if(!elmerDefs->setContent(&file, true, &errStr, &errRow, &errCol)) {594QMessageBox::information(window(), tr("Elmer definitions file"),595tr("Parse error at line %1, col %2:\n%3")596.arg(errRow).arg(errCol).arg(errStr));597file.close();598return;599600} else {601602if(elmerDefs->documentElement().tagName() != "edf") {603QMessageBox::information(window(), tr("Elmer definitions file"),604tr("This is not an edf file"));605delete elmerDefs;606file.close();607return;608609}610}611612setupEditor(elmerDefs);613614edfTree->setCurrentItem(NULL);615616// Commented out as restoring defaultDir is not so useful617//QFileInfo info(file);618//defaultDir = info.dir().absolutePath();619}620621// Append...622//----------------------------------------------------------------------------623void EdfEditor::appendButtonClicked()624{625QString fileName;626627fileName = QFileDialog::getOpenFileName(this,628tr("Open definitions"), defaultDir, tr("EDF (*.xml)") );629630if(fileName.isEmpty())631return;632633QFile file;634file.setFileName(fileName);635file.open(QIODevice::ReadOnly);636637QDomDocument tmpDoc;638639QString errStr;640int errRow;641int errCol;642643if(!tmpDoc.setContent(&file, true, &errStr, &errRow, &errCol)) {644QMessageBox::information(window(), tr("Elmer definitions file"),645tr("Parse error at line %1, col %2:\n%3")646.arg(errRow).arg(errCol).arg(errStr));647file.close();648return;649650} else {651652if(tmpDoc.documentElement().tagName() != "edf") {653QMessageBox::information(window(), tr("Elmer definitions file"),654tr("This is not an edf file"));655file.close();656return;657}658}659660// add new elements to the document661QDomElement root = elmerDefs->documentElement();662QDomElement tmpRoot = tmpDoc.documentElement();663664QDomElement element = tmpRoot.firstChildElement();665while(!element.isNull()) {666root.appendChild(element);667element = tmpRoot.firstChildElement();668}669670setupEditor(elmerDefs);671672edfTree->setCurrentItem(NULL);673674// Commented out as restoring defaultDir is not so useful675//QFileInfo info(file);676//defaultDir = info.dir().absolutePath();677}678679680// Close...681//----------------------------------------------------------------------------682void EdfEditor::applyButtonClicked()683{684// rebuild document from tree view:685//---------------------------------686this->close();687}688689// Change the place of two items and elements...690//----------------------------------------------------------------------------691void EdfEditor::treeItemClicked(QTreeWidgetItem *item, int column)692{693if(item == lastActiveItem)694return;695696if(lastActiveItem == NULL) {697lastActiveItem = item;698return;699}700701if(!ctrlPressed)702return;703704// items must have the same parent:705if(item->parent() != lastActiveItem->parent()) {706// cout << "Items have different parent - unable to swap" << endl;707// cout.flush();708lastActiveItem = item;709return;710}711712// get elements:713QDomElement element = elementForItem.value(item);714QDomElement lastActiveItemElement = elementForItem.value(lastActiveItem);715716// elements must have the same parent (should always be true):717if(element.parentNode() != lastActiveItemElement.parentNode()) {718// cout << "Parent element mismatch - unable to swap items" << endl;719// cout.flush();720lastActiveItem = item;721return;722}723724// clone elements:725QDomNode clone = element.cloneNode(true);726QDomNode lastActiveItemClone = lastActiveItemElement.cloneNode(true);727728// replace elements with their clones:729element.parentNode().replaceChild(lastActiveItemClone, element);730lastActiveItemElement.parentNode().replaceChild(clone, lastActiveItemElement);731732// remove old elements from the document:733element.parentNode().removeChild(element);734lastActiveItemElement.parentNode().removeChild(lastActiveItemElement);735736// make sure that old elements are cleared (they should be already):737element.clear();738lastActiveItemElement.clear();739740// rebuild tree & hash:741setupEditor(elmerDefs);742743// set focus back to the last selected item:744lastActiveItem = NULL;745for(int i = 0; i < elementForItem.count(); i++) {746if(elementForItem.values().at(i) == lastActiveItemClone) {747edfTree->setCurrentItem(elementForItem.keys().at(i));748edfTree->scrollToItem(elementForItem.keys().at(i),749QAbstractItemView::PositionAtCenter);750}751}752753return;754}755756// Key pressed...757//-----------------------------------------------------------------------------758void EdfEditor::keyPressEvent(QKeyEvent *event)759{760if(event->key() == Qt::Key_Control)761ctrlPressed = true;762763if(event->key() == Qt::Key_Alt)764altPressed = true;765}766767768// Key released...769//-----------------------------------------------------------------------------770void EdfEditor::keyReleaseEvent(QKeyEvent *event)771{772if(event->key() == Qt::Key_Control)773ctrlPressed = false;774775if(event->key() == Qt::Key_Alt)776altPressed = false;777}778779// Append from specified file path Nov 2019 by TS780//----------------------------------------------------------------------------781bool EdfEditor::appendFrom(QString path)782{783QString fileName = path;784785if(fileName.isEmpty())786return false;787788QFile file;789file.setFileName(fileName);790file.open(QIODevice::ReadOnly);791792QDomDocument tmpDoc;793794QString errStr;795int errRow;796int errCol;797798if(!tmpDoc.setContent(&file, true, &errStr, &errRow, &errCol)) {799QMessageBox::information(window(), tr("Elmer definitions file"),800tr("Parse error at line %1, col %2:\n%3")801.arg(errRow).arg(errCol).arg(errStr));802file.close();803return false;804805} else {806807if(tmpDoc.documentElement().tagName() != "edf") {808QMessageBox::information(window(), tr("Elmer definitions file"),809tr("This is not an edf file"));810file.close();811return false;812}813}814815// add new elements to the document816QDomElement root = elmerDefs->documentElement();817QDomElement tmpRoot = tmpDoc.documentElement();818819QDomElement element = tmpRoot.firstChildElement();820while(!element.isNull()) {821root.appendChild(element);822element = tmpRoot.firstChildElement();823}824825setupEditor(elmerDefs);826827edfTree->setCurrentItem(NULL);828829return true;830}831832QString EdfEditor::defaultEdfDir(){833return defaultDir;834}835836837