File indexing completed on 2025-04-27 04:08:16
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 RECENTIMAGESMODEL_H 0007 #define RECENTIMAGESMODEL_H 0008 0009 #include <QAbstractListModel> 0010 0011 0012 class RecentImagesModel : 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 RecentImagesModel(QObject *parent = nullptr); 0026 ~RecentImagesModel() override; 0027 QHash<int, QByteArray> roleNames() const override; 0028 int rowCount(const QModelIndex &parent) const override; 0029 QVariant data(const QModelIndex &index, int role) const override; 0030 QVariant headerData(int section, 0031 Qt::Orientation orientation, 0032 int role) const override; 0033 0034 QObject* recentFileManager() const; 0035 void setRecentFileManager(QObject* recentFileManager); 0036 0037 Q_SIGNALS: 0038 void recentFileManagerChanged(); 0039 0040 public Q_SLOTS: 0041 0042 void addRecent(const QString &fileName); 0043 0044 private: 0045 class Private; 0046 Private* d; 0047 0048 private Q_SLOTS: 0049 void recentFilesListChanged(); 0050 }; 0051 0052 #endif // RECENTIMAGESMODEL_H