void MainWindow::showNotify(Notify::NotifyType type, QString text) {
+
switch(type) {
case Notify::Info:
#ifdef Q_WS_MAEMO_5
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:
connect(backbone, SIGNAL(searchCanceled()),
this, SIGNAL(setIdle()));
+ connect(backbone, SIGNAL(notify(Notify::NotifyType,QString)),
+ this, SLOT(showNotify(Notify::NotifyType,QString)));
+
#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("")),
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);
}
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();
}
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);
}
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 "";
}
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;
}
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;
}
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;
}
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();
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;
}