File indexing completed on 2024-04-14 03:51:15

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 1999 Reginald Stadlbauer <reggie@kde.org>
0004     SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org>
0005     SPDX-FileCopyrightText: 2000 Nicolas Hadacek <haadcek@kde.org>
0006     SPDX-FileCopyrightText: 2000 Kurt Granroth <granroth@kde.org>
0007     SPDX-FileCopyrightText: 2000 Michael Koch <koch@kde.org>
0008     SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org>
0009     SPDX-FileCopyrightText: 2002 Ellis Whitehead <ellis@kde.org>
0010     SPDX-FileCopyrightText: 2002 Joseph Wenninger <jowenn@kde.org>
0011     SPDX-FileCopyrightText: 2003 Andras Mantia <amantia@kde.org>
0012     SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org>
0013 
0014     SPDX-License-Identifier: LGPL-2.0-only
0015 */
0016 
0017 #ifndef KRECENTFILESACTION_P_H
0018 #define KRECENTFILESACTION_P_H
0019 
0020 #include "krecentfilesaction.h"
0021 
0022 class KRecentFilesActionPrivate
0023 {
0024     Q_DECLARE_PUBLIC(KRecentFilesAction)
0025 
0026 public:
0027     explicit KRecentFilesActionPrivate(KRecentFilesAction *parent)
0028         : q_ptr(parent)
0029     {
0030     }
0031 
0032     virtual ~KRecentFilesActionPrivate()
0033     {
0034     }
0035 
0036     void init();
0037 
0038     void urlSelected(QAction *);
0039 
0040     int m_maxItems = 10;
0041 
0042     struct RecentActionInfo {
0043         QAction *action = nullptr;
0044         QUrl url;
0045         QString shortName;
0046     };
0047     std::vector<RecentActionInfo> m_recentActions;
0048 
0049     std::vector<RecentActionInfo>::iterator findByUrl(const QUrl &url)
0050     {
0051         return std::find_if(m_recentActions.begin(), m_recentActions.end(), [&url](const RecentActionInfo &info) {
0052             return info.url == url;
0053         });
0054     }
0055 
0056     std::vector<RecentActionInfo>::iterator findByAction(const QAction *action)
0057     {
0058         return std::find_if(m_recentActions.begin(), m_recentActions.end(), [action](const RecentActionInfo &info) {
0059             return info.action == action;
0060         });
0061     }
0062 
0063     void removeAction(std::vector<RecentActionInfo>::iterator it);
0064 
0065     QAction *m_noEntriesAction = nullptr;
0066     QAction *clearSeparator = nullptr;
0067     QAction *clearAction = nullptr;
0068 
0069     KRecentFilesAction *const q_ptr;
0070 };
0071 
0072 #endif // KRECENTFILESACTION_P_H