File indexing completed on 2024-05-05 17:04:27

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2012 Boudewijn Rempt <boud@kogmbh.com>
0003  *
0004  *  This program is free software; you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation; either version 2 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program; if not, write to the Free Software
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0017  */
0018 #ifndef RECENTFILESMODEL_H
0019 #define RECENTFILESMODEL_H
0020 
0021 #include <QAbstractListModel>
0022 
0023 
0024 class RecentFilesModel : public QAbstractListModel
0025 {
0026     Q_OBJECT
0027     Q_PROPERTY(QObject* recentFileManager READ recentFileManager WRITE setRecentFileManager NOTIFY recentFileManagerChanged)
0028 public:
0029     enum PresetRoles {
0030         ImageRole = Qt::UserRole + 1,
0031         TextRole,
0032         UrlRole,
0033         NameRole,
0034         DateRole
0035     };
0036 
0037     explicit RecentFilesModel(QObject *parent = 0);
0038     ~RecentFilesModel() override;
0039 
0040     int rowCount(const QModelIndex &parent) const override;
0041     QVariant data(const QModelIndex &index, int role) const override;
0042     QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0043 
0044     QObject* recentFileManager() const;
0045     void setRecentFileManager(QObject* recentFileManager);
0046 
0047 Q_SIGNALS:
0048     void recentFileManagerChanged();
0049 
0050 public Q_SLOTS:
0051 
0052     void addRecent(const QString &fileName);
0053 
0054 private:
0055     class Private;
0056     Private* d;
0057 
0058 private Q_SLOTS:
0059     void recentFilesListChanged();
0060 };
0061 
0062 #endif // RECENTFILESMODEL_H