Qt 4.8
Public Types | Signals | Public Functions | Private Slots | Properties | List of all members
QDeclarativeFolderListModel Class Reference

[class begin] More...

#include <qdeclarativefolderlistmodel.h>

Inheritance diagram for QDeclarativeFolderListModel:
QAbstractListModel QDeclarativeParserStatus QAbstractItemModel QObject

Public Types

enum  Roles { FileNameRole = Qt::UserRole+1, FilePathRole = Qt::UserRole+2 }
 
enum  SortField {
  Unsorted, Name, Time, Size,
  Type
}
 

Signals

void folderChanged ()
 [parserstatus] More...
 
- Signals inherited from QAbstractItemModel
void columnsAboutToBeInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted just before columns are inserted into the model. More...
 
void columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 This signal is emitted just before columns are moved within the model. More...
 
void columnsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted just before columns are removed from the model. More...
 
void columnsInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted after columns have been inserted into the model. More...
 
void columnsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column)
 This signal is emitted after columns have been moved within the model. More...
 
void columnsRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted after columns have been removed from the model. More...
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 This signal is emitted whenever the data in an existing item changes. More...
 
void headerDataChanged (Qt::Orientation orientation, int first, int last)
 This signal is emitted whenever a header is changed. More...
 
void layoutAboutToBeChanged ()
 This signal is emitted just before the layout of a model is changed. More...
 
void layoutChanged ()
 This signal is emitted whenever the layout of items exposed by the model has changed; for example, when the model has been sorted. More...
 
void modelAboutToBeReset ()
 This signal is emitted when reset() is called, before the model's internal state (e. More...
 
void modelReset ()
 This signal is emitted when reset() is called, after the model's internal state (e. More...
 
void rowsAboutToBeInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted just before rows are inserted into the model. More...
 
void rowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
 This signal is emitted just before rows are moved within the model. More...
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted just before rows are removed from the model. More...
 
void rowsInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted after rows have been inserted into the model. More...
 
void rowsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
 This signal is emitted after rows have been moved within the model. More...
 
void rowsRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted after rows have been removed from the model. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

virtual void classBegin ()
 [isfolder] More...
 
virtual void componentComplete ()
 Invoked after the root component that caused this instantiation has completed construction. More...
 
int count () const
 [abslistmodel] More...
 
QVariant data (const QModelIndex &index, int role) const
 Returns the data stored under the given role for the item referred to by the index. More...
 
QUrl folder () const
 [count] More...
 
Q_INVOKABLE bool isFolder (int index) const
 [prop funcs] More...
 
QStringList nameFilters () const
 
QUrl parentFolder () const
 
 QDeclarativeFolderListModel (QObject *parent=0)
 [class props] More...
 
int rowCount (const QModelIndex &parent) const
 Returns the number of rows under the given parent. More...
 
void setFolder (const QUrl &folder)
 
void setNameFilters (const QStringList &filters)
 
void setShowDirs (bool)
 
void setShowDotAndDotDot (bool)
 
void setShowOnlyReadable (bool)
 
void setSortField (SortField field)
 
void setSortReversed (bool rev)
 
bool showDirs () const
 
bool showDotAndDotDot () const
 
bool showOnlyReadable () const
 
SortField sortField () const
 
bool sortReversed () const
 
 ~QDeclarativeFolderListModel ()
 
- Public Functions inherited from QAbstractListModel
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 Reimplemented Function More...
 
QModelIndex index (int row, int column=0, const QModelIndex &parent=QModelIndex()) const
 Returns the index of the data in row and column with parent. More...
 
 QAbstractListModel (QObject *parent=0)
 Constructs an abstract list model with the given parent. More...
 
 ~QAbstractListModel ()
 Destroys the abstract list model. More...
 
- Public Functions inherited from QAbstractItemModel
virtual QModelIndex buddy (const QModelIndex &index) const
 Returns a model index for the buddy of the item represented by index. More...
 
virtual bool canFetchMore (const QModelIndex &parent) const
 Returns true if there is more data available for parent; otherwise returns false. More...
 
virtual void fetchMore (const QModelIndex &parent)
 Fetches any available data for the items with the parent specified by the parent index. More...
 
virtual Qt::ItemFlags flags (const QModelIndex &index) const
 Returns the item flags for the given index. More...
 
bool hasIndex (int row, int column, const QModelIndex &parent=QModelIndex()) const
 Returns true if the model returns a valid QModelIndex for row and column with parent, otherwise returns false. More...
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 Returns the data for the given role and section in the header with the specified orientation. More...
 
bool insertColumn (int column, const QModelIndex &parent=QModelIndex())
 Inserts a single column before the given column in the child items of the parent specified. More...
 
virtual bool insertColumns (int column, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, inserts count new columns into the model before the given column. More...
 
bool insertRow (int row, const QModelIndex &parent=QModelIndex())
 Inserts a single row before the given row in the child items of the parent specified. More...
 
virtual bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, inserts count rows into the model before the given row. More...
 
virtual QMap< int, QVariantitemData (const QModelIndex &index) const
 Returns a map with values for all predefined roles in the model for the item at the given index. More...
 
virtual QModelIndexList match (const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
 Returns a list of indexes for the items in the column of the start index where data stored under the given role matches the specified value. More...
 
virtual QMimeDatamimeData (const QModelIndexList &indexes) const
 Returns an object that contains serialized items of data corresponding to the list of indexes specified. More...
 
virtual QStringList mimeTypes () const
 Returns a list of MIME types that can be used to describe a list of model indexes. More...
 
 QAbstractItemModel (QObject *parent=0)
 Constructs an abstract item model with the given parent. More...
 
bool removeColumn (int column, const QModelIndex &parent=QModelIndex())
 Removes the given column from the child items of the parent specified. More...
 
virtual bool removeColumns (int column, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, removes count columns starting with the given column under parent parent from the model. More...
 
bool removeRow (int row, const QModelIndex &parent=QModelIndex())
 Removes the given row from the child items of the parent specified. More...
 
virtual bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, removes count rows starting with the given row under parent parent from the model. More...
 
const QHash< int, QByteArray > & roleNames () const
 Returns the model's role names. More...
 
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 Sets the role data for the item at index to value. More...
 
virtual bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole)
 Sets the data for the given role and section in the header with the specified orientation to the value supplied. More...
 
virtual bool setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles)
 Sets the role data for the item at index to the associated value in roles, for every Qt::ItemDataRole. More...
 
void setSupportedDragActions (Qt::DropActions)
 Sets the supported drag actions for the items in the model. More...
 
QModelIndex sibling (int row, int column, const QModelIndex &idx) const
 Returns the sibling at row and column for the item at index, or an invalid QModelIndex if there is no sibling at that location. More...
 
virtual void sort (int column, Qt::SortOrder order=Qt::AscendingOrder)
 Sorts the model by column in the given order. More...
 
virtual QSize span (const QModelIndex &index) const
 Returns the row and column span of the item represented by index. More...
 
Qt::DropActions supportedDragActions () const
 Returns the actions supported by the data in this model. More...
 
virtual Qt::DropActions supportedDropActions () const
 Returns the drop actions supported by this model. More...
 
virtual ~QAbstractItemModel ()
 Destroys the abstract item model. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QDeclarativeParserStatus
 QDeclarativeParserStatus ()
 
virtual ~QDeclarativeParserStatus ()
 

Private Slots

void handleDataChanged (const QModelIndex &start, const QModelIndex &end)
 
void inserted (const QModelIndex &index, int start, int end)
 
void refresh ()
 [notifier] More...
 
void removed (const QModelIndex &index, int start, int end)
 

Properties

int count
 
QDeclarativeFolderListModelPrivated
 
QUrl folder
 [class begin] More...
 
QStringList nameFilters
 
QUrl parentFolder
 
bool showDirs
 
bool showDotAndDotDot
 
bool showOnlyReadable
 
SortField sortField
 
bool sortReversed
 

Additional Inherited Members

- Public Slots inherited from QAbstractItemModel
virtual void revert ()
 Lets the model know that it should discard cached information. More...
 
virtual bool submit ()
 Lets the model know that it should submit cached information to permanent storage. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QAbstractItemModel
void resetInternalData ()
 This slot is called just after the internal data of a model is cleared while it is being reset. More...
 
- Protected Functions inherited from QAbstractListModel
 QAbstractListModel (QAbstractItemModelPrivate &dd, QObject *parent)
 Constructs an abstract list model with dd and the given parent. More...
 
- Protected Functions inherited from QAbstractItemModel
void beginInsertColumns (const QModelIndex &parent, int first, int last)
 Begins a column insertion operation. More...
 
void beginInsertRows (const QModelIndex &parent, int first, int last)
 Begins a row insertion operation. More...
 
bool beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn)
 Begins a column move operation. More...
 
bool beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow)
 Begins a row move operation. More...
 
void beginRemoveColumns (const QModelIndex &parent, int first, int last)
 Begins a column removal operation. More...
 
void beginRemoveRows (const QModelIndex &parent, int first, int last)
 Begins a row removal operation. More...
 
void beginResetModel ()
 Begins a model reset operation. More...
 
void changePersistentIndex (const QModelIndex &from, const QModelIndex &to)
 Changes the QPersistentModelIndex that is equal to the given from model index to the given to model index. More...
 
void changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to)
 Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list to the given to model index list. More...
 
QModelIndex createIndex (int row, int column, void *data=0) const
 Creates a model index for the given row and column with the internal pointer ptr. More...
 
QModelIndex createIndex (int row, int column, int id) const
 Use QModelIndex QAbstractItemModel::createIndex(int row, int column, quint32 id) instead. More...
 
QModelIndex createIndex (int row, int column, quint32 id) const
 Creates a model index for the given row and column with the internal identifier, id. More...
 
bool decodeData (int row, int column, const QModelIndex &parent, QDataStream &stream)
 
void encodeData (const QModelIndexList &indexes, QDataStream &stream) const
 
void endInsertColumns ()
 Ends a column insertion operation. More...
 
void endInsertRows ()
 Ends a row insertion operation. More...
 
void endMoveColumns ()
 Ends a column move operation. More...
 
void endMoveRows ()
 Ends a row move operation. More...
 
void endRemoveColumns ()
 Ends a column removal operation. More...
 
void endRemoveRows ()
 Ends a row removal operation. More...
 
void endResetModel ()
 Completes a model reset operation. More...
 
QModelIndexList persistentIndexList () const
 Returns the list of indexes stored as persistent indexes in the model. More...
 
 QAbstractItemModel (QAbstractItemModelPrivate &dd, QObject *parent=0)
 
void reset ()
 Resets the model to its original state in any attached views. More...
 
void setRoleNames (const QHash< int, QByteArray > &roleNames)
 Sets the model's role names to roleNames. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

[class begin]

Definition at line 64 of file qdeclarativefolderlistmodel.h.

Enumerations

◆ Roles

◆ SortField

Constructors and Destructors

◆ QDeclarativeFolderListModel()

QDeclarativeFolderListModel::QDeclarativeFolderListModel ( QObject parent = 0)

[class props]

[abslistmodel]

Definition at line 158 of file qdeclarativefolderlistmodel.cpp.

159  : QAbstractListModel(parent)
160 {
162  roles[FileNameRole] = "fileName";
163  roles[FilePathRole] = "filePath";
164  setRoleNames(roles);
165 
168  connect(&d->model, SIGNAL(rowsInserted(const QModelIndex&,int,int))
169  , this, SLOT(inserted(const QModelIndex&,int,int)));
170  connect(&d->model, SIGNAL(rowsRemoved(const QModelIndex&,int,int))
171  , this, SLOT(removed(const QModelIndex&,int,int)));
173  , this, SLOT(handleDataChanged(const QModelIndex&,const QModelIndex&)));
174  connect(&d->model, SIGNAL(modelReset()), this, SLOT(refresh()));
175  connect(&d->model, SIGNAL(layoutChanged()), this, SLOT(refresh()));
176 }
QDeclarativeFolderListModelPrivate * d
void handleDataChanged(const QModelIndex &start, const QModelIndex &end)
void inserted(const QModelIndex &index, int start, int end)
#define SLOT(a)
Definition: qobjectdefs.h:226
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void setFilter(QDir::Filters filters)
Sets the directory model&#39;s filter to that specified by filters.
Definition: qdirmodel.cpp:694
void layoutChanged()
This signal is emitted whenever the layout of items exposed by the model has changed; for example...
QAbstractListModel(QObject *parent=0)
Constructs an abstract list model with the given parent.
void rowsInserted(const QModelIndex &parent, int first, int last)
This signal is emitted after rows have been inserted into the model.
The QModelIndex class is used to locate data in a data model.
void modelReset()
This signal is emitted when reset() is called, after the model&#39;s internal state (e.
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
This signal is emitted whenever the data in an existing item changes.
void setRoleNames(const QHash< int, QByteArray > &roleNames)
Sets the model&#39;s role names to roleNames.
void rowsRemoved(const QModelIndex &parent, int first, int last)
This signal is emitted after rows have been removed from the model.
void removed(const QModelIndex &index, int start, int end)

◆ ~QDeclarativeFolderListModel()

QDeclarativeFolderListModel::~QDeclarativeFolderListModel ( )

Definition at line 178 of file qdeclarativefolderlistmodel.cpp.

179 {
180  delete d;
181 }
QDeclarativeFolderListModelPrivate * d

Functions

◆ classBegin()

void QDeclarativeFolderListModel::classBegin ( )
virtual

[isfolder]

[parserstatus]

Implements QDeclarativeParserStatus.

Definition at line 299 of file qdeclarativefolderlistmodel.cpp.

300 {
301 }

◆ componentComplete()

void QDeclarativeFolderListModel::componentComplete ( )
virtual

Invoked after the root component that caused this instantiation has completed construction.

At this point all static values and binding values have been assigned to the class.

Implements QDeclarativeParserStatus.

Definition at line 303 of file qdeclarativefolderlistmodel.cpp.

304 {
305  if (!d->folder.isValid() || d->folder.toLocalFile().isEmpty() || !QDir().exists(d->folder.toLocalFile()))
307 
308  if (!d->folderIndex.isValid())
310 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
QDeclarativeFolderListModelPrivate * d
bool isValid() const
Returns true if the URL is valid; otherwise returns false.
Definition: qurl.cpp:4303
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
static QString currentPath()
Returns the absolute path of the application&#39;s current directory.
Definition: qdir.cpp:1875
bool exists() const
Returns true if the directory exists; otherwise returns false.
Definition: qdir.cpp:1560
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition: qurl.cpp:6412
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.

◆ count()

int QDeclarativeFolderListModel::count ( ) const
inline

[abslistmodel]

[count]

Definition at line 94 of file qdeclarativefolderlistmodel.h.

94 { return rowCount(QModelIndex()); }
int rowCount(const QModelIndex &parent) const
Returns the number of rows under the given parent.
The QModelIndex class is used to locate data in a data model.

◆ data()

QVariant QDeclarativeFolderListModel::data ( const QModelIndex index,
int  role 
) const
virtual

Returns the data stored under the given role for the item referred to by the index.

Note
If you do not have a value to return, return an invalid QVariant instead of returning 0.
See also
Qt::ItemDataRole, setData(), headerData()

Implements QAbstractItemModel.

Definition at line 183 of file qdeclarativefolderlistmodel.cpp.

184 {
185  QVariant rv;
186  QModelIndex modelIndex = d->model.index(index.row(), 0, d->folderIndex);
187  if (modelIndex.isValid()) {
188  if (role == FileNameRole)
189  rv = d->model.data(modelIndex, QDirModel::FileNameRole).toString();
190  else if (role == FilePathRole)
192  }
193  return rv;
194 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDeclarativeFolderListModelPrivate * d
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
int row() const
Returns the row this model index refers to.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QModelIndex class is used to locate data in a data model.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Returns the model item index for the item in the parent with the given row and column.
Definition: qdirmodel.cpp:281
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Returns the data for the model item index with the given role.
Definition: qdirmodel.cpp:365
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition: qurl.cpp:6374

◆ folder()

QUrl QDeclarativeFolderListModel::folder ( ) const

[count]

[prop funcs]

Referenced by count(), rowCount(), and setFolder().

◆ folderChanged

void QDeclarativeFolderListModel::folderChanged ( )
signal

[parserstatus]

[notifier]

Referenced by setFolder().

◆ handleDataChanged

void QDeclarativeFolderListModel::handleDataChanged ( const QModelIndex start,
const QModelIndex end 
)
privateslot

Definition at line 420 of file qdeclarativefolderlistmodel.cpp.

Referenced by QDeclarativeFolderListModel().

421 {
422  if (start.parent() == d->folderIndex)
423  emit dataChanged(index(start.row(),0), index(end.row(),0));
424 }
QDeclarativeFolderListModelPrivate * d
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
QModelIndex index(int row, int column=0, const QModelIndex &parent=QModelIndex()) const
Returns the index of the data in row and column with parent.
int row() const
Returns the row this model index refers to.
#define emit
Definition: qobjectdefs.h:76
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
This signal is emitted whenever the data in an existing item changes.

◆ inserted

void QDeclarativeFolderListModel::inserted ( const QModelIndex index,
int  start,
int  end 
)
privateslot

Definition at line 402 of file qdeclarativefolderlistmodel.cpp.

Referenced by QDeclarativeFolderListModel().

403 {
404  if (index == d->folderIndex) {
405  emit beginInsertRows(QModelIndex(), start, end);
408  }
409 }
QDeclarativeFolderListModelPrivate * d
void endInsertRows()
Ends a row insertion operation.
#define emit
Definition: qobjectdefs.h:76
The QModelIndex class is used to locate data in a data model.
static const KeyPair *const end
int rowCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of rows in the parent model item.
Definition: qdirmodel.cpp:331
void beginInsertRows(const QModelIndex &parent, int first, int last)
Begins a row insertion operation.

◆ isFolder()

bool QDeclarativeFolderListModel::isFolder ( int  index) const

[prop funcs]

[isfolder]

Definition at line 375 of file qdeclarativefolderlistmodel.cpp.

376 {
377  if (index != -1) {
378  QModelIndex idx = d->model.index(index, 0, d->folderIndex);
379  if (idx.isValid())
380  return d->model.isDir(idx);
381  }
382  return false;
383 }
QDeclarativeFolderListModelPrivate * d
QModelIndex index(int row, int column=0, const QModelIndex &parent=QModelIndex()) const
Returns the index of the data in row and column with parent.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
bool isDir(const QModelIndex &index) const
Returns true if the model item index represents a directory; otherwise returns false.
Definition: qdirmodel.cpp:986
The QModelIndex class is used to locate data in a data model.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Returns the model item index for the item in the parent with the given row and column.
Definition: qdirmodel.cpp:281

◆ nameFilters()

QStringList QDeclarativeFolderListModel::nameFilters ( ) const

Referenced by count(), and setFolder().

◆ parentFolder()

QUrl QDeclarativeFolderListModel::parentFolder ( ) const

Referenced by count(), and setFolder().

◆ refresh

void QDeclarativeFolderListModel::refresh ( )
privateslot

[notifier]

[class end]

Definition at line 385 of file qdeclarativefolderlistmodel.cpp.

Referenced by QDeclarativeFolderListModel().

386 {
388  if (d->count) {
390  d->count = 0;
392  }
394  int newcount = d->model.rowCount(d->folderIndex);
395  if (newcount) {
396  emit beginInsertRows(QModelIndex(), 0, newcount-1);
397  d->count = newcount;
399  }
400 }
QDeclarativeFolderListModelPrivate * d
void endInsertRows()
Ends a row insertion operation.
#define emit
Definition: qobjectdefs.h:76
void endRemoveRows()
Ends a row removal operation.
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition: qurl.cpp:6412
void beginRemoveRows(const QModelIndex &parent, int first, int last)
Begins a row removal operation.
The QModelIndex class is used to locate data in a data model.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Returns the model item index for the item in the parent with the given row and column.
Definition: qdirmodel.cpp:281
int rowCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of rows in the parent model item.
Definition: qdirmodel.cpp:331
void beginInsertRows(const QModelIndex &parent, int first, int last)
Begins a row insertion operation.

◆ removed

void QDeclarativeFolderListModel::removed ( const QModelIndex index,
int  start,
int  end 
)
privateslot

Definition at line 411 of file qdeclarativefolderlistmodel.cpp.

Referenced by QDeclarativeFolderListModel().

412 {
413  if (index == d->folderIndex) {
414  emit beginRemoveRows(QModelIndex(), start, end);
417  }
418 }
QDeclarativeFolderListModelPrivate * d
#define emit
Definition: qobjectdefs.h:76
void endRemoveRows()
Ends a row removal operation.
void beginRemoveRows(const QModelIndex &parent, int first, int last)
Begins a row removal operation.
The QModelIndex class is used to locate data in a data model.
static const KeyPair *const end
int rowCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of rows in the parent model item.
Definition: qdirmodel.cpp:331

◆ rowCount()

int QDeclarativeFolderListModel::rowCount ( const QModelIndex parent) const
virtual

Returns the number of rows under the given parent.

When the parent is valid it means that rowCount is returning the number of children of parent.

Note
When implementing a table based model, rowCount() should return 0 when the parent is valid.
See also
columnCount()

Implements QAbstractItemModel.

Definition at line 205 of file qdeclarativefolderlistmodel.cpp.

Referenced by count().

206 {
207  Q_UNUSED(parent);
208  return d->count;
209 }
QDeclarativeFolderListModelPrivate * d
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ setFolder()

void QDeclarativeFolderListModel::setFolder ( const QUrl folder)

Definition at line 230 of file qdeclarativefolderlistmodel.cpp.

Referenced by componentComplete(), and count().

231 {
232  if (folder == d->folder)
233  return;
234  QModelIndex index = d->model.index(folder.toLocalFile());
235  if ((index.isValid() && d->model.isDir(index)) || folder.toLocalFile().isEmpty()) {
236 
237  d->folder = folder;
240  }
241 }
QDeclarativeFolderListModelPrivate * d
QModelIndex index(int row, int column=0, const QModelIndex &parent=QModelIndex()) const
Returns the index of the data in row and column with parent.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define emit
Definition: qobjectdefs.h:76
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition: qurl.cpp:6412
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
bool isDir(const QModelIndex &index) const
Returns true if the model item index represents a directory; otherwise returns false.
Definition: qdirmodel.cpp:986
The QModelIndex class is used to locate data in a data model.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Returns the model item index for the item in the parent with the given row and column.
Definition: qdirmodel.cpp:281
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
void folderChanged()
[parserstatus]
QUrl folder() const
[count]

◆ setNameFilters()

void QDeclarativeFolderListModel::setNameFilters ( const QStringList filters)

Definition at line 293 of file qdeclarativefolderlistmodel.cpp.

Referenced by count().

294 {
295  d->nameFilters = filters;
297 }
QDeclarativeFolderListModelPrivate * d
static const char *const filters[3]
void setNameFilters(const QStringList &filters)
Sets the name filters for the directory model.
Definition: qdirmodel.cpp:663

◆ setShowDirs()

void QDeclarativeFolderListModel::setShowDirs ( bool  on)

Definition at line 446 of file qdeclarativefolderlistmodel.cpp.

447 {
448  if (!(d->model.filter() & QDir::AllDirs) == !on)
449  return;
450  if (on)
452  else
454 }
QDir::Filters filter() const
Returns the filter specification for the directory model.
Definition: qdirmodel.cpp:712
QDeclarativeFolderListModelPrivate * d
void setFilter(QDir::Filters filters)
Sets the directory model&#39;s filter to that specified by filters.
Definition: qdirmodel.cpp:694

◆ setShowDotAndDotDot()

void QDeclarativeFolderListModel::setShowDotAndDotDot ( bool  on)

Definition at line 474 of file qdeclarativefolderlistmodel.cpp.

475 {
476  if (!(d->model.filter() & QDir::NoDotAndDotDot) == on)
477  return;
478  if (on)
479  d->model.setFilter(d->model.filter() & ~QDir::NoDotAndDotDot);
480  else
482 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
QDir::Filters filter() const
Returns the filter specification for the directory model.
Definition: qdirmodel.cpp:712
QDeclarativeFolderListModelPrivate * d
void setFilter(QDir::Filters filters)
Sets the directory model&#39;s filter to that specified by filters.
Definition: qdirmodel.cpp:694

◆ setShowOnlyReadable()

void QDeclarativeFolderListModel::setShowOnlyReadable ( bool  on)

Definition at line 502 of file qdeclarativefolderlistmodel.cpp.

503 {
504  if (!(d->model.filter() & QDir::Readable) == !on)
505  return;
506  if (on)
508  else
510 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
QDir::Filters filter() const
Returns the filter specification for the directory model.
Definition: qdirmodel.cpp:712
QDeclarativeFolderListModelPrivate * d
void setFilter(QDir::Filters filters)
Sets the directory model&#39;s filter to that specified by filters.
Definition: qdirmodel.cpp:694

◆ setSortField()

void QDeclarativeFolderListModel::setSortField ( SortField  field)

Definition at line 335 of file qdeclarativefolderlistmodel.cpp.

336 {
337  if (field != d->sortField) {
338  d->sortField = field;
339  d->updateSorting();
340  }
341 }
QDeclarativeFolderListModel::SortField sortField
QDeclarativeFolderListModelPrivate * d

◆ setSortReversed()

void QDeclarativeFolderListModel::setSortReversed ( bool  rev)

Definition at line 358 of file qdeclarativefolderlistmodel.cpp.

359 {
360  if (rev != d->sortReversed) {
361  d->sortReversed = rev;
362  d->updateSorting();
363  }
364 }
QDeclarativeFolderListModelPrivate * d

◆ showDirs()

bool QDeclarativeFolderListModel::showDirs ( ) const

Referenced by handleDataChanged().

◆ showDotAndDotDot()

bool QDeclarativeFolderListModel::showDotAndDotDot ( ) const

Referenced by setShowDirs().

◆ showOnlyReadable()

bool QDeclarativeFolderListModel::showOnlyReadable ( ) const

Referenced by setShowDotAndDotDot().

◆ sortField()

SortField QDeclarativeFolderListModel::sortField ( ) const

Referenced by componentComplete().

◆ sortReversed()

bool QDeclarativeFolderListModel::sortReversed ( ) const

Referenced by setSortField().

Properties

◆ count

int QDeclarativeFolderListModel::count
private

Definition at line 79 of file qdeclarativefolderlistmodel.h.

◆ d

QDeclarativeFolderListModelPrivate* QDeclarativeFolderListModel::d
private

◆ folder

QUrl QDeclarativeFolderListModel::folder
private

[class begin]

[class props]

Definition at line 71 of file qdeclarativefolderlistmodel.h.

◆ nameFilters

QStringList QDeclarativeFolderListModel::nameFilters
private

Definition at line 73 of file qdeclarativefolderlistmodel.h.

◆ parentFolder

QUrl QDeclarativeFolderListModel::parentFolder
private

Definition at line 72 of file qdeclarativefolderlistmodel.h.

◆ showDirs

bool QDeclarativeFolderListModel::showDirs
private

Definition at line 76 of file qdeclarativefolderlistmodel.h.

◆ showDotAndDotDot

bool QDeclarativeFolderListModel::showDotAndDotDot
private

Definition at line 77 of file qdeclarativefolderlistmodel.h.

◆ showOnlyReadable

bool QDeclarativeFolderListModel::showOnlyReadable
private

Definition at line 78 of file qdeclarativefolderlistmodel.h.

◆ sortField

QDeclarativeFolderListModel::SortField QDeclarativeFolderListModel::sortField
private

Definition at line 74 of file qdeclarativefolderlistmodel.h.

◆ sortReversed

bool QDeclarativeFolderListModel::sortReversed
private

Definition at line 75 of file qdeclarativefolderlistmodel.h.


The documentation for this class was generated from the following files: