9
|
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>
|
12
|
28 |
#include <QMap>
|
9
|
29 |
|
|
30 |
#include "bookmarksapi.h"
|
|
31 |
class QWidget;
|
|
32 |
class BookmarkFav;
|
|
33 |
class BookmarkResults;
|
|
34 |
class TagResults;
|
|
35 |
|
|
36 |
#define BOOKMARKS_DB_NAME "Bookmarks"
|
|
37 |
#define BOOKMARKS_DB_FILE "bookmarks.db"
|
|
38 |
|
|
39 |
class BOOKMARKSAPI_EXPORT BookmarksManager : public QObject {
|
|
40 |
|
|
41 |
Q_OBJECT
|
|
42 |
|
|
43 |
public:
|
|
44 |
enum status {
|
|
45 |
SUCCESS = 0,
|
|
46 |
DATABASEERROR = -1,
|
|
47 |
FAILURE = -2
|
|
48 |
};
|
|
49 |
|
|
50 |
BookmarksManager(QWidget *parent = 0);
|
|
51 |
~BookmarksManager();
|
|
52 |
|
|
53 |
public slots:
|
|
54 |
int addBookmark(QString title, QString URL);
|
|
55 |
int modifyBookmark(int origBookmarkId, QString newTitle, QString newURl);
|
|
56 |
int deleteBookmark(int bookmarkId);
|
|
57 |
int clearAll();
|
|
58 |
int deleteTag(int bookmarkId, QString tag);
|
|
59 |
int addTag(int bookmarkId, QString tag);
|
|
60 |
BookmarkResults *findAllBookmarks();
|
|
61 |
TagResults *findAllTags();
|
|
62 |
BookmarkResults *findBookmarksByTag(QString tag);
|
|
63 |
int importBookmarks(QString xbelFilePath);
|
|
64 |
int exportBookmarks(QString xbelFilePath);
|
|
65 |
BookmarkFav* findBookmark(int bookmarkId);
|
|
66 |
BookmarkResults *findUntaggedBookmarks();
|
|
67 |
int reorderBookmark(int bookmarkID, int newIndex);
|
|
68 |
TagResults* findTagsByBookmark(int bookmarkID);
|
12
|
69 |
QMap<QString, QString> findBookmarks(QString atitle);
|
|
70 |
|
9
|
71 |
private:
|
|
72 |
bool doQuery(QString query);
|
|
73 |
void createBookmarksSchema();
|
|
74 |
QString normalizeUrl(const QString& url);
|
|
75 |
void lastErrMsg(QSqlQuery& query);
|
|
76 |
|
|
77 |
QSqlDatabase m_db;
|
|
78 |
// Note: One instance of a query was locking the database even after using finish() and clear()
|
|
79 |
//QSqlQuery* m_query;
|
|
80 |
};
|
|
81 |
#endif //BOOKMARKSMANAGER_H
|