summaryrefslogtreecommitdiffstats
path: root/examples/xml/saxbookmarks
diff options
context:
space:
mode:
authorQt by Nokia <qt-info@nokia.com>2011-04-27 12:05:43 +0200
committeraxis <qt-info@nokia.com>2011-04-27 12:05:43 +0200
commit38be0d13830efd2d98281c645c3a60afe05ffece (patch)
tree6ea73f3ec77f7d153333779883e8120f82820abe /examples/xml/saxbookmarks
Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
Diffstat (limited to 'examples/xml/saxbookmarks')
-rw-r--r--examples/xml/saxbookmarks/frank.xbel230
-rw-r--r--examples/xml/saxbookmarks/jennifer.xbel93
-rw-r--r--examples/xml/saxbookmarks/main.cpp56
-rw-r--r--examples/xml/saxbookmarks/mainwindow.cpp169
-rw-r--r--examples/xml/saxbookmarks/mainwindow.h77
-rw-r--r--examples/xml/saxbookmarks/saxbookmarks.pro28
-rw-r--r--examples/xml/saxbookmarks/xbelgenerator.cpp114
-rw-r--r--examples/xml/saxbookmarks/xbelgenerator.h68
-rw-r--r--examples/xml/saxbookmarks/xbelhandler.cpp146
-rw-r--r--examples/xml/saxbookmarks/xbelhandler.h78
10 files changed, 1059 insertions, 0 deletions
diff --git a/examples/xml/saxbookmarks/frank.xbel b/examples/xml/saxbookmarks/frank.xbel
new file mode 100644
index 0000000000..6bd63b8b07
--- /dev/null
+++ b/examples/xml/saxbookmarks/frank.xbel
@@ -0,0 +1,230 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE xbel>
+<xbel version="1.0">
+ <folder folded="yes">
+ <title>Literate Programming</title>
+ <bookmark href="http://www.vivtek.com/litprog.html">
+ <title>Synopsis of Literate Programming</title>
+ </bookmark>
+ <bookmark href="http://vasc.ri.cmu.edu/old_help/Programming/Literate/literate.html">
+ <title>Literate Programming: Propaganda and Tools</title>
+ </bookmark>
+ <bookmark href="http://www.isy.liu.se/%7Eturbell/litprog/">
+ <title>Literate Programming by Henrik Turbell</title>
+ </bookmark>
+ <bookmark href="http://www.desy.de/user/projects/LitProg.html">
+ <title>Literate Programming Library</title>
+ </bookmark>
+ <bookmark href="http://www.loria.fr/services/tex/english/litte.html">
+ <title>Literate Programming Basics</title>
+ </bookmark>
+ <bookmark href="http://ei.cs.vt.edu/%7Ecs5014/courseNotes/4.LiterateProgramming/literate_prog.html">
+ <title>Literate Programming Overview</title>
+ </bookmark>
+ <bookmark href="http://www.perl.com/pub/a/tchrist/litprog.html">
+ <title>POD is not Literate Programming</title>
+ </bookmark>
+ <bookmark href="http://www.cornellcollege.edu/%7Eltabak/publications/articles/swsafety.html">
+ <title>Computers That We Can Count On</title>
+ </bookmark>
+ <bookmark href="http://www.cs.auc.dk/%7Enormark/litpro/issues-and-problems.html">
+ <title>Literate Programming - Issues and Problems</title>
+ </bookmark>
+ <bookmark href="http://c2.com/cgi/wiki?LiterateProgramming">
+ <title>Literate Programming - Wiki Pages</title>
+ </bookmark>
+ <bookmark href="http://developers.slashdot.org/developers/02/05/19/2216233.shtml">
+ <title>What is well-commented code?</title>
+ </bookmark>
+ <bookmark href="http://liinwww.ira.uka.de/bibliography/SE/litprog.html">
+ <title>Bibliography on literate programming - A searchable bibliography</title>
+ </bookmark>
+ <bookmark href="http://www2.umassd.edu/SWPI/ProcessBibliography/bib-codereading.html">
+ <title>Program comprehension and code reading bibliography</title>
+ </bookmark>
+ <bookmark href="http://www.cs.auc.dk/%7Enormark/elucidative-programming/">
+ <title>Elucidative Programming</title>
+ </bookmark>
+ <bookmark href="http://www.msu.edu/%7Epfaffben/avl/index.html">
+ <title>AVL Trees (TexiWeb)</title>
+ </bookmark>
+ <bookmark href="http://literate-programming.wikiverse.org/">
+ <title>Literate Programming on Wikiverse</title>
+ </bookmark>
+ <bookmark href="http://www.pbrt.org/">
+ <title>Physically Based Rendering: From Theory to Implementation</title>
+ </bookmark>
+ </folder>
+ <folder folded="no">
+ <title>Useful C++ Links</title>
+ <folder folded="no">
+ <title>STL</title>
+ <bookmark href="http://www.sgi.com/tech/stl/table_of_contents.html">
+ <title>STL Reference Documentation</title>
+ </bookmark>
+ <bookmark href="http://www.yrl.co.uk/~phil/stl/stl.htmlx">
+ <title>STL Tutorial</title>
+ </bookmark>
+ <bookmark href="http://www.cppreference.com/cpp_stl.html">
+ <title>STL Reference</title>
+ </bookmark>
+ </folder>
+ <folder folded="no">
+ <title>Qt</title>
+ <bookmark href="http://qt.nokia.com/doc/2.3/">
+ <title>Qt 2.3 Reference</title>
+ </bookmark>
+ <bookmark href="http://qt.nokia.com/doc/3.3/">
+ <title>Qt 3.3 Reference</title>
+ </bookmark>
+ <bookmark href="http://qt.nokia.com/doc/4.0/">
+ <title>Qt 4.0 Reference</title>
+ </bookmark>
+ <bookmark href="http://qt.nokia.com/">
+ <title>Qt Home Page</title>
+ </bookmark>
+ </folder>
+ <folder folded="yes">
+ <title>IOStreams</title>
+ <bookmark href="http://www.cplusplus.com/ref/iostream/index.html">
+ <title>IO Stream Library</title>
+ </bookmark>
+ <bookmark href="http://courses.cs.vt.edu/~cs2604/fall01/binio.html">
+ <title>Binary I/O</title>
+ </bookmark>
+ <bookmark href="http://www.parashift.com/c++-faq-lite/input-output.html">
+ <title>I/O Stream FAQ</title>
+ </bookmark>
+ </folder>
+ <folder folded="yes">
+ <title>gdb</title>
+ <bookmark href="http://www.cs.princeton.edu/~benjasik/gdb/gdbtut.html">
+ <title>GDB Tutorial</title>
+ </bookmark>
+ <bookmark href="http://www.gnu.org/manual/gdb-4.17/html_mono/gdb.html">
+ <title>Debugging with GDB</title>
+ </bookmark>
+ <bookmark href="http://www.cs.washington.edu/orgs/acm/tutorials/dev-in-unix/gdb-refcard.pdf">
+ <title>GDB Quick Reference Page (PDF) (Handy)</title>
+ </bookmark>
+ </folder>
+ <folder folded="yes">
+ <title>Classes and Constructors</title>
+ <bookmark href="http://www.parashift.com/c++-faq-lite/ctors.html">
+ <title>Constructor FAQ</title>
+ </bookmark>
+ <bookmark href="http://www.juicystudio.com/tutorial/cpp/index.html">
+ <title>Organizing Classes</title>
+ </bookmark>
+ </folder>
+ </folder>
+ <folder folded="yes">
+ <title>Software Documentation or System Documentation</title>
+ <bookmark href="http://www.martinfowler.com/distributedComputing/thud.html">
+ <title>The Almighty Thud</title>
+ </bookmark>
+ <bookmark href="http://msdn.microsoft.com/library/techart/cfr.htm">
+ <title>Microsoft Coding Techniques and Programming Practices</title>
+ </bookmark>
+ <bookmark href="http://www.bearcave.com/software/prog_docs.html">
+ <title>Software and Documentation</title>
+ </bookmark>
+ <bookmark href="http://c2.com/cgi/wiki?TheSourceCodeIsTheDesign">
+ <title>The Source Code is the Design</title>
+ </bookmark>
+ <bookmark href="http://www.bleading-edge.com/Publications/C++Journal/Cpjour2.htm">
+ <title>What is Software Design?</title>
+ </bookmark>
+ <bookmark href="http://www.mindprod.com/unmain.html">
+ <title>How To Write Unmaintainable Code</title>
+ </bookmark>
+ <bookmark href="http://www.idinews.com/selfDoc.html">
+ <title>Self Documenting Program Code Remains a Distant Goal</title>
+ </bookmark>
+ <bookmark href="http://www.sdmagazine.com/documents/s=730/sdm0106m/0106m.htm">
+ <title>Place Tab A in Slot B</title>
+ </bookmark>
+ <bookmark href="http://www.holub.com/class/uml/uml.html">
+ <title>UML Reference Card</title>
+ </bookmark>
+ </folder>
+ <folder folded="yes">
+ <title>TeX Resources</title>
+ <bookmark href="http://www.tug.org/">
+ <title>The TeX User's Group</title>
+ </bookmark>
+ <bookmark href="http://www.miktex.org/">
+ <title>MikTeX website</title>
+ </bookmark>
+ <bookmark href="http://cm.bell-labs.com/who/hobby/MetaPost.html">
+ <title>MetaPost website</title>
+ </bookmark>
+ <bookmark href="http://pauillac.inria.fr/%7Emaranget/hevea/">
+ <title>HEVEA is a quite complete and fast LATEX to HTML translator</title>
+ </bookmark>
+ </folder>
+ <folder folded="no">
+ <title>Portable Document Format (PDF)</title>
+ <bookmark href="http://www.adobe.com/">
+ <title>Adobe - The postscript and PDF standards</title>
+ </bookmark>
+ <bookmark href="http://partners.adobe.com/asn/developer/technotes/acrobatpdf.html">
+ <title>Reference Manual Portable Document Format</title>
+ </bookmark>
+ <bookmark href="http://partners.adobe.com/asn/developer/acrosdk/main.html">
+ <title>Adobe Acrobat Software Development Kit</title>
+ </bookmark>
+ </folder>
+ <folder folded="yes">
+ <title>Literature Sites</title>
+ <bookmark href="http://www.cc.columbia.edu/cu/libraries/subjects/speccol.html">
+ <title>Guide to Special Collections (Columbia University)</title>
+ </bookmark>
+ <bookmark href="http://www.ipl.org/ref/litcrit/">
+ <title>Literary Criticism on the Web from the Internet Public Library</title>
+ </bookmark>
+ <bookmark href="http://www.victorianweb.org/">
+ <title>Victorian Web.</title>
+ </bookmark>
+ <bookmark href="http://vos.ucsb.edu/">
+ <title>Voice of the Shuttle.</title>
+ </bookmark>
+ <bookmark href="http://www.modjourn.brown.edu/">
+ <title>Modernist Journals Project</title>
+ </bookmark>
+ <bookmark href="http://www.poetspath.com">
+ <title>Museum of American Poetics</title>
+ </bookmark>
+ <bookmark href="http://www.english.uiuc.edu/maps/">
+ <title>Modern American Poetry</title>
+ </bookmark>
+ <bookmark href="http://www.findarticles.com/">
+ <title>FindArticles.com</title>
+ </bookmark>
+ <bookmark href="http://www.literaryhistory.com">
+ <title>Literary History</title>
+ </bookmark>
+ <bookmark href="http://www.litencyc.com/LitEncycFrame.htm">
+ <title>Literary Encyclopedia</title>
+ </bookmark>
+ <separator/>
+ <bookmark href="http://texts.cdlib.org/ucpress/">
+ <title>The University of California Press</title>
+ </bookmark>
+ <bookmark href="http://www.letrs.indiana.edu/web/w/wright2/">
+ <title>Wright American Fiction, 1851-1875</title>
+ </bookmark>
+ <bookmark href="http://docsouth.unc.edu/">
+ <title>Documenting the American South: Beginnings to 1920</title>
+ </bookmark>
+ <bookmark href="http://etext.lib.virginia.edu/eng-on.html">
+ <title>Electronic Text Center at the University of Virginia</title>
+ </bookmark>
+ <bookmark href="http://digital.nypl.org/schomburg/writers_aa19/">
+ <title>The Schomburg Center for Research in Black Culture</title>
+ </bookmark>
+ <bookmark href="http://www.infomotions.com/alex2/">
+ <title>Alex Catalogue of Electronic Texts.</title>
+ </bookmark>
+ </folder>
+</xbel>
diff --git a/examples/xml/saxbookmarks/jennifer.xbel b/examples/xml/saxbookmarks/jennifer.xbel
new file mode 100644
index 0000000000..d6a5b41d05
--- /dev/null
+++ b/examples/xml/saxbookmarks/jennifer.xbel
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE xbel>
+<xbel version="1.0">
+ <folder folded="no">
+ <title>Qt Resources</title>
+ <folder folded="yes">
+ <title>Qt Partners</title>
+ <bookmark href="http://partners.trolltech.com/partners/training.html">
+ <title>Training Partners</title>
+ </bookmark>
+ <bookmark href="http://partners.trolltech.com/partners/service.html">
+ <title>Consultants and System Integrators</title>
+ </bookmark>
+ <bookmark href="http://partners.trolltech.com/partners/tech.html">
+ <title>Technology Partners</title>
+ </bookmark>
+ <bookmark href="http://partners.trolltech.com/partners/resellers.html">
+ <title>Value Added Resellers (VARs)</title>
+ </bookmark>
+ </folder>
+ <folder folded="yes">
+ <title>Community Resources</title>
+ <bookmark href="http://www.qtforum.org/">
+ <title>QtForum.org</title>
+ </bookmark>
+ <bookmark href="http://www.digitalfanatics.org/projects/qt_tutorial/">
+ <title>The Independent Qt Tutorial</title>
+ </bookmark>
+ <bookmark href="http://prog.qt.free.fr/">
+ <title>French PROG.Qt</title>
+ </bookmark>
+ <bookmark href="http://www.qtforum.de/">
+ <title>German Qt Forum</title>
+ </bookmark>
+ <bookmark href="http://www.korone.net/">
+ <title>Korean Qt Community Site</title>
+ </bookmark>
+ <bookmark href="http://prog.org.ru/forum/forum_14.html">
+ <title>Russian Qt Forum</title>
+ </bookmark>
+ <bookmark href="http://qt4.digitalfanatics.org/">
+ <title>Digitalfanatics: The QT 4 Resource Center</title>
+ </bookmark>
+ <bookmark href="http://www.qtquestions.org/">
+ <title>QtQuestions</title>
+ </bookmark>
+ </folder>
+ <bookmark href="http://qt.nokia.com/doc/qq/">
+ <title>Qt Quarterly</title>
+ </bookmark>
+ <bookmark href="http://qt.nokia.com/">
+ <title>qt home page</title>
+ </bookmark>
+ <bookmark href="http://qt.nokia.com/doc/4.0/">
+ <title>Qt 4.0 documentation</title>
+ </bookmark>
+ <bookmark href="http://qt.nokia.com/developer/faqs/">
+ <title>Frequently Asked Questions</title>
+ </bookmark>
+ </folder>
+ <folder folded="no">
+ <title>Online Dictionaries</title>
+ <bookmark href="http://www.dictionary.com/">
+ <title>Dictionary.com</title>
+ </bookmark>
+ <bookmark href="http://www.m-w.com/">
+ <title>Merriam-Webster Online</title>
+ </bookmark>
+ <bookmark href="http://dictionary.cambridge.org/">
+ <title>Cambridge Dictionaries Online</title>
+ </bookmark>
+ <bookmark href="http://www.onelook.com/">
+ <title>OneLook Dictionary Search</title>
+ </bookmark>
+ <separator/>
+ <bookmark href="www.iee.et.tu-dresden.de/">
+ <title>The New English-German Dictionary</title>
+ </bookmark>
+ <bookmark href="http://dict.tu-chemnitz.de/">
+ <title>TU Chemnitz German-English Dictionary</title>
+ </bookmark>
+ <separator/>
+ <bookmark href="http://atilf.atilf.fr/tlf.htm">
+ <title>Trésor de la Langue Française informatisé</title>
+ </bookmark>
+ <bookmark href="http://dictionnaires.atilf.fr/dictionnaires/ACADEMIE/">
+ <title>Dictionnaire de l'Académie Française</title>
+ </bookmark>
+ <bookmark href="http://elsap1.unicaen.fr/cgi-bin/cherches.cgi">
+ <title>Dictionnaire des synonymes</title>
+ </bookmark>
+ </folder>
+</xbel>
diff --git a/examples/xml/saxbookmarks/main.cpp b/examples/xml/saxbookmarks/main.cpp
new file mode 100644
index 0000000000..5d70ec89a5
--- /dev/null
+++ b/examples/xml/saxbookmarks/main.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow mainWin;
+#if defined(Q_OS_SYMBIAN)
+ mainWin.showFullScreen();
+#else
+ mainWin.show();
+#endif
+ mainWin.open();
+ return app.exec();
+}
diff --git a/examples/xml/saxbookmarks/mainwindow.cpp b/examples/xml/saxbookmarks/mainwindow.cpp
new file mode 100644
index 0000000000..e5300121e5
--- /dev/null
+++ b/examples/xml/saxbookmarks/mainwindow.cpp
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+#include "xbelgenerator.h"
+#include "xbelhandler.h"
+
+MainWindow::MainWindow()
+{
+ QStringList labels;
+ labels << tr("Title") << tr("Location");
+
+ treeWidget = new QTreeWidget;
+ treeWidget->header()->setResizeMode(QHeaderView::Stretch);
+ treeWidget->setHeaderLabels(labels);
+ setCentralWidget(treeWidget);
+
+ createActions();
+ createMenus();
+
+ statusBar()->showMessage(tr("Ready"));
+
+ setWindowTitle(tr("SAX Bookmarks"));
+ resize(480, 320);
+}
+
+void MainWindow::open()
+{
+#if defined(Q_OS_SYMBIAN)
+ // Look for bookmarks on the same drive where the application is installed to,
+ // if drive is not read only. QDesktopServices::DataLocation does this check,
+ // and returns writable drive.
+ QString bookmarksFolder =
+ QDesktopServices::storageLocation(QDesktopServices::DataLocation).left(1);
+ bookmarksFolder.append(":/Data/qt/saxbookmarks");
+ QDir::setCurrent(bookmarksFolder);
+#endif
+ QString fileName =
+ QFileDialog::getOpenFileName(this, tr("Open Bookmark File"),
+ QDir::currentPath(),
+ tr("XBEL Files (*.xbel *.xml)"));
+ if (fileName.isEmpty())
+ return;
+
+ treeWidget->clear();
+
+ XbelHandler handler(treeWidget);
+ QXmlSimpleReader reader;
+ reader.setContentHandler(&handler);
+ reader.setErrorHandler(&handler);
+
+ QFile file(fileName);
+ if (!file.open(QFile::ReadOnly | QFile::Text)) {
+ QMessageBox::warning(this, tr("SAX Bookmarks"),
+ tr("Cannot read file %1:\n%2.")
+ .arg(fileName)
+ .arg(file.errorString()));
+ return;
+ }
+
+ QXmlInputSource xmlInputSource(&file);
+ if (reader.parse(xmlInputSource))
+ statusBar()->showMessage(tr("File loaded"), 2000);
+}
+
+void MainWindow::saveAs()
+{
+ QString fileName =
+ QFileDialog::getSaveFileName(this, tr("Save Bookmark File"),
+ QDir::currentPath(),
+ tr("XBEL Files (*.xbel *.xml)"));
+ if (fileName.isEmpty())
+ return;
+
+ QFile file(fileName);
+ if (!file.open(QFile::WriteOnly | QFile::Text)) {
+ QMessageBox::warning(this, tr("SAX Bookmarks"),
+ tr("Cannot write file %1:\n%2.")
+ .arg(fileName)
+ .arg(file.errorString()));
+ return;
+ }
+
+ XbelGenerator generator(treeWidget);
+ if (generator.write(&file))
+ statusBar()->showMessage(tr("File saved"), 2000);
+}
+
+void MainWindow::about()
+{
+ QMessageBox::about(this, tr("About SAX Bookmarks"),
+ tr("The <b>SAX Bookmarks</b> example demonstrates how to use Qt's "
+ "SAX classes to read XML documents and how to generate XML by "
+ "hand."));
+}
+
+void MainWindow::createActions()
+{
+ openAct = new QAction(tr("&Open..."), this);
+ openAct->setShortcuts(QKeySequence::Open);
+ connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
+
+ saveAsAct = new QAction(tr("&Save As..."), this);
+ saveAsAct->setShortcuts(QKeySequence::SaveAs);
+ connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
+
+ exitAct = new QAction(tr("E&xit"), this);
+ exitAct->setShortcuts(QKeySequence::Quit);
+ connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
+
+ aboutAct = new QAction(tr("&About"), this);
+ connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
+
+ aboutQtAct = new QAction(tr("About &Qt"), this);
+ connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+}
+
+void MainWindow::createMenus()
+{
+ fileMenu = menuBar()->addMenu(tr("&File"));
+ fileMenu->addAction(openAct);
+ fileMenu->addAction(saveAsAct);
+ fileMenu->addAction(exitAct);
+
+ menuBar()->addSeparator();
+
+ helpMenu = menuBar()->addMenu(tr("&Help"));
+ helpMenu->addAction(aboutAct);
+ helpMenu->addAction(aboutQtAct);
+}
diff --git a/examples/xml/saxbookmarks/mainwindow.h b/examples/xml/saxbookmarks/mainwindow.h
new file mode 100644
index 0000000000..3313d8f574
--- /dev/null
+++ b/examples/xml/saxbookmarks/mainwindow.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+class QTreeWidget;
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void open();
+ void saveAs();
+ void about();
+
+private:
+ void createActions();
+ void createMenus();
+
+ QTreeWidget *treeWidget;
+
+ QMenu *fileMenu;
+ QMenu *helpMenu;
+ QAction *openAct;
+ QAction *saveAsAct;
+ QAction *exitAct;
+ QAction *aboutAct;
+ QAction *aboutQtAct;
+};
+
+#endif
diff --git a/examples/xml/saxbookmarks/saxbookmarks.pro b/examples/xml/saxbookmarks/saxbookmarks.pro
new file mode 100644
index 0000000000..3091947afc
--- /dev/null
+++ b/examples/xml/saxbookmarks/saxbookmarks.pro
@@ -0,0 +1,28 @@
+HEADERS = mainwindow.h \
+ xbelgenerator.h \
+ xbelhandler.h
+SOURCES = main.cpp \
+ mainwindow.cpp \
+ xbelgenerator.cpp \
+ xbelhandler.cpp
+QT += xml
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/xml/saxbookmarks
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS saxbookmarks.pro *.xbel
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/xml/saxbookmarks
+INSTALLS += target sources
+
+wince*: {
+ addFiles.files = frank.xbel jennifer.xbel
+ addFiles.path = "\\My Documents"
+ DEPLOYMENT += addFiles
+}
+
+symbian: {
+ TARGET.UID3 = 0xA000C60A
+ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+ addFiles.files = frank.xbel jennifer.xbel
+ addFiles.path = /data/qt/saxbookmarks
+ DEPLOYMENT += addFiles
+}
diff --git a/examples/xml/saxbookmarks/xbelgenerator.cpp b/examples/xml/saxbookmarks/xbelgenerator.cpp
new file mode 100644
index 0000000000..a0bfe67f69
--- /dev/null
+++ b/examples/xml/saxbookmarks/xbelgenerator.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "xbelgenerator.h"
+
+XbelGenerator::XbelGenerator(QTreeWidget *treeWidget)
+ : treeWidget(treeWidget)
+{
+}
+
+bool XbelGenerator::write(QIODevice *device)
+{
+ out.setDevice(device);
+ out.setCodec("UTF-8");
+ out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ << "<!DOCTYPE xbel>\n"
+ << "<xbel version=\"1.0\">\n";
+
+ for (int i = 0; i < treeWidget->topLevelItemCount(); ++i)
+ generateItem(treeWidget->topLevelItem(i), 1);
+
+ out << "</xbel>\n";
+ return true;
+}
+
+QString XbelGenerator::indent(int depth)
+{
+ const int IndentSize = 4;
+ return QString(IndentSize * depth, ' ');
+}
+
+QString XbelGenerator::escapedText(const QString &str)
+{
+ QString result = str;
+ result.replace("&", "&amp;");
+ result.replace("<", "&lt;");
+ result.replace(">", "&gt;");
+ return result;
+}
+
+QString XbelGenerator::escapedAttribute(const QString &str)
+{
+ QString result = escapedText(str);
+ result.replace("\"", "&quot;");
+ result.prepend("\"");
+ result.append("\"");
+ return result;
+}
+
+void XbelGenerator::generateItem(QTreeWidgetItem *item, int depth)
+{
+ QString tagName = item->data(0, Qt::UserRole).toString();
+ if (tagName == "folder") {
+ bool folded = !treeWidget->isItemExpanded(item);
+ out << indent(depth) << "<folder folded=\"" << (folded ? "yes" : "no")
+ << "\">\n"
+ << indent(depth + 1) << "<title>" << escapedText(item->text(0))
+ << "</title>\n";
+
+ for (int i = 0; i < item->childCount(); ++i)
+ generateItem(item->child(i), depth + 1);
+
+ out << indent(depth) << "</folder>\n";
+ } else if (tagName == "bookmark") {
+ out << indent(depth) << "<bookmark";
+ if (!item->text(1).isEmpty())
+ out << " href=" << escapedAttribute(item->text(1));
+ out << ">\n"
+ << indent(depth + 1) << "<title>" << escapedText(item->text(0))
+ << "</title>\n"
+ << indent(depth) << "</bookmark>\n";
+ } else if (tagName == "separator") {
+ out << indent(depth) << "<separator/>\n";
+ }
+}
diff --git a/examples/xml/saxbookmarks/xbelgenerator.h b/examples/xml/saxbookmarks/xbelgenerator.h
new file mode 100644
index 0000000000..84011a262f
--- /dev/null
+++ b/examples/xml/saxbookmarks/xbelgenerator.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XBELGENERATOR_H
+#define XBELGENERATOR_H
+
+#include <QTextStream>
+
+QT_BEGIN_NAMESPACE
+class QTreeWidget;
+class QTreeWidgetItem;
+QT_END_NAMESPACE
+
+class XbelGenerator
+{
+public:
+ XbelGenerator(QTreeWidget *treeWidget);
+
+ bool write(QIODevice *device);
+
+private:
+ static QString indent(int indentLevel);
+ static QString escapedText(const QString &str);
+ static QString escapedAttribute(const QString &str);
+ void generateItem(QTreeWidgetItem *item, int depth);
+
+ QTreeWidget *treeWidget;
+ QTextStream out;
+};
+
+#endif
diff --git a/examples/xml/saxbookmarks/xbelhandler.cpp b/examples/xml/saxbookmarks/xbelhandler.cpp
new file mode 100644
index 0000000000..09874c9edc
--- /dev/null
+++ b/examples/xml/saxbookmarks/xbelhandler.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "xbelhandler.h"
+
+XbelHandler::XbelHandler(QTreeWidget *treeWidget)
+ : treeWidget(treeWidget)
+{
+ item = 0;
+ metXbelTag = false;
+
+ QStyle *style = treeWidget->style();
+
+ folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon),
+ QIcon::Normal, QIcon::Off);
+ folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon),
+ QIcon::Normal, QIcon::On);
+ bookmarkIcon.addPixmap(style->standardPixmap(QStyle::SP_FileIcon));
+}
+
+bool XbelHandler::startElement(const QString & /* namespaceURI */,
+ const QString & /* localName */,
+ const QString &qName,
+ const QXmlAttributes &attributes)
+{
+ if (!metXbelTag && qName != "xbel") {
+ errorStr = QObject::tr("The file is not an XBEL file.");
+ return false;
+ }
+
+ if (qName == "xbel") {
+ QString version = attributes.value("version");
+ if (!version.isEmpty() && version != "1.0") {
+ errorStr = QObject::tr("The file is not an XBEL version 1.0 file.");
+ return false;
+ }
+ metXbelTag = true;
+ } else if (qName == "folder") {
+ item = createChildItem(qName);
+ item->setFlags(item->flags() | Qt::ItemIsEditable);
+ item->setIcon(0, folderIcon);
+ item->setText(0, QObject::tr("Folder"));
+ bool folded = (attributes.value("folded") != "no");
+ treeWidget->setItemExpanded(item, !folded);
+ } else if (qName == "bookmark") {
+ item = createChildItem(qName);
+ item->setFlags(item->flags() | Qt::ItemIsEditable);
+ item->setIcon(0, bookmarkIcon);
+ item->setText(0, QObject::tr("Unknown title"));
+ item->setText(1, attributes.value("href"));
+ } else if (qName == "separator") {
+ item = createChildItem(qName);
+ item->setFlags(item->flags() & ~Qt::ItemIsSelectable);
+ item->setText(0, QString(30, 0xB7));
+ }
+
+ currentText.clear();
+ return true;
+}
+
+bool XbelHandler::endElement(const QString & /* namespaceURI */,
+ const QString & /* localName */,
+ const QString &qName)
+{
+ if (qName == "title") {
+ if (item)
+ item->setText(0, currentText);
+ } else if (qName == "folder" || qName == "bookmark"
+ || qName == "separator") {
+ item = item->parent();
+ }
+ return true;
+}
+
+bool XbelHandler::characters(const QString &str)
+{
+ currentText += str;
+ return true;
+}
+
+bool XbelHandler::fatalError(const QXmlParseException &exception)
+{
+ QMessageBox::information(treeWidget->window(), QObject::tr("SAX Bookmarks"),
+ QObject::tr("Parse error at line %1, column %2:\n"
+ "%3")
+ .arg(exception.lineNumber())
+ .arg(exception.columnNumber())
+ .arg(exception.message()));
+ return false;
+}
+
+QString XbelHandler::errorString() const
+{
+ return errorStr;
+}
+
+QTreeWidgetItem *XbelHandler::createChildItem(const QString &tagName)
+{
+ QTreeWidgetItem *childItem;
+ if (item) {
+ childItem = new QTreeWidgetItem(item);
+ } else {
+ childItem = new QTreeWidgetItem(treeWidget);
+ }
+ childItem->setData(0, Qt::UserRole, tagName);
+ return childItem;
+}
diff --git a/examples/xml/saxbookmarks/xbelhandler.h b/examples/xml/saxbookmarks/xbelhandler.h
new file mode 100644
index 0000000000..cee1bafe48
--- /dev/null
+++ b/examples/xml/saxbookmarks/xbelhandler.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XBELHANDLER_H
+#define XBELHANDLER_H
+
+#include <QIcon>
+#include <QXmlDefaultHandler>
+
+QT_BEGIN_NAMESPACE
+class QTreeWidget;
+class QTreeWidgetItem;
+QT_END_NAMESPACE
+
+class XbelHandler : public QXmlDefaultHandler
+{
+public:
+ XbelHandler(QTreeWidget *treeWidget);
+
+ bool startElement(const QString &namespaceURI, const QString &localName,
+ const QString &qName, const QXmlAttributes &attributes);
+ bool endElement(const QString &namespaceURI, const QString &localName,
+ const QString &qName);
+ bool characters(const QString &str);
+ bool fatalError(const QXmlParseException &exception);
+ QString errorString() const;
+
+private:
+ QTreeWidgetItem *createChildItem(const QString &tagName);
+
+ QTreeWidget *treeWidget;
+ QTreeWidgetItem *item;
+ QString currentText;
+ QString errorStr;
+ bool metXbelTag;
+
+ QIcon folderIcon;
+ QIcon bookmarkIcon;
+};
+
+#endif