1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 mDictionary is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
24 \brief Bookmarks functionality - marking words as favorite, managing marked
25 words, searching in marked words (with cached translations)
27 \author Bartosz Szatkowski <bulislaw@linux.com>
36 #include <QStringList>
39 #include <QSqlDatabase>
43 #include "../../include/settings.h"
44 #include "../../include/translation.h"
45 #include "../../include/AccentsNormalizer.h"
46 class BookmarkTranslation;
50 Bookmarks are a way to store words that You think You will need to search
53 When You add a bookmark (by clicking on "star" in words list) You add it to
54 a special list with cached translations from all available dictionaries so
55 You can search for them quickly even when You delete corresponding dict.
57 class Bookmarks : public AccentsNormalizer {
63 Adds new word and translation to bookmarks
64 \param translation new translation to be saved and cached as a bookmark
66 void add(Translation* translation);
68 void add(QString key,QString removeAccentKey,QString value);
71 Removes word and corresponding translation cache from bookmarks list
72 \param translation translation to be removed
74 void remove(Translation* translation);
77 \return all bookmarks (word and translation as a translation object
80 QList<Translation*> list();
83 Searches in bookmarks for a given word (wildcards may apply '*' and '?')
84 \param word word to search for
85 \return list of matching Translation objects
87 QList<Translation*> searchWordList(QString word);
90 Searches for final translation of a given word
91 \return word translation list in text format xml to be formatted
93 \param word word to search for
95 QStringList search(QString word, QString dbname);
98 Clears bookmarks database
103 \return true if a given word is already in bookmarks
104 \param word word to check
106 bool inBookmarks(QString word);
109 bool checkAndCreateDb(QString dbName = "");
113 QSqlDatabase getDbCnx();
114 QMap<QChar, QRegExp> letters;
120 #endif // BOOKMARKS_H