File indexing completed on 2024-05-19 03:55:15
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2007 Daniel Teske <teske@squorn.de> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 #ifndef __kbookmarkdialog_h 0008 #define __kbookmarkdialog_h 0009 0010 #include "kbookmark.h" 0011 #include "kbookmarkowner.h" 0012 #include <kbookmarkswidgets_export.h> 0013 0014 #include <QDialog> 0015 #include <memory> 0016 0017 class KBookmarkManager; 0018 class KBookmarkDialogPrivate; 0019 0020 /** 0021 * @class KBookmarkDialog kbookmarkdialog.h KBookmarkDialog 0022 * 0023 * This class provides a Dialog for editing properties, adding Bookmarks and creating new folders. 0024 * It can be used to show dialogs for common tasks with bookmarks. 0025 * 0026 * It is used by KBookmarkMenu to show a dialog for "Properties", "Add Bookmark" and "Create New Folder". 0027 * If you want to customize those dialogs, derive from KBookmarkOwner and reimplement bookmarkDialog(), 0028 * return a KBookmarkDialog subclass and reimplement initLayout(), aboutToShow() and save(). 0029 */ 0030 class KBOOKMARKSWIDGETS_EXPORT KBookmarkDialog : public QDialog 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 /** 0036 * Creates a KBookmarkDialog instance 0037 */ 0038 KBookmarkDialog(KBookmarkManager *manager, QWidget *parent = nullptr); 0039 /** 0040 * Shows a properties dialog 0041 * Note: this updates the bookmark and calls KBookmarkManager::emitChanged 0042 */ 0043 KBookmark editBookmark(const KBookmark &bm); 0044 /** 0045 * Shows a "Add Bookmark" dialog 0046 * Note: this updates the bookmark and calls KBookmarkManager::emitChanged 0047 */ 0048 KBookmark addBookmark(const QString &title, const QUrl &url, const QString &icon, KBookmark parent = KBookmark()); 0049 /** 0050 * Creates a folder from a list of bookmarks 0051 * Note: this updates the bookmark and calls KBookmarkManager::emitChanged 0052 */ 0053 KBookmarkGroup addBookmarks(const QList<KBookmarkOwner::FutureBookmark> &list, const QString &name = QString(), KBookmarkGroup parent = KBookmarkGroup()); 0054 /** 0055 * Shows a dialog to create a new folder. 0056 */ 0057 KBookmarkGroup createNewFolder(const QString &name, KBookmark parent = KBookmark()); 0058 /** 0059 * Shows a dialog to select a folder. 0060 */ 0061 KBookmarkGroup selectFolder(KBookmark start = KBookmark()); 0062 0063 ~KBookmarkDialog() override; 0064 0065 protected: 0066 void accept() override; 0067 0068 protected Q_SLOTS: 0069 void newFolderButton(); 0070 0071 private: 0072 std::unique_ptr<KBookmarkDialogPrivate> const d; 0073 friend class KBookmarkDialogPrivate; 0074 }; 0075 0076 #endif