QString mappedSearch;
QList<Translation*> mapSearch(CommonDictInterface *dict) {
+ qDebug() << "ooooooooooooooooooooooo" << unsigned(dict);
if(dict)
return dict->searchWordList(mappedSearch, 15);
return QList<Translation*>();
dict->setHash(_dicts.size()+1);
_dicts[dict] = active;
connect(dict, SIGNAL(settingsChanged()), this, SLOT(dictUpdated()));
+ connect(dict, SIGNAL(notify(Notify::NotifyType,QString)), this,
+ SIGNAL(notify(Notify::NotifyType,QString)));
}
void Backbone::removeDictionary(CommonDictInterface *dict) {
QDir plug(QDir::toNativeSeparators(dir));
if(!plug.exists()) {
qDebug() << plug.absolutePath() << " folder dosen't exists";
+ Q_EMIT notify(Notify::Warning,
+ QString("%1 folder dosen't exists.").arg(plug.path()));
return QStringList();
}
plug.setFilter(QDir::Files);
foreach(QString file, files) {
QPluginLoader loader(file);
if(!loader.load()) {
+ Q_EMIT notify(Notify::Error,
+ QString("%1 plugin cannot be loaded: %2.")
+ .arg(file).arg(loader.errorString()));
qDebug()<< file << " " << loader.errorString();
continue;
}
if(!confDir.exists()){
qDebug() << "Configuration file dosn't exists ("
<< file.filePath() << ")";
+ Q_EMIT notify(Notify::Warning,
+ QString("%1 configurationfile dosen't exists.")
+ .arg(file.filePath()));
return;
}
QSettings set(file.filePath(), QSettings::IniFormat);
if(!confDir.exists()){
qDebug() << "Configuration file dosn't exists ("
<< file.filePath() << ")";
+ Q_EMIT notify(Notify::Warning,
+ QString("%1 configurationfile dosen't exists.")
+ .arg(file.filePath()));
return;
}
qDebug() << "Config file error: "
<< set.value(dict + "/type", "").toString()
<< " dosen't exists";
+ Q_EMIT notify(Notify::Warning,
+ QString("Configuration file error. %2 plugin dosen't exists.")
+ .arg(set.value(dict + "/type", "").toString()));
continue;
}
Settings* plugSet = new Settings();
#include "../../includes/settings.h"
#include "../../includes/translation.h"
#include "../../includes/History.h"
+#include "../../includes/Notify.h"
#include "Bookmarks.h"
QStringList htmls();
+
+
public Q_SLOTS:
//! stops all current searches and emiting searchCanceled signal
void stopSearching();
+
+
Q_SIGNALS:
/*! emmited when backbone is ready to close - after getting stop signal it
should kill all threads and so on */
//! emmited when bookmark list is ready to fetch
void bookmarksReady();
+ /*! emited by direct connection to plugins notifying signals
+ \param Notify::NotifyType gui my dacide to show different typet in
+ different ways
+ \param QString text of the notification
+ */
+ void notify(Notify::NotifyType, QString);
+
private Q_SLOTS:
void bookmarksListReady();
History* _history;
+ friend class BackboneTest;
+
};
#endif // BACKBONE_H
backbone/Bookmarks.cpp \
gui/SettingsWidget.cpp \
gui/BookmarksWidget.cpp \
- gui/WelcomeScreenWidget.cpp \
+ gui/WelcomeScreenWidget.cpp \
gui/AboutWidget.cpp
-
-HEADERS += gui/MainWindow.h \
+HEADERS += gui/MainWindow.h \
gui/AboutWidget.h \
gui/SearchBarWidget.h \
gui/WordListWidget.h \
backbone/BookmarkTranslations.h \
gui/SettingsWidget.h \
gui/BookmarksWidget.h \
- gui/WelcomeScreenWidget.h
-
-FORMS += gui/MainWindow.ui
+ gui/WelcomeScreenWidget.h \
+ ../includes/Notify.h
+FORMS += gui/MainWindow.ui
RESOURCES += gui/gui.qrc
-
unix {
# VARIABLES
isEmpty(PREFIX):PREFIX = /usr
#include <QObject>
#include <QList>
#include "translation.h"
+#include "Notify.h"
class DictDialog;
class Settings;
//! emited after change dictionary settings
void settingsChanged();
+
+ /*! emmited to backbone when needed to inform user about something
+ \param Backbone::NotifyType gui my dacide to show different typet in
+ different ways
+ \param QString text of the notification
+ */
+ void notify(Notify::NotifyType, QString);
};
Q_DECLARE_INTERFACE(CommonDictInterface, "CommonDictInterface/0.1");
--- /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>
+
+/*! Notify wraps NotifyType which is interpreted by GUI and may change way in
+ which GUI handles given notification
+ */
+class Notify : QObject {
+ Q_OBJECT
+public:
+ enum notifytype {Error, Warning, Info};
+ Q_DECLARE_FLAGS(NotifyType, notifytype);
+};
+#endif // NOTIFY_H
qDebug() << "search " << this->thread()->currentThreadId();
stopped = 0;
QList<Translation*> list;
+ qDebug() << "in MOOOCCCCCCCCK";
+ qDebug() << "in MOOOCCCCCCCCK";
+ qDebug() << "in MOOOCCCCCCCCK";
+ qDebug() << "in MOOOCCCCCCCCK";
+ qDebug() << "in MOOOCCCCCCCCK";
TranslationMock *tm = new TranslationMock();
tm->_key = langFrom();
void BackboneTest::addDicts() {
for(int i = 0; i < total; i++) {
- back->addDictionary(dict[i]);
+ back->addInternalDictionary(dict[i],true);
}
}
QCOMPARE(m->stopped, 1);
}
- qDebug() << "main " << this->thread()->currentThreadId();
+ qDebug() << "main search " << this->thread()->currentThreadId();
QString list("pigwa");
+ back->_searchBookmarks = 0;
+ back->_searchDicts = 1;
back->search(list);
- usleep(2000);
+ qDebug() << back->activeDicts().size() << "!!!!!!!!!!!!!";
+
for(int i = 0; i < total; i++) {
CommonDictInterfaceMock *m = (CommonDictInterfaceMock*)dict[i];