| 1 | /* |
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 1999 Reginald Stadlbauer <reggie@kde.org> |
| 4 | SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org> |
| 5 | SPDX-FileCopyrightText: 2000 Nicolas Hadacek <haadcek@kde.org> |
| 6 | SPDX-FileCopyrightText: 2000 Kurt Granroth <granroth@kde.org> |
| 7 | SPDX-FileCopyrightText: 2000 Michael Koch <koch@kde.org> |
| 8 | SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org> |
| 9 | SPDX-FileCopyrightText: 2002 Ellis Whitehead <ellis@kde.org> |
| 10 | SPDX-FileCopyrightText: 2002 Joseph Wenninger <jowenn@kde.org> |
| 11 | SPDX-FileCopyrightText: 2003 Andras Mantia <amantia@kde.org> |
| 12 | SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org> |
| 13 | |
| 14 | SPDX-License-Identifier: LGPL-2.0-only |
| 15 | */ |
| 16 | |
| 17 | #ifndef KRECENTFILESACTION_P_H |
| 18 | #define KRECENTFILESACTION_P_H |
| 19 | |
| 20 | #include "krecentfilesaction.h" |
| 21 | |
| 22 | class KRecentFilesActionPrivate |
| 23 | { |
| 24 | Q_DECLARE_PUBLIC(KRecentFilesAction) |
| 25 | |
| 26 | public: |
| 27 | explicit KRecentFilesActionPrivate(KRecentFilesAction *parent) |
| 28 | : q_ptr(parent) |
| 29 | { |
| 30 | } |
| 31 | |
| 32 | virtual ~KRecentFilesActionPrivate() |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | void init(); |
| 37 | |
| 38 | void urlSelected(QAction *); |
| 39 | |
| 40 | int m_maxItems = 10; |
| 41 | |
| 42 | struct RecentActionInfo { |
| 43 | QAction *action = nullptr; |
| 44 | QUrl url; |
| 45 | QString shortName; |
| 46 | QMimeType mimeType; |
| 47 | }; |
| 48 | std::vector<RecentActionInfo> m_recentActions; |
| 49 | |
| 50 | std::vector<RecentActionInfo>::iterator findByUrl(const QUrl &url) |
| 51 | { |
| 52 | return std::find_if(first: m_recentActions.begin(), last: m_recentActions.end(), pred: [&url](const RecentActionInfo &info) { |
| 53 | return info.url == url; |
| 54 | }); |
| 55 | } |
| 56 | |
| 57 | std::vector<RecentActionInfo>::iterator findByAction(const QAction *action) |
| 58 | { |
| 59 | return std::find_if(first: m_recentActions.begin(), last: m_recentActions.end(), pred: [action](const RecentActionInfo &info) { |
| 60 | return info.action == action; |
| 61 | }); |
| 62 | } |
| 63 | |
| 64 | void removeAction(std::vector<RecentActionInfo>::iterator it); |
| 65 | |
| 66 | QAction *m_noEntriesAction = nullptr; |
| 67 | QAction *clearSeparator = nullptr; |
| 68 | QAction *clearAction = nullptr; |
| 69 | |
| 70 | KRecentFilesAction *const q_ptr; |
| 71 | }; |
| 72 | |
| 73 | #endif // KRECENTFILESACTION_P_H |
| 74 | |