File indexing completed on 2024-05-12 05:00:20

0001 /* This file is part of the KDE project
0002     SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #ifndef bookmark_module_h
0008 #define bookmark_module_h
0009 
0010 #include <QMap>
0011 #include <QObject>
0012 
0013 #include <konq_sidebartreemodule.h>
0014 #include <kdialog.h>
0015 #include <klocale.h>
0016 
0017 class KActionCollection;
0018 class KLineEdit;
0019 class KBookmarkGroup;
0020 class KonqSidebarBookmarkItem;
0021 
0022 /**
0023  * This module displays bookmarks in the tree
0024  */
0025 class KonqSidebarBookmarkModule : public QObject, public KonqSidebarTreeModule
0026 {
0027     Q_OBJECT
0028 public:
0029     KonqSidebarBookmarkModule(KonqSidebarTree *parentTree);
0030     virtual ~KonqSidebarBookmarkModule();
0031 
0032     // Handle this new toplevel item [can only be called once currently]
0033     virtual void addTopLevelItem(KonqSidebarTreeTopLevelItem *item);
0034     virtual bool handleTopLevelContextMenu(KonqSidebarTreeTopLevelItem *, const QPoint &);
0035 
0036     void showPopupMenu();
0037 
0038 protected Q_SLOTS:
0039     void slotBookmarksChanged(const QString &);
0040     void slotMoved(Q3ListViewItem *, Q3ListViewItem *, Q3ListViewItem *);
0041     void slotDropped(K3ListView *, QDropEvent *, Q3ListViewItem *, Q3ListViewItem *);
0042     void slotCreateFolder();
0043     void slotDelete();
0044     void slotProperties(KonqSidebarBookmarkItem *bi = 0);
0045     void slotOpenNewWindow();
0046     void slotOpenTab();
0047     void slotCopyLocation();
0048 
0049 protected:
0050     void fillListView();
0051     void fillGroup(KonqSidebarTreeItem *parentItem, const KBookmarkGroup &group);
0052     KonqSidebarBookmarkItem *findByAddress(const QString &address) const;
0053 
0054 private Q_SLOTS:
0055     void slotOpenChange(Q3ListViewItem *);
0056 
0057 private:
0058     KonqSidebarTreeTopLevelItem *m_topLevelItem;
0059     KonqSidebarBookmarkItem *m_rootItem;
0060 
0061     KActionCollection *m_collection;
0062 
0063     bool m_ignoreOpenChange;
0064     QMap<QString, bool> m_folderOpenState;
0065 };
0066 
0067 class BookmarkEditDialog : public KDialog
0068 {
0069     Q_OBJECT
0070 
0071 public:
0072     BookmarkEditDialog(const QString &title, const QString &url,
0073                        QWidget * = nullptr, const char * = nullptr,
0074                        const QString &caption = i18nc("@title:window", "Add Bookmark"));
0075 
0076     QString finalUrl() const;
0077     QString finalTitle() const;
0078 
0079 private:
0080     KLineEdit *m_title, *m_location;
0081 };
0082 
0083 #endif