File indexing completed on 2024-04-21 05:50:23

0001 /* This file is part of the KDE project
0002    Copyright (C) 2000 David Faure <faure@kde.org>
0003    Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>
0004 
0005    This program is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU General Public License as
0007    published by the Free Software Foundation; either version 2 of
0008    the License, or (at your option) version 3.
0009 
0010    This program is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013    GNU General Public License for more details.
0014 
0015    You should have received a copy of the GNU General Public License
0016    along with this program.  If not, see <http://www.gnu.org/licenses/>
0017 */
0018 
0019 #ifndef __toplevel_h
0020 #define __toplevel_h
0021 
0022 #include "bookmarklistview.h"
0023 #include <KBookmark>
0024 #include <KXMLGUIFactory>
0025 #include <QMenu>
0026 #include <kxmlguiwindow.h>
0027 
0028 class ActionsImpl;
0029 class CommandHistory;
0030 class KToggleAction;
0031 class BookmarkInfoWidget;
0032 class BookmarkListView;
0033 
0034 struct SelcAbilities {
0035     bool itemSelected : 1;
0036     bool group : 1;
0037     bool root : 1;
0038     bool separator : 1;
0039     bool urlIsEmpty : 1;
0040     bool multiSelect : 1;
0041     bool singleSelect : 1;
0042     bool notEmpty : 1;
0043     bool deleteEnabled : 1;
0044 };
0045 
0046 class KEBApp : public KXmlGuiWindow
0047 {
0048     Q_OBJECT
0049     Q_CLASSINFO("D-Bus Interface", "org.kde.keditbookmarks")
0050 public:
0051     static KEBApp *self()
0052     {
0053         return s_topLevel;
0054     }
0055 
0056     KEBApp(const QString &bookmarksFile, bool readonly, const QString &address, bool browser, const QString &caption, const QString &dbusObjectName);
0057     ~KEBApp() override;
0058 
0059     void reset(const QString &caption, const QString &bookmarksFileName);
0060 
0061     void updateActions();
0062     SelcAbilities getSelectionAbilities() const;
0063     void setActionsEnabled(SelcAbilities);
0064 
0065     QMenu *popupMenuFactory(const QString &type)
0066     {
0067         QWidget *menu = factory()->container(type, this);
0068         return dynamic_cast<QMenu *>(menu);
0069     }
0070 
0071     QString caption() const
0072     {
0073         return m_caption;
0074     }
0075     bool readonly() const
0076     {
0077         return m_readOnly;
0078     }
0079     bool browser() const
0080     {
0081         return m_browser;
0082     }
0083 
0084     BookmarkInfoWidget *bkInfo()
0085     {
0086         return m_bkinfo;
0087     }
0088 
0089     void expandAll();
0090     void collapseAll();
0091 
0092     enum Column { NameColumn = 0, UrlColumn = 1, CommentColumn = 2, StatusColumn = 3 };
0093     void startEdit(Column c);
0094     KBookmark firstSelected() const;
0095     QString insertAddress() const;
0096     KBookmark::List selectedBookmarks() const;
0097     KBookmark::List selectedBookmarksExpanded() const;
0098     KBookmark::List allBookmarks() const;
0099 
0100 public Q_SLOTS:
0101     void notifyCommandExecuted();
0102 
0103     Q_SCRIPTABLE QString bookmarkFilename();
0104 
0105 public Q_SLOTS:
0106     void slotConfigureToolbars();
0107 
0108 private Q_SLOTS:
0109     void slotClipboardDataChanged();
0110     void slotNewToolbarConfig();
0111     void selectionChanged();
0112     void setCancelFavIconUpdatesEnabled(bool);
0113     void setCancelTestsEnabled(bool);
0114     void slotManagerError(const QString &errorMessage);
0115 
0116 private:
0117     void selectedBookmarksExpandedHelper(const KBookmark &bk, KBookmark::List &bookmarks) const;
0118     BookmarkListView *mBookmarkListView;
0119     BookmarkFolderView *mBookmarkFolderView;
0120 
0121 private:
0122     void resetActions();
0123     void createActions();
0124 
0125     static KEBApp *s_topLevel;
0126 
0127     ActionsImpl *m_actionsImpl;
0128     CommandHistory *m_cmdHistory;
0129     QString m_bookmarksFilename;
0130     QString m_caption;
0131     QString m_dbusObjectName;
0132 
0133     BookmarkInfoWidget *m_bkinfo;
0134 
0135     bool m_canPaste : 1;
0136     bool m_readOnly : 1;
0137     bool m_browser : 1;
0138 };
0139 
0140 #endif