|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 #ifndef BOOKMARKSMANAGER_H |
|
22 #define BOOKMARKSMANAGER_H |
|
23 |
|
24 #include <QString> |
|
25 #include <QObject> |
|
26 #include <QSqlDatabase> |
|
27 #include <QSqlError> |
|
28 |
|
29 #include "bookmarksapi.h" |
|
30 class QWidget; |
|
31 class BookmarkFav; |
|
32 class BookmarkResults; |
|
33 class TagResults; |
|
34 |
|
35 #define BOOKMARKS_DB_NAME "Bookmarks" |
|
36 #define BOOKMARKS_DB_FILE "bookmarks.db" |
|
37 |
|
38 class BOOKMARKSAPI_EXPORT BookmarksManager : public QObject { |
|
39 |
|
40 Q_OBJECT |
|
41 |
|
42 public: |
|
43 enum status { |
|
44 SUCCESS = 0, |
|
45 DATABASEERROR = -1, |
|
46 FAILURE = -2 |
|
47 }; |
|
48 |
|
49 BookmarksManager(QWidget *parent = 0); |
|
50 ~BookmarksManager(); |
|
51 |
|
52 public slots: |
|
53 int addBookmark(QString title, QString URL); |
|
54 int modifyBookmark(int origBookmarkId, QString newTitle, QString newURl); |
|
55 int deleteBookmark(int bookmarkId); |
|
56 int clearAll(); |
|
57 int deleteTag(int bookmarkId, QString tag); |
|
58 int addTag(int bookmarkId, QString tag); |
|
59 BookmarkResults *findAllBookmarks(); |
|
60 TagResults *findAllTags(); |
|
61 BookmarkResults *findBookmarksByTag(QString tag); |
|
62 int importBookmarks(QString xbelFilePath); |
|
63 int exportBookmarks(QString xbelFilePath); |
|
64 BookmarkFav* findBookmark(int bookmarkId); |
|
65 BookmarkResults *findUntaggedBookmarks(); |
|
66 int reorderBookmark(int bookmarkID, int newIndex); |
|
67 TagResults* findTagsByBookmark(int bookmarkID); |
|
68 |
|
69 private: |
|
70 bool doQuery(QString query); |
|
71 void createBookmarksSchema(); |
|
72 QString normalizeUrl(const QString& url); |
|
73 void lastErrMsg(QSqlQuery& query); |
|
74 |
|
75 QSqlDatabase m_db; |
|
76 // Note: One instance of a query was locking the database even after using finish() and clear() |
|
77 //QSqlQuery* m_query; |
|
78 }; |
|
79 #endif //BOOKMARKSMANAGER_H |