KBookmarks 5.109.0
kbookmarkmanager.h
1// -*- c-basic-offset:4; indent-tabs-mode:nil -*-
2/*
3 This file is part of the KDE libraries
4 SPDX-FileCopyrightText: 2000, 2006 David Faure <faure@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-only
7*/
8#ifndef __kbookmarkmanager_h
9#define __kbookmarkmanager_h
10
11#include <QDomDocument>
12#include <QObject>
13#include <QString>
14
15#include <memory>
16
17class KBookmarkManagerPrivate;
18
19#include "kbookmark.h"
20#if KBOOKMARKS_ENABLE_DEPRECATED_SINCE(5, 79)
21#include "kbookmarkowner.h" // for SC reasons
22#endif
23
24class KBookmarkGroup;
25class QDBusMessage;
26
51class KBOOKMARKS_EXPORT KBookmarkManager : public QObject
52{
53 Q_OBJECT
54private:
72 KBOOKMARKS_NO_EXPORT KBookmarkManager(const QString &bookmarksFile, const QString &dbusObjectName);
73
79 KBOOKMARKS_NO_EXPORT explicit KBookmarkManager(const QString &bookmarksFile);
80
84 KBOOKMARKS_NO_EXPORT KBookmarkManager();
85
86public:
91
102
114 void setAutoErrorHandlingEnabled(bool enable, QWidget *parent);
115
120 void setUpdate(bool update);
121
128 // KF6 TODO: Use an enum and not a bool
129 bool saveAs(const QString &filename, bool toolbarCache = true) const;
130
136 bool updateAccessMetadata(const QString &url);
137
138 /*
139 * NB. currently *unimplemented*
140 *
141 * Update favicon url for a given url.
142 * @param url the viewed url
143 * @param faviconurl the favicion url
144 */
145 void updateFavicon(const QString &url, const QString &faviconurl);
146
153 QString path() const;
154
162
170
177 KBookmark findByAddress(const QString &address);
178
184
189 void emitChanged(const KBookmarkGroup &group);
190
199 // KF6 TODO: Use an enum and not a bool
200 bool save(bool toolbarCache = true) const;
201
202 void emitConfigChanged();
203
213 // KF6 TODO: Use an enum and not a bool
214 void setEditorOptions(const QString &caption, bool browser);
215
235 static KBookmarkManager *managerForFile(const QString &bookmarksFile, const QString &dbusObjectName);
236
243 static KBookmarkManager *managerForExternalFile(const QString &bookmarksFile);
244
249
254
258 QDomDocument internalDocument() const;
259
260public Q_SLOTS:
261 void slotEditBookmarks();
262 void slotEditBookmarksAtAddress(const QString &address);
263
270 void notifyCompleteChange(const QString &caller);
271
272#ifndef KBOOKMARKS_NO_DBUS
281 void notifyChanged(const QString &groupAddress, const QDBusMessage &msg);
282#endif
283
284 void notifyConfigChanged();
285
286Q_SIGNALS:
290 void bookmarkCompleteChange(QString caller);
291
295 void bookmarksChanged(QString groupAddress);
296
301
308 void changed(const QString &groupAddress, const QString &caller);
309
314
320 void error(const QString &errorMessage);
321
322private Q_SLOTS:
323 KBOOKMARKS_NO_EXPORT void slotFileChanged(const QString &path); // external bookmarks
324
325private:
326 // consts added to avoid a copy-and-paste of internalDocument
327 KBOOKMARKS_NO_EXPORT void parse() const;
328 KBOOKMARKS_NO_EXPORT void init(const QString &dbusPath);
329
330 KBOOKMARKS_NO_EXPORT void startKEditBookmarks(const QStringList &args);
331
332private:
333 std::unique_ptr<KBookmarkManagerPrivate> const d;
334
335 friend class KBookmarkGroup;
336};
337
338#endif
A group of bookmarks.
Definition kbookmark.h:323
This class implements the reading/writing of bookmarks in XML.
Definition kbookmarkmanager.h:52
void configChanged()
Signals that the config changed.
bool autoErrorHandlingEnabled() const
Check whether auto error handling is enabled.
void setAutoErrorHandlingEnabled(bool enable, QWidget *parent)
Enable or disable auto error handling is enabled.
KBookmark findByAddress(const QString &address)
void notifyChanged(const QString &groupAddress, const QDBusMessage &msg)
Emit the changed signal for the group whose address is given.
static KBookmarkManager * createTempManager()
only used for KBookmarkBar
void emitChanged(const KBookmarkGroup &group)
Saves the bookmark file and notifies everyone.
static KBookmarkManager * managerForFile(const QString &bookmarksFile, const QString &dbusObjectName)
This static function will return an instance of the KBookmarkManager, responsible for the given bookm...
bool updateAccessMetadata(const QString &url)
Update access time stamps for a given url.
KBookmarkGroup toolbar()
This returns the root of the toolbar menu.
void setUpdate(bool update)
Set the update flag.
void bookmarkConfigChanged()
Signal send over D-Bus.
bool save(bool toolbarCache=true) const
Save the bookmarks to an XML file on disk.
QString path() const
This will return the path that this manager is using to read the bookmarks.
void notifyCompleteChange(const QString &caller)
Reparse the whole bookmarks file and notify about the change Doesn't send signal over D-Bus to the ot...
KBookmarkGroup root() const
This will return the root bookmark.
static KBookmarkManager * managerForExternalFile(const QString &bookmarksFile)
Returns a KBookmarkManager, which will use QFileSystemWatcher for change detection This is important ...
static KBookmarkManager * userBookmarksManager()
Returns a pointer to the user's main (konqueror) bookmark collection.
void error(const QString &errorMessage)
Emitted when an error occurs.
bool saveAs(const QString &filename, bool toolbarCache=true) const
Save the bookmarks to the given XML file on disk.
void bookmarksChanged(QString groupAddress)
Signal send over D-Bus.
void bookmarkCompleteChange(QString caller)
Signal send over D-Bus.
~KBookmarkManager() override
Destructor.
void setEditorOptions(const QString &caption, bool browser)
Set options with which slotEditBookmarks called keditbookmarks this can be used to change the appeara...
void emitChanged()
Saves the bookmark file and notifies everyone.
void changed(const QString &groupAddress, const QString &caller)
Signals that the group (or any of its children) with the address groupAddress (e.g.
A class representing a bookmark.
Definition kbookmark.h:28