Merge branch 'master' of ssh://drop.maemo.org/git/mdictionary
authorBartosz Szatkowski <bulislaw@linux.com>
Mon, 30 Aug 2010 08:19:08 +0000 (10:19 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Mon, 30 Aug 2010 08:19:08 +0000 (10:19 +0200)
13 files changed:
trunk/src/base/gui/AboutWidget.cpp
trunk/src/base/gui/DictManagerWidget.cpp
trunk/src/base/gui/MainWindow.cpp
trunk/src/base/gui/SearchBarWidget.cpp
trunk/src/base/gui/SearchBarWidget.h
trunk/src/base/gui/SettingsWidget.cpp
trunk/src/includes/AccentsNormalizer.h
trunk/src/includes/CommonDictInterface.h
trunk/src/plugins/google/src/GoogleSettingsDialog.cpp
trunk/src/plugins/google/src/GoogleSettingsDialog.h
trunk/src/plugins/xdxf/src/xdxfplugin.cpp
trunk/src/plugins/xdxf/tests/test.cpp
trunk/src/plugins/xdxf/tests/test.h

index 73df15f..1e3be9d 100644 (file)
@@ -49,19 +49,19 @@ AboutWidget::AboutWidget(GUIInterface *parent): QDialog(parent)
                   QString("</p></font>");
 
     setWindowTitle(tr("About"));
-    mainLayout = new QVBoxLayout(this);
+    mainLayout = new QVBoxLayout;
 
     #ifndef Q_WS_MAEMO_5
-        scrollLayout = new QVBoxLayout(this);
-        scroll = new QScrollArea(this);
+        scrollLayout = new QVBoxLayout;
+        scroll = new QScrollArea;
         w = new QWidget(this);
 
     #endif
 
 
-    imageLabel = new QLabel(this);
-    mainLabel = new QLabel(this);
-    licenseLabel = new QLabel(this);
+    imageLabel = new QLabel;
+    mainLabel = new QLabel;
+    licenseLabel = new QLabel;
 
 
     QImage img(":/icons/logo/mdictionary.png");
index 157aa2f..c718908 100644 (file)
@@ -36,23 +36,23 @@ DictManagerWidget::DictManagerWidget(GUIInterface *parent) :
     setWindowTitle(tr("Dictionaries"));
     this->guiInterface = parent;
 
-    verticalLayout = new QVBoxLayout(this);
+    verticalLayout = new QVBoxLayout;
     setLayout(verticalLayout);
 
-    dictListWidget = new QListWidget(this);
+    dictListWidget = new QListWidget;
     verticalLayout->addWidget(dictListWidget);
 
     dictListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
     dictListWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
-    addNewDictButton = new QPushButton(tr("Add"),this);
-    removeDictButton = new QPushButton(tr("Remove"),this);
-    settingsButton = new QPushButton(tr("Settings"),this);
+    addNewDictButton = new QPushButton(tr("Add"));
+    removeDictButton = new QPushButton(tr("Remove"));
+    settingsButton = new QPushButton(tr("Settings"));
 
     removeDictButton->setEnabled(false);
     settingsButton->setEnabled(false);
 
-    buttonGroup = new QHBoxLayout(this);
+    buttonGroup = new QHBoxLayout;
 
     buttonGroup->addWidget(addNewDictButton);
     buttonGroup->addWidget(removeDictButton);
@@ -157,6 +157,7 @@ void DictManagerWidget::saveChanges() {
 
 void DictManagerWidget::hideEvent(QHideEvent *e)
 {
+    qDebug()<<"hide";
     saveChanges();
     QWidget::hideEvent(e);
 }
index 5179780..aa48cc2 100644 (file)
@@ -332,7 +332,7 @@ void MainWindow::showNotify(Notify::NotifyType type, QString text) {
     switch(type) {
     case Notify::Info:
         #ifdef Q_WS_MAEMO_5
-            QMaemo5InformationBox::information(this,
+            QMaemo5InformationBox::information(0,
                                 text,
                                 QMaemo5InformationBox::DefaultTimeout);
         #else
@@ -344,13 +344,11 @@ void MainWindow::showNotify(Notify::NotifyType type, QString text) {
         #ifndef Q_WS_MAEMO_5
                 QMessageBox::warning(this, "Warning", text);
                 break;
-        #else
-            QMessageBox::information(this, "Warning", text);
         #endif
 
     case Notify::Error:
         #ifdef Q_WS_MAEMO_5
-            QMaemo5InformationBox::information(this,
+            QMaemo5InformationBox::information(0,
                                 text,
                                 QMaemo5InformationBox::NoTimeout);
         #else
index 6921e26..b8c823a 100644 (file)
@@ -101,21 +101,33 @@ void SearchBarWidget::initializeUI() {
     #ifdef Q_WS_MAEMO_5
         setMaximumHeight(150);
     #else
-        setMaximumHeight(70);
+        setMaximumHeight(100);
     #endif
 
 
-    horizontalLayout = new QHBoxLayout();
-    verticalLayout = new QVBoxLayout();
+    horizontalLayout = new QHBoxLayout;
+    verticalLayout = new QVBoxLayout;
 
 
     searchPushButton = new QPushButton(tr("Search"));
     searchPushButton->setMinimumWidth(125);
 
 
-    searchWordLineEdit = new QLineEdit();
+    searchWordLineEdit = new QLineEdit;
     searchWordLineEdit->setMinimumWidth(250);
 
+
+
+    completerModel = new QStringListModel;
+
+
+    lineEditCompleter = new QCompleter(searchWordLineEdit);
+    lineEditCompleter->setModel(completerModel);
+    lineEditCompleter->setCaseSensitivity(Qt::CaseInsensitive);
+    lineEditCompleter->setCompletionMode(QCompleter::InlineCompletion);
+    searchWordLineEdit->setCompleter(lineEditCompleter);
+
+
     #ifndef Q_WS_MAEMO_5
         searchWordLineEdit->setMinimumHeight(
                 searchWordLineEdit->sizeHint().height()*3/2);
@@ -123,11 +135,11 @@ void SearchBarWidget::initializeUI() {
 
 
     //create layout for lineEdit to have clear button on it
-    QHBoxLayout* lineEditLayout = new QHBoxLayout();
+    QHBoxLayout* lineEditLayout = new QHBoxLayout;
     searchWordLineEdit->setLayout(lineEditLayout);
 
 
-    clearSearchWordToolButton = new QToolButton();
+    clearSearchWordToolButton = new QToolButton;
     #ifdef Q_WS_MAEMO_5
         clearSearchWordToolButton->setIcon(QIcon::fromTheme("general_stop"));
         //tool buttons will have size 2 times smaller
@@ -144,7 +156,7 @@ void SearchBarWidget::initializeUI() {
     #endif
 
 
-    historyNextToolButton = new QToolButton();
+    historyNextToolButton = new QToolButton;
     #ifdef Q_WS_MAEMO_5
         historyNextToolButton->setIcon(
                 generateIcon(QIcon::fromTheme("general_forward")));
@@ -155,7 +167,7 @@ void SearchBarWidget::initializeUI() {
 
 
 
-    historyPrevToolButton = new QToolButton();
+    historyPrevToolButton = new QToolButton;
     #ifdef Q_WS_MAEMO_5
         historyPrevToolButton->setIcon(
                 generateIcon(QIcon::fromTheme("general_back")));
@@ -166,7 +178,7 @@ void SearchBarWidget::initializeUI() {
 
 
 
-    historyShowToolButton = new QToolButton();
+    historyShowToolButton = new QToolButton;
     #ifdef Q_WS_MAEMO_5
         historyShowToolButton->setIcon(
                 generateIcon(QIcon::fromTheme("general_back"), 90));
@@ -175,27 +187,15 @@ void SearchBarWidget::initializeUI() {
                 generateIcon(QIcon::fromTheme("go-up")));
     #endif
 
-    /*fullScreenToolButton = new QToolButton();
-    #ifdef Q_WS_MAEMO_5
-        fullScreenToolButton->setIcon(
-                generateIcon(QIcon::fromTheme("general_fullsize")));
-    #else
-        fullScreenToolButton->setIcon(
-                generateIcon(QIcon::fromTheme("view-fullscreen")));
-        fullScreenToolButton->setMinimumSize(
-                fullScreenToolButton->sizeHint().height()*2,
-                fullScreenToolButton->sizeHint().height()*2);
-    #endif*/
-
-    searchingProgressBar = new QProgressBar();
+    searchingProgressBar = new QProgressBar;
     //progress bar have minimum and maximum values set to 0, which will effect
     //with "I'm alive" bar
     searchingProgressBar->setMinimum(0);
     searchingProgressBar->setMaximum(0);
-    searchingProgressBar->hide();
     #ifdef Q_WS_MAEMO_5
         searchingProgressBar->setMaximumHeight(50);
     #endif
+    searchingProgressBar->hide();
 
 
     setLayout(verticalLayout);
@@ -208,7 +208,6 @@ void SearchBarWidget::initializeUI() {
     horizontalLayout->addWidget(historyPrevToolButton);
     horizontalLayout->addWidget(historyShowToolButton);
     horizontalLayout->addWidget(historyNextToolButton);
-   // horizontalLayout->addWidget(fullScreenToolButton);
 
     //adding clear toolButton to textEdit with right alignment
     lineEditLayout->addWidget(clearSearchWordToolButton, 0, Qt::AlignRight);
@@ -230,6 +229,13 @@ void SearchBarWidget::searchPushButtonClicked() {
 
 void SearchBarWidget::search(QString word) {
     if(!_isSearching && !word.isEmpty()) {
+        completerModel->insertRow(completerModel->rowCount());
+        QModelIndex index =
+                completerModel->index(completerModel->rowCount() -1);
+
+        completerModel->setData(index, word);
+
+
         searchWordLineEdit->setText(word);
         Q_EMIT searchForTranslations(word);
     }
index 6fed28f..388c468 100644 (file)
@@ -112,6 +112,8 @@ private Q_SLOTS:
 
 private:
     QLineEdit* searchWordLineEdit;
+    QCompleter* lineEditCompleter;
+    QStringListModel* completerModel;
     QToolButton* clearSearchWordToolButton;
     QPushButton* searchPushButton;
     QToolButton* historyPrevToolButton;
index 854d5c3..15e3e40 100644 (file)
@@ -31,16 +31,16 @@ SettingsWidget::SettingsWidget(GUIInterface *parent) :
 
     setWindowTitle(tr("Settings"));
 
-    verticalLayout = new QVBoxLayout(this);
+    verticalLayout = new QVBoxLayout;
     setLayout(verticalLayout);
 
-    historySizeSpinBox = new QSpinBox(this);
-    searchResultSizeSpinBox = new QSpinBox(this);
+    historySizeSpinBox = new QSpinBox;
+    searchResultSizeSpinBox = new QSpinBox;
     limitTip = "Limit maximal number of finded words, affect only when "
                 "searching in file.";
     searchResultSizeSpinBox->setToolTip(limitTip);
 
-    spinBoxesFormLayout = new QFormLayout(this);
+    spinBoxesFormLayout = new QFormLayout;
 
     spinBoxesFormLayout->addRow(tr("Search result size"),
                                 searchResultSizeSpinBox);
@@ -83,7 +83,7 @@ SettingsWidget::SettingsWidget(GUIInterface *parent) :
     #ifndef Q_WS_MAEMO_5
         setMinimumWidth(250);
         setMaximumWidth(250);
-        footerLayout = new QHBoxLayout(this);
+        footerLayout = new QHBoxLayout;
         closeButton = new QPushButton(tr("Save"));
         footerLayout->addStretch(0);
         footerLayout->addWidget(closeButton);
index d94a6b2..dc378c6 100644 (file)
@@ -49,27 +49,32 @@ class AccentsNormalizer {
        return normalized;
     }
     void initAccents() {
-        letters['a'] = QRegExp(QString::fromUtf8("[ÀàÁáÂÂâÃãÄäÅåæÆĀāĂ㥹]"), Qt::CaseInsensitive);
-        letters['c'] = QRegExp(QString::fromUtf8("[ÇçÈçŒĆćĈĉĊċČč]"), Qt::CaseInsensitive);
-        letters['d'] = QRegExp(QString::fromUtf8("[ÐĐđĎď]"), Qt::CaseInsensitive);
-        letters['e'] = QRegExp(QString::fromUtf8("[ÈéèÉÊêËëĒēĔĕĖėĘęĚěē]"), Qt::CaseInsensitive);
-        letters['f'] = QRegExp(QString::fromUtf8("[ſ]"), Qt::CaseInsensitive);
-        letters['g'] = QRegExp(QString::fromUtf8("[ĠġĢģĜĝĞğ]"), Qt::CaseInsensitive);
-        letters['h'] = QRegExp(QString::fromUtf8("[ħĤĥĦ]"), Qt::CaseInsensitive);
-        letters['i'] = QRegExp(QString::fromUtf8("[ÌìÍíÎîÏïİijĨĩĪīĬĭĮį]"), Qt::CaseInsensitive);
-        letters['j'] = QRegExp(QString::fromUtf8("[Ĵĵ]"), Qt::CaseInsensitive);
-        letters['k'] = QRegExp(QString::fromUtf8("[Ķķĸ]"), Qt::CaseInsensitive);
-        letters['l'] = QRegExp(QString::fromUtf8("[ŀŁłĹĺĻļĽľĿ]"), Qt::CaseInsensitive);
-        letters['n'] = QRegExp(QString::fromUtf8("[ÑñŃńŅņŇňʼnŊŋ]"), Qt::CaseInsensitive);
-        letters['o'] = QRegExp(QString::fromUtf8("[ÒòÓóÔÕõÖöØøŐőœŌōŎŏ]"), Qt::CaseInsensitive);
-        letters['r'] = QRegExp(QString::fromUtf8("[ŕŖŖŗŘř]"), Qt::CaseInsensitive);
-        letters['s'] = QRegExp(QString::fromUtf8("[ߊšŚśŜŝŞş]"), Qt::CaseInsensitive);
-        letters['t'] = QRegExp(QString::fromUtf8("[ŢţŤťŦŧ]"), Qt::CaseInsensitive);
-        letters['u'] = QRegExp(QString::fromUtf8("[ÙùÚúÛûÜüŰűŲųŨũŪūŬŮů]"), Qt::CaseInsensitive);
-        letters['w'] = QRegExp(QString::fromUtf8("[Ŵŵ]"), Qt::CaseInsensitive);
-        letters['y'] = QRegExp(QString::fromUtf8("[ÿÝýŶŷŸ]"), Qt::CaseInsensitive);
-        letters['z'] = QRegExp(QString::fromUtf8("[ŹźŻżŽž]"), Qt::CaseInsensitive);
-        noLetter = QRegExp("[^a-z ]", Qt::CaseInsensitive);
+        letters['a'] = QRegExp(QString::fromUtf8("[ÀàÁáÂÂâÃãÄäÅåæÆĀāĂ㥹ǠȀǡȁǢȂǣȃȦȧǺȺǻǼǍǽǎǞǟⱥ]"), Qt::CaseInsensitive);
+        letters['b'] = QRegExp(QString::fromUtf8("[ƀƁƂƃɃƄƅ]"), Qt::CaseInsensitive);
+        letters['c'] = QRegExp(QString::fromUtf8("[ÇçÈçŒĆćĈĉĊċČčƇƈȻȼ]"), Qt::CaseInsensitive);
+        letters['d'] = QRegExp(QString::fromUtf8("[ÐĐđĎďȡƉ]"), Qt::CaseInsensitive);
+        letters['e'] = QRegExp(QString::fromUtf8("[ÈéèÉÊêËëĒēĔĕĖėĘęĚěēȄȅȆɆȇɇȨȩ]"), Qt::CaseInsensitive);
+        letters['f'] = QRegExp(QString::fromUtf8("[ſƑƒꜰ]"), Qt::CaseInsensitive);
+        letters['g'] = QRegExp(QString::fromUtf8("[ĠġĢģĜĝĞğƓǤǴǥǵǦǧ]"), Qt::CaseInsensitive);
+        letters['h'] = QRegExp(QString::fromUtf8("[ħĤĥĦȞȟⱧⱨ]"), Qt::CaseInsensitive);
+        letters['i'] = QRegExp(QString::fromUtf8("[ÌìÍíÎîÏïİijĨĩĪīĬĭĮįǐƗȈȉȊȋǏꟾ]"), Qt::CaseInsensitive);
+        letters['j'] = QRegExp(QString::fromUtf8("[ĴĵǰȷɈɉⱼ]"), Qt::CaseInsensitive);
+        letters['k'] = QRegExp(QString::fromUtf8("[ĶķĸƘǨƙǩⱩⱪ]"), Qt::CaseInsensitive);
+        letters['l'] = QRegExp(QString::fromUtf8("[ŀŁłĹĺĻļĽľĿȴȽⱠⱡⱢꝈ]"), Qt::CaseInsensitive);
+        letters['m'] = QRegExp(QString::fromUtf8("[Ɱ]"), Qt::CaseInsensitive);
+        letters['n'] = QRegExp(QString::fromUtf8("[ÑñŃńŅņŇňʼnŊŋȵǸǹƝ]"), Qt::CaseInsensitive);
+        letters['o'] = QRegExp(QString::fromUtf8("[ÒòÓóÔÕõÖöØøŐőœŌōŎŏƠȰơǑȱǒǪȪǫȫǬȌȬǭȍȭǾȎȮǿȏȯⱺ]"), Qt::CaseInsensitive);
+        letters['p'] = QRegExp(QString::fromUtf8("[ƤƥⱣ]"), Qt::CaseInsensitive);
+        letters['q'] = QRegExp(QString::fromUtf8("[Ɋɋ]"), Qt::CaseInsensitive);
+        letters['r'] = QRegExp(QString::fromUtf8("[ŕŖŖŗŘřȐȑȒȓɌɍⱤ]"), Qt::CaseInsensitive);
+        letters['s'] = QRegExp(QString::fromUtf8("[ߊšŚśŜŝŞşȘșȿꜱ]"), Qt::CaseInsensitive);
+        letters['t'] = QRegExp(QString::fromUtf8("[ŢţŤťŦŧȶȚƫțƬƮȾⱦ]"), Qt::CaseInsensitive);
+        letters['u'] = QRegExp(QString::fromUtf8("[ÙùÚúÛûÜüŰűŲųŨũŪūŬŮůưǓǔȔɄǕȕǖȖǗȗǘǙǚǛǜƯ]"), Qt::CaseInsensitive);
+        letters['v'] = QRegExp(QString::fromUtf8("[Ʋⱱⱴⱽ]"), Qt::CaseInsensitive);
+        letters['w'] = QRegExp(QString::fromUtf8("[ŴŵⱲⱳ]"), Qt::CaseInsensitive);
+        letters['y'] = QRegExp(QString::fromUtf8("[ÿÝýŶŷŸȲƳȳƴɎɏ]"), Qt::CaseInsensitive);
+        letters['z'] = QRegExp(QString::fromUtf8("[ŹźŻżŽžɀȤƵȥƶⱫⱬ]"), Qt::CaseInsensitive);
+        noLetter = QRegExp("[^-a-z '\"]", Qt::CaseInsensitive);
     }
 };
 
index 712f68c..48dc535 100644 (file)
@@ -133,7 +133,7 @@ protected:
         return string;
     }
 
-    void initAccents() { AccentsNormalizer::initAccents(); }
+    //void initAccents() { AccentsNormalizer::initAccents(); }
 
 
 
index 39c1aec..555a143 100644 (file)
 #include "GoogleSettingsDialog.h"
 #include <QDebug>
 
-GoogleSettingsDialog::GoogleSettingsDialog(QWidget *parent,QString langTo,QString langFrom) :
-    QDialog(parent)
-{
+GoogleSettingsDialog::GoogleSettingsDialog(QWidget *parent,
+                                           QString langTo,
+                                           QString langFrom,
+                                           QString acceptButtonLabel) :
+    QDialog(parent) {
     QMap<QString, QString> languages;
     languages=GooglePlugin::initLanguages();
 
@@ -45,9 +47,12 @@ GoogleSettingsDialog::GoogleSettingsDialog(QWidget *parent,QString langTo,QStrin
 
 
     #ifdef Q_WS_MAEMO_5
-        changeLangButton=new QPushButton(QIcon::fromTheme("general_refresh"),tr(""));
+        changeLangButton=new
+                         QPushButton(
+                                 QIcon::fromTheme("general_refresh"),tr(""));
     #else
-        changeLangButton=new QPushButton(QIcon::fromTheme("object-flip-vertical"),tr(""));
+        changeLangButton=new QPushButton(
+                QIcon::fromTheme("object-flip-vertical"),tr(""));
     #endif
     langFromLabel = new QLabel("From:");
     langToLabel = new QLabel(" To: ");
@@ -58,22 +63,22 @@ GoogleSettingsDialog::GoogleSettingsDialog(QWidget *parent,QString langTo,QStrin
 
     setWindowTitle(tr("Google Settings"));
 
-    verticalLayout = new QVBoxLayout(this);
-    langLayout = new QVBoxLayout(this);
-    langFromLayout = new QHBoxLayout(this);
-    langToLayout = new QHBoxLayout(this);
-    changelangLayout = new QHBoxLayout(this);
+    verticalLayout = new QVBoxLayout;
+    langLayout = new QVBoxLayout;
+    langFromLayout = new QHBoxLayout;
+    langToLayout = new QHBoxLayout;
+    changelangLayout = new QHBoxLayout;
 
     setLayout(verticalLayout);
 
-    infoLabel = new QLabel(this);
+    infoLabel = new QLabel;
     infoLabel->setText(tr("Plugin:GoogleTranslator \n")+
                    tr("From: ") + languages.key(langFrom) + "\n" +
                    tr("To: ") + languages.key(langTo));
     verticalLayout->addWidget(infoLabel);
 
-    langFromComboBox = new QComboBox(this);
-    langToComboBox = new QComboBox(this);
+    langFromComboBox = new QComboBox;
+    langToComboBox = new QComboBox;
     int i=0;
     foreach(QString langs,languages.keys()){
         if(langs==languages.key(langTo))
@@ -100,15 +105,19 @@ GoogleSettingsDialog::GoogleSettingsDialog(QWidget *parent,QString langTo,QStrin
     langToComboBox->setCurrentIndex(actualLangTo);
     langFromComboBox->setCurrentIndex(actualLangFrom);
 
-    saveButton = new QPushButton(tr("Save settings"),this);
+    saveButton = new QPushButton(acceptButtonLabel);
     verticalLayout->addWidget(saveButton);
 
     setModal(true);
 
-    connect(saveButton, SIGNAL(clicked()),this, SLOT(accept()));
-    connect(langFromComboBox, SIGNAL(activated(int)),this, SLOT(activatedFrom(int)));
-    connect(langToComboBox, SIGNAL(activated(int)),this, SLOT(activatedTo(int)));
-    connect(changeLangButton, SIGNAL(clicked()),this, SLOT(changeLangButtonClicked()));
+    connect(saveButton, SIGNAL(clicked()),
+            this, SLOT(accept()));
+    connect(langFromComboBox, SIGNAL(activated(int)),
+            this, SLOT(activatedFrom(int)));
+    connect(langToComboBox, SIGNAL(activated(int)),
+            this, SLOT(activatedTo(int)));
+    connect(changeLangButton, SIGNAL(clicked()),
+            this, SLOT(changeLangButtonClicked()));
 }
 
 void GoogleSettingsDialog::activatedFrom(int index) {
@@ -138,23 +147,34 @@ QString GoogleSettingsDialog::langTo() {
     return _langTo;
 }
 
-Settings* GoogleSettingsDialog::getSettings(QWidget *parent,QString langTo,QString langFrom) {
-    GoogleSettingsDialog settingsDialog(parent,langTo,langFrom);
+Settings* GoogleSettingsDialog::getSettings(QWidget *parent,
+                                            QString langTo,
+                                            QString langFrom,
+                                            QString acceptButtonLabel) {
+    GoogleSettingsDialog settingsDialog(parent,
+                                        langTo,
+                                        langFrom,
+                                        acceptButtonLabel);
     QMap<QString, QString> languages;
     languages=GooglePlugin::initLanguages();
     if(settingsDialog.exec()==QDialog::Accepted) {
         Settings *settings = new Settings();
         settings->setValue("langTo",languages.value(settingsDialog.langTo()));
-        settings->setValue("langFrom",languages.value(settingsDialog.langFrom()));
+        settings->setValue("langFrom",
+                           languages.value(settingsDialog.langFrom()));
         settings->setValue("connectionAccept","true");
         return settings;
     }
     return 0;
 }
 
-void GoogleSettingsDialog::changeSettings(GooglePlugin* plugin, QWidget *parent) {
+void GoogleSettingsDialog::changeSettings(GooglePlugin* plugin,
+                                          QWidget *parent) {
     Settings *settings = new Settings();
-    settings=getSettings(parent,plugin->settings()->value("langTo"),plugin->settings()->value("langFrom"));
+    settings=getSettings(parent,
+                         plugin->settings()->value("langTo"),
+                         plugin->settings()->value("langFrom"),
+                         tr("Save changes"));
     if(settings)
         plugin->setSettings(settings);
 }
index 13ae5ee..866bda2 100644 (file)
@@ -38,7 +38,10 @@ class GoogleSettingsDialog : public QDialog
 {
     Q_OBJECT
 public:
-    explicit GoogleSettingsDialog(QWidget *parent = 0,QString langTo ="",QString langFrom ="");
+    explicit GoogleSettingsDialog(QWidget *parent = 0,
+                                  QString langTo ="",
+                                  QString langFrom ="",
+                                  QString acceptButtonLabel = tr("Add"));
 
     /*!
         \param parent parent widget on which will be displayed dialog
@@ -46,7 +49,10 @@ public:
         \param langFrom language witch is display in the comboBox as a startup item
         \returns function return settings to GooglePlugin
     */
-    static Settings* getSettings(QWidget *parent,QString langTo ="",QString langFrom ="");
+    static Settings* getSettings(QWidget *parent,
+                                 QString langTo ="",
+                                 QString langFrom ="",
+                                 QString acceptButtonLabel = tr("Add"));
 
     /*!
         function set a new settings in plugin;
index 78a5905..50e9567 100644 (file)
@@ -80,6 +80,7 @@ QList<Translation*> XdxfPlugin::searchWordList(QString word, int limit) {
     if(word.indexOf("*")==-1 && word.indexOf("?")==-1 && word.indexOf("_")==-1
        && word.indexOf("%")==-1)
         word+="*";
+
     if(isCached())
         return searchWordListCache(word,limit);
     return searchWordListFile(word, limit);
@@ -157,7 +158,6 @@ QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
     QXmlStreamReader reader(&dictionaryFile);
     /*search words list*/
     QString a;
-
     int i=0;
     while(!reader.atEnd() && !stopped){
         reader.readNextStartElement();
index dffbbe9..db858b2 100644 (file)
@@ -319,6 +319,23 @@ void XdxfTest::timeCacheNormalize() {
     File.close();
 }
 
+void XdxfTest::removeAccents()
+{
+    XdxfPluginSub xdxf;
+    xdxf.settings()->setValue(QString("strip_accents"), QString("true"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("nóżka")), QString("nozka"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("motor")), QString("motor"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("nÓżKa")), QString("nozka"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("ławka")), QString("lawka"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("éàèùâêîôûëïüÿäöüç")), QString("eaeuaeioueiuyaouc"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("íőűúó")), QString("iouuo"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("-ę")), QString("-e"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("\"e\"")), QString("\"e\""));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("'e'")), QString("'e'"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("\\e")), QString("e"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("\\")), QString(""));
+}
+
 void XdxfTest::timeFileNormalize(){
     QTime timer;
     QDate date;
index f4fed84..a88d6a7 100644 (file)
      void searchWordListCache();
      void timeCache();
      void timeFile();
+     void removeAccents();
+ };
+
+ class XdxfPluginSub : public XdxfPlugin
+ {
+    public:
+     XdxfPluginSub(QObject *parent = 0) : XdxfPlugin(parent){}
+     QString getRemoveAccents(QString s)
+     {
+         return removeAccents(s);
+     }
      void timeCacheNormalize();
      void timeFileNormalize();
  };