CommonDictInterface(QObject *parent = 0):QObject(parent) {}
virtual ~CommonDictInterface() {}
- //! returns source language code iso 639-2
+ //! \returns source language code iso 639-2
virtual QString langFrom() const = 0;
- //! returns destination language code iso 639-2
+ //! \returns destination language code iso 639-2
virtual QString langTo() const = 0;
- //! returns dictionary name (like "old English" or so)
+ //! \returns dictionary name (like "old English" or so)
virtual QString name() const = 0;
- //! returns dictionary type (xdxf, google translate, etc)
+ //! \returns dictionary type (xdxf, google translate, etc)
virtual QString type() const = 0;
- //! \returns information about dictionary in html (name, authors, etc)
+ //! returns information about dictionary (name, authors, etc)
virtual QString infoNote() const = 0;
- /*! returns DictDialog object that creates dialogs
- for adding new dictionary and changing plugin settings*/
+ /*! \returns DictDialog object that creates dialogs
+ for adding a new dictionary and changing plugin settings*/
virtual DictDialog* dictDialog() = 0;
- //! returns new, clean copy of plugin with settings set as in Settings*
+ //! \returns new, clean copy of plugin with settings set as in Settings*
virtual CommonDictInterface* getNew(const Settings*) const = 0;
- //! returns whether plugin can start searching
+ //! \returns whether plugin can start searching
virtual bool isAvailable() const = 0;
- //! returns the actual translation of a word given in key
+ //! \returns the actual translation of a word given in a key
virtual QString search(QString key) = 0;
//! \returns unique value (unique for every dictionary, not plugin)
this->_hash=h;
}
- //! returns current plugin settings
+ //! \returns current plugin settings
virtual Settings* settings() = 0;
- //! returns plugin icon
+ //! \returns plugin icon
virtual QIcon* icon() = 0;
- //! returns empty translation object (to be fetched later) for given key
+ //! \returns empty translation object (to be fetched later) for a given key
virtual Translation* getTranslationFor(QString ) {return 0;}
/*! plugin should delete any files (eg. cache) that have been created and are ready
virtual void retranslate() {}
Q_SIGNALS:
- //! emitted after change in a dictionary settings
+ //! emitted after change in dictionary settings
void settingsChanged();
/*! emitted to backbone when it's needed to inform user about something
\param Backbone::NotifyType GUI may decide to show different types in
different ways
- \param QString text of the notification
+ \param text of the notification
*/
void notify(Notify::NotifyType, QString);
return this->key()==translation->key();
}
- //! \return parsed raw format into html
- virtual QString toHtml() const = 0;
+ //! \return parsed raw format into xml
+ virtual QString toXml() const = 0;
//! \return whether given translation is taken from bookmarks
virtual bool isBookmark() const {
_bookmark = b;
}
- //! returns coresponding dict object
+ //! \returns corresponding dict object
virtual uint dict() const {return 0;}
protected:
/*! Bookmarks are a way to store words that You think You will need to search
for often.
- When You add bookmark (by clicking on "star" in words list) You add it to
- special list with cached translations from all available dictionaries so
+ When You add a bookmark (by clicking on "star" in words list) You add it to
+ a special list with cached translations from all available dictionaries so
You can search for them quickly even when You delete corresponding dict.
*/
class Bookmarks : public AccentsNormalizer {
*/
void add(Translation* translation);
- /*! Removes word and corresponding translation cache from bookmark list
+ /*! Removes word and corresponding translation cache from bookmarks list
\param translation translation to be removed
*/
void remove(Translation* translation);
QList<Translation*> list();
/*! Searches in bookmarks for a given word (wildcards may apply '*' and '?')
- \param word to search for
+ \param word word to search for
\return list of matching Translation objects
*/
QList<Translation*> searchWordList(QString word);
/*! Searches for final translation of a given word
- \return word translation list in text format xml or html to be formatted
+ \return word translation list in text format xml to be formatted
and displayed
\param word word to search for
*/
/*! \return true if a given word is already in bookmarks
- \param word to check
+ \param word word to check
*/
bool inBookmarks(QString word);
* search_bookmarks - true/false, whether search in bookmarks
Searching schema:
- At first GUI should ask for list of words matching given pattern,
+ At first GUI should ask for a list of words matching a given pattern,
then each Translation object is capable of finding its own final translation
List of words:
- GUI calls result()
Final translation:
- - GUI calls searchHtml()
- - Backbone starts toHtml for each translation object in separate threads
- - Backbone sets FutureWatcher to be notified after last toHtml returns
+ - GUI calls searchXml()
+ - Backbone starts toXml for each translation object in separate threads
+ - Backbone sets FutureWatcher to be notified after last toXml returns
- Backbone fetches translation from Future<...> objects and calls
- htmlReady()
- - Gui calls htmlResult()
+ xmlReady()
+ - Gui calls xmlResult()
*/
class Backbone : public QObject
Q_OBJECT
public:
- /*!\param pluginPath path to plugins (leave blank for default)
- \param configPath path to folder with configuration files
- \param dry dry run is mode without paying attention to configuration etc
+ /*! \param pluginPath path to plugins (leave blank for default)
+ \param configPath path to folder with configuration files
+ \param dry dry run is mode without paying attention to configuration etc
mainly for testing
*/
Backbone(QString pluginPath="", QString configPath="",
//! \return history of performed searches
History* history();
- //! \return return search fesult
+ //! \return search fesult
QMultiHash<QString, Translation*> result();
//! \return maximum number of words that plugin could find
int searchLimit() const;
- //! \return final translation (after searching for html)
- QStringList htmls();
+ //! \return final translation (after searching for xml)
+ QStringList xmls();
/*! maximum number of translations that each plugin may return; it must be
public static because of QtConcurent::mapped restrictions about
void stopSearching();
/*! searches for a word translation
- \param word to be translated
+ \param word word to be translated
*/
void search(QString word);
/*! sets active dictionaries (searches are performed only in active dicts)
\param List of dictionaries to be activated
*/
- void selectedDictionaries(QList<CommonDictInterface* >);
+ void selectedDictionaries(QList<CommonDictInterface*>);
- /*! adds new dictionary and activates it
+ /*! adds a new dictionary and activates it
\param dict dictionary to be added
\param active decides whether searches are perfomed in given dictionaries
*/
void quit();
- /*! Fired by FutureWatcher when list of words is ready (after calling search)
+ /*! Fired by FutureWatcher when a list of words is ready (after calling search),
fetch Future<...> to final result
*/
void translationReady();
/*! Fired by FutureWatcher when search result is ready, fetch Future to
final result
*/
- void htmlTranslationReady();
+ void xmlTranslationReady();
- /*! Removes given dictionary
+ /*! Removes a given dictionary
\param dict dictionary to be deleted
*/
void removeDictionary(CommonDictInterface* dict);
/*! Saves plugins new state/configuration after each change */
void dictUpdated();
- /*! Performs search for final translation (html/xml) from a list
+ /*! Performs search for final translation (xml) form
\param list of Translation* to be searched for
*/
- void searchHtml(QList<Translation*>);
+ void searchXml(QList<Translation*>);
/*! adds bookmarks to given translations (translation object is fetched and
added to bookmarks data base (key and translation stored in db))
- \param translation translation object to be stored in db
+ \param translations list of Translation objects to be stored in db
*/
void addBookmark(QList<Translation*> translations) {
foreach(Translation* translation, translations)
/*! Removes bookmarks to given translations
- \param translation remove bookmark to this translation
+ \param translations remove bookmark to these translations
*/
void removeBookmark(QList<Translation*> translations) {
foreach(Translation* translation, translations)
}
- /*! Searching a list of bookmarks may take some time, so I moved it to
+ /*! Searching a list of bookmarks may take some time, so it's moved to a
new thread (to avoid GUI blocking), further it's consistent with ordinary
searching a list of words (\see search)
*/
//! emitted when there are search results ready to fetch
void ready();
- //! emitted when html result is ready to fetch
- void htmlReady();
+ //! emitted when xml result is ready to fetch
+ void xmlReady();
//! thrown when searches are stopped
void searchCanceled();
/*! emitted by direct connection to plugins notifying signals
\param Notify::NotifyType GUI may decide to show different types in
different ways
- \param QString text of the notification
+ \param text of the notification
*/
void notify(Notify::NotifyType, QString);
QFuture<QList<Translation*> > _innerResult; //Res of concurrent word search
- QFuture<QString> _innerHtmlResult; // Result of html search
+ QFuture<QString> _innerXmlResult; // Result of xml search
QFuture<QList<Translation*> > _innerBookmarks; //Res of search in bookmarks
QFuture<QList<Translation*> > _innerListBookmarks; //Res of search in bookmarks
- QFuture<QStringList> _innerHtmlBookmarks; //Html result of bookmarks search
+ QFuture<QStringList> _innerXmlBookmarks; //Xml result of bookmarks search
QMultiHash<QString, Translation*> _result; //Final result of word search
- QStringList _htmlResult; // Final result of html search
+ QStringList _xmlResult; // Final result of xml search
QList<Translation*> _bookmarksResult; // Final result of search in bookmarks
QFutureWatcher<QList<Translation*> > _resultWatcher;
QFutureWatcher<QList<Translation*> > _bookmarkWatcher;
QFutureWatcher<QList<Translation*> > _bookmarkSearchWatcher;
- QFutureWatcher<QString> _htmlResultWatcher;
+ QFutureWatcher<QString> _xmlResultWatcher;
QString _pluginPath;
#include <QPropertyAnimation>
#include "../../include/GUIInterface.h"
- //! Displays translation of word found in dictionaries
+ //! Displays translation of a word found in dictionaries
/*!
- Displays many translations of word, formatted as html.
+ Displays many translations of word, formatted as xml.
*/
class TranslationWidget : public QScrollArea {
Q_OBJECT
//! Show widget.
void show();
- //! Requests to show translation of word list passed as parameter.
+ //! Requests to show a translation of words list passed as parameter.
void show(QStringList);
- //! Updates users zoom preferences and sends its to backbone to be saved
+ //! Updates user's zoom preferences and sends its to backbone to be saved
void updateZoom(qreal);
protected:
GooglePlugin(QObject *parent=0);
~GooglePlugin();
- //! returns source language code iso 639-2
+ //! \returns source language code iso 639-2
QString langFrom() const;
- //! returns destination language code iso 639-2
+ //! \returns destination language code iso 639-2
QString langTo() const;
- //! returns dictionary name (like "old English" or so)
+ //! \returns dictionary name (like "old English" or so)
QString name() const;
- //! returns dictionary type (xdxf, google translate, etc)
+ //! \returns dictionary type (xdxf, google translate, etc)
QString type() const;
- //! \returns information about dictionary in html (name, authors, etc)
+ //! returns information about dictionary (name, authors, etc)
QString infoNote() const;
//! sets the language to which the translation is done
//! sets the language from which the translation is done
void setLangFrom(QString langFrom);
- /*! returns DictDialog object that creates dialogs
+ /*! \returns DictDialog object that creates dialogs
for adding new dictionaries and changing plugin things
*/
DictDialog* dictDialog();
- //! returns new, clean copy of plugin with settings set as in Settings*
+ //! \returns new, clean copy of plugin with settings set as in Settings*
CommonDictInterface* getNew(const Settings*) const;
- //! returns whether plugin can start searching
+ //! \returns whether plugin can start searching
bool isAvailable() const;
//! sets if connection with Internet is possible
void setConnectionAccept(QString connectionAcepted);
- //! returns the value of "connection_accepted" from settings
+ //! \returns the value of "connection_accepted" from settings
bool isConnectionAccept() const;
- //! returns a description of a word given by a QString
+ //! \returns a description of a word given by a QString
QString search(QString key);
- //! returns current plugin settings
+ //! \returns current plugin settings
Settings* settings();
//! Sets new settings
void setSettings(const Settings*);
- //! returns plugin icon
+ //! \returns plugin icon
QIcon* icon();
- //! returns empty translation object (to be fetched later) for given key
+ //! \returns empty translation object (to be fetched later) for a given key
Translation* getTranslationFor(QString key);
//! initializes the list of available languages in Google translator
*/
QList<Translation*> searchWordList(QString word, int limit=0);
- //! stop current operation
+ //! stops current operation
void stop();
//! function called after the request from Google is returned
//! information about dictionary
QString _infoNote;
- //! icon displayed during translations and when the dictionary is chosen
+ //! icon displayed during translations and when a dictionary is chosen
QIcon _icon;
Settings *_settings;
//! indicates if search is stopped
//! \return word to be translated
QString key() const;
- //! \return parsed raw format into html
- QString toHtml() const;
+ //! \return parsed raw format into xml
+ QString toXml() const;
/*! sets the word for which we want to find a translation
\param word for which we want to find a translation */
return _bookmark;
}
- //! returns corresponding dict object
+ //! \returns corresponding dict object
uint dict() const {return _dictHash;}
private:
//! \return word to be translated
QString key() const;
- //! \return parsed raw format into html
- QString toHtml() const;
+ //! \return parsed raw format into xml
+ QString toXml() const;
/*! sets the word for which we want to find a translation
\param word for which we want to find a translation */
return _bookmark;
}
- //! returns coresponding dict object
+ //! returns corresponding dict object
uint dict() const {return _dictHash;}
private:
CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
XdxfPlugin *plugin = new XdxfPlugin();
+ connect(plugin, SIGNAL(notify(Notify::NotifyType,QString)),
+ this, SIGNAL(notify(Notify::NotifyType,QString)));
+
+ ((XdxfDictDialog*)plugin->dictDialog())->setLastDialogParent(_dictDialog->lastDialogParent());
+
+
+
if(settings && plugin->setSettings(settings)) {
+
+ disconnect(plugin, SIGNAL(notify(Notify::NotifyType,QString)),
+ this, SIGNAL(notify(Notify::NotifyType,QString)));
return plugin;
}
else {
+ disconnect(plugin, SIGNAL(notify(Notify::NotifyType,QString)),
+ this, SIGNAL(notify(Notify::NotifyType,QString)));
delete plugin;
return 0;
}
reader.readNextStartElement();
if(reader.name()=="full_name")
_name=reader.readElementText();
+ else
+ qDebug()<<"no full_name";
reader.readNextStartElement();
if(reader.name()=="description")
_infoNote=reader.readElementText();
+ else
+ qDebug()<<"no description";
_dictionaryInfo= _name + " [" + _langFrom + "-"
+ _langTo + "]";
XdxfCachingDialog d(_dictDialog->lastDialogParent());
+ qDebug()<<_dictDialog->lastDialogParent();
+
connect(&d, SIGNAL(cancelCaching()),
this, SLOT(stop()));
~XdxfPlugin();
- //! returns source language code iso 639-2
+ //! \returns source language code iso 639-2
QString langFrom() const;
- //! returns destination language code iso 639-2
+ //! \returns destination language code iso 639-2
QString langTo() const;
- //! returns dictionary name (like "old English" or so)
+ //! \returns dictionary name (like "old English" or so)
QString name() const;
- //! returns dictionary type (xdxf, google translate, etc)
+ //! \returns dictionary type (xdxf, google translate, etc)
QString type() const;
++<<<<<<< HEAD
+ //! returns information about dictionary in xml (name, authors, etc)
++=======
+ //! \returns information about dictionary in html (name, authors, etc)
++>>>>>>> master
QString infoNote() const;
- /*! returns DictDialog object that creates dialogs
- for adding new dictionary and changing plugin settings
+ /*! \returns DictDialog object that creates dialogs
+ for adding a new dictionary and changing plugin settings
*/
DictDialog* dictDialog();
- //! returns new, clean copy of plugin with settings set as in Settings*
+ //! \returns new, clean copy of plugin with settings set as in Settings*
CommonDictInterface* getNew(const Settings*) const;
- //! returns whether plugin can start searching
+ //! \returns whether plugin can start searching
bool isAvailable() const;
- //! returns a description of a word given by a QString
+ //! \returns a description of a word given by a QString
QString search(QString key);
- //! returns current plugin settings
+ //! \returns current plugin settings
Settings* settings();
- //! returns words count in a dictionary
+ //! \returns words count in a dictionary
long wordsCount();
//! Sets new settings
bool setSettings(const Settings*);
- //! returns plugin icon
+ //! \returns plugin icon
QIcon* icon();
/*! plugin should delete any files (eg. cache) that have been created and are ready
*/
QList<Translation*> searchWordList(QString word, int limit=0);
- //! stop current operation
+ //! stops current operation
void stop();
//! loads translations for each plugin only once
private:
- /*! returns true or false depending on whether the dictionary is cached
- or not, not implemented yet
+ /*! \returns true or false depending on whether the dictionary is cached
+ or not
*/
bool isCached();
/*! searches for a list of words similar to a word in a database file
QList<Translation*> searchWordListFile(QString word, int limit=0);
/*! searches for a translation of a word which is exactly like a key
- in xdxf file */
+ in a xdxf file */
QString searchFile(QString key);
/*! searches for a translation of a word which is exactly like a key
- in database file */
+ in a database file */
QString searchCache(QString key);
//! scans dictionary file to get information about it
bool getDictionaryInfo();
- //! counts the keys in xdxf file
+ //! counts the keys in a xdxf file
int countWords();
/*! transforms xdxf files to database files (caching operation)
QString _dictionaryInfo;
- //! icon displayed during translations and when the dictionary is chosen
+ //! icon displayed during translations and when a dictionary is chosen
QIcon _icon;
QSqlDatabase db;
QString db_name;