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
8#include <QAbstractListModel>
9#include <QQmlEngine>
10#include <QStringList>
11#include <QtQmlIntegration/qqmlintegration.h>
12
13namespace zrythm::gui
14{
15
16class RecentProjectsModel : public QAbstractListModel
17{
18 Q_OBJECT
19 QML_ELEMENT
20 QML_UNCREATABLE ("")
21
22public:
23 enum RecentProjectRoles
24 {
25 NameRole = Qt::UserRole + 1,
26 PathRole,
27 DateRole,
28 };
29
30 explicit RecentProjectsModel (
31 utils::AppSettings &app_settings,
32 QObject * parent = nullptr);
33
34 int rowCount (const QModelIndex &parent = QModelIndex ()) const override;
35 QVariant
36 data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
37 QHash<int, QByteArray> roleNames () const override;
38
39 Q_INVOKABLE void addRecentProject (const QString &path);
40 Q_INVOKABLE void removeRecentProject (const QString &path);
41 Q_INVOKABLE void clearRecentProjects ();
42
43private:
44 std::vector<std::unique_ptr<ProjectInfo>> get_recent_projects () const;
45 void store_recent_projects (const QStringList &list);
46
47 static constexpr int MAX_RECENT_DOCUMENTS = 12;
48
49private:
50 utils::AppSettings &app_settings_;
51};
52
53} // namespace zrythm::gui