Merge branch 'cache' of ssh://drop.maemo.org/git/mdictionary into cache
authorJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Tue, 24 Aug 2010 13:14:47 +0000 (15:14 +0200)
committerJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Tue, 24 Aug 2010 13:14:47 +0000 (15:14 +0200)
Conflicts:
trunk/src/base/gui/MenuWidget.cpp
trunk/src/base/gui/SearchBarWidget.cpp
trunk/src/base/xsl.xsl
trunk/src/plugins/xdxf/src/xdxfplugin.h

23 files changed:
trunk/src/base/backbone/Bookmarks.cpp
trunk/src/base/gui/AboutWidget.cpp
trunk/src/base/gui/BookmarksWidget.cpp
trunk/src/base/gui/DictManagerWidget.cpp
trunk/src/base/gui/DictTypeSelectDialog.cpp
trunk/src/base/gui/HistoryListDialog.cpp
trunk/src/base/gui/MainWindow.cpp
trunk/src/base/gui/MenuWidget.cpp
trunk/src/base/gui/SearchBarWidget.cpp
trunk/src/base/gui/SettingsWidget.cpp
trunk/src/base/gui/TranslationWidget.cpp
trunk/src/base/xsl.xsl
trunk/src/includes/settings.h
trunk/src/plugins/xdxf/src/TranslationXdxf.cpp
trunk/src/plugins/xdxf/src/TranslationXdxf.h
trunk/src/plugins/xdxf/src/XdxfCachingDialog.cpp
trunk/src/plugins/xdxf/src/XdxfDictDialog.h
trunk/src/plugins/xdxf/src/XdxfLoadDialog.cpp
trunk/src/plugins/xdxf/src/XdxfSettingsDialog.cpp
trunk/src/plugins/xdxf/src/xdxfplugin.cpp
trunk/src/plugins/xdxf/src/xdxfplugin.h
trunk/src/plugins/xdxf/tests/test.cpp
trunk/src/plugins/xdxf/tests/test.h

index 2f20ea9..3770eb6 100644 (file)
@@ -51,6 +51,7 @@ void Bookmarks::add(Translation* translation) {
         qDebug() << "Database error: " << db.lastError().text() << endl;
         return ;
     }
+    translation->setBookmark(true);
     QSqlQuery cur(db);
     cur.prepare("insert into bookmarks values (?,?)");
     cur.addBindValue(translation->key());
index d2edb32..c77d58b 100644 (file)
@@ -22,19 +22,19 @@ AboutWidget::AboutWidget(GUIInterface *parent): QDialog(parent)
                   QString("</p></font>");
 
     setWindowTitle(tr("About"));
-    mainLayout = new QVBoxLayout;
+    mainLayout = new QVBoxLayout(this);
 
     #ifndef Q_WS_MAEMO_5
-        scrollLayout = new QVBoxLayout;
-        scroll = new QScrollArea;
+        scrollLayout = new QVBoxLayout(this);
+        scroll = new QScrollArea(this);
         w = new QWidget(this);
 
     #endif
 
 
-    imageLabel = new QLabel;
-    mainLabel = new QLabel;
-    licenseLabel = new QLabel;
+    imageLabel = new QLabel(this);
+    mainLabel = new QLabel(this);
+    licenseLabel = new QLabel(this);
 
 
     QImage img(":/icons/logo/mdictionary.png");
index 047bad7..438edac 100644 (file)
@@ -30,12 +30,12 @@ BookmarksWidget::BookmarksWidget(GUIInterface *parent) :
 {
     setWindowTitle(tr("Bookmarks"));
 
-    verticalLayout = new QVBoxLayout;
+    verticalLayout = new QVBoxLayout(this);
     setLayout(verticalLayout);
 
-    showAllBookmarksPushButton = new QPushButton(tr("Show all bookmarks"));
+    showAllBookmarksPushButton = new QPushButton(tr("Show all bookmarks"),this);
     removeAllBookmarksPushButton =
-            new QPushButton(tr("Remove all bookmarks"));
+            new QPushButton(tr("Remove all bookmarks"),this);
 
     verticalLayout->addWidget(showAllBookmarksPushButton);
     verticalLayout->addWidget(removeAllBookmarksPushButton);
index ab57e0b..22fe241 100644 (file)
@@ -36,23 +36,23 @@ DictManagerWidget::DictManagerWidget(GUIInterface *parent) :
     setWindowTitle(tr("Dictionaries"));
     this->guiInterface = parent;
 
-    verticalLayout = new QVBoxLayout;
+    verticalLayout = new QVBoxLayout(this);
     setLayout(verticalLayout);
 
-    dictListWidget = new QListWidget;
+    dictListWidget = new QListWidget(this);
     verticalLayout->addWidget(dictListWidget);
 
     dictListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
     dictListWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
-    addNewDictButton = new QPushButton(tr("Add"));
-    removeDictButton = new QPushButton(tr("Remove"));
-    settingsButton = new QPushButton(tr("Settings"));
+    addNewDictButton = new QPushButton(tr("Add"),this);
+    removeDictButton = new QPushButton(tr("Remove"),this);
+    settingsButton = new QPushButton(tr("Settings"),this);
 
     removeDictButton->setEnabled(false);
     settingsButton->setEnabled(false);
 
-    buttonGroup = new QHBoxLayout;
+    buttonGroup = new QHBoxLayout(this);
 
     buttonGroup->addWidget(addNewDictButton);
     buttonGroup->addWidget(removeDictButton);
@@ -94,7 +94,7 @@ void DictManagerWidget::refreshDictsList() {
 
     while(i.hasNext()) {
         i.next();
-        QListWidgetItem* item = new QListWidgetItem;
+        QListWidgetItem* item = new QListWidgetItem();
         QString name = i.key()->langFrom() + " - " + i.key()->langTo() + " (" +
                        i.key()->type() + " " + i.key()->name() + ")";
         item->setText(name);
index 6b28fc4..4d0e317 100644 (file)
@@ -30,10 +30,10 @@ DictTypeSelectDialog::DictTypeSelectDialog(QList<CommonDictInterface *> plugins,
 
     this->plugins = plugins;
 
-    verticalLayout = new QVBoxLayout;
+    verticalLayout = new QVBoxLayout(this);
     setLayout(verticalLayout);
 
-    pluginsListWidget = new QListWidget;
+    pluginsListWidget = new QListWidget(this);
 
     verticalLayout->addWidget(pluginsListWidget);
 
index 97c5ce9..8905578 100644 (file)
 HistoryListDialog::HistoryListDialog(QStringList words, QWidget *parent):
         QDialog(parent)
 {
-    verticalLayout = new QVBoxLayout;
+    verticalLayout = new QVBoxLayout(this);
     setLayout(verticalLayout);
 
     oryginalList = words;
 
-    historyListWidget = new QListWidget;
+    historyListWidget = new QListWidget(this);
     verticalLayout->addWidget(historyListWidget);
 
     for(int i=0; i<words.count(); i++) {
index 57f9e31..1f75d97 100644 (file)
@@ -67,18 +67,18 @@ void MainWindow::initializeUI() {
     translationWidget = new TranslationWidget(this);
 
 
-    mainLayout = new QVBoxLayout;
-    QWidget* w = new QWidget;
+    mainLayout = new QVBoxLayout(this);
+    QWidget* w = new QWidget(this);
     w->setLayout(mainLayout);
     setCentralWidget(w);
-    menuBar = new QMenuBar;
+    menuBar = new QMenuBar(this);
     setMenuBar(menuBar);
 
-    searchBarWidget = new SearchBarWidget;
+    searchBarWidget = new SearchBarWidget(this);
 
-    wordListWidget = new WordListWidget;
+    wordListWidget = new WordListWidget(this);
 
-    welcomeScreenWidget = new WelcomeScreenWidget;
+    welcomeScreenWidget = new WelcomeScreenWidget(this);
 
 
     #ifdef Q_WS_MAEMO_5
index afd234c..c79f0ac 100644 (file)
@@ -28,6 +28,8 @@
 MenuWidget::MenuWidget(QWidget *parent) :
     QWidgetAction(parent) {
 
+    //creating custom tab widget, and sets style sheet to have centered tabs
+    tabWidget = new MenuTabWidget(this);
     //creates custom tab widget, and sets style sheet to have centered tabs
     tabWidget = new MenuTabWidget();
     tabWidget->setStyleSheet("QTabWidget::tab-bar {alignment: center;}");
index eb30983..43519dc 100644 (file)
@@ -105,15 +105,15 @@ void SearchBarWidget::initializeUI() {
     #endif
 
 
-    horizontalLayout = new QHBoxLayout();
-    verticalLayout = new QVBoxLayout();
+    horizontalLayout = new QHBoxLayout(this);
+    verticalLayout = new QVBoxLayout(this);
 
 
-    searchPushButton = new QPushButton(tr("Search"));
+    searchPushButton = new QPushButton(tr("Search"),this);
     searchPushButton->setMinimumWidth(125);
 
 
-    searchWordLineEdit = new QLineEdit();
+    searchWordLineEdit = new QLineEdit(this);
     searchWordLineEdit->setMinimumWidth(250);
 
     #ifndef Q_WS_MAEMO_5
@@ -123,11 +123,11 @@ void SearchBarWidget::initializeUI() {
 
 
     //create layout for lineEdit to have clear button on it
-    QHBoxLayout* lineEditLayout = new QHBoxLayout;
+    QHBoxLayout* lineEditLayout = new QHBoxLayout(this);
     searchWordLineEdit->setLayout(lineEditLayout);
 
 
-    clearSearchWordToolButton = new QToolButton();
+    clearSearchWordToolButton = new QToolButton(this);
     #ifdef Q_WS_MAEMO_5
         clearSearchWordToolButton->setIcon(QIcon::fromTheme("general_stop"));
         //tool buttons will have size 2 times smaller
@@ -142,7 +142,7 @@ void SearchBarWidget::initializeUI() {
     #endif
 
 
-    historyNextToolButton = new QToolButton();
+    historyNextToolButton = new QToolButton(this);
     #ifdef Q_WS_MAEMO_5
         historyNextToolButton->setIcon(
                 generateIcon(QIcon::fromTheme("general_forward")));
@@ -153,7 +153,7 @@ void SearchBarWidget::initializeUI() {
 
 
 
-    historyPrevToolButton = new QToolButton();
+    historyPrevToolButton = new QToolButton(this);
     #ifdef Q_WS_MAEMO_5
         historyPrevToolButton->setIcon(
                 generateIcon(QIcon::fromTheme("general_back")));
@@ -164,7 +164,7 @@ void SearchBarWidget::initializeUI() {
 
 
 
-    historyShowToolButton = new QToolButton();
+    historyShowToolButton = new QToolButton(this);
     #ifdef Q_WS_MAEMO_5
         historyShowToolButton->setIcon(
                 generateIcon(QIcon::fromTheme("general_back"), 90));
@@ -185,7 +185,6 @@ void SearchBarWidget::initializeUI() {
                 fullScreenToolButton->sizeHint().height()*2);
     #endif*/
 
-
     searchingProgressBar = new QProgressBar();
     //progress bar has minimum and maximum values set to 0, which will effect
     //with "I'm alive" bar
index 72f0b20..77a239b 100644 (file)
@@ -31,13 +31,13 @@ SettingsWidget::SettingsWidget(GUIInterface *parent) :
 
     setWindowTitle(tr("Settings"));
 
-    verticalLayout = new QVBoxLayout;
+    verticalLayout = new QVBoxLayout(this);
     setLayout(verticalLayout);
 
-    historySizeSpinBox = new QSpinBox;
-    searchResultSizeSpinBox = new QSpinBox;
+    historySizeSpinBox = new QSpinBox(this);
+    searchResultSizeSpinBox = new QSpinBox(this);
 
-    spinBoxesFormLayout = new QFormLayout;
+    spinBoxesFormLayout = new QFormLayout(this);
 
     spinBoxesFormLayout->addRow(tr("Search result size"),
                                 searchResultSizeSpinBox);
@@ -54,10 +54,10 @@ SettingsWidget::SettingsWidget(GUIInterface *parent) :
     verticalLayout->addLayout(spinBoxesFormLayout);
 
 
-    checkBoxesLabel = new QLabel(tr("Search in:"));
+    checkBoxesLabel = new QLabel(tr("Search in:"),this);
 
-    searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks"));
-    searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries"));
+    searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks"),this);
+    searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries"),this);
 
     verticalLayout->addSpacing(20);
     verticalLayout->addWidget(checkBoxesLabel);
index 1480f91..cacfebf 100644 (file)
@@ -76,15 +76,18 @@ void TranslationWidget::show(QStringList translations) {
         trans += t + "\n";
     }
 
- //   qDebug()<<trans;
+    QImage image(":icons/16x16/staron.png");
+    QTextDocument *document = textEdit->document();
+    document->addResource(QTextDocument::ImageResource, QUrl("mydata://image.png"), QVariant(image));
 
     trans=tr("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") + tr("\n <ar>") + trans + tr("\n </ar>");
     trans=XslConversion(trans);
+
     textEdit->insertHtml(trans);
- //   textEdit->setPlainText(trans);
 
-    textEdit->repaint(this->rect());
+//  textEdit->setPlainText(trans);
 
+    textEdit->repaint(this->rect());
     update(this->rect());
 
     Q_EMIT updateSize();
@@ -191,14 +194,14 @@ void TranslationWidget::initButtons() {
 
 void TranslationWidget::initializeUI() {
 
-    textEdit = new TranslationTextEdit;
+    textEdit = new TranslationTextEdit(this);
     textEdit->setReadOnly(true);
 
     resizer = new TranslationWidgetAutoResizer(textEdit);
     connect(this, SIGNAL(updateSize()),
             resizer, SLOT(textEditChanged()));
 
-    QWidget*w = new QWidget;
+    QWidget*w = new QWidget(this);
     verticalLayout = new QVBoxLayout(w);
     verticalLayout->addWidget(textEdit);
 
index c6db7fd..a3dd6e1 100644 (file)
 </xsl:template> 
 
 <xsl:template match="info">
+<<<<<<< HEAD
+       <!-- <xsl:variable name="path" select="info/@path"/>-->
+       <tr bgcolor="#99FF99">
+               <th>            
+               <xsl:if test="@bookmark = 'true'">
+                       <img src="mydata://image.png"/>   
+               </xsl:if>
+               <xsl:value-of select="."/> <!-- <img src="{$path}"/> -->
+               </th>
+=======
        <tr>
        <th class="info"><xsl:value-of select="."/></th>
+>>>>>>> 3e7118bfec64f44b11205ca836cb1a82c725d123
        </tr>
 </xsl:template>
 
 <xsl:template match="key">
+<<<<<<< HEAD
+       <tr bgcolor="#99CCFF">
+       <th><xsl:value-of select="."/></th>                     
+       </tr>
+=======
        <tr>
        <th class="key"><xsl:value-of select="."/></th>         
         </tr>
+>>>>>>> 3e7118bfec64f44b11205ca836cb1a82c725d123
 </xsl:template> 
 
 <xsl:template match="t">
index cf40c48..bc8c35b 100644 (file)
@@ -31,6 +31,7 @@
 #include <QString>
 #include <QHash>
 #include "CommonDictInterface.h"
+#include <QDebug>
 
 class CommonDictInterface;
 
@@ -45,6 +46,7 @@ class Settings {
     Settings(const Settings* set) {
         _settings = QHash<QString, QString>(set->_settings);
     }
+    ~Settings(){}
 
     /*! \returns value fo given key
          \param key
index 39caf28..0a1246b 100644 (file)
@@ -43,15 +43,17 @@ QString TranslationXdxf::dictionaryInfo() const {
     return _dictionaryInfo;
 }
 
-QString TranslationXdxf::toHtml() const {
+QString TranslationXdxf::toHtml() const { 
     QString result("");
-    
     if(!xdxfPlugin)
         return result;
-    result+="<dict>" + _dictionaryInfo + xdxfPlugin->search(_key) + "</dict>";
-    result.replace("&","&amp;");
-    
-    return result;
+    result=result + "<dict>" + "<info";
+    if(isBookmark())
+        result+= " bookmark=\"true\" ";
+    else
+        result+= " bookmark=\"false\" ";
+    result+= _dictionaryInfo + "</info>" + xdxfPlugin->search(_key) + "</dict>";
+    return result.replace("&","&amp;");
 }
 
 void TranslationXdxf::setKey(QString _key) {
index 31a5193..8236e39 100644 (file)
@@ -50,6 +50,10 @@ public:
     //! sets information about dictionary
     void setDictionaryInfo(QString);
 
+    //! \retrun whether given translation is taken from bookmarks
+    bool isBookmark() const {
+        return _bookmark;
+   }
 
     //! returns coresponding dict object
     uint dict() const {return _dictHash;}
index 8cb8e45..604ee03 100644 (file)
@@ -35,15 +35,15 @@ XdxfCachingDialog::XdxfCachingDialog(XdxfPlugin *parent) :
     setLayout(verticalLayout);
 
     setWindowTitle(tr("Caching dictionary, please wait"));
-    cachingProgressBar = new QProgressBar;
+    cachingProgressBar = new QProgressBar(this);
     cachingProgressBar->setMinimum(0);
     cachingProgressBar->setMaximum(100);
     cachingProgressBar->setTextVisible(true);
 
-    cancelButton = new QPushButton(tr("Cancel"));
+    cancelButton = new QPushButton(tr("Cancel"),this);
 
 
-    cachingLabel = new QLabel();
+    cachingLabel = new QLabel(this);
     cachingLabel->hide();
 
 
index 73f882c..e0b2ba8 100644 (file)
@@ -36,7 +36,6 @@ class XdxfDictDialog : public DictDialog {
     Q_OBJECT
 public:
     explicit XdxfDictDialog(XdxfPlugin* plugin, QObject *parent = 0);
-
     /*!
       Shows add new xdxf dictionary dialog and returns settings of new dict
       \param parent parent widget on which dialog will be displayed
index 2cf4a00..8b4a039 100644 (file)
 
 XdxfLoadDialog::XdxfLoadDialog(QWidget *parent) :
     QDialog(parent) {
-    verticalLayout = new QVBoxLayout;
+    verticalLayout = new QVBoxLayout(this);
     setLayout(verticalLayout);
 
     setWindowTitle(tr("Add new XDXF dictionary"));
 
-    browseLayout = new QHBoxLayout;
+    browseLayout = new QHBoxLayout(this);
     verticalLayout->addLayout(browseLayout);
 
-    browseButton =  new QPushButton(tr("Browse"));
-    browseLabel = new QLabel(tr("Dictionary file: not selected"));
+    browseButton =  new QPushButton(tr("Browse"),this);
+    browseLabel = new QLabel(tr("Dictionary file: not selected"),this);
 
     browseLayout->addWidget(browseLabel);
     browseLayout->addWidget(browseButton,0, Qt::AlignRight);
 
 
-    cacheLayout = new QHBoxLayout;
+    cacheLayout = new QHBoxLayout(this);
     verticalLayout->addLayout(cacheLayout);
 
-    cacheCheckBox = new QCheckBox(tr("Optimize for quicker searches (may take some time)"));
+    cacheCheckBox = new QCheckBox(tr("Optimize for quicker searches (may take some time)"),this);
     cacheCheckBox->setChecked(true);
     cacheLayout->addWidget(cacheCheckBox);
 
-    addButton = new QPushButton(tr("Add"));
+    addButton = new QPushButton(tr("Add"),this);
 
     verticalLayout->addWidget(addButton);
 
index 26e0176..9b6d991 100644 (file)
@@ -30,13 +30,13 @@ XdxfSettingsDialog::XdxfSettingsDialog(XdxfPlugin *plugin, QWidget *parent) :
     QDialog(parent)
 {
     this->plugin = plugin;
-    verticalLayout = new QVBoxLayout;
+    verticalLayout = new QVBoxLayout(this);
     setLayout(verticalLayout);
 
     setWindowTitle(tr("XDXF Settings"));
 
 
-    infoLabel = new QLabel;
+    infoLabel = new QLabel(this);
 
     infoLabel->setText(tr("Plugin type: ") + plugin->type() +"\n" +
                    tr("From: ") + plugin->langFrom() + "\n" +
@@ -45,21 +45,21 @@ XdxfSettingsDialog::XdxfSettingsDialog(XdxfPlugin *plugin, QWidget *parent) :
 
     verticalLayout->addWidget(infoLabel);
 
-    browseLayout = new QHBoxLayout;
+    browseLayout = new QHBoxLayout(this);
     verticalLayout->addLayout(browseLayout);
 
-    browseButton =  new QPushButton(tr("Browse"));
+    browseButton =  new QPushButton(tr("Browse"),this);
     browseLabel = new QLabel(tr("Dictionary file: ") +
-                             plugin->settings()->value("path"));
+                             plugin->settings()->value("path"),this);
 
     browseLayout->addWidget(browseLabel);
     browseLayout->addWidget(browseButton,0, Qt::AlignRight);
 
 
-    cacheLayout = new QHBoxLayout;
+    cacheLayout = new QHBoxLayout(this);
     verticalLayout->addLayout(cacheLayout);
 
-    cacheCheckBox = new QCheckBox(tr("Cached"));
+    cacheCheckBox = new QCheckBox(tr("Cached"),this);
     if(plugin->settings()->value("cached") == "true") {
         cacheCheckBox->setChecked(true);
         _generateCache = true;
@@ -71,7 +71,7 @@ XdxfSettingsDialog::XdxfSettingsDialog(XdxfPlugin *plugin, QWidget *parent) :
 
     cacheLayout->addWidget(cacheCheckBox);
 
-    saveButton = new QPushButton(tr("Save settings"));
+    saveButton = new QPushButton(tr("Save settings"),this);
 
     verticalLayout->addWidget(saveButton);
 
@@ -133,10 +133,11 @@ Settings* XdxfSettingsDialog::getSettings(XdxfPlugin *plugin,
             settings->setValue("generateCache", "false");
         }
         plugin->setSettings(settings);
-        return NULL;
+        delete settings;
+        return 0;
     }
 
-    return NULL;
+    return 0;
 }
 
 
index 2694625..b0c75d4 100644 (file)
 
 #include "xdxfplugin.h"
 #include <QDebug>
-#include <QFile>
-#include <QXmlStreamReader>
-#include <QtPlugin>
-#include "TranslationXdxf.h"
-#include "../../../includes/settings.h"
 
 XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
                     _langFrom(tr("")), _langTo(tr("")),_name(tr("")),
@@ -50,9 +45,11 @@ XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
 
 XdxfPlugin::~XdxfPlugin()
 {
-    qDebug()<<"/n /n destruktor";
-    if(!db.connectionName().isEmpty())
-        db.removeDatabase(_type+path);
+//  QString connection(db.connectionName());
+//   db.close();
+//  QSqlDatabase::removeDatabase(connection);
+
+    delete _settings;
 }
 
 QString XdxfPlugin::langFrom() const {   
@@ -125,7 +122,7 @@ QList<Translation*> XdxfPlugin::searchWordListCache(QString word, int limit) {
                         _infoNote, this));
         }
         db.close();
-       return translations.toList();
+    return translations.toList();
 }
 
 QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
@@ -201,7 +198,9 @@ QString XdxfPlugin::searchCache(QString key) {
     cur.exec();
     while(cur.next())
         result += cur.value(0).toString();
+
     db.close();
+
     return result;
 
 }
@@ -211,13 +210,10 @@ QString XdxfPlugin::searchFile(QString key) {
     QFile dictionaryFile(path);
     QString resultString("");
     if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
-        qDebug()<<"Error: could not open file";
+        qDebug()<<"Error: could not open file when search";
         return "";
     }
     QXmlStreamReader reader(&dictionaryFile);
-
-
-
     QString a;
 
     bool match =false;
@@ -286,9 +282,8 @@ CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
 
         a=a+1;
         plugin->db_name = plugin->_settings->value("type")
-               + plugin->_settings->value("path");
-//        if(!plugin->db.connectionName().isEmpty() || settings->value("generateCache")=="true")
-            plugin->db = QSqlDatabase::addDatabase("QSQLITE", plugin->db_name);
+                         + plugin->_settings->value("path");
+        plugin->db = QSqlDatabase::addDatabase("QSQLITE", plugin->db_name);
 
         if(settings->value("cached").isEmpty() &&
            settings->value("generateCache") == "true") {
@@ -371,9 +366,7 @@ void XdxfPlugin::getDictionaryInfo() {
 //  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>";
-
-
+    _infoNote="path=\""+initialPath+"\">"+"\n" + _name + " [" + _langFrom + "-" + _langTo + "] "+ "(" + _type + ")";
 
     dictionaryFile.close();
 }
@@ -527,6 +520,7 @@ bool XdxfPlugin::makeCache(QString dir) {
     _settings->setValue("cache_path", cachePathN);
     _settings->setValue("cached", "true");
 
+
     db.close();
     return true;
 }
index bbd6cb5..f844971 100644 (file)
@@ -25,7 +25,7 @@
 #ifndef XDXFPLUGIN_H
 #define XDXFPLUGIN_H
 
-#include "../../../includes/CommonDictInterface.h"
+
 #include <QObject>
 #include <QDialog>
 #include <QRegExp>
 #include <QSqlQuery>
 #include <QSqlDatabase>
 #include <QSqlError>
+#include <QFile>
+#include <QXmlStreamReader>
+#include <QtPlugin>
+
+#include "../../../includes/CommonDictInterface.h"
+#include "../../../includes/settings.h"
 #include "XdxfDictDialog.h"
 #include "XdxfCachingDialog.h"
+#include "TranslationXdxf.h"
 
 class TranslationXdxf;
 
@@ -44,8 +51,7 @@ class XdxfPlugin : public CommonDictInterface
     Q_INTERFACES(CommonDictInterface)
 public:
     XdxfPlugin(QObject *parent=0);
-
-    virtual ~XdxfPlugin();
+    ~XdxfPlugin();
 
     //! returns source language code iso 639-2
     QString langFrom() const;
@@ -67,7 +73,6 @@ public:
       */
     DictDialog* dictDialog();
 
-
     //! returns new, clean copy of plugin with setting set as in Settings*
     CommonDictInterface* getNew(const Settings*) const;
 
@@ -130,6 +135,9 @@ private:
     QList<Translation*> searchWordListFile(QString word, int limit=0);
     QString searchFile(QString key);
     QString searchCache(QString key);
+    //! scan dictionary file to get information about it
+    void getDictionaryInfo();
+
     int countWords();
     bool makeCache(QString dir);
 
@@ -143,8 +151,6 @@ private:
     QString _type;
     //! information about dictionary
     QString _infoNote;
-    QDialog *_loadDialog;
-    QDialog *_settingsDialog;
     //! path to dictionary file
     QString path;
     uint _hash;
@@ -155,9 +161,6 @@ private:
     //! number of words in dictionary
     long _wordsCount;
 
-    //! scans dictionary file to get information about it
-    void getDictionaryInfo();
-
     volatile bool stopped;
     Settings *_settings;
     XdxfDictDialog* _dictDialog;
index efc88f5..58aeb02 100644 (file)
@@ -165,7 +165,8 @@ void XdxfTest::stop() {
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
 
     QString string("*");
-    QFuture<QList<Translation*> > future = QtConcurrent::run(xdxfPlugin, &CommonDictInterface::searchWordList, string, 10);
+    QFuture<QList<Translation*> > future = QtConcurrent::run(xdxfPlugin,
+                        &CommonDictInterface::searchWordList, string, 10);
     QList<Translation*> te5 = future.result();
     QCOMPARE(te5.size(), 9);
 
@@ -185,5 +186,95 @@ void XdxfTest::langFrom() {
     delete xdxfPlugin;
 }
 
+void XdxfTest::timeCache()
+{
+    QTime timer;
+    QDate date;
+    QFile File("../tests/time.xml");
+    if(!File.open(QFile::ReadWrite | QFile::Text)) {
+        qDebug()<<"Error: could not open file";
+        return;
+    }
+    QTextStream out(&File);
+    while(!out.atEnd())
+        out.seek(out.pos()+1);
+
+    timer.start();
+    XdxfPlugin xdxfPluginB(this);
+    Settings *settings=new Settings;
+    settings->setValue("path","../../../../../../dict.xdxf");
+    settings->setValue("generateCache", "true");
+    CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+
+    out<<"\n<date>" + date.currentDate().toString("dd.MM.yyyy") +" ";
+    out<<timer.currentTime().toString(Qt::TextDate) + "</date>";
+    out<<"\n<type> Cache </type> <time>" << timer.elapsed();
+    out<<"</time>";
+
+    timer.start();
+    xdxfPlugin->search("Bantu");
+    out<<"\n<type> SearchCache-begin </type> <time>" << timer.elapsed();
+    out<< "</time>";
+
+    timer.start();
+    xdxfPlugin->search("level");
+    out<<"\n<type> SearchCache-midle </type> <time>" << timer.elapsed();
+    out<< "</time>";
+
+    timer.start();
+    xdxfPlugin->search("zoril");
+    out<<"\n<type> SearchCache-end </type> <time>" << timer.elapsed();
+    out<< "</time>";
+
+    timer.start();
+    xdxfPlugin->searchWordList("level");
+    out<<"\n<type> SearchWorlListCache </type> <time>" << timer.elapsed();
+    out<< "</time>";
+
+    File.close();
+}
+
+void XdxfTest::timeFile()
+{
+    QTime timer;
+    QDate date;
+    QFile File("../tests/time.xml");
+    if(!File.open(QFile::ReadWrite | QFile::Text)) {
+        qDebug()<<"Error: could not open file";
+        return;
+    }
+    QTextStream out(&File);
+    while(!out.atEnd())
+        out.seek(out.pos()+1);
+
+    XdxfPlugin xdxfPluginB(this);
+    Settings *settings=new Settings;
+    settings->setValue("path","../../../../../../dict.xdxf");
+    CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+
+    timer.start();
+    xdxfPlugin->search("Bantu");
+    out<<"\n<type> SearchFile-begin </type> <time>" << timer.elapsed();
+    out << "</time>";
+
+    timer.start();
+    xdxfPlugin->search("level");
+    out<<"\n<type> SearchFile-midle </type> <time>" << timer.elapsed();
+    out << "</time>";
+
+    timer.start();
+    xdxfPlugin->search("zoril");
+    out<<"\n<type> SearchFile-end </type> <time>" << timer.elapsed();
+    out << "</time>";
+
+    timer.start();
+    xdxfPlugin->searchWordList("level");
+    out<<"\n<type> SearchWordListFile </type> <time>" << timer.elapsed();
+    out<< "</time>\n";
+
+    File.close();
+}
+
+
 QTEST_MAIN(XdxfTest)
 //#include "testqstring.moc"
index 100b171..70f540c 100644 (file)
@@ -29,6 +29,9 @@
 #include <QtConcurrentRun>
 #include <QFuture>
 #include "../src/xdxfplugin.h"
+#include <QTime>
+#include <QDate>
+#include <QTextStream>
 
  class XdxfTest: public QObject
  {
@@ -44,6 +47,8 @@
      void makeCache();
      void searchCache();
      void searchWordListCache();
+     void timeCache();
+     void timeFile();
  };