}
-Backbone::Backbone(const Backbone &b) {
- dicts = QList<CommonDictInterface* > (b.dicts);
+Backbone::Backbone(const Backbone &b){
+ dicts = QHash<CommonDictInterface*, bool > (b.dicts);
plugins = QList<CommonDictInterface* > (b.plugins);
resultv = QHash<QString, Translation* > (b.resultv);
}
return searchLimitv;
}
-QHash<const CommonDictInterface*, bool > Backbone::getDictionaries() {
+QHash<CommonDictInterface*, bool > Backbone::getDictionaries() {
return dicts;
}
-QList<const CommonDictInterface* > Backbone::getPlugins() {
+QList<CommonDictInterface* > Backbone::getPlugins() {
return plugins;
}
+QList<QString> Backbone::getHistory() {
+ //TODO code needed
+}
+
QHash<QString, Translation*> Backbone::result() {
return resultv;
}
void Backbone::stopSearching() {
- foreach(CommonDictInterface* dict, dicts)
+ foreach(CommonDictInterface* dict, dicts.keys())
dict->stop();
}
void Backbone::search(QString word) {
//TODO add running searches in new threads
- foreach(CommonDictInterface* dict, dicts)
- dict->search(word, searchLimit());
+ foreach(CommonDictInterface* dict, dicts.keys())
+ if(dicts[dict] == 1)
+ dict->search(word, searchLimit());
}
void Backbone::selectedDictionaries(QList<CommonDictInterface* > activeDicts) {
dicts[dict] = 0;
}
+ void Backbone::addDictionary(Settings *settings) {
+ CommonDictInterface* dict = settings->type()->getNew(settings);
+ dicts[dict] = 1;
+ }
+
+ void Backbone::quit() {
+ foreach(CommonDictInterface* dict, dicts.keys())
+ dict->stop();
+ Q_EMIT closeOk();
+}
+
+
#include <QObject>
#include <QList>
+#include <QHash>
#include "../../includes/CommonDictInterface.h"
#include "../../includes/settings.h"
#include "../../includes/translation.h"
-uint qHash(CommonDictInterface* dict) {
- return dict->hash();
-}
//! Inner part of dictionary - glues together GUI and plugins
class Backbone : public QObject
Backbone(const Backbone& b);
//! \return all loadded dictionaries with activity state flag
- QHash<const CommonDictInterface*, bool > getDictionaries();
+ QHash<CommonDictInterface*, bool > getDictionaries();
//! \return all loadded plugins
- QList<const CommonDictInterface* > getPlugins();
+ QList<CommonDictInterface* > getPlugins();
//! \return history of performed searches
- QList<const QString> getHistory(); //TODO implementation needed (in future)
+ QList<QString> getHistory(); //TODO implementation needed (in future)
//! \return return search fesult
QHash<QString, Translation*> result();
#include <QtGui/QApplication>
#include "backbone.h"
+uint qHash(CommonDictInterface* dict) {
+ return dict->hash();
+}
+
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- backbone w;
- w.show();
+ Backbone w;
return a.exec();
}
backbone/backbone.cpp
HEADERS += \
- backbone/backbone.h
+ backbone/backbone.h \
+ ../includes/translation.h \
+ ../includes/settings.h \
+ ../includes/CommonDictInterface.h
<valuemap type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Desktop</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value>
- <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
+ <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">2</value>
<value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
<valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Qt w PATH Debug</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/bulislaw/devel/mdictionary/trunk/src/base/mDictionary-build-desktop</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/bulislaw/devel/mDictionary-build</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">3</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">0</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Qt 4.6.3 OpenSource Debug</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/bulislaw/devel/mdictionary/trunk/src/base/mDictionary-build-desktop</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/bulislaw/devel/mDictionary-build</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">2</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">0</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
*******************************************************************************/
// Created by Bartosz Szatkowski
+
+
+#ifndef COMMONDICTINTERFACE_H
+#define COMMONDICTINTERFACE_H
+
#include <QString>
#include <QDialog>
#include <QObject>
#include <QList>
-#include "CommonDictInterface.h"
#include "translation.h"
-#include "settings.h"
+class Settings;
class CommonDictInterface : public QObject {
Q_OBJECT
public:
- CommonDictInterface(const QObject *parent = 0) = 0;
+ CommonDictInterface(const QObject *parent = 0) ;
//! returns source language code iso 639-2
virtual QString langFrom() const = 0;
//! returns whether plugin can start searching
virtual bool isAvailable() const = 0;
+ virtual uint hash() const = 0;
+
public Q_SLOTS:
/*! performes search in dictionary
\param word word to search in dictionary
//! emited after dictionary is ready to use afer being loaded
void loaded(CommonDictInterface*);
-}
+};
+#endif
*******************************************************************************/
//Created by Bartosz Szatkowski
+
+#ifndef SETTINGS_H
+#define SETTINGS_H
+
#include <QString>
#include "CommonDictInterface.h"
//! Plugin specific configuration
class Settings {
public:
-<<<<<<< HEAD
//! \retrun value fo given key
//! \param key
- QString value(const QString key) const = 0;
+ virtual QString value(const QString key) const = 0;
//! sets key to value
- void setValue(const QString key, const QString value) = 0;
+ virtual void setValue(const QString key, const QString value) = 0;
//! \return dict CommonDictInterface
- CommonDictInterface type() const = 0;
+ virtual CommonDictInterface* type() const = 0;
//! sets settings type to given dictionary
- void setType(const CommonDictInterface) = 0;
-}
+ virtual void setType(const CommonDictInterface*) = 0;
+};
+
+#endif
*******************************************************************************/
//Created by Bartosz Szatkowski
+
+#ifndef TRANSLATION_H
+#define TRANSLATION_H
+
#include <QString>
+
+
//! Keeping raw form of translation to be parsed only when needed
class Translation {
public:
//! \return word to be translated
- QString key() const = 0;
+ virtual QString key() const = 0;
- //! \returns dictionary information (plugin name, languages, <logo> etc)\
- //! to be displayed in translation table header
- QString dictionaryInfo() const = 0;
+ /*! \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
- QString toHtml() const = 0;
-}
+ virtual QString toHtml() const = 0;
+};
+
+#endif