TEMPLATE = subdirs
+SUBDIRS = src tests
+CONFIG += ordered
include (mdictionary.pri)
-SUBDIRS = src
+
+
+check.CONFIG += recursive
+check.recurse = src tests
+check.depends = install
+QMAKE_EXTRA_TARGETS += check
message("Enabled sources: "$$ENABLED_SRC)
message("Enabled plugins: "$$ENABLED_PLUGINS)
message("Data directory: "$$DATA_DIR)
message("Plugins directory: "$$PLUGINS_DIR)
message("Documentation directory: "$$DOCS_DIR)
+
+
+if(coverage) {
+ coverage-report.CONFIG = recursive
+ coverage-report.recurse = src
+ QMAKE_EXTRA_TARGETS += coverage-report
+ message('******************************************************************' )
+ message('* Remember to disable CCACHE in scratchbox to make Code Coverage' )
+ message('* report!' )
+ message('* use command: export SBOX_USE_CCACHE="no"' )
+ message('******************************************************************' )
+}
+++ /dev/null
-/*******************************************************************************
-
- This file is part of mDictionary.
-
- mDictionary is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- mDictionary is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-/*! /file AccentsNormalizer.h
-\brief Common functionality for all classes that need to remove accents from strings
-
-\author Bartosz Szatkowski <bulislaw@linux.com>
-*/
-
-#ifndef ACCENTSNORMALIZER_H
-#define ACCENTSNORMALIZER_H
-
-#include <QMap>
-#include <QString>
-#include <QRegExp>
-
-
-class AccentsNormalizer {
- protected:
- QMap<QChar, QRegExp> letters;
- QRegExp noLetter;
-
- QString removeAccents(QString string) {
- string = string.toLower();
- QString normalized = string.normalized(QString::NormalizationForm_KD);
- foreach(QChar let, letters.keys()) {
- normalized.replace(letters[let], QString(let));
- }
- normalized.replace(noLetter, "");
- return normalized;
- }
-
- void initAccents() {
- letters['a'] = QRegExp(QString::fromUtf8("[ÀàÁáÂÂâÃãÄäÅåæÆĀāĂ㥹ǠȀǡȁǢȂǣȃȦȧǺȺǻǼǍǽǎǞǟⱥ]"), Qt::CaseInsensitive);
- letters['b'] = QRegExp(QString::fromUtf8("[ƀƁƂƃɃƄƅ]"), Qt::CaseInsensitive);
- letters['c'] = QRegExp(QString::fromUtf8("[ÇçÈçŒĆćĈĉĊċČčƇƈȻȼ]"), Qt::CaseInsensitive);
- letters['d'] = QRegExp(QString::fromUtf8("[ÐĐđĎďȡƉ]"), Qt::CaseInsensitive);
- letters['e'] = QRegExp(QString::fromUtf8("[ÈéèÉÊêËëĒēĔĕĖėĘęĚěēȄȅȆɆȇɇȨȩ]"), Qt::CaseInsensitive);
- letters['f'] = QRegExp(QString::fromUtf8("[ſƑƒꜰ]"), Qt::CaseInsensitive);
- letters['g'] = QRegExp(QString::fromUtf8("[ĠġĢģĜĝĞğƓǤǴǥǵǦǧ]"), Qt::CaseInsensitive);
- letters['h'] = QRegExp(QString::fromUtf8("[ħĤĥĦȞȟⱧⱨ]"), Qt::CaseInsensitive);
- letters['i'] = QRegExp(QString::fromUtf8("[ÌìÍíÎîÏïİijĨĩĪīĬĭĮįǐƗȈȉȊȋǏꟾ]"), Qt::CaseInsensitive);
- letters['j'] = QRegExp(QString::fromUtf8("[ĴĵǰȷɈɉⱼ]"), Qt::CaseInsensitive);
- letters['k'] = QRegExp(QString::fromUtf8("[ĶķĸƘǨƙǩⱩⱪ]"), Qt::CaseInsensitive);
- letters['l'] = QRegExp(QString::fromUtf8("[ŀŁłĹĺĻļĽľĿȴȽⱠⱡⱢꝈ]"), Qt::CaseInsensitive);
- letters['m'] = QRegExp(QString::fromUtf8("[Ɱ]"), Qt::CaseInsensitive);
- letters['n'] = QRegExp(QString::fromUtf8("[ÑñŃńŅņŇňʼnŊŋȵǸǹƝ]"), Qt::CaseInsensitive);
- letters['o'] = QRegExp(QString::fromUtf8("[ÒòÓóÔÕõÖöØøŐőœŌōŎŏƠȰơǑȱǒǪȪǫȫǬȌȬǭȍȭǾȎȮǿȏȯⱺ]"), Qt::CaseInsensitive);
- letters['p'] = QRegExp(QString::fromUtf8("[ƤƥⱣ]"), Qt::CaseInsensitive);
- letters['q'] = QRegExp(QString::fromUtf8("[Ɋɋ]"), Qt::CaseInsensitive);
- letters['r'] = QRegExp(QString::fromUtf8("[ŕŖŖŗŘřȐȑȒȓɌɍⱤ]"), Qt::CaseInsensitive);
- letters['s'] = QRegExp(QString::fromUtf8("[ߊšŚśŜŝŞşȘșȿꜱ]"), Qt::CaseInsensitive);
- letters['t'] = QRegExp(QString::fromUtf8("[ŢţŤťŦŧȶȚƫțƬƮȾⱦ]"), Qt::CaseInsensitive);
- letters['u'] = QRegExp(QString::fromUtf8("[ÙùÚúÛûÜüŰűŲųŨũŪūŬŮůưǓǔȔɄǕȕǖȖǗȗǘǙǚǛǜƯ]"), Qt::CaseInsensitive);
- letters['v'] = QRegExp(QString::fromUtf8("[Ʋⱱⱴⱽ]"), Qt::CaseInsensitive);
- letters['w'] = QRegExp(QString::fromUtf8("[ŴŵⱲⱳ]"), Qt::CaseInsensitive);
- letters['y'] = QRegExp(QString::fromUtf8("[ÿÝýŶŷŸȲƳȳƴɎɏ]"), Qt::CaseInsensitive);
- letters['z'] = QRegExp(QString::fromUtf8("[ŹźŻżŽžɀȤƵȥƶⱫⱬ]"), Qt::CaseInsensitive);
- noLetter = QRegExp("[^-a-z '\"]", Qt::CaseInsensitive);
- }
-};
-
-#endif // ACCENTSNORMALIZER_H
+++ /dev/null
-/*******************************************************************************
-
- This file is part of mDictionary.
-
- mDictionary is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- mDictionary is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-/*! \file CommonDictInterface.h
-\brief Common interface for all dicts and plugins \see CommonDictInterface
-
-\author Bartosz Szatkowski <bulislaw@linux.com>
-*/
-
-#ifndef COMMONDICTINTERFACE_H
-#define COMMONDICTINTERFACE_H
-
-#include <QString>
-#include <QDialog>
-#include <QObject>
-#include <QList>
-#include "translation.h"
-#include "Notify.h"
-#include "settings.h"
-#include "AccentsNormalizer.h"
-
-class DictDialog;
-
-
-//! Interface for dict engines plugins
-class CommonDictInterface : public QObject, public AccentsNormalizer {
- Q_OBJECT
- public:
- CommonDictInterface(QObject *parent = 0):QObject(parent) {}
-
- virtual ~CommonDictInterface() {}
-
- //! returns source language code iso 639-2
- virtual QString langFrom() const = 0;
-
- //! returns destination language code iso 639-2
- virtual QString langTo() const = 0;
-
- //! returns dictionary name (like "old English" or so)
- virtual QString name() const = 0;
-
- //! returns dictionary type (xdxf, google translate, etc)
- virtual QString type() const = 0;
-
- //! returns information about dictionary in html (name, authors, etc)
- virtual QString infoNote() const = 0;
-
- /*! returns DictDialog object that creates dialogs
- for adding new dictionary and changing plugin settings*/
- virtual DictDialog* dictDialog() = 0;
-
-
- //! 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
- virtual bool isAvailable() const = 0;
-
- //! returns the actual translation of a word given in key
- virtual QString search(QString key) = 0;
-
- //! \returns unique value (unique for every dictionary, not plugin)
- virtual uint hash() const = 0;
-
- //! sets unique value (unique for every dictionary, not plugin)
- virtual void setHash(uint) = 0;
-
- //! returns current plugin settings
- virtual Settings* settings() = 0;
-
- //! returns plugin icon
- virtual QIcon* icon() = 0;
-
- //! returns empty translation object (to be fetched later) for given key
- virtual Translation* getTranslationFor(QString ) {return 0;}
-
- /*! plugin should delete any files (eg. cache) that have been created and are ready
- to be deleted
- */
- virtual void clean() {}
-
-
- public Q_SLOTS:
- /*! performs search in dictionary
- \param word word to search in dictionary
- \param limit limit on number of results,
- if limit=0 all matching words are returned
-
- After finishing search it has to emit
- \see CommonDictInterface:finalTranslation finalTranslation
- */
- virtual QList<Translation*> searchWordList(QString word, int limit=0) = 0;
-
- //! stops current operation
- virtual void stop() = 0;
-
- Q_SIGNALS:
-
- //! emitted when dictionary is ready to use afer being loaded
- void loaded(CommonDictInterface*);
-
- //! 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
- */
- void notify(Notify::NotifyType, QString);
-
-
-protected:
- QString removeAccents(QString string) {
- if(settings()->value("strip_accents") == "true")
- return AccentsNormalizer::removeAccents(string);
- return string;
- }
-};
-
-Q_DECLARE_INTERFACE(CommonDictInterface, "CommonDictInterface/0.1");
-
-#endif
+++ /dev/null
-/*******************************************************************************
-
- This file is part of mDictionary.
-
- mDictionary is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- mDictionary is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-//Created by Mateusz Półrola
-
-#ifndef DICTDIALOG_H
-#define DICTDIALOG_H
-
-#include <QObject>
-
-class Settings;
-
-//! Interface for plugin dialog provider
-class DictDialog : public QObject {
- Q_OBJECT
-
-public:
- DictDialog(QObject *parent = 0) : QObject(parent) {}
-
- /*!
- Shows "add new dictionary" dialog and returns settings of new dict
- \param parent parent widget on which dialog will be displayed
- */
- virtual Settings* addNewDictionary(QWidget*parent=0)=0;
-
- /*!
- Shows "settings" dialog and saves new settings in plugin
- \param parent parent widget on which dialog will be displayed
- */
- virtual void changeSettings(QWidget *parent = 0) = 0;
-};
-
-#endif // DICTDIALOG_H
+++ /dev/null
-/*******************************************************************************
-
- This file is part of mDictionary.
-
- mDictionary is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- mDictionary is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-//! \file GUIInterface.h
-//! \brief Defines interface for GUI
-//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
-
-
-
-#ifndef GUIINTERFACE_H
-#define GUIINTERFACE_H
-#include <QMainWindow>
-#include <QMultiHash>
-
-#include "translation.h"
-#include "CommonDictInterface.h"
-
-class Settings;
-
-//! Interface for different GUIs
-/*!
- Default base class for all GUIs is QMainWindow
- */
-class GUIInterface : public QMainWindow {
- Q_OBJECT
-
-public:
- GUIInterface(QWidget *parent = 0) :QMainWindow(parent) {}
-
- virtual ~GUIInterface() {}
-
- //! Returns all loaded dictionaries with information about that they are
- //! active/inactive
- /*!
- \return Hash of pointers to dictionary and boolean flag indicating if
- dictionary is active
- */
- virtual QHash<CommonDictInterface*, bool> getDictionaries() = 0;
-
-
- //! Returns all loaded plugins
- /*!
- \return List of pointers to plugins
- */
- virtual QList<CommonDictInterface*> getPlugins() = 0;
-
- //! Indicates if GUI is in exact search mode.
- /*! When GUI is in exact search mode it searches for word, and
- if it finds exactly matching translation it directly displays it, without
- displaying matching word list. This mode should be
- used for browsing search history and searching words from application
- arguments.
- \returns flag indicating if GUI is in exact search mode
- */
- bool exactSearch();
-
- //! Sets GUI exact search mode.
- /*! \sa exactSearch() */
- void setExactSearch(bool exactSearch);
-
- virtual Settings* settings() = 0;
-
- virtual void setSettings(Settings*) = 0;
-
-
-public Q_SLOTS:
- //! Searches in exact mode for given word
- /*!
- GUI will be automatically set into exact search mode, and after search or
- break it will be unset from exact search mode.
- \param word which will be searched in dictionaries
- */
- virtual void searchExact(QString word) = 0;
-
- //! Adds key words from given translations to history
- /*!
- By default this slot is connected to searchTranslations signal, and
- passed translations list contains only translations with the same key, so
- only one word is added to history.
- \param list of translations with key words
- \sa searchTranslations();
- */
- virtual void addToHistory(QList<Translation*>) = 0;
-
- //! Shows history dialog
- virtual void showHistory(QPoint) = 0;
-
- //! Shows translation of next word in history
- /*!
- It will work only if there is next word available in history.
- Translation of word is searched with searchExact() function
- \sa searchExact()
- */
- virtual void historyNext() = 0;
-
- //! Shows translation of previous word in history
- /*!
- It will work only if there is previous word available in history.
- Translation of word is searched with searchExact() function
- \sa searchExact()
- */
- virtual void historyPrev() = 0;
-
- //! Gets words list from backbone and prepares received list to display
- /*!
- Checks if received list is empty, in that case it displays suitable
- information. If GUI is in exact search mode it will search for exact
- word in received list, and if word is found it will emit signal to
- display its translation. Otherwise it will display list of matching
- words and show suitable information.
- \sa exactSearch()
- \sa showTranslation()
- */
- virtual void wordListReady() = 0;
-
- //! Gets translation strings from backbone and emits signal to display them
- virtual void translationsReady() = 0;
-
-Q_SIGNALS:
- //! Should be emitted when user wants to close application to stop
- //! all ongoing searches
- void quit();
-
- //! Emitted when user wants to search for list of words matching given word
- /*! \param word word which will be matched, it can contain wildcards
- */
- void searchWordList(QString word);
-
- //! Emitted when user wants to see translation of words.
- /*! \param list of translations for given word which will be received
- in wordListReady() slot
- \sa wordListReady()
- */
- void searchTranslations(QList<Translation*>);
-
- //! Emitted when starting search, will disable GUI components
- //! and show progress bars
- void setBusy();
-
- //! Emitted when searching ends, will enable GUI components
- void setIdle();
-
- //! Emitted when user wants to break search
- void stopSearching();
-
- //! Emitted after receiving word list in wordListReady() slot, will display
- //! list of matched words
- /*! \param hash of word and list of translations of this word found
- in dictionaries
- */
- void showWordList(QHash<QString, QList<Translation*> >);
-
- //! Emitted after receiving translation strings in translationsReady() slot,
- //! will display translation of given word
- /*! \param list of translations from different dictionaries
- in dictionaries
- */
- void showTranslation(QStringList);
-
- //! Emitted when user wants to add new dictionary
- /*! \param new dictionary returned by specific plugin dialog
- */
- void addNewDictionary(CommonDictInterface*);
-
- //! Emitted when user wants to remove dictionary
- /*! \param dictionary which will be removed
- */
- void removeDictionary(CommonDictInterface*);
-
- //! Emitted when user changes dictionaries active/inactive states
- /*! \param list of only active dictionaries
- */
- void selectedDictionaries(QList<CommonDictInterface* >);
-
- void addToBookmarks(QList<Translation*>);
-};
-
-#endif // GUIINTERFACE_H
+++ /dev/null
-/*******************************************************************************
-
- This file is part of mDictionary.
-
- mDictionary is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- mDictionary is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-//Created by Mateusz Półrola
-
-#ifndef HISTORY_H
-#define HISTORY_H
-
-#include <QObject>
-#include <QVector>
-#include <QStringList>
-
-class History : public QObject
-{
- Q_OBJECT
-public:
- explicit History(int maxSize = 5, QObject *parent = 0);
-
-Q_SIGNALS:
- void historyChanged(bool prevAvailable,
- bool nextAvailable,
- bool listAvailable);
-
-public Q_SLOTS:
- void refreshStatus();
-
-public:
- void add(QString);
- QString previous();
- QString next();
- QStringList list();
-
- bool prevAvailable();
- bool nextAvailable();
- bool listAvailable();
-
- void setCurrentElement(int element);
-
- int maxSize();
-
- void setMaxSize(int size);
-
-private:
- QVector<QString> _history;
- int _maxSize;
- int currentElement;
- bool _prevAvailable;
- bool _nextAvailable;
- bool _listAvailable;
-};
-
-#endif // HISTORY_H
+++ /dev/null
-/*******************************************************************************
-
- This file is part of mDictionary.
-
- mDictionary is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- mDictionary is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-/*! /file Notify.h
-\brief Declaration of common notify subsystem (NotifyType for now)
-
-\author Bartosz Szatkowski <bulislaw@linux.com>
-*/
-
-#ifndef NOTIFY_H
-#define NOTIFY_H
-
-#include <QObject>
-#include <QMetaClassInfo>
-
-/*! Notify wraps NotifyType which is interpreted by GUI and may change way in
- which GUI handles given notification
- */
-class Notify : QObject {
- Q_OBJECT
-public:
- Notify() : QObject(0) {}
- Notify(const Notify&) : QObject(0) {}
- enum notifytype {Error, Warning, Info};
- Q_DECLARE_FLAGS(NotifyType, notifytype);
-};
-#endif // NOTIFY_H
+++ /dev/null
-/*******************************************************************************
-
- This file is part of mDictionary.
-
- mDictionary is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- mDictionary is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-/*! \file settings.h
-\brief Settings object for plugins \see Settings
-
-\author Bartosz Szatkowski <bulislaw@linux.com>
-*/
-
-#ifndef SETTINGS_H
-#define SETTINGS_H
-
-#include <QString>
-#include <QHash>
-#include <QDebug>
-
-/*! Plugins or dictionaries may need to keep some of configuration between
- sessions, moreover Backbone or GUI may want to store some additional info in
- plugin Settings.
-
- It's important for plugin to store all information given to it in Settings.*/
-class Settings {
- public:
- Settings(){}
- Settings(const Settings* set) {
- _settings = QHash<QString, QString>(set->_settings);
- }
- ~Settings(){}
-
- /*! \returns value fo given key
- \param key
- */
- QString value(const QString key) const {
- if(!_settings.contains(key)) {
- return QString();
- }
- return _settings[key];
- }
-
- //! sets key to value
- void setValue(const QString key, const QString value) {
- _settings.insert(key, value);
- }
-
- QList<QString> keys() const {
- return _settings.keys();
- }
-
-private:
- QHash<QString, QString> _settings;
-};
-
-#endif // SETTINGS_H
+++ /dev/null
-/*******************************************************************************
-
- This file is part of mDictionary.
-
- mDictionary is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- mDictionary is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-/*! \file translation.h
-\brief Interface for translation instances \see Translation
-
-\author Bartosz Szatkowski <bulislaw@linux.com>
-*/
-
-#ifndef TRANSLATION_H
-#define TRANSLATION_H
-
-#include <QString>
-#include <QMetaType>
-#include <QDebug>
-
-class CommonDictInterface;
-
-
-/*! Translation is kind of GoF proxy, it stores key:translation pair and
- provides it in lazy way -> key is available always, but translation is fetched
- as late as possible*/
-class Translation {
- public:
- Translation () { _bookmark = 0;}
- virtual ~Translation () {}
- //! \return word to be translated
- virtual QString key() const = 0;
-
- bool operator==(Translation* translation) {
- return this->key()==translation->key();
- }
-
- /*! \returns dictionary information (plugin name, languages, <logo> etc)\
- to be displayed in translation table header */
- virtual QString dictionaryInfo() const = 0;
-
- //! \return parsed raw format into html
- virtual QString toHtml() const = 0;
-
- //! \return whether given translation is taken from bookmarks
- virtual bool isBookmark() const {
- return _bookmark;
- }
-
- //! \param b if true then translation is from bookmarks
- void setBookmark(bool b) {
- _bookmark = b;
- }
-
- //! returns coresponding dict object
- virtual uint dict() const {return 0;}
-
- protected:
- bool _bookmark;
-
-};
-
-Q_DECLARE_METATYPE(Translation*);
-Q_DECLARE_METATYPE(QList<Translation*>);
-
-#endif
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! /file AccentsNormalizer.h
+\brief Common functionality for all classes that need to remove accents from strings
+
+\author Bartosz Szatkowski <bulislaw@linux.com>
+*/
+
+#ifndef ACCENTSNORMALIZER_H
+#define ACCENTSNORMALIZER_H
+
+#include <QMap>
+#include <QString>
+#include <QRegExp>
+
+
+class AccentsNormalizer {
+ protected:
+ QMap<QChar, QRegExp> letters;
+ QRegExp noLetter;
+
+ QString removeAccents(QString string) {
+ string = string.toLower();
+ QString normalized = string.normalized(QString::NormalizationForm_KD);
+ foreach(QChar let, letters.keys()) {
+ normalized.replace(letters[let], QString(let));
+ }
+ normalized.replace(noLetter, "");
+ return normalized;
+ }
+
+ void initAccents() {
+ letters['a'] = QRegExp(QString::fromUtf8("[ÀàÁáÂÂâÃãÄäÅåæÆĀāĂ㥹ǠȀǡȁǢȂǣȃȦȧǺȺǻǼǍǽǎǞǟⱥ]"), Qt::CaseInsensitive);
+ letters['b'] = QRegExp(QString::fromUtf8("[ƀƁƂƃɃƄƅ]"), Qt::CaseInsensitive);
+ letters['c'] = QRegExp(QString::fromUtf8("[ÇçÈçŒĆćĈĉĊċČčƇƈȻȼ]"), Qt::CaseInsensitive);
+ letters['d'] = QRegExp(QString::fromUtf8("[ÐĐđĎďȡƉ]"), Qt::CaseInsensitive);
+ letters['e'] = QRegExp(QString::fromUtf8("[ÈéèÉÊêËëĒēĔĕĖėĘęĚěēȄȅȆɆȇɇȨȩ]"), Qt::CaseInsensitive);
+ letters['f'] = QRegExp(QString::fromUtf8("[ſƑƒꜰ]"), Qt::CaseInsensitive);
+ letters['g'] = QRegExp(QString::fromUtf8("[ĠġĢģĜĝĞğƓǤǴǥǵǦǧ]"), Qt::CaseInsensitive);
+ letters['h'] = QRegExp(QString::fromUtf8("[ħĤĥĦȞȟⱧⱨ]"), Qt::CaseInsensitive);
+ letters['i'] = QRegExp(QString::fromUtf8("[ÌìÍíÎîÏïİijĨĩĪīĬĭĮįǐƗȈȉȊȋǏꟾ]"), Qt::CaseInsensitive);
+ letters['j'] = QRegExp(QString::fromUtf8("[ĴĵǰȷɈɉⱼ]"), Qt::CaseInsensitive);
+ letters['k'] = QRegExp(QString::fromUtf8("[ĶķĸƘǨƙǩⱩⱪ]"), Qt::CaseInsensitive);
+ letters['l'] = QRegExp(QString::fromUtf8("[ŀŁłĹĺĻļĽľĿȴȽⱠⱡⱢꝈ]"), Qt::CaseInsensitive);
+ letters['m'] = QRegExp(QString::fromUtf8("[Ɱ]"), Qt::CaseInsensitive);
+ letters['n'] = QRegExp(QString::fromUtf8("[ÑñŃńŅņŇňʼnŊŋȵǸǹƝ]"), Qt::CaseInsensitive);
+ letters['o'] = QRegExp(QString::fromUtf8("[ÒòÓóÔÕõÖöØøŐőœŌōŎŏƠȰơǑȱǒǪȪǫȫǬȌȬǭȍȭǾȎȮǿȏȯⱺ]"), Qt::CaseInsensitive);
+ letters['p'] = QRegExp(QString::fromUtf8("[ƤƥⱣ]"), Qt::CaseInsensitive);
+ letters['q'] = QRegExp(QString::fromUtf8("[Ɋɋ]"), Qt::CaseInsensitive);
+ letters['r'] = QRegExp(QString::fromUtf8("[ŕŖŖŗŘřȐȑȒȓɌɍⱤ]"), Qt::CaseInsensitive);
+ letters['s'] = QRegExp(QString::fromUtf8("[ߊšŚśŜŝŞşȘșȿꜱ]"), Qt::CaseInsensitive);
+ letters['t'] = QRegExp(QString::fromUtf8("[ŢţŤťŦŧȶȚƫțƬƮȾⱦ]"), Qt::CaseInsensitive);
+ letters['u'] = QRegExp(QString::fromUtf8("[ÙùÚúÛûÜüŰűŲųŨũŪūŬŮůưǓǔȔɄǕȕǖȖǗȗǘǙǚǛǜƯ]"), Qt::CaseInsensitive);
+ letters['v'] = QRegExp(QString::fromUtf8("[Ʋⱱⱴⱽ]"), Qt::CaseInsensitive);
+ letters['w'] = QRegExp(QString::fromUtf8("[ŴŵⱲⱳ]"), Qt::CaseInsensitive);
+ letters['y'] = QRegExp(QString::fromUtf8("[ÿÝýŶŷŸȲƳȳƴɎɏ]"), Qt::CaseInsensitive);
+ letters['z'] = QRegExp(QString::fromUtf8("[ŹźŻżŽžɀȤƵȥƶⱫⱬ]"), Qt::CaseInsensitive);
+ noLetter = QRegExp("[^-a-z '\"]", Qt::CaseInsensitive);
+ }
+};
+
+#endif // ACCENTSNORMALIZER_H
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file CommonDictInterface.h
+\brief Common interface for all dicts and plugins \see CommonDictInterface
+
+\author Bartosz Szatkowski <bulislaw@linux.com>
+*/
+
+#ifndef COMMONDICTINTERFACE_H
+#define COMMONDICTINTERFACE_H
+
+#include <QString>
+#include <QDialog>
+#include <QObject>
+#include <QList>
+#include "translation.h"
+#include "Notify.h"
+#include "settings.h"
+#include "AccentsNormalizer.h"
+
+class DictDialog;
+
+
+//! Interface for dict engines plugins
+class CommonDictInterface : public QObject, public AccentsNormalizer {
+ Q_OBJECT
+ public:
+ CommonDictInterface(QObject *parent = 0):QObject(parent) {}
+
+ virtual ~CommonDictInterface() {}
+
+ //! returns source language code iso 639-2
+ virtual QString langFrom() const = 0;
+
+ //! returns destination language code iso 639-2
+ virtual QString langTo() const = 0;
+
+ //! returns dictionary name (like "old English" or so)
+ virtual QString name() const = 0;
+
+ //! returns dictionary type (xdxf, google translate, etc)
+ virtual QString type() const = 0;
+
+ //! returns information about dictionary in html (name, authors, etc)
+ virtual QString infoNote() const = 0;
+
+ /*! returns DictDialog object that creates dialogs
+ for adding new dictionary and changing plugin settings*/
+ virtual DictDialog* dictDialog() = 0;
+
+
+ //! 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
+ virtual bool isAvailable() const = 0;
+
+ //! returns the actual translation of a word given in key
+ virtual QString search(QString key) = 0;
+
+ //! \returns unique value (unique for every dictionary, not plugin)
+ virtual uint hash() const = 0;
+
+ //! sets unique value (unique for every dictionary, not plugin)
+ virtual void setHash(uint) = 0;
+
+ //! returns current plugin settings
+ virtual Settings* settings() = 0;
+
+ //! returns plugin icon
+ virtual QIcon* icon() = 0;
+
+ //! returns empty translation object (to be fetched later) for given key
+ virtual Translation* getTranslationFor(QString ) {return 0;}
+
+ /*! plugin should delete any files (eg. cache) that have been created and are ready
+ to be deleted
+ */
+ virtual void clean() {}
+
+
+ public Q_SLOTS:
+ /*! performs search in dictionary
+ \param word word to search in dictionary
+ \param limit limit on number of results,
+ if limit=0 all matching words are returned
+
+ After finishing search it has to emit
+ \see CommonDictInterface:finalTranslation finalTranslation
+ */
+ virtual QList<Translation*> searchWordList(QString word, int limit=0) = 0;
+
+ //! stops current operation
+ virtual void stop() = 0;
+
+ Q_SIGNALS:
+
+ //! emitted when dictionary is ready to use afer being loaded
+ void loaded(CommonDictInterface*);
+
+ //! 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
+ */
+ void notify(Notify::NotifyType, QString);
+
+
+protected:
+ QString removeAccents(QString string) {
+ if(settings()->value("strip_accents") == "true")
+ return AccentsNormalizer::removeAccents(string);
+ return string;
+ }
+};
+
+Q_DECLARE_INTERFACE(CommonDictInterface, "CommonDictInterface/0.1");
+
+#endif
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#ifndef DICTDIALOG_H
+#define DICTDIALOG_H
+
+#include <QObject>
+
+class Settings;
+
+//! Interface for plugin dialog provider
+class DictDialog : public QObject {
+ Q_OBJECT
+
+public:
+ DictDialog(QObject *parent = 0) : QObject(parent) {}
+
+ /*!
+ Shows "add new dictionary" dialog and returns settings of new dict
+ \param parent parent widget on which dialog will be displayed
+ */
+ virtual Settings* addNewDictionary(QWidget*parent=0)=0;
+
+ /*!
+ Shows "settings" dialog and saves new settings in plugin
+ \param parent parent widget on which dialog will be displayed
+ */
+ virtual void changeSettings(QWidget *parent = 0) = 0;
+};
+
+#endif // DICTDIALOG_H
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+//! \file GUIInterface.h
+//! \brief Defines interface for GUI
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+
+
+
+#ifndef GUIINTERFACE_H
+#define GUIINTERFACE_H
+#include <QMainWindow>
+#include <QMultiHash>
+
+#include "translation.h"
+#include "CommonDictInterface.h"
+
+class Settings;
+
+//! Interface for different GUIs
+/*!
+ Default base class for all GUIs is QMainWindow
+ */
+class GUIInterface : public QMainWindow {
+ Q_OBJECT
+
+public:
+ GUIInterface(QWidget *parent = 0) :QMainWindow(parent) {}
+
+ virtual ~GUIInterface() {}
+
+ //! Returns all loaded dictionaries with information about that they are
+ //! active/inactive
+ /*!
+ \return Hash of pointers to dictionary and boolean flag indicating if
+ dictionary is active
+ */
+ virtual QHash<CommonDictInterface*, bool> getDictionaries() = 0;
+
+
+ //! Returns all loaded plugins
+ /*!
+ \return List of pointers to plugins
+ */
+ virtual QList<CommonDictInterface*> getPlugins() = 0;
+
+ //! Indicates if GUI is in exact search mode.
+ /*! When GUI is in exact search mode it searches for word, and
+ if it finds exactly matching translation it directly displays it, without
+ displaying matching word list. This mode should be
+ used for browsing search history and searching words from application
+ arguments.
+ \returns flag indicating if GUI is in exact search mode
+ */
+ bool exactSearch();
+
+ //! Sets GUI exact search mode.
+ /*! \sa exactSearch() */
+ void setExactSearch(bool exactSearch);
+
+ virtual Settings* settings() = 0;
+
+ virtual void setSettings(Settings*) = 0;
+
+
+public Q_SLOTS:
+ //! Searches in exact mode for given word
+ /*!
+ GUI will be automatically set into exact search mode, and after search or
+ break it will be unset from exact search mode.
+ \param word which will be searched in dictionaries
+ */
+ virtual void searchExact(QString word) = 0;
+
+ //! Adds key words from given translations to history
+ /*!
+ By default this slot is connected to searchTranslations signal, and
+ passed translations list contains only translations with the same key, so
+ only one word is added to history.
+ \param list of translations with key words
+ \sa searchTranslations();
+ */
+ virtual void addToHistory(QList<Translation*>) = 0;
+
+ //! Shows history dialog
+ virtual void showHistory(QPoint) = 0;
+
+ //! Shows translation of next word in history
+ /*!
+ It will work only if there is next word available in history.
+ Translation of word is searched with searchExact() function
+ \sa searchExact()
+ */
+ virtual void historyNext() = 0;
+
+ //! Shows translation of previous word in history
+ /*!
+ It will work only if there is previous word available in history.
+ Translation of word is searched with searchExact() function
+ \sa searchExact()
+ */
+ virtual void historyPrev() = 0;
+
+ //! Gets words list from backbone and prepares received list to display
+ /*!
+ Checks if received list is empty, in that case it displays suitable
+ information. If GUI is in exact search mode it will search for exact
+ word in received list, and if word is found it will emit signal to
+ display its translation. Otherwise it will display list of matching
+ words and show suitable information.
+ \sa exactSearch()
+ \sa showTranslation()
+ */
+ virtual void wordListReady() = 0;
+
+ //! Gets translation strings from backbone and emits signal to display them
+ virtual void translationsReady() = 0;
+
+Q_SIGNALS:
+ //! Should be emitted when user wants to close application to stop
+ //! all ongoing searches
+ void quit();
+
+ //! Emitted when user wants to search for list of words matching given word
+ /*! \param word word which will be matched, it can contain wildcards
+ */
+ void searchWordList(QString word);
+
+ //! Emitted when user wants to see translation of words.
+ /*! \param list of translations for given word which will be received
+ in wordListReady() slot
+ \sa wordListReady()
+ */
+ void searchTranslations(QList<Translation*>);
+
+ //! Emitted when starting search, will disable GUI components
+ //! and show progress bars
+ void setBusy();
+
+ //! Emitted when searching ends, will enable GUI components
+ void setIdle();
+
+ //! Emitted when user wants to break search
+ void stopSearching();
+
+ //! Emitted after receiving word list in wordListReady() slot, will display
+ //! list of matched words
+ /*! \param hash of word and list of translations of this word found
+ in dictionaries
+ */
+ void showWordList(QHash<QString, QList<Translation*> >);
+
+ //! Emitted after receiving translation strings in translationsReady() slot,
+ //! will display translation of given word
+ /*! \param list of translations from different dictionaries
+ in dictionaries
+ */
+ void showTranslation(QStringList);
+
+ //! Emitted when user wants to add new dictionary
+ /*! \param new dictionary returned by specific plugin dialog
+ */
+ void addNewDictionary(CommonDictInterface*);
+
+ //! Emitted when user wants to remove dictionary
+ /*! \param dictionary which will be removed
+ */
+ void removeDictionary(CommonDictInterface*);
+
+ //! Emitted when user changes dictionaries active/inactive states
+ /*! \param list of only active dictionaries
+ */
+ void selectedDictionaries(QList<CommonDictInterface* >);
+
+ void addToBookmarks(QList<Translation*>);
+};
+
+#endif // GUIINTERFACE_H
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#ifndef HISTORY_H
+#define HISTORY_H
+
+#include <QObject>
+#include <QVector>
+#include <QStringList>
+
+class History : public QObject
+{
+ Q_OBJECT
+public:
+ explicit History(int maxSize = 5, QObject *parent = 0);
+
+Q_SIGNALS:
+ void historyChanged(bool prevAvailable,
+ bool nextAvailable,
+ bool listAvailable);
+
+public Q_SLOTS:
+ void refreshStatus();
+
+public:
+ void add(QString);
+ QString previous();
+ QString next();
+ QStringList list();
+
+ bool prevAvailable();
+ bool nextAvailable();
+ bool listAvailable();
+
+ void setCurrentElement(int element);
+
+ int maxSize();
+
+ void setMaxSize(int size);
+
+private:
+ QVector<QString> _history;
+ int _maxSize;
+ int currentElement;
+ bool _prevAvailable;
+ bool _nextAvailable;
+ bool _listAvailable;
+};
+
+#endif // HISTORY_H
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! /file Notify.h
+\brief Declaration of common notify subsystem (NotifyType for now)
+
+\author Bartosz Szatkowski <bulislaw@linux.com>
+*/
+
+#ifndef NOTIFY_H
+#define NOTIFY_H
+
+#include <QObject>
+#include <QMetaClassInfo>
+
+/*! Notify wraps NotifyType which is interpreted by GUI and may change way in
+ which GUI handles given notification
+ */
+class Notify : QObject {
+ Q_OBJECT
+public:
+ Notify() : QObject(0) {}
+ Notify(const Notify&) : QObject(0) {}
+ enum notifytype {Error, Warning, Info};
+ Q_DECLARE_FLAGS(NotifyType, notifytype);
+};
+#endif // NOTIFY_H
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file settings.h
+\brief Settings object for plugins \see Settings
+
+\author Bartosz Szatkowski <bulislaw@linux.com>
+*/
+
+#ifndef SETTINGS_H
+#define SETTINGS_H
+
+#include <QString>
+#include <QHash>
+#include <QDebug>
+
+/*! Plugins or dictionaries may need to keep some of configuration between
+ sessions, moreover Backbone or GUI may want to store some additional info in
+ plugin Settings.
+
+ It's important for plugin to store all information given to it in Settings.*/
+class Settings {
+ public:
+ Settings(){}
+ Settings(const Settings* set) {
+ _settings = QHash<QString, QString>(set->_settings);
+ }
+ ~Settings(){}
+
+ /*! \returns value fo given key
+ \param key
+ */
+ QString value(const QString key) const {
+ if(!_settings.contains(key)) {
+ return QString();
+ }
+ return _settings[key];
+ }
+
+ //! sets key to value
+ void setValue(const QString key, const QString value) {
+ _settings.insert(key, value);
+ }
+
+ QList<QString> keys() const {
+ return _settings.keys();
+ }
+
+private:
+ QHash<QString, QString> _settings;
+};
+
+#endif // SETTINGS_H
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file translation.h
+\brief Interface for translation instances \see Translation
+
+\author Bartosz Szatkowski <bulislaw@linux.com>
+*/
+
+#ifndef TRANSLATION_H
+#define TRANSLATION_H
+
+#include <QString>
+#include <QMetaType>
+#include <QDebug>
+
+class CommonDictInterface;
+
+
+/*! Translation is kind of GoF proxy, it stores key:translation pair and
+ provides it in lazy way -> key is available always, but translation is fetched
+ as late as possible*/
+class Translation {
+ public:
+ Translation () { _bookmark = 0;}
+ virtual ~Translation () {}
+ //! \return word to be translated
+ virtual QString key() const = 0;
+
+ bool operator==(Translation* translation) {
+ return this->key()==translation->key();
+ }
+
+ /*! \returns dictionary information (plugin name, languages, <logo> etc)\
+ to be displayed in translation table header */
+ virtual QString dictionaryInfo() const = 0;
+
+ //! \return parsed raw format into html
+ virtual QString toHtml() const = 0;
+
+ //! \return whether given translation is taken from bookmarks
+ virtual bool isBookmark() const {
+ return _bookmark;
+ }
+
+ //! \param b if true then translation is from bookmarks
+ void setBookmark(bool b) {
+ _bookmark = b;
+ }
+
+ //! returns coresponding dict object
+ virtual uint dict() const {return 0;}
+
+ protected:
+ bool _bookmark;
+
+};
+
+Q_DECLARE_METATYPE(Translation*);
+Q_DECLARE_METATYPE(QList<Translation*>);
+
+#endif
#ifndef BOOKMARKTRANSLATIONS_H
#define BOOKMARKTRANSLATIONS_H
-#include "../../common/settings.h"
-#include "../../common/translation.h"
+#include "../../include/settings.h"
+#include "../../include/translation.h"
#include "Bookmarks.h"
#include "QObject"
#include <QSqlError>
#include <QDir>
#include <QDebug>
-#include "../../common/settings.h"
-#include "../../common/translation.h"
-#include "../../common/AccentsNormalizer.h"
+#include "../../include/settings.h"
+#include "../../include/translation.h"
+#include "../../include/AccentsNormalizer.h"
class BookmarkTranslation;
//Created by Mateusz Półrola
-#include "../../common/History.h"
+#include "../../include/History.h"
#include <QDebug>
History::History(int maxSize, QObject *parent) :
#include <QThread>
#include <QSettings>
#include <QFutureWatcher>
-#include "../../common/CommonDictInterface.h"
-#include "../../common/settings.h"
-#include "../../common/translation.h"
-#include "../../common/History.h"
-#include "../../common/Notify.h"
+#include "../../include/CommonDictInterface.h"
+#include "../../include/settings.h"
+#include "../../include/translation.h"
+#include "../../include/History.h"
+#include "../../include/Notify.h"
#include "ConfigGenerator.h"
#include "Bookmarks.h"
#include <QDialog>
#include <QWidget>
#include <QtGui>
-#include "../../common/GUIInterface.h"
+#include "../../include/GUIInterface.h"
class AboutWidget : public QDialog
{
#include <QDialog>
#include <QtGui>
-#include "../../common/GUIInterface.h"
+#include "../../include/GUIInterface.h"
//! Implements bookmarks management widget
/*!
#include "DictManagerWidget.h"
#include "DictTypeSelectDialog.h"
#include <QDebug>
-#include "../../common/DictDialog.h"
+#include "../../include/DictDialog.h"
DictManagerWidget::DictManagerWidget(GUIInterface *parent) :
QDialog(parent) {
#include <QWidget>
#include <QtGui>
-#include "../../common/GUIInterface.h"
+#include "../../include/GUIInterface.h"
//! Implements dictionaries management widget
#include <QDialog>
#include <QtGui>
-#include "../../common/settings.h"
-#include "../../common/CommonDictInterface.h"
+#include "../../include/settings.h"
+#include "../../include/CommonDictInterface.h"
#define PLUGIN_ROW_ROLE 99 //TODO remove this
#include <QDialog>
#include "SearchBarWidget.h"
-#include "../../common/History.h"
+#include "../../include/History.h"
#include <QtGui>
#define MAINWINDOW_H
#include <QMainWindow>
-#include "../../common/GUIInterface.h"
-#include "../../common/settings.h"
+#include "../../include/GUIInterface.h"
+#include "../../include/settings.h"
#include "../backbone/backbone.h"
#include "TranslationWidget.h"
#include "WordListWidget.h"
#include <QHash>
#include <QString>
#include <QDialog>
-#include "../../common/Notify.h"
+#include "../../include/Notify.h"
//! Manages notifications in applications
/*!
#include "SearchBarWidget.h"
#include <QDebug>
-#include "../../common/DictDialog.h"
+#include "../../include/DictDialog.h"
#include "HistoryListDialog.h"
#include <QWidget>
#include <QtGui>
#include "../backbone/backbone.h"
-#include "../../common/History.h"
+#include "../../include/History.h"
//! Displays search bar
/*!
#include <QWidget>
#include <QtGui>
#include <QPushButton>
-#include "../../common/GUIInterface.h"
-#include "../../common/settings.h"
+#include "../../include/GUIInterface.h"
+#include "../../include/settings.h"
//! Implements applications settings widget
/*!
#include <QXmlQuery>
#include "TranslationTextEdit.h"
#include <QPropertyAnimation>
-#include "../../common/GUIInterface.h"
+#include "../../include/GUIInterface.h"
//! Displays translation of word found in dictionaries
/*!
#include "WordListWidget.h"
#include "WordListProxyStyle.h"
-#include "../../common/translation.h"
+#include "../../include/translation.h"
WordListWidget::WordListWidget(QWidget *parent):
#include <QtGui/QApplication>
#include "MainWindow.h"
#include "../backbone/backbone.h"
-#include "../../common/translation.h"
-#include "../../common/Notify.h"
+#include "../../include/translation.h"
+#include "../../include/Notify.h"
#include "DBusAdapter.h"
#include <QDebug>
#include <QDBusConnection>
gui/WordListWidget.h \
gui/TranslationWidget.h \
backbone/backbone.h \
- ../common/translation.h \
- ../common/settings.h \
- ../common/CommonDictInterface.h \
+ ../include/translation.h \
+ ../include/settings.h \
+ ../include/CommonDictInterface.h \
gui/MenuWidget.h \
gui/MenuTabWidget.h \
gui/DictManagerWidget.h \
gui/DictTypeSelectDialog.h \
- ../common/History.h \
+ ../include/History.h \
gui/HistoryListDialog.h \
- ../common/GUIInterface.h \
+ ../include/GUIInterface.h \
gui/WordListProxyStyle.h \
backbone/Bookmarks.h \
backbone/BookmarkTranslations.h \
gui/SettingsWidget.h \
gui/BookmarksWidget.h \
gui/WelcomeScreenWidget.h \
- ../common/Notify.h \
+ ../include/Notify.h \
gui/TranslationTextEdit.h \
- ../common/AccentsNormalizer.h \
- ../common/DictDialog.h \
+ ../include/AccentsNormalizer.h \
+ ../include/DictDialog.h \
gui/DBusAdapter.h \
gui/NotifyManager.h
INSTALLS += desktop icon64 bookmarks service
}
+
+
+
+coverage {
+ # add flags to compiler
+ LIBS += -lgcov
+ QMAKE_CXXFLAGS += -ftest-coverage -fprofile-arcs -fno-elide-constructors
+
+ # and add a target for generating report
+ QMAKE_EXTRA_TARGETS += coverage-report
+ coverage-report.commands = lcov -d .obj --capture --output-file all.cov -b . &&
+ coverage-report.commands += lcov -r all.cov '*thumbtest*' -r all.cov '*/src/dbus/*' -r all.cov '*/src/.moc/*' -o to_test.cov &&
+ coverage-report.commands += lcov -e to_test.cov '*/*/src/*.cpp*' -e to_test.cov '*/*/src/*.h*' -e to_test.cov '*/*/src/common/*.h*' -o final.cov &&
+ coverage-report.commands += genhtml -o coverage final.cov
+}
+
+check.commands = echo 'No check here'
+QMAKE_EXTRA_TARGETS += check
#ifndef GOOGLEDICTDIALOG_H
#define GOOGLEDICTDIALOG_H
-#include "../../common/DictDialog.h"
-#include "../../common/settings.h"
+#include "../../include/DictDialog.h"
+#include "../../include/settings.h"
#include "GooglePlugin.h"
#include "GoogleSettingsDialog.h"
#include <QIcon>
#include <QtNetwork>
-#include "../../common/CommonDictInterface.h"
-#include "../../common/settings.h"
-#include "../../common/DictDialog.h"
+#include "../../include/CommonDictInterface.h"
+#include "../../include/settings.h"
+#include "../../include/DictDialog.h"
#include "TranslationGoogle.h"
#include "GoogleDictDialog.h"
#define GOOGLESETTINGSDIALOG_H
#include <QDialog>
-#include "../../common/settings.h"
+#include "../../include/settings.h"
#include <QtGui>
#include "GooglePlugin.h"
#ifndef TRANSLATIONGOOGLE_H
#define TRANSLATIONGOOGLE_H
-#include "../../common/translation.h"
+#include "../../include/translation.h"
#include "GooglePlugin.h"
class GooglePlugin;
HEADERS += \
GooglePlugin.h \
- ../../common/DictDialog.h \
- ../../common/translation.h \
- ../../common/settings.h \
- ../../common/CommonDictInterface.h \
+ ../../include/DictDialog.h \
+ ../../include/translation.h \
+ ../../include/settings.h \
+ ../../include/CommonDictInterface.h \
TranslationGoogle.h \
GoogleDictDialog.h \
GoogleSettingsDialog.h
#define TRANSLATIONXDXF_H
#include <QString>
-#include "../../common/translation.h"
+#include "../../include/translation.h"
#include "xdxfplugin.h"
class TranslationXdxf : public Translation
#ifndef XDXFDICTDIALOG_H
#define XDXFDICTDIALOG_H
-#include "../../common/DictDialog.h"
+#include "../../include/DictDialog.h"
#include "XdxfLoadDialog.h"
class XdxfPlugin;
#include <QDialog>
#include <QtGui>
-#include "../../common/settings.h"
+#include "../../include/settings.h"
//! Displays dialog which allows user to add new xdxf dictionary
class XdxfLoadDialog : public QDialog {
#define XDXFSETTINGSDIALOG_H
#include <QDialog>
-#include "../../common/settings.h"
+#include "../../include/settings.h"
#include <QtGui>
#include "xdxfplugin.h"
xdxfplugin.h \
TranslationXdxf.h \
XdxfLoadDialog.h \
- ../../common/DictDialog.h \
+ ../../include/DictDialog.h \
XdxfDictDialog.h \
- ../../common/translation.h \
- ../../common/settings.h \
- ../../common/CommonDictInterface.h \
+ ../../include/translation.h \
+ ../../include/settings.h \
+ ../../include/CommonDictInterface.h \
XdxfSettingsDialog.h \
XdxfCachingDialog.h
#include "xdxfplugin.h"
#include <QDebug>
-#include "../../common/Notify.h"
+#include "../../include/Notify.h"
XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
_langFrom(""), _langTo(""),_name(""), _infoNote("") {
#include <QXmlStreamReader>
#include <QtPlugin>
-#include "../../common/CommonDictInterface.h"
-#include "../../common/settings.h"
+#include "../../include/CommonDictInterface.h"
+#include "../../include/settings.h"
#include "XdxfDictDialog.h"
#include "XdxfCachingDialog.h"
#include "TranslationXdxf.h"
TEMPLATE = subdirs
SUBDIRS = $$ENABLED_SRC
+
+check.CONFIG = recursive
+check.recurse = $$ENABLED_SRC
+QMAKE_EXTRA_TARGETS += check
+
+coverage {
+ # add flags to compiler
+ LIBS += -lgcov
+ QMAKE_CXXFLAGS += -ftest-coverage -fprofile-arcs -fno-elide-constructors
+}
#ifndef COMMONDICTINTERFACEMOCK_H
#define COMMONDICTINTERFACEMOCK_H
-#include "../../src/common/CommonDictInterface.h"
+#include "../../src/include/CommonDictInterface.h"
#include "TranslationMock.h"
/*! CommonDictInterfaceMock simulates dict/plugin behaviour without any
#ifndef TRANSLATIONMOCK_H
#define TRANSLATIONMOCK_H
-#include "../../src/common/translation.h"
+#include "../../src/include/translation.h"
/*! Translation mock is intended to simulate behaviour of real plugins
translation, but without dependency and any kind of complicated operations*/
DEFINES += SRCDIR=\\\"$$PWD/\\\"
HEADERS += CommonDictInterfaceMock.h \
../../src/mdictionary/backbone/backbone.h \
- ../../src/common/translation.h \
- ../../src/common/settings.h \
- ../../src/common/CommonDictInterface.h \
- ../../src/common/History.h \
+ ../../src/include/translation.h \
+ ../../src/include/settings.h \
+ ../../src/include/CommonDictInterface.h \
+ ../../src/include/History.h \
TranslationMock.h \
../../src/mdictionary/backbone/BookmarkTranslations.h \
../../src/mdictionary/backbone/Bookmarks.h \
../../src/mdictionary/backbone/ConfigGenerator.h
+
+
target.path = .
target.commands += ./mDictionaryTests
INSTALLS += target
+
+
+coverage {
+ LIBS += -lgcov
+ QMAKE_CXXFLAGS += -ftest-coverage -fprofile-arcs -fno-elide-constructors
+}
+
+check.depends = $$TARGET
+check.commands = ./mDictionaryTests
+QMAKE_EXTRA_TARGETS += check
TEMPLATE=subdirs
SUBDIRS = mDictionaryTests
-check.target = check
check.CONFIG = recursive
check.recurse = mDictionaryTests
QMAKE_EXTRA_TARGETS += check
+
+coverage {
+ # add flags to compiler
+ LIBS += -lgcov
+ QMAKE_CXXFLAGS += -ftest-coverage -fprofile-arcs -fno-elide-constructors
+}