From: Bartosz Szatkowski Date: Thu, 19 Aug 2010 09:53:27 +0000 (+0200) Subject: Added notification iterface X-Git-Tag: 0.4~41 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=2c2a1c8e89bd08066d2c756c6b174a7dc10874a6;p=mdictionary Added notification iterface --- diff --git a/trunk/src/base/backbone/backbone.cpp b/trunk/src/base/backbone/backbone.cpp index b353e2c..054d453 100644 --- a/trunk/src/base/backbone/backbone.cpp +++ b/trunk/src/base/backbone/backbone.cpp @@ -30,6 +30,7 @@ QString mappedSearch; QList mapSearch(CommonDictInterface *dict) { + qDebug() << "ooooooooooooooooooooooo" << unsigned(dict); if(dict) return dict->searchWordList(mappedSearch, 15); return QList(); @@ -218,6 +219,8 @@ void Backbone::addDictionary(CommonDictInterface *dict, bool active) { 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) { @@ -263,6 +266,8 @@ QStringList Backbone::getFilesFromDir(QString dir, QStringList nameFilter) { 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); @@ -284,6 +289,9 @@ void Backbone::loadPlugins() { 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; } @@ -313,6 +321,9 @@ void Backbone::loadPrefs(QString fileName) { 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); @@ -355,6 +366,9 @@ void Backbone::loadDicts(QString fileName, bool _default) { 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; } @@ -369,6 +383,9 @@ void Backbone::loadDicts(QString fileName, bool _default) { 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(); diff --git a/trunk/src/base/backbone/backbone.h b/trunk/src/base/backbone/backbone.h index d715b7d..693e322 100644 --- a/trunk/src/base/backbone/backbone.h +++ b/trunk/src/base/backbone/backbone.h @@ -47,6 +47,7 @@ #include "../../includes/settings.h" #include "../../includes/translation.h" #include "../../includes/History.h" +#include "../../includes/Notify.h" #include "Bookmarks.h" @@ -107,6 +108,8 @@ public: QStringList htmls(); + + public Q_SLOTS: //! stops all current searches and emiting searchCanceled signal void stopSearching(); @@ -219,6 +222,8 @@ public Q_SLOTS: + + Q_SIGNALS: /*! emmited when backbone is ready to close - after getting stop signal it should kill all threads and so on */ @@ -236,6 +241,13 @@ Q_SIGNALS: //! 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(); @@ -294,6 +306,8 @@ private: History* _history; + friend class BackboneTest; + }; #endif // BACKBONE_H diff --git a/trunk/src/base/base.pro b/trunk/src/base/base.pro index 8d29e8a..1272aef 100644 --- a/trunk/src/base/base.pro +++ b/trunk/src/base/base.pro @@ -26,10 +26,9 @@ SOURCES += gui/main.cpp \ 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 \ @@ -51,11 +50,10 @@ HEADERS += gui/MainWindow.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 diff --git a/trunk/src/includes/CommonDictInterface.h b/trunk/src/includes/CommonDictInterface.h index 596220e..d52a21f 100644 --- a/trunk/src/includes/CommonDictInterface.h +++ b/trunk/src/includes/CommonDictInterface.h @@ -33,6 +33,7 @@ #include #include #include "translation.h" +#include "Notify.h" class DictDialog; class Settings; @@ -106,6 +107,13 @@ class CommonDictInterface : public QObject { //! 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"); diff --git a/trunk/src/includes/Notify.h b/trunk/src/includes/Notify.h new file mode 100644 index 0000000..7fe2995 --- /dev/null +++ b/trunk/src/includes/Notify.h @@ -0,0 +1,42 @@ +/******************************************************************************* + + 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 . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ + +/*! /file Notify.h +\brief Declaration of common notify subsystem (NotifyType for now) + +\author Bartosz Szatkowski +*/ + +#ifndef NOTIFY_H +#define NOTIFY_H + +#include + +/*! 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 diff --git a/trunk/tests/mDictionaryTests/CommonDictInterfaceMock.h b/trunk/tests/mDictionaryTests/CommonDictInterfaceMock.h index 2e924e2..20626f1 100644 --- a/trunk/tests/mDictionaryTests/CommonDictInterfaceMock.h +++ b/trunk/tests/mDictionaryTests/CommonDictInterfaceMock.h @@ -63,6 +63,11 @@ public: qDebug() << "search " << this->thread()->currentThreadId(); stopped = 0; QList list; + qDebug() << "in MOOOCCCCCCCCK"; + qDebug() << "in MOOOCCCCCCCCK"; + qDebug() << "in MOOOCCCCCCCCK"; + qDebug() << "in MOOOCCCCCCCCK"; + qDebug() << "in MOOOCCCCCCCCK"; TranslationMock *tm = new TranslationMock(); tm->_key = langFrom(); diff --git a/trunk/tests/mDictionaryTests/tst_Backbone.cpp b/trunk/tests/mDictionaryTests/tst_Backbone.cpp index a97bd6a..a29199c 100644 --- a/trunk/tests/mDictionaryTests/tst_Backbone.cpp +++ b/trunk/tests/mDictionaryTests/tst_Backbone.cpp @@ -85,7 +85,7 @@ void BackboneTest::init() void BackboneTest::addDicts() { for(int i = 0; i < total; i++) { - back->addDictionary(dict[i]); + back->addInternalDictionary(dict[i],true); } } @@ -173,11 +173,14 @@ void BackboneTest::searchTest() { 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];