Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
recent_projects_model.h
1// SPDX-FileCopyrightText: © 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "project_info.h"
7#include "utils/app_settings.h"
8
9#include <QAbstractListModel>
10#include <QQmlEngine>
11#include <QStringList>
12#include <QtQmlIntegration/qqmlintegration.h>
13
14namespace zrythm::gui
15{
16
17class RecentProjectsModel : public QAbstractListModel
18{
19 Q_OBJECT
20 QML_ELEMENT
21 QML_UNCREATABLE ("")
22
23public:
24 enum RecentProjectRoles
25 {
26 NameRole = Qt::UserRole + 1,
27 PathRole,
28 DateRole,
29 };
30
31 explicit RecentProjectsModel (
32 utils::AppSettings &app_settings,
33 QObject * parent = nullptr);
34
35 int rowCount (const QModelIndex &parent = QModelIndex ()) const override;
36 QVariant
37 data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
38 QHash<int, QByteArray> roleNames () const override;
39
40 Q_INVOKABLE void addRecentProject (const QString &path);
41 Q_INVOKABLE void removeRecentProject (const QString &path);
42 Q_INVOKABLE void clearRecentProjects ();
43 Q_INVOKABLE void clearNonExistingProjects ();
44
45private:
46 std::vector<std::unique_ptr<ProjectInfo>> get_recent_projects () const;
47 void store_recent_projects (const QStringList &list);
48
49 static constexpr int MAX_RECENT_DOCUMENTS = 12;
50
51private:
52 utils::AppSettings &app_settings_;
53};
54
55} // namespace zrythm::gui