-void Bookmarks::initAccents() {
- letters['a'] = QRegExp("[ÀàÁáÂÂâÃãÄäÅåæÆĀāĂ㥹]", Qt::CaseInsensitive);
- letters['c'] = QRegExp("[ÇçÈçŒĆćĈĉĊċČč]", Qt::CaseInsensitive);
- letters['d'] = QRegExp("[ÐĐđĎď]", Qt::CaseInsensitive);
- letters['e'] = QRegExp("[ÈéèÉÊêËëĒēĔĕĖėĘęĚěē]", Qt::CaseInsensitive);
- letters['f'] = QRegExp("[ſ]", Qt::CaseInsensitive);
- letters['g'] = QRegExp("[ĠġĢģĜĝĞğ]", Qt::CaseInsensitive);
- letters['h'] = QRegExp("[ħĤĥĦ]", Qt::CaseInsensitive);
- letters['i'] = QRegExp("[ÌìÍíÎîÏïİijĨĩĪīĬĭĮį]", Qt::CaseInsensitive);
- letters['j'] = QRegExp("[Ĵĵ]", Qt::CaseInsensitive);
- letters['k'] = QRegExp("[Ķķĸ]", Qt::CaseInsensitive);
- letters['l'] = QRegExp("[ŀŁłĹĺĻļĽľĿ]", Qt::CaseInsensitive);
- letters['n'] = QRegExp("[ÑñŃńŅņŇňʼnŊŋ]", Qt::CaseInsensitive);
- letters['o'] = QRegExp("[ÒòÓóÔÕõÖöØøŐőœŌōŎŏ]", Qt::CaseInsensitive);
- letters['r'] = QRegExp("[ŕŖŖŗŘř]", Qt::CaseInsensitive);
- letters['s'] = QRegExp("[ߊšŚśŜŝŞş]", Qt::CaseInsensitive);
- letters['t'] = QRegExp("[ŢţŤťŦŧ]", Qt::CaseInsensitive);
- letters['u'] = QRegExp("[ÙùÚúÛûÜüŰűŲųŨũŪūŬŮů]", Qt::CaseInsensitive);
- letters['w'] = QRegExp("[Ŵŵ]", Qt::CaseInsensitive);
- letters['y'] = QRegExp("[ÿÝýŶŷŸ]", Qt::CaseInsensitive);
- letters['z'] = QRegExp("[ŹźŻżŽž]", Qt::CaseInsensitive);
- noLetter = QRegExp("[^a-z ]", Qt::CaseInsensitive);
-}
-
-
-
-
bool Bookmarks::checkAndCreateDb() {
QSqlDatabase db = getDbCnx(dbName);
if(!db.isOpen() && !db.open()) {
-QString Bookmarks::removeAccents(QString string) {
- string = string.toLower();
- QString normalized = string.normalized(QString::NormalizationForm_KD);
- foreach(QChar let, letters.keys())
- normalized.replace(letters[let], QString(let));
-
- normalized.replace(noLetter, "");
- //qDebug() << "NORMALIZED: " << normalized;
- return normalized;
-}
-
-
bool Bookmarks::inBookmarks(QString word) {
QSqlDatabase db = getDbCnx(dbName);
#include <QDebug>
#include "../../includes/settings.h"
#include "../../includes/translation.h"
+#include "../../includes/AccentsNormalizer.h"
class BookmarkTranslation;
special list with cached translations from all available dictionaries so
You can search for them quickly even when You delete coresponding dict.
*/
-class Bookmarks
-{
+class Bookmarks : public AccentsNormalizer {
public:
Bookmarks();
private:
bool checkAndCreateDb();
- void initAccents();
QString dbName;
- QString removeAccents(QString);
QSqlDatabase getDbCnx(QString dbName);
QMap<QChar, QRegExp> letters;
QRegExp noLetter;
# -------------------------------------------------
# Project created by QtCreator 2010-08-03T08:54:27
-#-------------------------------------------------
-
+# -------------------------------------------------
QT += core \
gui \
sql \
xml \
xmlpatterns
-
maemo5:QT += maemo5
-
-
TARGET = mdictionary
TEMPLATE = app
MDICT_BINDIR = $$[MDICT_BINDIR]
gui/WelcomeScreenWidget.cpp \
gui/AboutWidget.cpp \
gui/TranslationTextEdit.cpp
-
HEADERS += gui/MainWindow.h \
gui/AboutWidget.h \
gui/SearchBarWidget.h \
gui/BookmarksWidget.h \
gui/WelcomeScreenWidget.h \
../includes/Notify.h \
- gui/TranslationTextEdit.h
-
-FORMS +=
-
-RESOURCES += \
- ../../../data/icons/gui.qrc
+ gui/TranslationTextEdit.h \
+ ../includes/AccentsNormalizer.h \
+ ../includes/DictDialog.h
+FORMS +=
+RESOURCES += ../../../data/icons/gui.qrc
unix {
# VARIABLES
isEmpty(PREFIX):PREFIX = /usr
desktop.files += ../../../data/other/$${TARGET}.desktop
icon64.files += ../../../data/icons/64x64/$${TARGET}.png
}
-
RESOURCES += xslt2.qrc
#include <QDialog>
#include <QtGui>
#include "../../includes/settings.h"
+#include "../../includes/CommonDictInterface.h"
#define PLUGIN_ROW_ROLE 99 //TODO remove this
--- /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 AccentsNormalizer.h
+\brief Common funcionality for all classes that need to remove accents from strings
+
+\author Bartosz Szatkowski <bulislaw@linux.com>
+*/
+
+#ifndef ACCENTSNORMALIZER_H
+#define ACCENTSNORMALIZER_H
+
+#include <QMap>
+#include <QString>
+#include <QRegExp>
+
+
+class AccentsNormalizer {
+ protected:
+ QMap<QChar, QRegExp> letters;
+ QRegExp noLetter;
+
+ QString removeAccents(QString string) {
+ string = string.toLower();
+ QString normalized = string.normalized(QString::NormalizationForm_KD);
+ foreach(QChar let, letters.keys())
+ normalized.replace(letters[let], QString(let));
+
+ normalized.replace(noLetter, "");
+ //qDebug() << "NORMALIZED: " << normalized;
+ return normalized;
+ }
+ void initAccents() {
+ letters['a'] = QRegExp("[ÀàÁáÂÂâÃãÄäÅåæÆĀāĂ㥹]", Qt::CaseInsensitive);
+ letters['c'] = QRegExp("[ÇçÈçŒĆćĈĉĊċČč]", Qt::CaseInsensitive);
+ letters['d'] = QRegExp("[ÐĐđĎď]", Qt::CaseInsensitive);
+ letters['e'] = QRegExp("[ÈéèÉÊêËëĒēĔĕĖėĘęĚěē]", Qt::CaseInsensitive);
+ letters['f'] = QRegExp("[ſ]", Qt::CaseInsensitive);
+ letters['g'] = QRegExp("[ĠġĢģĜĝĞğ]", Qt::CaseInsensitive);
+ letters['h'] = QRegExp("[ħĤĥĦ]", Qt::CaseInsensitive);
+ letters['i'] = QRegExp("[ÌìÍíÎîÏïİijĨĩĪīĬĭĮį]", Qt::CaseInsensitive);
+ letters['j'] = QRegExp("[Ĵĵ]", Qt::CaseInsensitive);
+ letters['k'] = QRegExp("[Ķķĸ]", Qt::CaseInsensitive);
+ letters['l'] = QRegExp("[ŀŁłĹĺĻļĽľĿ]", Qt::CaseInsensitive);
+ letters['n'] = QRegExp("[ÑñŃńŅņŇňʼnŊŋ]", Qt::CaseInsensitive);
+ letters['o'] = QRegExp("[ÒòÓóÔÕõÖöØøŐőœŌōŎŏ]", Qt::CaseInsensitive);
+ letters['r'] = QRegExp("[ŕŖŖŗŘř]", Qt::CaseInsensitive);
+ letters['s'] = QRegExp("[ߊšŚśŜŝŞş]", Qt::CaseInsensitive);
+ letters['t'] = QRegExp("[ŢţŤťŦŧ]", Qt::CaseInsensitive);
+ letters['u'] = QRegExp("[ÙùÚúÛûÜüŰűŲųŨũŪūŬŮů]", Qt::CaseInsensitive);
+ letters['w'] = QRegExp("[Ŵŵ]", Qt::CaseInsensitive);
+ letters['y'] = QRegExp("[ÿÝýŶŷŸ]", Qt::CaseInsensitive);
+ letters['z'] = QRegExp("[ŹźŻżŽž]", Qt::CaseInsensitive);
+ noLetter = QRegExp("[^a-z ]", Qt::CaseInsensitive);
+ }
+};
+
+#endif // ACCENTSNORMALIZER_H
#include <QList>
#include "translation.h"
#include "Notify.h"
+#include "settings.h"
+#include "AccentsNormalizer.h"
class DictDialog;
-class Settings;
//! Interface for dict engines plugins
-class CommonDictInterface : public QObject {
+class CommonDictInterface : public QObject, public AccentsNormalizer {
Q_OBJECT
public:
CommonDictInterface(QObject *parent = 0):QObject(parent) {}
\param QString text of the notification
*/
void notify(Notify::NotifyType, QString);
+
+protected:
+ QString removeAccents(QString string) {
+ if(settings()->value("strip_accents") == "true")
+ return AccentsNormalizer::removeAccents(string);
+ return string;
+ }
+
+ void initAccents() { AccentsNormalizer::initAccents(); }
+
+
+
};
Q_DECLARE_INTERFACE(CommonDictInterface, "CommonDictInterface/0.1");
#include <QString>
#include <QHash>
-#include "CommonDictInterface.h"
#include <QDebug>
-class CommonDictInterface;
-
/*! Plugins or dictionaries may need to keep some of configuration between
sessions, moreover Backbone or GUI may want store some additional info in
plugin Settings.
delete _settings;
}
-void XdxfPlugin::initAccents() {
- letters['a'] = QRegExp("[ÀàÁáÂÂâÃãÄäÅåæÆĀāĂ㥹]", Qt::CaseInsensitive);
- letters['c'] = QRegExp("[ÇçÈçŒĆćĈĉĊċČč]", Qt::CaseInsensitive);
- letters['d'] = QRegExp("[ÐĐđĎď]", Qt::CaseInsensitive);
- letters['e'] = QRegExp("[ÈéèÉÊêËëĒēĔĕĖėĘęĚěē]", Qt::CaseInsensitive);
- letters['f'] = QRegExp("[ſ]", Qt::CaseInsensitive);
- letters['g'] = QRegExp("[ĠġĢģĜĝĞğ]", Qt::CaseInsensitive);
- letters['h'] = QRegExp("[ħĤĥĦ]", Qt::CaseInsensitive);
- letters['i'] = QRegExp("[ÌìÍíÎîÏïİijĨĩĪīĬĭĮį]", Qt::CaseInsensitive);
- letters['j'] = QRegExp("[Ĵĵ]", Qt::CaseInsensitive);
- letters['k'] = QRegExp("[Ķķĸ]", Qt::CaseInsensitive);
- letters['l'] = QRegExp("[ŀŁłĹĺĻļĽľĿ]", Qt::CaseInsensitive);
- letters['n'] = QRegExp("[ÑñŃńŅņŇňʼnŊŋ]", Qt::CaseInsensitive);
- letters['o'] = QRegExp("[ÒòÓóÔÕõÖöØøŐőœŌōŎŏ]", Qt::CaseInsensitive);
- letters['r'] = QRegExp("[ŕŖŖŗŘř]", Qt::CaseInsensitive);
- letters['s'] = QRegExp("[ߊšŚśŜŝŞş]", Qt::CaseInsensitive);
- letters['t'] = QRegExp("[ŢţŤťŦŧ]", Qt::CaseInsensitive);
- letters['u'] = QRegExp("[ÙùÚúÛûÜüŰűŲųŨũŪūŬŮů]", Qt::CaseInsensitive);
- letters['w'] = QRegExp("[Ŵŵ]", Qt::CaseInsensitive);
- letters['y'] = QRegExp("[ÿÝýŶŷŸ]", Qt::CaseInsensitive);
- letters['z'] = QRegExp("[ŹźŻżŽž]", Qt::CaseInsensitive);
- noLetter = QRegExp("[^a-z ]", Qt::CaseInsensitive);
-}
QString XdxfPlugin::langFrom() const {
return _langFrom;
-QString XdxfPlugin::removeAccents(QString string) {
- if(settings()->value("strip_accents") == "true") {
- string = string.toLower();
- QString normalized = string.normalized(QString::NormalizationForm_KD);
- foreach(QChar let, letters.keys())
- normalized.replace(letters[let], QString(let));
-
- normalized.replace(noLetter, "");
- //qDebug() << "NORMALIZED: " << normalized;
- return normalized;
- }
- return string;
-}
-
-
-
QIcon* XdxfPlugin::icon() {
return &_icon;
}
void updateCachingProgress(int, int);
-protected:
- QString removeAccents(QString);
private:
/*! returns true or false depending on whether the dictionary is cached
int countWords();
bool makeCache(QString dir);
- void initAccents();
//! language from which we translate
QString _langFrom;
Settings *_settings;
XdxfDictDialog* _dictDialog;
XdxfCachingDialog* cachingDialog;
-
- QMap<QChar, QRegExp> letters;
- QRegExp noLetter;
+// extern void initAccents();
+ // extern QString removeAccents(QString string);
};