2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2014-01-11 16:11:42 +01:00
|
|
|
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
2011-03-03 18:29:20 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2014-02-05 15:26:51 +01:00
|
|
|
#ifndef BOOKMARKS_H
|
|
|
|
#define BOOKMARKS_H
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-04-15 20:45:22 +02:00
|
|
|
#include <QObject>
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QVariant>
|
|
|
|
|
2014-02-26 20:03:20 +01:00
|
|
|
#include "qzcommon.h"
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2014-02-10 12:58:34 +01:00
|
|
|
class QUrl;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2014-02-06 17:07:19 +01:00
|
|
|
class BookmarkItem;
|
2014-02-07 22:48:30 +01:00
|
|
|
class BookmarksModel;
|
2014-03-06 16:12:36 +01:00
|
|
|
class AutoSaver;
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2014-02-19 22:12:32 +01:00
|
|
|
class QUPZILLA_EXPORT Bookmarks : public QObject
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2011-04-15 20:45:22 +02:00
|
|
|
Q_OBJECT
|
2011-03-02 16:57:41 +01:00
|
|
|
public:
|
2014-03-09 21:51:42 +01:00
|
|
|
explicit Bookmarks(QObject* parent = 0);
|
2014-02-10 12:58:34 +01:00
|
|
|
~Bookmarks();
|
2011-04-15 20:45:22 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void loadSettings();
|
2012-02-17 19:54:58 +01:00
|
|
|
|
2014-02-10 12:58:34 +01:00
|
|
|
bool showOnlyIconsInToolbar() const;
|
2013-12-30 00:35:01 +01:00
|
|
|
|
2014-02-07 22:48:30 +01:00
|
|
|
BookmarkItem* rootItem() const;
|
2014-02-08 20:01:07 +01:00
|
|
|
BookmarkItem* toolbarFolder() const;
|
|
|
|
BookmarkItem* menuFolder() const;
|
|
|
|
BookmarkItem* unsortedFolder() const;
|
2014-02-09 12:43:06 +01:00
|
|
|
BookmarkItem* lastUsedFolder() const;
|
2014-02-10 12:58:34 +01:00
|
|
|
|
2014-02-09 17:27:55 +01:00
|
|
|
BookmarksModel* model() const;
|
2014-02-08 23:01:01 +01:00
|
|
|
|
2014-02-09 12:43:06 +01:00
|
|
|
bool isBookmarked(const QUrl &url);
|
2014-02-10 12:58:34 +01:00
|
|
|
bool canBeModified(BookmarkItem* item) const;
|
2014-02-09 13:34:52 +01:00
|
|
|
|
|
|
|
// Search bookmarks (urls only) for exact url match
|
2014-02-09 12:18:52 +01:00
|
|
|
QList<BookmarkItem*> searchBookmarks(const QUrl &url) const;
|
2014-02-18 16:17:22 +01:00
|
|
|
// Search bookmarks for contains match through all properties
|
|
|
|
QList<BookmarkItem*> searchBookmarks(const QString &string, int limit = -1, Qt::CaseSensitivity sensitive = Qt::CaseInsensitive) const;
|
2014-02-09 12:18:52 +01:00
|
|
|
|
2014-02-07 22:48:30 +01:00
|
|
|
void addBookmark(BookmarkItem* parent, BookmarkItem* item);
|
|
|
|
void insertBookmark(BookmarkItem* parent, int row, BookmarkItem* item);
|
|
|
|
bool removeBookmark(BookmarkItem* item);
|
2014-03-06 16:12:36 +01:00
|
|
|
void changeBookmark(BookmarkItem* item);
|
2014-02-08 18:14:38 +01:00
|
|
|
|
2014-02-10 12:58:34 +01:00
|
|
|
public slots:
|
|
|
|
void setShowOnlyIconsInToolbar(bool state);
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
signals:
|
2014-02-07 22:48:30 +01:00
|
|
|
// Item was added to bookmarks
|
|
|
|
void bookmarkAdded(BookmarkItem* item);
|
|
|
|
// Item was removed from bookmarks
|
|
|
|
void bookmarkRemoved(BookmarkItem* item);
|
|
|
|
// Item data has changed
|
|
|
|
void bookmarkChanged(BookmarkItem* item);
|
|
|
|
|
2014-02-10 12:58:34 +01:00
|
|
|
void showOnlyIconsInToolbarChanged(bool show);
|
|
|
|
|
2014-03-06 16:12:36 +01:00
|
|
|
private slots:
|
|
|
|
void saveSettings();
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
private:
|
2014-02-09 17:27:55 +01:00
|
|
|
void init();
|
2014-02-10 16:58:05 +01:00
|
|
|
void loadBookmarks();
|
2014-02-10 12:58:34 +01:00
|
|
|
void saveBookmarks();
|
2014-02-06 17:07:19 +01:00
|
|
|
|
2014-02-09 18:55:11 +01:00
|
|
|
void loadBookmarksFromMap(const QVariantMap &map);
|
2014-02-06 17:07:19 +01:00
|
|
|
void readBookmarks(const QVariantList &list, BookmarkItem* parent);
|
|
|
|
QVariantList writeBookmarks(BookmarkItem* parent);
|
|
|
|
|
2014-02-09 12:18:52 +01:00
|
|
|
void search(QList<BookmarkItem*>* items, BookmarkItem* parent, const QUrl &url) const;
|
2014-02-18 16:17:22 +01:00
|
|
|
void search(QList<BookmarkItem*>* items, BookmarkItem* parent, const QString &string, int limit, Qt::CaseSensitivity sensitive) const;
|
2014-02-09 12:18:52 +01:00
|
|
|
|
2014-02-06 17:07:19 +01:00
|
|
|
BookmarkItem* m_root;
|
|
|
|
BookmarkItem* m_folderToolbar;
|
|
|
|
BookmarkItem* m_folderMenu;
|
|
|
|
BookmarkItem* m_folderUnsorted;
|
2014-02-09 17:27:55 +01:00
|
|
|
BookmarkItem* m_lastFolder;
|
2014-03-06 16:12:36 +01:00
|
|
|
|
2014-02-07 22:48:30 +01:00
|
|
|
BookmarksModel* m_model;
|
2014-03-06 16:12:36 +01:00
|
|
|
AutoSaver* m_autoSaver;
|
2014-02-09 17:27:55 +01:00
|
|
|
|
|
|
|
bool m_showOnlyIconsInToolbar;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
2014-02-05 15:26:51 +01:00
|
|
|
#endif // BOOKMARKS_H
|