Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
file_system_model.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2/* SPDX-License-Identifier: LicenseRef-ZrythmLicense */
3
4#pragma once
5
6#include <QFileSystemModel>
7#include <QtQmlIntegration>
8
9namespace zrythm::gui
10{
11class FileSystemModel : public QFileSystemModel
12{
13 Q_OBJECT
14 Q_PROPERTY (
15 QModelIndex rootIndex READ rootIndex WRITE setRootIndex NOTIFY
16 rootIndexChanged)
17 QML_ELEMENT
18
19public:
20 explicit FileSystemModel (QObject * parent = nullptr);
21
22 enum Roles
23 {
24 FileSizeRole = Qt::UserRole + 1
25 };
26
27 Q_INVOKABLE static bool isDir (const QFileInfo * fileInfo)
28 {
29 return fileInfo->isDir ();
30 }
31
32 Q_INVOKABLE QMimeType getFileMimeType (const QString &filePath) const;
33 Q_INVOKABLE QString getFileInfoAsString (const QString &filePath) const;
34
35 QModelIndex rootIndex () const { return root_index_; }
36 void setRootIndex (const QModelIndex &index);
37 Q_SIGNAL void rootIndexChanged ();
38
39 int columnCount (const QModelIndex &parent) const override;
40 QVariant data (const QModelIndex &index, int role) const override;
41 QHash<int, QByteArray> roleNames () const override;
42
43private:
44 QModelIndex root_index_;
45 const QMimeDatabase mime_db_;
46};
47}