Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / keditbookmarks / toplevel.h
blob536d3619d7a1c96c4b992682727cf67e82426c9e
1 /* This file is part of the KDE project
2 Copyright (C) 2000 David Faure <faure@kde.org>
3 Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License, or (at your option) version 3.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>
19 #ifndef __toplevel_h
20 #define __toplevel_h
22 #include <kxmlguiwindow.h>
23 #include <k3command.h>
24 #include <kbookmark.h>
25 #include <QtGui/QMenu>
26 #include <kxmlguifactory.h>
27 #include "bookmarklistview.h"
29 class KBookmarkModel;
30 class KBookmarkManager;
31 class KToggleAction;
32 class KBookmarkEditorIface;
33 class BookmarkInfoWidget;
34 class BookmarkListView;
36 struct SelcAbilities {
37 bool itemSelected:1;
38 bool group:1;
39 bool root:1;
40 bool separator:1;
41 bool urlIsEmpty:1;
42 bool multiSelect:1;
43 bool singleSelect:1;
44 bool notEmpty:1;
45 bool deleteEnabled:1;
48 class CmdHistory : public QObject {
49 Q_OBJECT
50 public:
51 CmdHistory(KActionCollection *collection);
52 virtual ~CmdHistory() {}
54 void notifyDocSaved();
56 void clearHistory();
57 void addCommand(K3Command *);
58 void didCommand(K3Command *);
60 //For an explanation see bookmarkInfo::commitChanges()
61 void addInFlightCommand(K3Command *);
63 static CmdHistory *self();
65 protected Q_SLOTS:
66 void slotCommandExecuted(K3Command *k);
68 private:
69 K3CommandHistory m_commandHistory;
70 static CmdHistory *s_self;
73 class KBookmark;
74 class KBookmarkManager;
76 class CurrentMgr : public QObject {
77 Q_OBJECT
78 public:
79 typedef enum {HTMLExport, OperaExport, IEExport, MozillaExport, NetscapeExport} ExportType;
81 static CurrentMgr* self() { if (!s_mgr) { s_mgr = new CurrentMgr(); } return s_mgr; }
82 ~CurrentMgr();
83 KBookmarkGroup root();
84 static KBookmark bookmarkAt(const QString & a);
86 KBookmarkModel* model() const { return m_model; }
87 KBookmarkManager* mgr() const { return m_mgr; }
88 QString path() const;
90 void createManager(const QString &filename, const QString &dbusObjectName);
91 void notifyManagers(const KBookmarkGroup& grp);
92 void notifyManagers();
93 bool managerSave();
94 void saveAs(const QString &fileName);
95 void doExport(ExportType type, const QString & path = QString());
96 void setUpdate(bool update);
98 void reloadConfig();
100 static QString makeTimeStr(const QString &);
101 static QString makeTimeStr(int);
103 protected Q_SLOTS:
104 void slotBookmarksChanged(const QString &, const QString &);
106 private:
107 CurrentMgr();
108 KBookmarkManager *m_mgr;
109 KBookmarkModel *m_model;
110 static CurrentMgr *s_mgr;
111 uint ignorenext;
114 class KEBApp : public KXmlGuiWindow {
115 Q_OBJECT
116 Q_CLASSINFO("D-Bus Interface", "org.kde.keditbookmarks")
117 public:
118 static KEBApp* self() { return s_topLevel; }
120 KEBApp(const QString & bookmarksFile, bool readonly, const QString &address, bool browser, const QString &caption, const QString& dbusObjectName);
121 virtual ~KEBApp();
123 void reset(const QString & caption, const QString & bookmarksFileName);
125 void updateActions();
126 void updateStatus(const QString &url);
127 SelcAbilities getSelectionAbilities() const;
128 void setActionsEnabled(SelcAbilities);
130 void setCancelFavIconUpdatesEnabled(bool);
131 void setCancelTestsEnabled(bool);
133 void notifyCommandExecuted();
134 void findURL(QString url);
136 QMenu* popupMenuFactory(const char *type)
138 QWidget * menu = factory()->container(type, this);
139 return dynamic_cast<QMenu *>(menu);
142 KToggleAction* getToggleAction(const char *) const;
144 QString caption() const { return m_caption; }
145 bool readonly() const { return m_readOnly; }
146 bool browser() const { return m_browser; }
147 bool nsShown() const;
149 BookmarkInfoWidget *bkInfo() { return m_bkinfo; }
151 void expandAll();
152 void collapseAll();
154 enum Column {
155 NameColumn = 0,
156 UrlColumn = 1,
157 CommentColumn = 2,
158 StatusColumn = 3
160 void startEdit( Column c );
161 KBookmark firstSelected() const;
162 QString insertAddress() const;
163 KBookmark::List selectedBookmarks() const;
164 KBookmark::List selectedBookmarksExpanded() const;
165 KBookmark::List allBookmarks() const;
166 public Q_SLOTS:
167 Q_SCRIPTABLE QString bookmarkFilename();
169 public Q_SLOTS:
170 void slotConfigureToolbars();
172 protected Q_SLOTS:
173 void slotClipboardDataChanged();
174 void slotNewToolbarConfig();
175 void selectionChanged();
177 private:
178 void selectedBookmarksExpandedHelper(const KBookmark& bk,
179 KBookmark::List & bookmarks) const;
180 BookmarkListView * mBookmarkListView;
181 BookmarkFolderView * mBookmarkFolderView;
182 private:
184 void resetActions();
185 void createActions();
187 static KEBApp *s_topLevel;
189 CmdHistory *m_cmdHistory;
190 QString m_bookmarksFilename;
191 QString m_caption;
192 QString m_dbusObjectName;
194 BookmarkInfoWidget *m_bkinfo;
196 bool m_canPaste:1;
197 bool m_readOnly:1;
198 bool m_browser:1;
201 #endif