--- /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;
+
++ virtual void retranslate() = 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