File indexing completed on 2024-04-28 08:50:37

0001 /* This file is part of the KDE project
0002     SPDX-FileCopyrightText: 2000 Simon Hausmann <hausmann@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef __konq_actions_h__
0008 #define __konq_actions_h__
0009 
0010 #include <ktoolbarpopupaction.h>
0011 #include <konqhistorymanager.h>
0012 #include <kactionmenu.h>
0013 #include <QList>
0014 
0015 struct HistoryEntry;
0016 class QMenu;
0017 
0018 namespace KonqActions
0019 {
0020 void fillHistoryPopup(const QList<HistoryEntry *> &history, int historyIndex,
0021                       QMenu *popup,
0022                       bool onlyBack,
0023                       bool onlyForward);
0024 }
0025 
0026 #if 0
0027 /**
0028  * Plug this action into a menu to get a bidirectional history
0029  * (both back and forward, including current location)
0030  */
0031 class KonqBidiHistoryAction : public KToolBarPopupAction
0032 {
0033     Q_OBJECT
0034 public:
0035     KonqBidiHistoryAction(const QString &text, QObject *parent);
0036     virtual ~KonqBidiHistoryAction();
0037 
0038     void fillGoMenu(const QList<HistoryEntry *> &history, int historyIndex);
0039 
0040 protected Q_SLOTS:
0041     void slotTriggered(QAction *action);
0042 
0043 Q_SIGNALS:
0044     void menuAboutToShow();
0045     // -1 for one step back, 0 for don't move, +1 for one step forward, etc.
0046     void step(int);
0047 private:
0048     int m_startPos;
0049     int m_currentPos; // == history.at()
0050 };
0051 
0052 #endif
0053 
0054 /////
0055 
0056 class KonqMostOftenURLSAction : public KActionMenu
0057 {
0058     Q_OBJECT
0059 
0060 public:
0061     KonqMostOftenURLSAction(const QString &text, QObject *parent);
0062     ~KonqMostOftenURLSAction() override;
0063 
0064     static bool numberOfVisitOrder(const KonqHistoryEntry &lhs, const KonqHistoryEntry &rhs)
0065     {
0066         return lhs.numberOfTimesVisited < rhs.numberOfTimesVisited;
0067     }
0068 
0069 Q_SIGNALS:
0070     void activated(const QUrl &);
0071 
0072 private Q_SLOTS:
0073     void slotHistoryCleared();
0074     void slotEntryAdded(const KonqHistoryEntry &entry);
0075     void slotEntryRemoved(const KonqHistoryEntry &entry);
0076 
0077     void slotFillMenu();
0078     void slotActivated(QAction *action);
0079 
0080 private:
0081     void init();
0082     void parseHistory();
0083     static void inSort(const KonqHistoryEntry &entry);
0084     bool m_parsingDone;
0085 };
0086 
0087 /////
0088 
0089 class KonqHistoryAction : public KActionMenu
0090 {
0091     Q_OBJECT
0092 
0093 public:
0094     KonqHistoryAction(const QString &text, QObject *parent);
0095     ~KonqHistoryAction() override;
0096 
0097 Q_SIGNALS:
0098     void activated(const QUrl &);
0099 
0100 private Q_SLOTS:
0101     void slotFillMenu();
0102     void slotActivated(QAction *action);
0103 };
0104 
0105 #endif