Fixed a bug with regular expression (If filename was one character, it
[emufront] / src / utils / datfileutil.cpp
1 #include "datfileutil.h"
2 #include <QtGui>
3
4 DatFileUtil::DatFileUtil(QWidget *parent) :
5     QWidget(parent)
6 {
7 }
8
9 void DatFileUtil::open()
10 {
11     QString fileName = QFileDialog::getOpenFileName(this, tr("Open Dat File"),
12         QDir::currentPath(), tr("XML Dat Files (*.xml)"));
13     if (fileName.isEmpty()) return;
14
15     QDomDocument doc("datFile");
16     QFile file(fileName);
17     if (!file.open(QIODevice::ReadOnly))
18         return;
19     if (!doc.setContent(&file)) {
20         file.close();
21         return;
22     }
23     file.close();
24
25     QDomElement docElem = doc.documentElement();
26     QDomNode n = docElem.firstChild();
27     while(!n.isNull()) {
28         QDomElement e = n.toElement(); // try to convert the node to an element.
29         if(!e.isNull()) {
30             qDebug() << qPrintable(e.tagName()) << endl; // the node really is an element.
31         }
32         n = n.nextSibling();
33     }
34 }