File indexing completed on 2024-07-14 14:26:45

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 
0013 #include <QDialog>
0014 #include <memory>
0015 
0016 class KBookmarkManager;
0017 class KBookmarkDialogPrivate;
0018 
0019 /**
0020  * @class KBookmarkDialog kbookmarkdialog.h KBookmarkDialog
0021  *
0022  * This class provides a Dialog for editing properties, adding Bookmarks and creating new folders.
0023  * It can be used to show dialogs for common tasks with bookmarks.
0024  *
0025  * It is used by KBookmarkMenu to show a dialog for "Properties", "Add Bookmark" and "Create New Folder".
0026  * If you want to customize those dialogs, derive from KBookmarkOwner and reimplement bookmarkDialog(),
0027  * return a KBookmarkDialog subclass and reimplement initLayout(), aboutToShow() and save().
0028  */
0029 class KBOOKMARKS_EXPORT KBookmarkDialog : public QDialog
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     /**
0035      * Creates a KBookmarkDialog instance
0036      */
0037     KBookmarkDialog(KBookmarkManager *manager, QWidget *parent = nullptr);
0038     /**
0039      * Shows a properties dialog
0040      * Note: this updates the bookmark and calls KBookmarkManager::emitChanged
0041      */
0042     KBookmark editBookmark(const KBookmark &bm);
0043     /**
0044      * Shows a "Add Bookmark" dialog
0045      * Note: this updates the bookmark and calls KBookmarkManager::emitChanged
0046      */
0047     KBookmark addBookmark(const QString &title, const QUrl &url, const QString &icon, KBookmark parent = KBookmark());
0048     /**
0049      * Creates a folder from a list of bookmarks
0050      * Note: this updates the bookmark and calls KBookmarkManager::emitChanged
0051      */
0052     KBookmarkGroup addBookmarks(const QList<KBookmarkOwner::FutureBookmark> &list, const QString &name = QString(), KBookmarkGroup parent = KBookmarkGroup());
0053     /**
0054      * Shows a dialog to create a new folder.
0055      */
0056     KBookmarkGroup createNewFolder(const QString &name, KBookmark parent = KBookmark());
0057     /**
0058      * Shows a dialog to select a folder.
0059      */
0060     KBookmarkGroup selectFolder(KBookmark start = KBookmark());
0061 
0062     ~KBookmarkDialog() override;
0063 
0064 protected:
0065     void accept() override;
0066 
0067 protected Q_SLOTS:
0068     void newFolderButton();
0069 
0070 private:
0071     std::unique_ptr<KBookmarkDialogPrivate> const d;
0072     friend class KBookmarkDialogPrivate;
0073 };
0074 
0075 #endif