Merge branch 'master' of ssh://drop.maemo.org/git/mdictionary
authorBartosz Szatkowski <bulislaw@linux.com>
Mon, 23 Aug 2010 07:58:59 +0000 (09:58 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Mon, 23 Aug 2010 07:58:59 +0000 (09:58 +0200)
trunk/src/base/backbone/Bookmarks.cpp
trunk/src/base/backbone/backbone.cpp
trunk/src/base/gui/AboutWidget.cpp
trunk/src/base/gui/AboutWidget.h
trunk/src/base/gui/MainWindow.cpp
trunk/src/base/gui/main.cpp
trunk/src/includes/Notify.h
trunk/src/plugins/xdxf/src/XdxfCachingDialog.cpp
trunk/src/plugins/xdxf/src/XdxfSettingsDialog.cpp
trunk/src/plugins/xdxf/src/xdxfplugin.cpp

index 2f20ea9..c39a2fa 100644 (file)
@@ -60,7 +60,6 @@ void Bookmarks::add(Translation* translation) {
 }
 
 
-
 void Bookmarks::remove(Translation* translation) {
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
index 05e17f0..e65582f 100644 (file)
@@ -18,7 +18,7 @@
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
-/*! /file backbone.cpp
+/*! \file backbone.cpp
 \brief Backbone/core main file \see Backbone
 
 
@@ -30,7 +30,7 @@
 
 int Backbone::_searchLimit;
 
-// Sadly QtConcurent mapped dont let me use something like calling method of
+// Sadly QtConcurent::mapped dosent let me use something like calling method of
 // some class with supplied argument
 QString mappedSearch;
 QList<Translation*> mapSearch(CommonDictInterface *dict) {
@@ -180,7 +180,6 @@ void Backbone::stopSearching() {
 
 
 void Backbone::search(QString word){
-    qDebug() << "SEEEEEEEEEARCH";
     _result.clear();
     mappedSearch = word.toLower();
 
@@ -270,7 +269,6 @@ void Backbone::translationReady() {
     }
 
     if(!stopped && bookmarkFin && dictFin && changed) {
-        qDebug() << "EMITTTTTT";
         Q_EMIT ready();
         }
 }
index 333436c..c33ffc0 100644 (file)
@@ -1,3 +1,30 @@
+/*******************************************************************************
+
+    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 AboutWidget.cpp
+\brief Simple "about" widget - product, company, license info
+
+
+\author Bartosz Szatkowski <bulislaw@linux.com>
+*/
+
 #include "AboutWidget.h"
 
 AboutWidget::AboutWidget(GUIInterface *parent): QDialog(parent)
index 567b663..a1cdda2 100644 (file)
@@ -1,3 +1,30 @@
+/*******************************************************************************
+
+    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 AboutWidget.h
+\brief Simple "about" widget - product, company, license info
+
+
+\author Bartosz Szatkowski <bulislaw@linux.com>
+*/
+
 #ifndef ABOUTWIDGET_H
 #define ABOUTWIDGET_H
 
index 5cc7f8e..eebe0ea 100644 (file)
@@ -328,6 +328,7 @@ Settings* MainWindow::settings() {
 
 
 void MainWindow::showNotify(Notify::NotifyType type, QString text) {
+
     switch(type) {
     case Notify::Info:
         #ifdef Q_WS_MAEMO_5
@@ -340,9 +341,12 @@ void MainWindow::showNotify(Notify::NotifyType type, QString text) {
         break;
 
     case Notify::Warning:
+        qDebug() << text;
         #ifndef Q_WS_MAEMO_5
                 QMessageBox::warning(this, "Warning", text);
                 break;
+        #else
+            QMessageBox::information(this, "Warning", text);
         #endif
 
     case Notify::Error:
@@ -399,6 +403,9 @@ void MainWindow::connectBackbone() {
     connect(backbone, SIGNAL(searchCanceled()),
             this, SIGNAL(setIdle()));
 
+    connect(backbone, SIGNAL(notify(Notify::NotifyType,QString)),
+            this, SLOT(showNotify(Notify::NotifyType,QString)));
+
 
 
 
index c5879c5..f047889 100644 (file)
@@ -25,6 +25,7 @@
 #include "MainWindow.h"
 #include "../backbone/backbone.h"
 #include "../../includes/translation.h"
+#include "../../includes/Notify.h"
 #include <QDebug>
 
 
@@ -60,6 +61,8 @@ int main(int argc, char *argv[]) {
 
     qRegisterMetaType<Translation*>("Translation*");
     qRegisterMetaType<QList<Translation*> >("QList<Translation*>");
+    qRegisterMetaType<Notify>("Notify");
+    qRegisterMetaType<Notify::NotifyType>("Notify::NotifyType");
     Backbone backbone;
     MainWindow w(&backbone);
     w.show();
index 7fe2995..a5266e9 100644 (file)
@@ -29,6 +29,7 @@
 #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
@@ -36,6 +37,8 @@
 class Notify : QObject {
     Q_OBJECT
 public:
+    Notify() : QObject(0) {}
+    Notify(const Notify&) : QObject(0) {}
     enum notifytype {Error, Warning, Info};
     Q_DECLARE_FLAGS(NotifyType, notifytype);
 };
index 8cb8e45..2b6932f 100644 (file)
@@ -70,6 +70,9 @@ void XdxfCachingDialog::updateCachingProgress(int progress, int time) {
 
     cachingLabel->setText(tr("Estimated time left: ") +
                       QString::number(seconds) + tr(" seconds"));
+    if(progress >= 100)
+        this->hide();
+        
 
 }
 
index 26e0176..09db806 100644 (file)
@@ -125,7 +125,6 @@ Settings* XdxfSettingsDialog::getSettings(XdxfPlugin *plugin,
             settings->setValue(key, plugin->settings()->value(key));
         settings->setValue("path", settingsDialog.dicitonaryFilePath());
 
-        qDebug()<<settingsDialog.generateCache();
         if(settingsDialog.generateCache()) {
             settings->setValue("generateCache", "true");
         }
index c20185d..d2a81fd 100644 (file)
@@ -29,6 +29,7 @@
 #include <QtPlugin>
 #include "TranslationXdxf.h"
 #include "../../../includes/settings.h"
+#include "../../../includes/Notify.h"
 
 XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
                     _langFrom(tr("")), _langTo(tr("")),_name(tr("")),
@@ -75,7 +76,6 @@ QString XdxfPlugin::infoNote() const {
 }
 
 QList<Translation*> XdxfPlugin::searchWordList(QString word, int limit) {
-    //if(_settings->value("cached") == "true")
     if(word.indexOf("*")==-1 && word.indexOf("?")==-1 && word.indexOf("_")==-1
        && word.indexOf("%")==-1)
         word+="*";
@@ -91,6 +91,9 @@ QList<Translation*> XdxfPlugin::searchWordListCache(QString word, int limit) {
         db.setDatabaseName(cacheFilePath);
         if(!db.open()) {
             qDebug() << "Database error" << db.lastError().text() << endl;
+            Q_EMIT notify(Notify::Warning, QString("Cache database cannot be "
+                    "opened for %1 dictionary. Searching in xdxf file. "
+                    "You may want to recache.").arg(name()));
             return searchWordListFile(word, limit);
         }
 
@@ -99,7 +102,6 @@ QList<Translation*> XdxfPlugin::searchWordListCache(QString word, int limit) {
         word = word.replace("*", "%");
         word = word.replace("?", "_");
         word = removeAccents(word);
-        //qDebug() << word;
 
         QSqlQuery cur(db);
         if(limit !=0)
@@ -139,6 +141,8 @@ QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
     regWord.setPatternSyntax(QRegExp::Wildcard);
     if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
         qDebug()<<"Error: could not open file";
+        Q_EMIT notify(Notify::Warning,
+                QString("Xdxf file cannot be read for %1").arg(name()));
         return translations.toList();
     }
 
@@ -190,6 +194,9 @@ QString XdxfPlugin::searchCache(QString key) {
 
     if(!db.open()) {
         qDebug() << "Database error" << db.lastError().text() << endl;
+        Q_EMIT notify(Notify::Warning, QString("Cache database cannot be "
+                "opened for %1 dictionary. Searching in xdxf file. "
+                "You may want to recache.").arg(name()));
         return searchFile(key);
     }
 
@@ -209,6 +216,8 @@ QString XdxfPlugin::searchFile(QString key) {
     QFile dictionaryFile(path);
     QString resultString("");
     if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
+        Q_EMIT notify(Notify::Warning,
+                QString("Xdxf file cannot be read for %1").arg(name()));
         qDebug()<<"Error: could not open file";
         return "";
     }
@@ -343,6 +352,8 @@ void XdxfPlugin::setSettings(Settings *settings) {
 void XdxfPlugin::getDictionaryInfo() {
     QFile dictionaryFile(path);
     if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
+       Q_EMIT notify(Notify::Warning,
+               QString("Xdxf file cannot be read dictionary"));
         qDebug()<<"Error: could not open file";
         return;
     }
@@ -364,10 +375,6 @@ void XdxfPlugin::getDictionaryInfo() {
 
     QString format = "png";
     QString initialPath = QDir::currentPath() + tr("/xdxf.") + format;
-//  qDebug()<<initialPath;
-//  QPixmap test(":/icons/xdxf.png");
-//  qDebug()<<QPixmap(test).save(initialPath,format.toAscii());
-//  qDebug()<<QPixmap("/home/jakub/star.jpg").save(initialPath,format.toAscii());
 
     _infoNote="<info path=\""+initialPath+"\">"+"\n" + _name + " [" + _langFrom + "-" + _langTo + "] "+ "(" + _type + ")"  + "</info>";
 
@@ -404,6 +411,9 @@ int XdxfPlugin::countWords() {
 
     QFile dictionaryFile(path);
     if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
+        Q_EMIT notify(Notify::Warning,
+                QString("Xdxf file cannot be read for %1 dictionary")
+                .arg(name()));
         qDebug()<<"Error: could not open file";
         return -1;
     }
@@ -437,6 +447,10 @@ bool XdxfPlugin::makeCache(QString dir) {
 
 
     if (!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
+        Q_EMIT updateCachingProgress(100, 0);
+        Q_EMIT notify(Notify::Warning,
+                QString("Xdxf file cannot be read for %1 dictionary")
+                .arg(name()));
         return 0;
     }
 
@@ -445,6 +459,10 @@ bool XdxfPlugin::makeCache(QString dir) {
     db.setDatabaseName(cachePathN);
     if(!db.open()) {
         qDebug() << "Database error" << db.lastError().text() << endl;
+        Q_EMIT updateCachingProgress(100, 0);
+        Q_EMIT notify(Notify::Warning, QString("Cache database cannot be "
+                "opened for %1 dictionary. Searching in xdxf file. "
+                "You may want to recache.").arg(name()));
         return false;
     }
     QCoreApplication::processEvents();
@@ -519,6 +537,9 @@ bool XdxfPlugin::makeCache(QString dir) {
 
     if(!cur.next() || countWords() != cur.value(0).toInt())
     {
+        Q_EMIT updateCachingProgress(100, timer.restart());
+        Q_EMIT notify(Notify::Warning,
+                QString("Database caching error, please try againg."));
         db.close();
         return false;
     }