File indexing completed on 2024-04-28 17:05:52

0001 /*
0002     SPDX-FileCopyrightText: 2002 Shie Erlich <erlich@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2002 Rafi Yanai <yanai@users.sourceforge.net>
0004     SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef KRBOOKMARK_H
0010 #define KRBOOKMARK_H
0011 
0012 // QtCore
0013 #include <QList>
0014 #include <QUrl>
0015 // QtWidgets
0016 #include <QAction>
0017 
0018 class KActionCollection;
0019 class ListPanelActions;
0020 
0021 class KrBookmark : public QAction
0022 {
0023     Q_OBJECT
0024 public:
0025     KrBookmark(const QString &name, QUrl url, KActionCollection *parent, const QString &iconName = "", const QString &actionName = QString());
0026     explicit KrBookmark(const QString &name, const QString &iconName = ""); // creates a folder
0027     ~KrBookmark() override;
0028 
0029     // text() and setText() to change the name of the bookmark
0030     // icon() and setIcon() to change icons
0031 
0032     void setIconName(const QString &iconName);
0033 
0034     inline const QString &iconName() const
0035     {
0036         return _iconName;
0037     }
0038 
0039     inline const QUrl &url() const
0040     {
0041         return _url;
0042     }
0043     inline void setURL(const QUrl &url)
0044     {
0045         _url = url;
0046     }
0047     inline bool isFolder() const
0048     {
0049         return _folder;
0050     }
0051     inline bool isSeparator() const
0052     {
0053         return _separator;
0054     }
0055     QList<KrBookmark *> &children()
0056     {
0057         return _children;
0058     }
0059 
0060     static KrBookmark *getExistingBookmark(const QString &actionName, KActionCollection *collection);
0061 
0062     // ----- special bookmarks
0063     static KrBookmark *trash(KActionCollection *collection);
0064     static KrBookmark *virt(KActionCollection *collection);
0065     static KrBookmark *lan(KActionCollection *collection);
0066     static QAction *jumpBackAction(KActionCollection *collection, bool isSetter = false, ListPanelActions *sourceActions = nullptr);
0067     static KrBookmark *separator();
0068 
0069 signals:
0070     void activated(const QUrl &url);
0071 
0072 protected slots:
0073     void activatedProxy();
0074 
0075 private:
0076     QUrl _url;
0077     QString _iconName;
0078     bool _folder;
0079     bool _separator;
0080     bool _autoDelete;
0081     QList<KrBookmark *> _children;
0082 };
0083 
0084 #endif // KRBOOKMARK_H