Merge branch 'xdxf'
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Thu, 5 Aug 2010 10:15:39 +0000 (12:15 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Thu, 5 Aug 2010 10:15:39 +0000 (12:15 +0200)
Conflicts:
trunk/src/plugins/xdxf/src/XdxfPlugin/xdxfplugin.cpp
trunk/src/plugins/xdxf/src/XdxfPlugin/xdxfplugin.h

1  2 
trunk/src/plugins/xdxf/src/XdxfPlugin/xdxfplugin.cpp
trunk/src/plugins/xdxf/src/XdxfPlugin/xdxfplugin.h

@@@ -2,13 -2,12 +2,14 @@@
  #include <QDebug>
  #include <QFile>
  #include <QXmlStreamReader>
 +#include <QtPlugin>
+ #include "TranslationXdxf.h"
  
  XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
                      _langFrom(tr("")), _langTo(tr("")),_name(tr("")),
                      _type(tr("xdxf")), _infoNote(tr("")) {
      path="dict.xdxf";
 +    stopped = false;
  }
  
  QString XdxfPlugin::langFrom() const {
@@@ -32,12 -31,9 +33,12 @@@ QString XdxfPlugin::infoNote() const 
  }
  
  QList<Translation*> XdxfPlugin::searchWordList(QString word, int limit) {
 +    stopped = false;
      QRegExp regWord(word);
 -    QList<Translation*> translations;
 +    regWord.setCaseSensitivity(Qt::CaseInsensitive);
      regWord.setPatternSyntax(QRegExp::Wildcard);
 +
 +    QList<Translation*> translations;
      QFile dictionaryFile(path);
      if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
          qDebug()<<"Error: could not open file";
          if(dictionaryReader.name()=="ar"){
              while(dictionaryReader.name()!="k" && !dictionaryReader.atEnd())
                  dictionaryReader.readNextStartElement();
 -            a = dictionaryReader.readElementText();
 -            if(regWord.exactMatch(a) && i<limit) {
 +          a = dictionaryReader.readElementText();
 +          if(regWord.exactMatch(a) && i<limit) {
                  translations.append(new TranslationXdxf(a,_infoNote,this));
 -                qDebug()<<a;
                  i++;
                  if(i>=limit)
                      break;
@@@ -81,8 -78,7 +82,8 @@@
  QString XdxfPlugin::search(QString key) {
      QFile dictionaryFile(path);
      if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
 -        return ""; //blad otwarcia pliku
 +        qDebug()<<"Error: could not open file";
 +        return "";
      }
      QXmlStreamReader dictionaryReader(&dictionaryFile);
  
                      match = true;
              }
          }
 -        else if(dictionaryReader.tokenType() == QXmlStreamReader::Characters)
 +        else if(dictionaryReader.tokenType() == QXmlStreamReader::Characters)  {
              if(match) {
 -                dictionaryFile.close();
 -                qDebug()<<dictionaryReader.text().toString().replace("\n","");
 -                return dictionaryReader.text().toString().replace("\n","");
 +              QString temp(dictionaryReader.text().toString().replace("\n",""));
 +              dictionaryFile.close();
 +              return temp;
              }
 +        }
      }
      return "";
  }
@@@ -117,11 -112,10 +118,11 @@@ QDialog* XdxfPlugin::loadDialog() 
  }
  
  QDialog* XdxfPlugin::settingsDialog() {
 -    ;
 +    path="dict.xdxf";
  }
  
  CommonDictInterface* XdxfPlugin::getNew(const Settings*) const {
 +  // CommonDictInterface *commonDictInterface= new
      ;
  }
  
@@@ -129,14 -123,7 +130,14 @@@ bool XdxfPlugin::isAvailable() const 
      return true;
  }
  
 +void XdxfPlugin::setHash(uint _hash)
 +{
 +    this->_hash=_hash;
 +}
 +
  uint XdxfPlugin::hash() const
  {
 -    return 1;
 +   return _hash;
  }
 +
 +Q_EXPORT_PLUGIN2(xdxf, XdxfPlugin)
@@@ -5,9 -5,9 +5,10 @@@
  #include <QObject>
  #include <QDialog>
  #include <QRegExp>
- #include "TranslationXdxf.h"
 +#include <QTime>
  
+ class TranslationXdxf;
  class XdxfPlugin : public CommonDictInterface
  {
      Q_OBJECT
@@@ -49,9 -49,6 +50,9 @@@ public
      //! returns a unique hash for a dictionary
      uint hash() const;
  
 +    //! set unique value (unique for every dictionary not plugin)
 +    void setHash(uint);
 +
  public Q_SLOTS:
      /*! performs search in dictionary
        \param  word word to search in dictionary
@@@ -75,7 -72,6 +76,7 @@@ private
      QDialog *_loadDialog;
      QDialog *_settingsDialog;
      QString path;
 +    uint _hash;
      bool stopped;   /*volatile*/
  };