8#include <QtCore/qloggingcategory.h>
32 bool sortReversed =
false;
33 bool showFiles =
true;
35 bool showDirsFirst =
false;
36 bool showDotAndDotDot =
false;
37 bool showOnlyReadable =
false;
38 bool showHidden =
false;
39 bool caseSensitive =
true;
40 bool sortCaseSensitive =
true;
59 qRegisterMetaType<QList<FileProperty> >(
"QList<FileProperty>");
60 qRegisterMetaType<QQuickFolderListModel::Status>(
"QQuickFolderListModel::Status");
77 QDir::SortFlags
flags;
97 emit q->layoutAboutToBeChanged();
109 qCDebug(lcFolderListModel) <<
"_q_directoryChanged called with directory" <<
directory;
115 qCDebug(lcFolderListModel) <<
"- endResetModel called";
116 emit q->rowCountChanged();
117 emit q->folderChanged();
128 QModelIndex modelIndexFrom =
q->createIndex(fromIndex, 0);
131 emit q->dataChanged(modelIndexFrom, modelIndexTo);
137 if (
data.size() > 0) {
148 emit q->rowCountChanged();
155 qCDebug(lcFolderListModel) <<
"_q_sortFinished called with" <<
list.
size() <<
"files";
158 if (
data.size() > 0) {
159 qCDebug(lcFolderListModel) <<
"- removing all existing rows...";
163 qCDebug(lcFolderListModel) <<
"- ...removed all existing rows";
166 qCDebug(lcFolderListModel) <<
"- inserting sorted rows...";
170 qCDebug(lcFolderListModel) <<
"- ... inserted sorted rows";
179 emit q->statusChanged();
331 if (
index.row() >=
d->data.size())
337 rv =
d->data.at(
index.row()).fileName();
340 rv =
d->data.at(
index.row()).filePath();
343 rv =
d->data.at(
index.row()).baseName();
346 rv =
d->data.at(
index.row()).suffix();
349 rv =
d->data.at(
index.row()).size();
352 rv =
d->data.at(
index.row()).lastModified();
355 rv =
d->data.at(
index.row()).lastRead();
358 rv =
d->data.at(
index.row()).isDir();
387 return d->data.size();
408 return d->currentDir;
420 qCDebug(lcFolderListModel) <<
"about to emit beginResetModel since our folder was set to" <<
folder;
424 if (!
d->currentDir.isEmpty())
425 d->fileInfoThread.removePath(
d->currentDir.path());
441 d->fileInfoThread.setPath(resolvedPath);
471 d->fileInfoThread.setRootPath(resolvedPath);
486 QString localFile =
d->currentDir.toLocalFile();
489 if (
dir.isRoot() || !
dir.cdUp())
491 localFile =
dir.path();
521 return d->nameFilters;
529 d->fileInfoThread.setNameFilters(
filters);
541 if (localPath.
isEmpty() || !
QDir(localPath).exists())
569 if (field !=
d->sortField) {
570 d->sortField = field;
578 return d->roleNames.key(roleName.
toLatin1(), -1);
591 return d->sortReversed;
598 if (rev !=
d->sortReversed) {
599 d->sortReversed = rev;
644 d->fileInfoThread.setShowFiles(on);
670 d->fileInfoThread.setShowDirs(on);
686 return d->showDirsFirst;
693 d->fileInfoThread.setShowDirsFirst(on);
694 d->showDirsFirst = on;
711 return d->showDotAndDotDot;
718 if (on !=
d->showDotAndDotDot) {
719 d->fileInfoThread.setShowDotAndDotDot(on);
720 d->showDotAndDotDot = on;
737 return d->showHidden;
744 if (on !=
d->showHidden) {
745 d->fileInfoThread.setShowHidden(on);
763 return d->showOnlyReadable;
770 if (on !=
d->showOnlyReadable) {
771 d->fileInfoThread.setShowOnlyReadable(on);
772 d->showOnlyReadable = on;
788 return d->caseSensitive;
795 if (on !=
d->caseSensitive) {
796 d->fileInfoThread.setCaseSensitive(on);
797 d->caseSensitive = on;
851 return d->sortCaseSensitive;
858 if (on !=
d->sortCaseSensitive) {
859 d->sortCaseSensitive = on;
886 if (role >= 0 && idx >= 0)
903 return d->data.indexOf(toFind);
909#include "moc_qquickfolderlistmodel_p.cpp"
void setSortFlags(QDir::SortFlags flags)
void endResetModel()
Completes a model reset operation.
void beginResetModel()
Begins a model reset operation.
QModelIndex createIndex(int row, int column, const void *data=nullptr) const
Creates a model index for the given row and column with the internal pointer ptr.
QObject * parent() const
Returns a pointer to the parent object.
static QString cleanPath(const QString &path)
Returns path with directory separators normalized (that is, platform-native separators converted to "...
static QString currentPath()
Returns the absolute path of the application's current directory.
\inmodule QtCore \reentrant
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory.
bool exists() const
Returns true if the file exists; otherwise returns false.
qsizetype size() const noexcept
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
static QString urlToLocalFileOrQrc(const QString &)
If url is a local file returns a path suitable for passing to QFile.
static QString resolvePath(const QUrl &path)
void _q_sortFinished(const QList< FileProperty > &list)
QQuickFolderListModelPrivate(QQuickFolderListModel *q)
QHash< int, QByteArray > roleNames
QQuickFolderListModel::SortField sortField
QList< FileProperty > data
FileInfoThread fileInfoThread
void _q_directoryChanged(const QString &directory, const QList< FileProperty > &list)
void _q_statusChanged(QQuickFolderListModel::Status s)
~QQuickFolderListModelPrivate()
void _q_directoryUpdated(const QString &directory, const QList< FileProperty > &list, int fromIndex, int toIndex)
QQuickFolderListModel * q_ptr
QQuickFolderListModel::Status status
void setFolder(const QUrl &folder)
Q_INVOKABLE QVariant get(int idx, const QString &property) const
\qmlmethod var FolderListModel::get(int index, string property)
void setShowDirs(bool showDirs)
void setShowDirsFirst(bool showDirsFirst)
QHash< int, QByteArray > roleNames() const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the index of the data in row and column with parent.
void setNameFilters(const QStringList &filters)
void rowCountChanged() const
Q_INVOKABLE int indexOf(const QUrl &file) const
\qmlmethod int FolderListModel::indexOf(url file)
void setSortField(SortField field)
void setShowDotAndDotDot(bool on)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void setCaseSensitive(bool on)
Q_INVOKABLE bool isFolder(int index) const
[prop funcs]
void setShowFiles(bool showFiles)
QQuickFolderListModel(QObject *parent=nullptr)
[class props]
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns the data stored under the given role for the item referred to by the index.
void setSortCaseSensitive(bool on)
void setRootFolder(const QUrl &path)
FINALbool sortCaseSensitive
void setSortReversed(bool rev)
void classBegin() override
[parserstatus]
FINALbool showOnlyReadable
void setShowOnlyReadable(bool on)
void setShowHidden(bool on)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
\qmlproperty int FolderListModel::count \readonly
int roleFromString(const QString &roleName) const
[parserstatus]
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
qsizetype size() const
Returns the number of characters in this string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
QString scheme() const
Returns the scheme of the URL.
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
void statusChanged(QDeclarativeComponent::Status status)
[1]
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
GLenum GLenum GLsizei void * row
QLatin1StringView QLatin1String
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
static uint toIndex(ExecutionEngine *e, const Value &v)
QFileInfo info(fileName)
[8]
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
\inmodule QtCore \reentrant
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent