Merge branch 'google'
authorJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Fri, 3 Sep 2010 12:58:04 +0000 (14:58 +0200)
committerJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Fri, 3 Sep 2010 12:58:04 +0000 (14:58 +0200)
18 files changed:
data/xsl/style.css
data/xsl/xsl.xsl
mdictionary.pro
src/mdictionary/backbone/Bookmarks.cpp
src/mdictionary/backbone/ConfigGenerator.cpp
src/mdictionary/backbone/backbone.cpp
src/mdictionary/gui/MainWindow.cpp
src/mdictionary/gui/NotifyManager.cpp
src/mdictionary/gui/TranslationWidget.cpp
src/plugins/google/GooglePlugin.cpp
src/plugins/google/TranslationGoogle.cpp
src/plugins/google/google.pro
src/plugins/xdxf/TranslationXdxf.cpp
src/plugins/xdxf/xdxf.pro
src/plugins/xdxf/xdxfplugin.cpp
tests/GooglePluginTests/test.cpp
tests/XdxfPluginTests/test.cpp
tests/XdxfPluginTests/test.h

index c8490f2..400f414 100644 (file)
@@ -1,5 +1,5 @@
 th.info {
-       background-color       : #99FF99; 
+       background-color        : #99FF99;     
 }
 
 th.key {
index 96770eb..bdd79ce 100644 (file)
 </xsl:template> 
 
 <xsl:template match="info">
+       <xsl:variable name="path" select="@path"/>
        <tr>
                <th class="info">               
                <xsl:if test="@bookmark = 'true'">
                        <img src="$STAR$" width="16" height="16"/>   
                </xsl:if>
-               <xsl:value-of select="."/> <!-- <img src="{$path}"/> -->
+               <xsl:value-of select="."/>  <img src="{$path}" height="16"/>
                </th>
        </tr>
 </xsl:template>
index e0fbf59..6dcf823 100644 (file)
@@ -1,11 +1,11 @@
 TEMPLATE = subdirs
-SUBDIRS = src
+SUBDIRS = src tests
 CONFIG += ordered
 include (mdictionary.pri)
 
 
 check.CONFIG += recursive
-check.recurse = src 
+check.recurse = src tests
 QMAKE_EXTRA_TARGETS += check
 
 
index c39f868..32a3ab3 100644 (file)
@@ -139,7 +139,7 @@ QList<Translation*> Bookmarks::searchWordList(QString word) {
 
 
 QStringList Bookmarks::search(QString word, QString dbName) {
-    //checkAndCreateDb();
+    checkAndCreateDb();
     QStringList result;
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
index 049d757..4a5f611 100644 (file)
@@ -26,6 +26,7 @@
 */
 
 #include "ConfigGenerator.h"
+#include <QDebug>
 
 bool ConfigGenerator::generateCss(QString file) {
     return generateFile(":/xsl/style.css", file);
index bdbb11a..f61266e 100644 (file)
@@ -263,13 +263,11 @@ void Backbone::addInternalDictionary(CommonDictInterface* dict, bool active) {
 
  void Backbone::removeDictionary(CommonDictInterface *dict) {
      _dicts.remove(dict);
-     if(dict)
+     if(dict) {
         dict->clean();
-     else
-        qDebug()<<"delete empty dict";
-     delete dict;
+        delete dict;
+     }
      dictUpdated();
-
  }
 
 
index 6039f08..16257c6 100644 (file)
@@ -562,7 +562,7 @@ void MainWindow::removeBookmarks() {
     #endif
     if(QMessageBox::question(par, tr("Delete all bookmarks"),
              tr("Do you want to delete all bookmarks? (This action cannot be revoked)"),
-             QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) {
+             QMessageBox::Yes, QMessageBox::Cancel) == QMessageBox::Yes) {
         backbone->removeAllBookmarks();
         if(searchString.size())
             backbone->search(searchString);
index 4bec722..c054f8d 100644 (file)
@@ -60,7 +60,6 @@ void NotifyManager::screenChanged() {
 }
 
 void NotifyManager::showNotification(Notify::NotifyType type, QString text) {
-
     if(activeNotifies.contains(text)) {
         return;
     }
index ab9f787..935323e 100644 (file)
@@ -90,8 +90,7 @@ void TranslationWidget::show(QStringList translations) {
     trans = head + trans;
 
     trans+= "</body></html>";
-    trans.replace("$STAR$", "/usr/lib/mdictionary/staron.png");
-
+    trans.replace("$STAR$", "/usr/share/mdictionary/staron.png");
 
     webkit->setHtml(trans, QUrl().fromLocalFile("/"));
 
index 2fcd0b5..5a9c13f 100644 (file)
@@ -430,7 +430,7 @@ QMap<QString, QString> GooglePlugin::initLanguages() {
 void GooglePlugin::getDictionaryInfo() {
     QString fullLangFrom=languages.key(_settings->value("lang_from"));
     QString fullLangTo=languages.key(_settings->value("lang_to"));
-    _infoNote=" [" + fullLangFrom + "-" + fullLangTo + "] (Google)";
+    _infoNote=" [" + fullLangFrom + "-" + fullLangTo + "] ";
 }
 
 
index fddaa2c..5d1d5c8 100644 (file)
@@ -40,7 +40,7 @@ TranslationGoogle::TranslationGoogle(QString _key,QString _trans,
 }
 
 TranslationGoogle::~TranslationGoogle(){
-    //qDebug()<<"\n\n delete translation:: Google\n\n";
+    ;
 }
 
 
@@ -55,8 +55,8 @@ QString TranslationGoogle::dictionaryInfo() const {
 QString TranslationGoogle::toHtml() const {
     QString result("");
     if(!googlePlugin)
-        return result;
-    result="<dict> <info path=\"\" ";
+        return result;   
+    result="<dict> <info path=\"/usr/share/mdictionary/drawing.png\" ";
     if(isBookmark())
         result+="bookmark=\"true\" >";
     else
index 9f80b38..f867bc1 100644 (file)
@@ -24,5 +24,12 @@ TRANSLATIONS += dict_google_pl.ts \
 RESOURCES += \
     icons.qrc
 
+
+unix {
+  INSTALLS += plugin-icon
+
+  plugin-icon.path = $$DATA_DIR
+  plugin-icon.files += drawing.png
+}
 check.commands = echo 'No check here'
 QMAKE_EXTRA_TARGETS += check
index 0bd9718..7bb8d8d 100644 (file)
@@ -28,7 +28,6 @@
 
 TranslationXdxf::TranslationXdxf():_key(""),_dictionaryInfo("") {
     xdxfPlugin=0;
-//   qDebug()<<"\n\n create translaton Xdxf\n\n";
 }
 
 TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo,
@@ -37,12 +36,10 @@ TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo,
     if(xdxfPlugin)
         _dictHash = xdxfPlugin->hash();
     _bookmark=0;
-
-//    qDebug()<<"create translaton Xdxf";
 }
 
 TranslationXdxf::~TranslationXdxf() {
-//    qDebug()<<"delete translation:: Xdxf";
+    ;
 }
 
 QString TranslationXdxf::key() const {
index d108a3c..1fe7ee8 100644 (file)
@@ -30,11 +30,14 @@ TRANSLATIONS += dict_xdxf_pl.ts \
                 dict_xdxf_en.ts
     
 unix {
-  INSTALLS += dicts
+  INSTALLS += dicts plugin-icon
 
   dicts.path = $$PLUGINS_DIR
   dicts.files += ../../../data/dicts/eng-us.xdxf
   dicts.files += ../../../data/dicts/eng-thai.xdxf
+
+  plugin-icon.path = $$DATA_DIR
+  plugin-icon.files += xdxf.png
 }
 
 check.commands = echo 'No check here'
index 302cb0c..626e300 100644 (file)
@@ -323,8 +323,9 @@ DictDialog* XdxfPlugin::dictDialog() {
 
 CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
     XdxfPlugin *plugin = new XdxfPlugin();
-    if(settings && plugin->setSettings(settings))
+    if(settings && plugin->setSettings(settings)) {
         return plugin;
+    }
     else {
         delete plugin;
         return 0;
@@ -452,11 +453,10 @@ bool XdxfPlugin::getDictionaryInfo() {
     if(reader.name()=="description")
         _infoNote=reader.readElementText();
 
-    QString format = "png";
-    QString initialPath = QDir::currentPath() + "/xdxf." + format;
+    QString initialPath = "/usr/share/mdictionary/xdxf.png";
 
-    _infoNote="path=\""+initialPath+"\"> \n" + _name + " [" + _langFrom + "-"
-                + _langTo + "] ( xdxf )";
+    _infoNote=" path=\""+initialPath+"\"> \n" + _name + " [" + _langFrom + "-"
+                + _langTo + "]";
     dictionaryFile.close();
     if(okFormat)
         return true;
@@ -518,9 +518,6 @@ bool XdxfPlugin::makeCache(QString) {
     db_name = _settings->value("type") + cachePathN;
     db = QSqlDatabase::addDatabase("QSQLITE",db_name);
 
-    qDebug()<<QSqlDatabase::connectionNames().size();
-    foreach(QString name,QSqlDatabase::connectionNames())
-        qDebug()<<name;
     /*checke errors (File open and db open)*/
     QFile dictionaryFile(dictFileN.filePath());
     if (!QFile::exists(_settings->value("path"))
index 36492bd..c803afd 100644 (file)
@@ -31,8 +31,8 @@ void GoogleTest::jsonParse() {
     QString test4("");
     QString test5("");
 
-    QCOMPARE(plugin.jsonParse(test1),QString("kot<br/><pos>rzeczownik</pos>:kot, kotka, kociątko, złośliwa kobieta<br/><pos>czasownik</pos>:podnieść"));
-    QCOMPARE(plugin.jsonParse(test2),QString("Go! wyjechać<br/><pos>czasownik</pos>:wyjechać, odchodzić, zgrzeszyć<br/><pos>wykrzyknik</pos>:Odejdź"));
+    QCOMPARE(plugin.jsonParse(test1),QString("kot<br/><pos>rzeczownik</pos>: kot, kotka, kociątko, złośliwa kobieta<br/><pos>czasownik</pos>: podnieść"));
+    QCOMPARE(plugin.jsonParse(test2),QString("Go! wyjechać<br/><pos>czasownik</pos>: wyjechać, odchodzić, zgrzeszyć<br/><pos>wykrzyknik</pos>: Odejdź"));
 }
 
 
@@ -42,7 +42,7 @@ void GoogleTest::getDictionaryInfo() {
     plugin.setLangTo("en");
     plugin.getDictionaryInfo();
 
-    QCOMPARE(plugin.infoNote(),QString(" [Polish-English] (Google)" ));
+    QCOMPARE(plugin.infoNote(),QString(" [Polish-English] " ));
 }
 
 QTEST_MAIN(GoogleTest)
index 7397adc..8cb0a2e 100644 (file)
@@ -26,7 +26,7 @@ void XdxfTest::getNew() {
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
 
@@ -42,7 +42,7 @@ void XdxfTest::searchFile() {
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
 
@@ -60,14 +60,14 @@ void XdxfTest::makeCache()
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     settings->setValue("generateCache", "true");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
-    delete settings;
 
     QCOMPARE(xdxfPlugin->settings()->value("cached"),tr("true"));
 
     xdxfPlugin->clean();
+    delete settings;
     delete xdxfPlugin;
 
 }
@@ -76,7 +76,7 @@ void XdxfTest::searchCache() {
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     settings->setValue("generateCache", "true");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
@@ -95,7 +95,7 @@ void XdxfTest::searchWordListCache(){
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     settings->setValue("generateCache", "true");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
@@ -142,7 +142,7 @@ void XdxfTest::searchWordListFile() {
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
 
@@ -187,7 +187,7 @@ void XdxfTest::stop() {
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
 
@@ -206,7 +206,7 @@ void XdxfTest::langFrom() {
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
 
@@ -220,7 +220,7 @@ void XdxfTest::timeCache() {
     qDebug()<<"\n";
     QTime timer;
     QDate date;
-    QFile File("../tests/time.xml");
+    QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
@@ -275,7 +275,7 @@ void XdxfTest::timeFile() {
     qDebug()<<"\n";
     QTime timer;
     QDate date;
-    QFile File("../tests/time.xml");
+    QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
@@ -325,7 +325,7 @@ void  XdxfTest::timeCacheNormalize() {
     qDebug()<<"\n";
     QTime timer;
     QDate date;
-    QFile File("../tests/time.xml");
+    QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
@@ -398,7 +398,7 @@ void XdxfTest::timeFileNormalize(){
     qDebug()<<"\n";
     QTime timer;
     QDate date;
-    QFile File("../tests/time.xml");
+    QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
index b713dca..e75db70 100644 (file)
@@ -37,7 +37,6 @@
  {
      Q_OBJECT
 
-
  private slots:
      void langFrom();
      void getNew();