author | John Kern <johnk@symbian.org> |
Wed, 24 Mar 2010 14:05:38 -0700 | |
changeset 3 | e6d1a78b6db9 |
parent 1 | 8e9c5760ce6f |
permissions | -rwxr-xr-x |
0
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
1 |
#include <QFile> |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
2 |
#include <QFileInfo> |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
3 |
#include <QMessageBox> |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
4 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
5 |
#include "Document.h" |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
6 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
7 |
Document::Document(QWidget *parent, QString filename) : QTreeView (parent) |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
8 |
{ |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
9 |
setAttribute(Qt::WA_DeleteOnClose); |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
10 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
11 |
QFile file(filename); |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
12 |
QFileInfo fi(file); |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
13 |
this->setWindowTitle(fi.baseName()); |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
14 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
15 |
if (!file.open(QIODevice::ReadOnly)) { |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
16 |
QMessageBox::warning(this, tr("Build Log Viewer"), tr("Cannot open log.")); |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
17 |
return ; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
18 |
} |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
19 |
QDomDocument *log = new QDomDocument("Build Log"); |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
20 |
if (!log->setContent(&file)) { |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
21 |
QMessageBox::warning(this, tr("Build Log Viewer"), tr("Cannot set content.")); |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
22 |
delete log; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
23 |
file.close(); |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
24 |
return ; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
25 |
} |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
26 |
file.close(); |
1 | 27 |
model = new DomModel(log, this); |
0
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
28 |
this->setModel(model); |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
29 |
} |