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 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>
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 (QObject * parent = nullptr);
31
32 int rowCount (const QModelIndex &parent = QModelIndex ()) const override;
33 QVariant
34 data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
35 QHash<int, QByteArray> roleNames () const override;
36
37 Q_INVOKABLE void addRecentProject (const QString &path);
38 Q_INVOKABLE void removeRecentProject (const QString &path);
39 Q_INVOKABLE void clearRecentProjects ();
40
41private:
42 static std::vector<std::unique_ptr<ProjectInfo>> get_recent_projects ();
43 static void store_recent_projects (const QStringList &list);
44
45 static constexpr int MAX_RECENT_DOCUMENTS = 12;
46};
47
48} // namespace zrythm::gui