2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#ifndef FILELISTMODEL_H
|
|
|
|
#define FILELISTMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
2021-04-22 09:29:08 +00:00
|
|
|
#include <QFileInfoList>
|
|
|
|
#include <QFileIconProvider>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
//![0]
|
|
|
|
class FileListModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-11-24 16:29:15 +00:00
|
|
|
FileListModel(QObject *parent = nullptr);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2016-06-15 08:12:35 +00:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2021-04-22 09:29:08 +00:00
|
|
|
QFileInfo fileInfoAt(const QModelIndex &) const;
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
signals:
|
2021-04-22 09:29:08 +00:00
|
|
|
void numberPopulated(const QString &path, int start, int number, int total);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setDirPath(const QString &path);
|
|
|
|
|
|
|
|
protected:
|
2016-06-15 08:12:35 +00:00
|
|
|
bool canFetchMore(const QModelIndex &parent) const override;
|
|
|
|
void fetchMore(const QModelIndex &parent) override;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
private:
|
2021-04-22 09:29:08 +00:00
|
|
|
QFileInfoList fileList;
|
|
|
|
QString path;
|
|
|
|
QFileIconProvider iconProvider;
|
|
|
|
int fileCount = 0;
|
2011-04-27 10:05:43 +00:00
|
|
|
};
|
|
|
|
//![0]
|
|
|
|
|
2012-11-22 12:40:51 +00:00
|
|
|
#endif // FILELISTMODEL_H
|