}
-
void Bookmarks::remove(Translation* translation) {
QSqlDatabase db = getDbCnx(dbName);
if(!db.isOpen() && !db.open()) {
Copyright 2010 Comarch S.A.
*******************************************************************************/
-/*! /file backbone.cpp
+/*! \file backbone.cpp
\brief Backbone/core main file \see Backbone
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) {
void Backbone::search(QString word){
- qDebug() << "SEEEEEEEEEARCH";
_result.clear();
mappedSearch = word.toLower();
}
if(!stopped && bookmarkFin && dictFin && changed) {
- qDebug() << "EMITTTTTT";
Q_EMIT ready();
}
}
+/*******************************************************************************
+
+ 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)
+/*******************************************************************************
+
+ 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
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 "MainWindow.h"
#include "../backbone/backbone.h"
#include "../../includes/translation.h"
+#include "../../includes/Notify.h"
#include <QDebug>
qRegisterMetaType<Translation*>("Translation*");
qRegisterMetaType<QList<Translation*> >("QList<Translation*>");
+ qRegisterMetaType<Notify>("Notify");
+ qRegisterMetaType<Notify::NotifyType>("Notify::NotifyType");
Backbone backbone;
MainWindow w(&backbone);
w.show();
#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
class Notify : QObject {
Q_OBJECT
public:
+ Notify() : QObject(0) {}
+ Notify(const Notify&) : QObject(0) {}
enum notifytype {Error, Warning, Info};
Q_DECLARE_FLAGS(NotifyType, notifytype);
};
cachingLabel->setText(tr("Estimated time left: ") +
QString::number(seconds) + tr(" seconds"));
+ if(progress >= 100)
+ this->hide();
+
}
settings->setValue(key, plugin->settings()->value(key));
settings->setValue("path", settingsDialog.dicitonaryFilePath());
- qDebug()<<settingsDialog.generateCache();
if(settingsDialog.generateCache()) {
settings->setValue("generateCache", "true");
}
#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("")),
}
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+="*";
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);
}
word = word.replace("*", "%");
word = word.replace("?", "_");
word = removeAccents(word);
- //qDebug() << word;
QSqlQuery cur(db);
if(limit !=0)
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;
}
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>";
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;
}