45 SUCCESS = 0, |
45 SUCCESS = 0, |
46 DATABASEERROR = -1, |
46 DATABASEERROR = -1, |
47 FAILURE = -2 |
47 FAILURE = -2 |
48 }; |
48 }; |
49 |
49 |
50 BookmarksManager(QWidget *parent = 0); |
50 public: |
51 ~BookmarksManager(); |
51 static BookmarksManager* instance(); |
52 |
52 |
|
53 public: |
|
54 virtual ~BookmarksManager(); |
|
55 |
|
56 public: // static functions |
|
57 static bool createFile(QString filename, QString fileContents); |
|
58 static void deleteFile(QString filename); |
|
59 |
53 public slots: |
60 public slots: |
54 int addBookmark(QString title, QString URL); |
61 int addBookmark(QString title, QString URL); |
55 int modifyBookmark(int origBookmarkId, QString newTitle, QString newURl); |
62 int modifyBookmark(int origBookmarkId, QString newTitle, QString newURl); |
56 int deleteBookmark(int bookmarkId); |
63 int deleteBookmark(int bookmarkId); |
57 int clearAll(); |
64 int clearAll(); |
58 int deleteTag(int bookmarkId, QString tag); |
65 int deleteTag(int bookmarkId, QString tag); |
59 int addTag(int bookmarkId, QString tag); |
66 int addTag(int bookmarkId, QString tag); |
60 BookmarkResults *findAllBookmarks(); |
67 BookmarkResults *findAllBookmarks(); |
61 TagResults *findAllTags(); |
68 TagResults *findAllTags(); |
62 BookmarkResults *findBookmarksByTag(QString tag); |
69 BookmarkResults *findBookmarksByTag(QString tag); |
|
70 bool needsImport() { return m_needsImport; } |
63 int importBookmarks(QString xbelFilePath); |
71 int importBookmarks(QString xbelFilePath); |
|
72 int importDefaultBookmarks(); |
64 int exportBookmarks(QString xbelFilePath); |
73 int exportBookmarks(QString xbelFilePath); |
65 BookmarkFav* findBookmark(int bookmarkId); |
74 BookmarkFav* findBookmark(int bookmarkId); |
66 BookmarkResults *findUntaggedBookmarks(); |
75 BookmarkResults *findUntaggedBookmarks(); |
67 int reorderBookmark(int bookmarkID, int newIndex); |
76 int reorderBookmark(int bookmarkID, int newIndex); |
68 TagResults* findTagsByBookmark(int bookmarkID); |
77 TagResults* findTagsByBookmark(int bookmarkID); |
69 QMap<QString, QString> findBookmarks(QString atitle); |
78 QMap<QString, QString> findBookmarks(QString atitle); |
70 |
79 |
71 private: |
80 private: |
|
81 BookmarksManager(QWidget *parent = 0); |
72 bool doQuery(QString query); |
82 bool doQuery(QString query); |
|
83 bool doesTableExist(QString tableName); |
73 void createBookmarksSchema(); |
84 void createBookmarksSchema(); |
74 QString normalizeUrl(const QString& url); |
85 QString normalizeUrl(const QString& url); |
75 void lastErrMsg(QSqlQuery& query); |
86 void lastErrMsg(QSqlQuery& query); |
76 |
87 |
|
88 bool m_needsImport; |
77 QSqlDatabase m_db; |
89 QSqlDatabase m_db; |
78 // Note: One instance of a query was locking the database even after using finish() and clear() |
90 // Note: One instance of a query was locking the database even after using finish() and clear() |
79 //QSqlQuery* m_query; |
91 //QSqlQuery* m_query; |
80 }; |
92 }; |
|
93 |
|
94 #ifndef B_Mgr |
|
95 #define B_Mgr BookmarksManager::instance(); |
|
96 #endif |
|
97 |
81 #endif //BOOKMARKSMANAGER_H |
98 #endif //BOOKMARKSMANAGER_H |