diff options
Diffstat (limited to 'examples/xmlpatterns/filetree')
-rw-r--r-- | examples/xmlpatterns/filetree/doc/src/filetree.qdoc | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/examples/xmlpatterns/filetree/doc/src/filetree.qdoc b/examples/xmlpatterns/filetree/doc/src/filetree.qdoc index 1093d56..218bf47 100644 --- a/examples/xmlpatterns/filetree/doc/src/filetree.qdoc +++ b/examples/xmlpatterns/filetree/doc/src/filetree.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the documentation of the Qt Toolkit. @@ -26,9 +26,11 @@ ****************************************************************************/ /*! - \example xmlpatterns/filetree + \example filetree \title File System Example \ingroup xmlpattern_examples + \brief Using Qt XML Patterns for querying non-XML data that is modeled to + look like XML. This example shows how to use Qt XML Patterns for querying non-XML data that is modeled to look like XML. @@ -69,7 +71,7 @@ \c{main.cpp} (\c{Q_INIT_RESOURCE(queries);}). It lists the XQuery files (\c{.xq}) that can be selected in the combobox. - \quotefromfile xmlpatterns/filetree/queries.qrc + \quotefromfile filetree/queries.qrc \printuntil To add your own queries to the example's combobox, store your @@ -104,12 +106,12 @@ QSimpleXmlNodeModel. When you implement your own custom node model, you must provide implementations for these callback functions: - \snippet xmlpatterns/filetree/filetree.h 0 - \snippet xmlpatterns/filetree/filetree.h 1 + \snippet filetree/filetree.h 0 + \snippet filetree/filetree.h 1 The \c{FileTree} class declares four data members: - \snippet xmlpatterns/filetree/filetree.h 2 + \snippet filetree/filetree.h 2 The QVector \c{m_fileInfos} will contain the node model. Each QFileInfo in the vector will represent a file or a directory in the @@ -141,7 +143,7 @@ types: \target Node_Type - \snippet xmlpatterns/filetree/filetree.h 4 + \snippet filetree/filetree.h 4 \c{Directory} and \c{File} will represent the XML element nodes for directories and files respectively, and the other enum values will @@ -150,7 +152,7 @@ initializes \c{m_names} with an appropriate QXmlName for each element and attribute type: - \snippet xmlpatterns/filetree/filetree.cpp 2 + \snippet filetree/filetree.cpp 2 Note that the constructor does \e{not} pre-build the entire node model. Instead, the node model is built \e{incrementally} as the @@ -176,7 +178,7 @@ a QFileInfo, the class uses the private function \c{toNodeIndex()}: \target main toNodeIndex - \snippet xmlpatterns/filetree/filetree.cpp 1 + \snippet filetree/filetree.cpp 1 It searches the \c{m_fileInfos} vector for a QFileInfo that matches \c{fileInfo}. If a match is found, its array index is passed to @@ -211,12 +213,12 @@ type directly from the QFileInfo: \target toNodeIndex of convenience - \snippet xmlpatterns/filetree/filetree.cpp 0 + \snippet filetree/filetree.cpp 0 Note that the auxiliary vector \c{m_names} is accessed using the \l{Node_Type} {node type}, for example: - \snippet xmlpatterns/filetree/filetree.cpp 3 + \snippet filetree/filetree.cpp 3 Most of the virtual functions in the callback interface are as simple as the ones described so far, but the callback function used @@ -253,7 +255,7 @@ each \l{QAbstractXmlNodeModel::SimpleAxis} {axis}. \target next node on axis - \snippet xmlpatterns/filetree/filetree.cpp 4 + \snippet filetree/filetree.cpp 4 The first thing this function does is call \l{to file info} {toFileInfo()} to get the QFileInfo of the context node. The use of @@ -262,7 +264,7 @@ in \c{m_fileInfos}. \target to file info - \snippet xmlpatterns/filetree/filetree.cpp 6 + \snippet filetree/filetree.cpp 6 The \l{QAbstractXmlNodeModel::Parent} {Parent} case looks up the context node's parent by constructing a QFileInfo from the context @@ -294,7 +296,7 @@ sibling to the node model, if it isn't in the model yet. \target nextSibling helper - \snippet xmlpatterns/filetree/filetree.cpp 5 + \snippet filetree/filetree.cpp 5 \section2 The UI Class: MainWindow @@ -302,7 +304,7 @@ QMainWindow and the Ui_MainWindow base class generated by \l{Qt Designer Manual} {Qt Designer}. - \snippet xmlpatterns/filetree/mainwindow.h 0 + \snippet filetree/mainwindow.h 0 It contains the custom node model (\c{m_fileTree}) and an instance of QXmlNodeModelIndex (\c{m_fileNode}) used for holding the node @@ -318,13 +320,13 @@ be loaded into the custom node model. Choosing a directory signals the \c{on_actionOpenDirectory_triggered()} slot: - \snippet xmlpatterns/filetree/mainwindow.cpp 1 + \snippet filetree/mainwindow.cpp 1 The slot function simply calls the private function \c{loadDirectory()} with the path of the chosen directory: \target the standard code pattern - \snippet xmlpatterns/filetree/mainwindow.cpp 4 + \snippet filetree/mainwindow.cpp 4 \c{loadDirectory()} demonstrates a standard code pattern for using Qt XML Patterns programatically. First it gets the node model index @@ -361,12 +363,12 @@ right. Choosing an XQuery signals the \c{on_queryBox_currentIndexChanged()} slot: - \snippet xmlpatterns/filetree/mainwindow.cpp 2 + \snippet filetree/mainwindow.cpp 2 The slot function opens and loads the query file and then calls the private function \c{evaluateResult()} to run the query: - \snippet xmlpatterns/filetree/mainwindow.cpp 3 + \snippet filetree/mainwindow.cpp 3 \c{evaluateResult()} is a second example of the same code pattern shown in \l{the standard code pattern} {loadDirectory()}. In this @@ -388,8 +390,8 @@ \c{FileTree} class, we can strip the running of \c{wholeTree.xq} out of \l{the standard code pattern} {MainWindow::loadDirectory()}: - \snippet xmlpatterns/filetree/mainwindow.cpp 5 - \snippet xmlpatterns/filetree/mainwindow.cpp 6 + \snippet filetree/mainwindow.cpp 5 + \snippet filetree/mainwindow.cpp 6 Note, however, that \c{FileTree} doesn't have the capability of deleting all or part of the node model. The node model, once built, |