File indexing completed on 2024-05-12 04:57:57

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2010-2014  David Rosca <nowrep@gmail.com>
0004 *
0005 * This program is free software: you can redistribute it and/or modify
0006 * it under the terms of the GNU General Public License as published by
0007 * the Free Software Foundation, either version 3 of the License, or
0008 * (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License
0016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017 * ============================================================ */
0018 #ifndef BOOKMARKSMANAGER_H
0019 #define BOOKMARKSMANAGER_H
0020 
0021 #include <QWidget>
0022 #include <QPointer>
0023 
0024 #include "qzcommon.h"
0025 
0026 #include "bookmarkitem.h"
0027 
0028 namespace Ui
0029 {
0030 class BookmarksManager;
0031 }
0032 
0033 class QUrl;
0034 
0035 class BrowserWindow;
0036 class Bookmarks;
0037 
0038 class FALKON_EXPORT BookmarksManager : public QWidget
0039 {
0040     Q_OBJECT
0041 
0042 public:
0043     explicit BookmarksManager(BrowserWindow* window, QWidget* parent = nullptr);
0044     ~BookmarksManager() override;
0045 
0046     void setMainWindow(BrowserWindow* window);
0047 
0048 public Q_SLOTS:
0049     void search(const QString &string);
0050 
0051 private Q_SLOTS:
0052     void bookmarkActivated(BookmarkItem* item);
0053     void bookmarkCtrlActivated(BookmarkItem* item);
0054     void bookmarkShiftActivated(BookmarkItem* item);
0055     void bookmarksSelected(const QList<BookmarkItem*> &items);
0056     void createContextMenu(const QPoint &pos);
0057 
0058     void openBookmark(BookmarkItem* item = nullptr);
0059     void openBookmarkInNewTab(BookmarkItem* item = nullptr);
0060     void openBookmarkInNewWindow(BookmarkItem* item = nullptr);
0061     void openBookmarkInNewPrivateWindow(BookmarkItem* item = nullptr);
0062 
0063     void addBookmark();
0064     void addFolder();
0065     void addSeparator();
0066     void deleteBookmarks();
0067 
0068     void bookmarkEdited();
0069     void descriptionEdited();
0070     void enableUpdates();
0071 
0072 private:
0073     void updateEditBox(BookmarkItem* item);
0074     bool bookmarkEditable(BookmarkItem* item) const;
0075     void addBookmark(BookmarkItem* item);
0076     BookmarkItem* parentForNewBookmark() const;
0077     BrowserWindow* getWindow();
0078 
0079     void showEvent(QShowEvent* event) override;
0080     void keyPressEvent(QKeyEvent* event) override;
0081 
0082     Ui::BookmarksManager* ui;
0083     QPointer<BrowserWindow> m_window;
0084 
0085     Bookmarks* m_bookmarks;
0086     BookmarkItem* m_selectedBookmark;
0087     bool m_blockDescriptionChangedSignal;
0088     bool m_adjustHeaderSizesOnShow;
0089 
0090 };
0091 
0092 #endif // BOOKMARKSMANAGER_H