1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qdeclarativefolderlistmodel.cpp -->
<title>Qt 4.8: QML FolderListModel Element</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="qdeclarativeelements.html">QML Elements</a></li>
<li>QML FolderListModel Element</li>
</ul>
</div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#methods">Methods</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#filtering">Filtering</a></li>
<li class="level2"><a href="#example-usage">Example Usage</a></li>
<li class="level2"><a href="#path-separators">Path Separators</a></li>
</ul>
</div>
<h1 class="title">QML FolderListModel Element</h1>
<span class="subtitle"></span>
<!-- $$$FolderListModel-brief -->
<p>The FolderListModel provides a model of the contents of a file system folder. <a href="#details">More...</a></p>
<!-- @@@FolderListModel -->
<ul>
<li><a href="qml-folderlistmodel-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2>Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-folderlistmodel.html#count-prop">count</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-folderlistmodel.html#folder-prop">folder</a></b></b> : string</li>
<li class="fn"><b><b><a href="qml-folderlistmodel.html#nameFilters-prop">nameFilters</a></b></b> : list<string></li>
<li class="fn"><b><b><a href="qml-folderlistmodel.html#parentFolder-prop">parentFolder</a></b></b> : url</li>
<li class="fn"><b><b><a href="qml-folderlistmodel.html#showDirs-prop">showDirs</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-folderlistmodel.html#showDotAndDotDot-prop">showDotAndDotDot</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-folderlistmodel.html#showOnlyReadable-prop">showOnlyReadable</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-folderlistmodel.html#sortField-prop">sortField</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-folderlistmodel.html#sortReversed-prop">sortReversed</a></b></b> : bool</li>
</ul>
<a name="methods"></a>
<h2>Methods</h2>
<ul>
<li class="fn"><b><b><a href="qml-folderlistmodel.html#isFolder-method">isFolder</a></b></b></li>
</ul>
<!-- $$$FolderListModel-description -->
<a name="details"></a>
<h2>Detailed Description</h2>
<p>FolderListModel provides access to information about the contents of a folder in the local file system, exposing a list of files to views and other data components.</p>
<p><b>Note:</b> This type is made available by importing the <tt>Qt.labs.folderlistmodel</tt> module. <i>Elements in the Qt.labs module are not guaranteed to remain compatible in future versions.</i></p>
<p><b>import Qt.labs.folderlistmodel 1.0</b></p>
<p>The <a href="qml-folderlistmodel.html#folder-prop">folder</a> property specifies the folder to access. Information about the files and directories in the folder is supplied via the model's interface. Components access names and paths via the following roles:</p>
<ul>
<li>fileName</li>
<li>filePath</li>
</ul>
<p>Additionally a file entry can be differentiated from a folder entry via the <a href="qml-folderlistmodel.html#isFolder-method">isFolder()</a> method.</p>
<a name="filtering"></a>
<h2>Filtering</h2>
<p>Various properties can be set to filter the number of files and directories exposed by the model.</p>
<p>The <a href="qml-folderlistmodel.html#nameFilters-prop">nameFilters</a> property can be set to contain a list of wildcard filters that are applied to names of files and directories, causing only those that match the filters to be exposed.</p>
<p>Directories can be included or excluded using the <a href="qml-folderlistmodel.html#showDirs-prop">showDirs</a> property, and navigation directories can also be excluded by setting the <a href="qml-folderlistmodel.html#showDotAndDotDot-prop">showDotAndDotDot</a> property to false.</p>
<p>It is sometimes useful to limit the files and directories exposed to those that the user can access. The <a href="qml-folderlistmodel.html#showOnlyReadable-prop">showOnlyReadable</a> property can be set to enable this feature.</p>
<a name="example-usage"></a>
<h2>Example Usage</h2>
<p>The following example shows a FolderListModel being used to provide a list of QML files in a <a href="qml-listview.html">ListView</a>:</p>
<pre class="qml"> import QtQuick 1.0
import Qt.labs.folderlistmodel 1.0
<span class="type"><a href="qml-listview.html">ListView</a></span> {
<span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="number">400</span>
<span class="type">FolderListModel</span> {
<span class="name">id</span>: <span class="name">folderModel</span>
<span class="name">nameFilters</span>: [<span class="string">"*.qml"</span>]
}
<span class="type"><a href="qml-component.html">Component</a></span> {
<span class="name">id</span>: <span class="name">fileDelegate</span>
<span class="type"><a href="qml-text.html">Text</a></span> { <span class="name">text</span>: <span class="name">fileName</span> }
}
<span class="name">model</span>: <span class="name">folderModel</span>
<span class="name">delegate</span>: <span class="name">fileDelegate</span>
}</pre>
<a name="path-separators"></a>
<h2>Path Separators</h2>
<p>Qt uses "/" as a universal directory separator in the same way that "/" is used as a path separator in URLs. If you always use "/" as a directory separator, Qt will translate your paths to conform to the underlying operating system.</p>
<p><b>See also </b><a href="qdeclarativemodels.html">QML Data Models</a>.</p>
<!-- @@@FolderListModel -->
<h2>Property Documentation</h2>
<!-- $$$count -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="count-prop"></a><span class="qmlreadonly">read-only</span><span class="name">count</span> : <span class="type"><a href="qml-int.html">int</a></span></p></td></tr></table></div><div class="qmldoc"><p>Returns the number of items in the current folder that match the filter criteria.</p>
</div></div><!-- @@@count -->
<br/>
<!-- $$$folder -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="folder-prop"></a><span class="name">folder</span> : <span class="type"><a href="qml-string.html">string</a></span></p></td></tr></table></div><div class="qmldoc"><p>The <i>folder</i> property holds a URL for the folder that the model is currently providing.</p>
<p>The value is a URL expressed as a string, and must be a <tt>file</tt>: or <tt>qrc</tt>: URL, or a relative URL.</p>
<p>By default, the value is an invalid URL.</p>
</div></div><!-- @@@folder -->
<br/>
<!-- $$$nameFilters -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="nameFilters-prop"></a><span class="name">nameFilters</span> : <span class="type"><a href="qml-list.html">list</a></span><<span class="type"><a href="qml-string.html">string</a></span>></p></td></tr></table></div><div class="qmldoc"><p>The <i>nameFilters</i> property contains a list of file name filters. The filters may include the ? and * wildcards.</p>
<p>The example below filters on PNG and JPEG files:</p>
<pre class="qml"> <span class="type"><a href="qml-folderlistmodel.html">FolderListModel</a></span> {
<span class="name">nameFilters</span>: [ <span class="string">"*.png"</span>, <span class="string">"*.jpg"</span> ]
}</pre>
<p><b>Note:</b> Directories are not excluded by filters.</p>
</div></div><!-- @@@nameFilters -->
<br/>
<!-- $$$parentFolder -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="parentFolder-prop"></a><span class="qmlreadonly">read-only</span><span class="name">parentFolder</span> : <span class="type"><a href="qml-url.html">url</a></span></p></td></tr></table></div><div class="qmldoc"><p>Returns the URL of the parent of of the current <a href="qml-folderlistmodel.html#folder-prop">folder</a>.</p>
</div></div><!-- @@@parentFolder -->
<br/>
<!-- $$$showDirs -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="showDirs-prop"></a><span class="name">showDirs</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>If true, directories are included in the model; otherwise only files are included.</p>
<p>By default, this property is true.</p>
<p>Note that the <a href="qml-folderlistmodel.html#nameFilters-prop">nameFilters</a> are not applied to directories.</p>
<p><b>See also </b><a href="qml-folderlistmodel.html#showDotAndDotDot-prop">showDotAndDotDot</a>.</p>
</div></div><!-- @@@showDirs -->
<br/>
<!-- $$$showDotAndDotDot -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="showDotAndDotDot-prop"></a><span class="name">showDotAndDotDot</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>If true, the "." and ".." directories are included in the model; otherwise they are excluded.</p>
<p>By default, this property is false.</p>
<p><b>See also </b><a href="qml-folderlistmodel.html#showDirs-prop">showDirs</a>.</p>
</div></div><!-- @@@showDotAndDotDot -->
<br/>
<!-- $$$showOnlyReadable -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="showOnlyReadable-prop"></a><span class="name">showOnlyReadable</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>If true, only readable files and directories are shown; otherwise all files and directories are shown.</p>
<p>By default, this property is false.</p>
<p><b>See also </b><a href="qml-folderlistmodel.html#showDirs-prop">showDirs</a>.</p>
</div></div><!-- @@@showOnlyReadable -->
<br/>
<!-- $$$sortField -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="sortField-prop"></a><span class="name">sortField</span> : <span class="type"><a href="qml-enumeration.html">enumeration</a></span></p></td></tr></table></div><div class="qmldoc"><p>The <i>sortField</i> property contains field to use for sorting. sortField may be one of:</p>
<ul>
<li>Unsorted - no sorting is applied. The order is system default.</li>
<li>Name - sort by filename</li>
<li>Time - sort by time modified</li>
<li>Size - sort by file size</li>
<li>Type - sort by file type (extension)</li>
</ul>
<p><b>See also </b><a href="qml-folderlistmodel.html#sortReversed-prop">sortReversed</a>.</p>
</div></div><!-- @@@sortField -->
<br/>
<!-- $$$sortReversed -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="sortReversed-prop"></a><span class="name">sortReversed</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>If set to true, reverses the sort order. The default is false.</p>
<p><b>See also </b><a href="qml-folderlistmodel.html#sortField-prop">sortField</a>.</p>
</div></div><!-- @@@sortReversed -->
<br/>
<h2>Method Documentation</h2>
<!-- $$$isFolder -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlFuncNode"><p><a name="isFolder-method"></a><span class="type"><a href="qml-bool.html">bool</a></span> FolderListModel::<span class="name">isFolder</span> ( <span class="type"><a href="qml-int.html">int</a></span> <i>index</i> )</p></td></tr></table></div><div class="qmldoc"><p>Returns true if the entry <i>index</i> is a folder; otherwise returns false.</p>
</div></div><!-- @@@isFolder -->
<br/>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
The documentation provided herein is licensed under the terms of the
<a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
License version 1.3</a> as published by the Free Software Foundation.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|