File indexing completed on 2025-12-07 04:19:09
0001 /* This file is part of the KDE project 0002 * 0003 * SPDX-FileCopyrightText: 2012 Arjen Hiemstra <ahiemstra@heimr.nl> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 0009 0010 #ifndef CALLIGRAMOBILE_FILESYSTEMMODEL_H 0011 #define CALLIGRAMOBILE_FILESYSTEMMODEL_H 0012 0013 #include <QQmlParserStatus> 0014 0015 #include <QAbstractListModel> 0016 0017 class FileSystemModel : public QAbstractListModel, public QQmlParserStatus 0018 { 0019 Q_OBJECT 0020 Q_INTERFACES(QQmlParserStatus) 0021 0022 Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) 0023 Q_PROPERTY(QString parentFolder READ parentFolder) 0024 Q_PROPERTY(QString filter READ filter WRITE setFilter) 0025 0026 public: 0027 enum FileRoles { 0028 FileNameRole = Qt::UserRole, 0029 FilePathRole, 0030 FileIconRole, 0031 FileDateRole 0032 }; 0033 0034 explicit FileSystemModel(QObject *parent = nullptr); 0035 ~FileSystemModel() override; 0036 0037 QVariant data(const QModelIndex &index, 0038 int role = Qt::DisplayRole) const override; 0039 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0040 0041 void classBegin() override; 0042 void componentComplete() override; 0043 0044 virtual QString path(); 0045 virtual void setPath(const QString& path); 0046 0047 virtual QString parentFolder(); 0048 0049 virtual QString filter(); 0050 virtual void setFilter(const QString& filter); 0051 0052 QHash<int, QByteArray> roleNames() const override; 0053 0054 Q_SIGNALS: 0055 void pathChanged(); 0056 0057 private: 0058 class Private; 0059 Private * const d; 0060 }; 0061 0062 #endif // CALLIGRAMOBILE_FILESYSTEMMODEL_H