1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 17:42:10 +01:00
falkonOfficial/src/lib/bookmarks/bookmarks.h

105 lines
3.2 KiB
C
Raw Normal View History

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/>.
* ============================================================ */
#ifndef BOOKMARKS_H
#define BOOKMARKS_H
2011-03-02 16:57:41 +01:00
#include <QObject>
#include <QVariant>
#include "qzcommon.h"
2014-02-10 12:58:34 +01:00
class QUrl;
2011-03-02 16:57:41 +01:00
class BookmarkItem;
2014-02-07 22:48:30 +01:00
class BookmarksModel;
class AutoSaver;
class QUPZILLA_EXPORT Bookmarks : public QObject
2011-03-02 16:57:41 +01:00
{
Q_OBJECT
2011-03-02 16:57:41 +01:00
public:
explicit Bookmarks(QObject* parent = 0);
2014-02-10 12:58:34 +01:00
~Bookmarks();
2011-03-02 16:57:41 +01:00
void loadSettings();
2014-02-10 12:58:34 +01:00
bool showOnlyIconsInToolbar() const;
2014-02-07 22:48:30 +01:00
BookmarkItem* rootItem() const;
BookmarkItem* toolbarFolder() const;
BookmarkItem* menuFolder() const;
BookmarkItem* unsortedFolder() const;
BookmarkItem* lastUsedFolder() const;
2014-02-10 12:58:34 +01:00
BookmarksModel* model() const;
bool isBookmarked(const QUrl &url);
2014-02-10 12:58:34 +01:00
bool canBeModified(BookmarkItem* item) const;
// Search bookmarks (urls only) for exact url match
QList<BookmarkItem*> searchBookmarks(const QUrl &url) const;
// 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-07 22:48:30 +01:00
void addBookmark(BookmarkItem* parent, BookmarkItem* item);
void insertBookmark(BookmarkItem* parent, int row, BookmarkItem* item);
bool removeBookmark(BookmarkItem* item);
void changeBookmark(BookmarkItem* item);
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);
private slots:
void saveSettings();
2011-03-02 16:57:41 +01:00
private:
void init();
void loadBookmarks();
2014-02-10 12:58:34 +01:00
void saveBookmarks();
void loadBookmarksFromMap(const QVariantMap &map);
void readBookmarks(const QVariantList &list, BookmarkItem* parent);
QVariantList writeBookmarks(BookmarkItem* parent);
void search(QList<BookmarkItem*>* items, BookmarkItem* parent, const QUrl &url) const;
void search(QList<BookmarkItem*>* items, BookmarkItem* parent, const QString &string, int limit, Qt::CaseSensitivity sensitive) const;
BookmarkItem* m_root;
BookmarkItem* m_folderToolbar;
BookmarkItem* m_folderMenu;
BookmarkItem* m_folderUnsorted;
BookmarkItem* m_lastFolder;
2014-02-07 22:48:30 +01:00
BookmarksModel* m_model;
AutoSaver* m_autoSaver;
bool m_showOnlyIconsInToolbar;
2011-03-02 16:57:41 +01:00
};
#endif // BOOKMARKS_H