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/>
22 #include <kxmlguiwindow.h>
23 #include <k3command.h>
24 #include <kbookmark.h>
25 #include <QtGui/QMenu>
26 #include <kxmlguifactory.h>
27 #include "bookmarklistview.h"
30 class KBookmarkManager
;
32 class KBookmarkEditorIface
;
33 class BookmarkInfoWidget
;
34 class BookmarkListView
;
36 struct SelcAbilities
{
48 class CmdHistory
: public QObject
{
51 CmdHistory(KActionCollection
*collection
);
52 virtual ~CmdHistory() {}
54 void notifyDocSaved();
57 void addCommand(K3Command
*);
58 void didCommand(K3Command
*);
60 //For an explanation see bookmarkInfo::commitChanges()
61 void addInFlightCommand(K3Command
*);
63 static CmdHistory
*self();
66 void slotCommandExecuted(K3Command
*k
);
69 K3CommandHistory m_commandHistory
;
70 static CmdHistory
*s_self
;
74 class KBookmarkManager
;
76 class CurrentMgr
: public QObject
{
79 typedef enum {HTMLExport
, OperaExport
, IEExport
, MozillaExport
, NetscapeExport
} ExportType
;
81 static CurrentMgr
* self() { if (!s_mgr
) { s_mgr
= new CurrentMgr(); } return s_mgr
; }
83 KBookmarkGroup
root();
84 static KBookmark
bookmarkAt(const QString
& a
);
86 KBookmarkModel
* model() const { return m_model
; }
87 KBookmarkManager
* mgr() const { return m_mgr
; }
90 void createManager(const QString
&filename
, const QString
&dbusObjectName
);
91 void notifyManagers(const KBookmarkGroup
& grp
);
92 void notifyManagers();
94 void saveAs(const QString
&fileName
);
95 void doExport(ExportType type
, const QString
& path
= QString());
96 void setUpdate(bool update
);
100 static QString
makeTimeStr(const QString
&);
101 static QString
makeTimeStr(int);
104 void slotBookmarksChanged(const QString
&, const QString
&);
108 KBookmarkManager
*m_mgr
;
109 KBookmarkModel
*m_model
;
110 static CurrentMgr
*s_mgr
;
114 class KEBApp
: public KXmlGuiWindow
{
116 Q_CLASSINFO("D-Bus Interface", "org.kde.keditbookmarks")
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
);
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
; }
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;
167 Q_SCRIPTABLE QString
bookmarkFilename();
170 void slotConfigureToolbars();
173 void slotClipboardDataChanged();
174 void slotNewToolbarConfig();
175 void selectionChanged();
178 void selectedBookmarksExpandedHelper(const KBookmark
& bk
,
179 KBookmark::List
& bookmarks
) const;
180 BookmarkListView
* mBookmarkListView
;
181 BookmarkFolderView
* mBookmarkFolderView
;
185 void createActions();
187 static KEBApp
*s_topLevel
;
189 CmdHistory
*m_cmdHistory
;
190 QString m_bookmarksFilename
;
192 QString m_dbusObjectName
;
194 BookmarkInfoWidget
*m_bkinfo
;