File indexing completed on 2024-05-26 12:48:12
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2012 Boudewijn Rempt <boud@kogmbh.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef RECENTFILESMODEL_H 0007 #define RECENTFILESMODEL_H 0008 0009 #include <QAbstractListModel> 0010 0011 0012 class RecentFilesModel : public QAbstractListModel 0013 { 0014 Q_OBJECT 0015 Q_PROPERTY(QObject* recentFileManager READ recentFileManager WRITE setRecentFileManager NOTIFY recentFileManagerChanged) 0016 public: 0017 enum PresetRoles { 0018 ImageRole = Qt::UserRole + 1, 0019 TextRole, 0020 UrlRole, 0021 NameRole, 0022 DateRole 0023 }; 0024 0025 explicit RecentFilesModel(QObject *parent = 0); 0026 ~RecentFilesModel() override; 0027 0028 QHash<int, QByteArray> roleNames() const override; 0029 int rowCount(const QModelIndex &parent) const override; 0030 QVariant data(const QModelIndex &index, int role) const override; 0031 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0032 0033 QObject* recentFileManager() const; 0034 void setRecentFileManager(QObject* recentFileManager); 0035 0036 Q_SIGNALS: 0037 void recentFileManagerChanged(); 0038 0039 public Q_SLOTS: 0040 0041 void addRecent(const QString &fileName); 0042 0043 private: 0044 class Private; 0045 Private* d; 0046 0047 private Q_SLOTS: 0048 void recentFilesListChanged(); 0049 }; 0050 0051 #endif // RECENTFILESMODEL_H