|  | Home · All Namespaces · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# File System Example

Files:

- xmlpatterns/filetree/filetree.cpp
- xmlpatterns/filetree/filetree.h
- xmlpatterns/filetree/mainwindow.cpp
- xmlpatterns/filetree/mainwindow.h
- xmlpatterns/filetree/forms/mainwindow.ui
- xmlpatterns/filetree/queries/listCPPFiles.xq
- xmlpatterns/filetree/queries/wholeTree.xq
- xmlpatterns/filetree/main.cpp
- xmlpatterns/filetree/filetree.pro
- xmlpatterns/filetree/queries.qrc

Shows how QSimpleXmlNodeModel can be used to use XQuery on top of arbitrary data, in this case the file system.

## Overview

The FileTree class, sub-class of QSimpleXmlNodeModel, uses QFileInfo internally for understanding files, but exposes them to the query engine as XML. Directories becomes a `<directory/>` elements and files `<file/>` elements. In addition they have attributes appropriately, to reflect paths, file sizes and names.

FileTree keeps an array of QFileInfo instances, and create QXmlNodeModelIndex instances that has an integer which is an index into this array. The FileTree class and the query engine passes these back and forth when referring to nodes.