*******************************************************************************/
-/*! \file BookmarkTranslation.h
-\brief Bookmarks functionality needs its own translation object - because
+/*!
+ \file BookmarkTranslation.h
+ \brief Bookmarks functionality needs its own translation object - because
Translation object should use slightly different api of Bookmarks objects
-\author Bartosz Szatkowski <bulislaw@linux.com>
+ \author Bartosz Szatkowski <bulislaw@linux.com>
*/
#ifndef BOOKMARKTRANSLATIONS_H
#define BOOKMARKTRANSLATIONS_H
}
- /*! sets the word for which we want to find a translation
- \param word for which we want to find a translation */
+ /*!
+ sets the word for which we want to find a translation
+ \param word for which we want to find a translation
+ */
void setKey(QString key) {
_key = key;
}
}
-
bool Bookmarks::checkAndCreateDb(QString dbName) {
QSqlDatabase db = QSqlDatabase::database();
if(dbName.size())
}
-
void Bookmarks::clear() {
checkAndCreateDb();
QSqlDatabase db = getDbCnx();
}
-
void Bookmarks::add(Translation* translation) {
if (!translation)
return ;
cur.exec();
}
+
void Bookmarks::add(QString key,QString removeAccentKey,QString value){
checkAndCreateDb();
QSqlDatabase db = getDbCnx();
}
-
QList<Translation*> Bookmarks::list() {
checkAndCreateDb();
QList<Translation*> res;
}
-
QList<Translation*> Bookmarks::searchWordList(QString word) {
checkAndCreateDb();
if(word.indexOf("*")==-1 && word.indexOf("?")== -1)
}
-
QStringList Bookmarks::search(QString word, QString dbName) {
QStringList result;
QSqlDatabase db = QSqlDatabase::database();
}
-
-
bool Bookmarks::inBookmarks(QString word) {
if(!mdb.isOpen() && !mdb.open()) {
qDebug() << "Database error: " << mdb.lastError().text() << endl;
*******************************************************************************/
-/*! \file Bookmarks.h
-\brief Bookmarks functionality - marking words as favorite, managing marked
+/*!
+ \file Bookmarks.h
+ \brief Bookmarks functionality - marking words as favorite, managing marked
words, searching in marked words (with cached translations)
-
-\author Bartosz Szatkowski <bulislaw@linux.com>
+ \author Bartosz Szatkowski <bulislaw@linux.com>
*/
#ifndef BOOKMARKS_H
class BookmarkTranslation;
-/*! Bookmarks are a way to store words that You think You will need to search
- for often.
+/*!
+ Bookmarks are a way to store words that You think You will need to search
+ for often.
- When You add a bookmark (by clicking on "star" in words list) You add it to
- a special list with cached translations from all available dictionaries so
- You can search for them quickly even when You delete corresponding dict.
- */
+ When You add a bookmark (by clicking on "star" in words list) You add it to
+ a special list with cached translations from all available dictionaries so
+ You can search for them quickly even when You delete corresponding dict.
+*/
class Bookmarks : public AccentsNormalizer {
public:
Bookmarks();
~Bookmarks();
- /*! Adds new word and translation to bookmarks
- \param translation new translation to be saved and cached as a bookmark
+ /*!
+ Adds new word and translation to bookmarks
+ \param translation new translation to be saved and cached as a bookmark
*/
void add(Translation* translation);
void add(QString key,QString removeAccentKey,QString value);
- /*! Removes word and corresponding translation cache from bookmarks list
+ /*!
+ Removes word and corresponding translation cache from bookmarks list
\param translation translation to be removed
*/
void remove(Translation* translation);
- /*! \return all bookmarks (word and translation as a translation object
- as a list)
- */
+ /*!
+ \return all bookmarks (word and translation as a translation object
+ as a list)
+ */
QList<Translation*> list();
- /*! Searches in bookmarks for a given word (wildcards may apply '*' and '?')
- \param word word to search for
- \return list of matching Translation objects
- */
+ /*!
+ Searches in bookmarks for a given word (wildcards may apply '*' and '?')
+ \param word word to search for
+ \return list of matching Translation objects
+ */
QList<Translation*> searchWordList(QString word);
- /*! Searches for final translation of a given word
- \return word translation list in text format xml to be formatted
+ /*!
+ Searches for final translation of a given word
+ \return word translation list in text format xml to be formatted
and displayed
- \param word word to search for
- */
+ \param word word to search for
+ */
QStringList search(QString word, QString dbname);
-
- /*! Clears bookmarks database */
+ /*!
+ Clears bookmarks database
+ */
void clear();
-
- /*! \return true if a given word is already in bookmarks
- \param word word to check
- */
+ /*!
+ \return true if a given word is already in bookmarks
+ \param word word to check
+ */
bool inBookmarks(QString word);
private:
*******************************************************************************/
-/*! \file ConfigGenerator.cpp
-\brief Generating default config files, css stylesheet etc
+/*!
+ \file ConfigGenerator.cpp
+ \brief Generating default config files, css stylesheet etc
-\author Bartosz Szatkowski <bulislaw@linux.com>
+ \author Bartosz Szatkowski <bulislaw@linux.com>
*/
#include "ConfigGenerator.h"
#include <QDebug>
+
bool ConfigGenerator::generateCss(QString file) {
generateFile(":/xsl/style.css", file);
}
-
bool ConfigGenerator::generateDefaultConfig(QString file) {
return generateFile(":/config/mdictionary.config", file);
}
-
bool ConfigGenerator::generateFile(QString source, QString file) {
QFile _file(file);
if(_file.exists())
*******************************************************************************/
-/*! \file ConfigGenerator.h
-\brief Generating default config files, css stylesheet etc
+/*!
+ \file ConfigGenerator.h
+ \brief Generating default config files, css stylesheet etc
-\author Bartosz Szatkowski <bulislaw@linux.com>
+ \author Bartosz Szatkowski <bulislaw@linux.com>
*/
#ifndef CONFIGGENERATOR_H
#include <QString>
#include <QDebug>
-/*! ConfigGenerator generates configuration files (with default values),
-if a given file doesn't exist.
+/*!
+ ConfigGenerator generates configuration files (with default values),
+ if a given file doesn't exist.
*/
class ConfigGenerator {
public:
- /*! Generates default css stylesheet for xslt transformations
+ /*!
+ Generates default css stylesheet for xslt transformations
\param file file to be generated
\return if file was generated - returns true; if file alredy exists
- returns true; if file doesn't exist but cannot be generated returns false
+ returns true; if file doesn't exist but cannot be generated returns false
*/
bool generateCss(QString file);
-
/*! Generates default configuration files
\param file file to be generated
\return if file was generated - returns true; if file already exists
- returns true; if file doesn't exist but cannot be generated returns false
+ returns true; if file doesn't exist but cannot be generated returns false
*/
bool generateDefaultConfig(QString file);
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-//Created by Mateusz Półrola
+/*!
+ \file CompressedReader.cpp
+ \author Mateusz Półrola
+*/
#include "CompressedReader.h"
#include <QtEndian>
QString cha;
gzread(_file, c, 1);
- if(((unsigned char)c[0])>240)
+ if(((unsigned char)c[0])>239)
gzread(_file, c+1, 3);
- else if(((unsigned char)c[0])>224)
+ else if(((unsigned char)c[0])>223)
gzread(_file, c+1, 2);
- else if(((unsigned char)c[0])>192)
+ else if(((unsigned char)c[0])>191)
gzread(_file, c+1, 1);
else if(((unsigned char)c[0])>127){
qDebug()<<"error - starDict - read wordList from UTF-8";
c[0]=0;
}
-
- /* gzread(_file, c, 1);
- if(((unsigned char)c[0])>127){
- gzread(_file, c+1, 1);
- if(((unsigned char)c[1])>127 && ((unsigned char)c[1])<192){
- gzread(_file, c+2, 1);
- if(((unsigned char)c[2])>127 && ((unsigned char)c[2])<192)
- gzread(_file, c+3, 1);
- }
- }
-*/
-
cha=QString::fromUtf8(c);
return cha.at(0);
}
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-//Created by Mateusz Półrola
+/*!
+ \file CompressedReader.cpp
+ \author Mateusz Półrola
+*/
#ifndef COMPRESSEDREADER_H
#define COMPRESSEDREADER_H
Q_OBJECT
public:
CompressedReader(QObject *parent = 0);
- /*!
- Creates new compressed reader and open file with passed filename
- */
+
+ //! Creates new compressed reader and open file with passed filename
CompressedReader(QString filename, QObject *parent = 0);
- /*!
- Destructs object and closing file
- */
+
+ //! Destructs object and closing file
~CompressedReader();
/*!
QString readKeyword();
- /*!
- Closing file;
- */
+ //! Closing file;
void close();
protected:
*/
bool open(QString file);
- /*!
- Reads single char from compressed.
- */
+ //! Reads single char from compressed.
QChar readChar();
private:
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-//Created by Mateusz Półrola
+/*!
+ \file StarDialog.cpp
+ \author Mateusz Półrola <mateusz.polrola@gmail.com>
+*/
#include "StarDialog.h"
#include <QDebug>
#else
if(type==New) {
infoLabel->setMinimumWidth(200);
- setMinimumSize(sizeHint().width()*1.5, sizeHint().height()*1.2);
- setMaximumSize(sizeHint().width()*1.7, sizeHint().height()*1.5);
+// setMinimumSize(sizeHint().width()*1.5, sizeHint().height()*1.2);
+// setMaximumSize(sizeHint().width()*1.7, sizeHint().height()*1.5);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}
#endif
_dictName = _dictionaryFilePath.left(_dictionaryFilePath.lastIndexOf("."));
}
-
if (QFile::exists(_dictName + ".idx") == false
&& QFile::exists(_dictName + ".idx.gz") == false) {
return false;
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
/*!
- \file XdxfDialog.cpp
+ \file StarDialog.h
\author Mateusz Półrola <mateusz.polrola@gmail.com>
*/
void notify(Notify::NotifyType, QString);
public Q_SLOTS:
- //! Reimplemented accept method, to check if all necessary fields in
- //! dialog are correct e. g. dictionary file path
- //! and saves new settings
+ /*!
+ Reimplemented accept method, to check if all necessary fields in
+ dialog are correct e. g. dictionary file path
+ and saves new settings
+ */
void accept();
private Q_SLOTS:
void selectFile();
private:
+ //! create a user interface
void initializeUI();
//! saves new settings after acceptance of dialog
void saveSettings();
+
+ //! check that files is compressed
bool checkFiles();
QLabel* infoLabel;
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-/*! \file XdxfDictDialog.cpp
+/*!
+ \file StarDictDialog.cpp
+ \author Mateusz Półrola
*/
-//Created by Mateusz Półrola
#include "StarDictDialog.h"
#include "StarDictPlugin.h"
Copyright 2010 Comarch S.A.
*******************************************************************************/
-/*! \file XdxfDictDialog.h
+/*!
+ \file StarDictDialog.h
+ \author Mateusz Półrola
*/
-//Created by Mateusz Półrola
#ifndef STARDICTDIALOG_H
#define STARDICTDIALOG_H
*/
void changeSettings(QWidget *parent);
+ //! return a pointer to parent Dialog
QWidget* lastDialogParent();
+ //! set a pointer to parent Dialog
void setLastDialogParent(QWidget*);
private:
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-/*! \file stardictplugin.cpp
+/*!
+ \file StarDictPlugin.cpp
+ \author Jakub Jaszczynski
*/
#include "StarDictPlugin.h"
QString idxPath = settings()->value("idxFileName");
StarDictReader * reader = StarDictReaderFactory::createReader(idxPath);
QString fkey;
- qint64 offset = 0, len = 0;
- QRegExp keyword(word, Qt::CaseInsensitive, QRegExp::Wildcard);
+ qint64 offset = 0,
+ len = 0;
if( word.indexOf("*")==-1 && word.indexOf("?")==-1 &&
word.indexOf("_")==-1 && word.indexOf("%")==-1)
word+="*";
+ QRegExp keyword(word, Qt::CaseInsensitive, QRegExp::Wildcard);
if((settings()->value("idxoffsetbits") == "32") ||
(settings()->value("idxoffsetbits") == ""))
if(keyword.exactMatch(fkey)) {
TranslationStarDict tran(fkey, infoNote(), this);
- qDebug() << "off/len" << offset << len;
+ // qDebug() << "off/len" << offset << len;
int id = translations.indexOf(tran);
if(id == -1) {
tran.add(offset, len);
result+="</t>";
}
-// Dont know whether mDictionary would ever handle binary stardict format
+// W & P Dont know whether mDictionary would ever handle binary stardict format
// to be honest dont see any kind of adventages (can't find any binary dict)
/*
}
return &_icon;
}
-
-int StarDictPlugin::countWords() {
- return 0;
-}
-
-
-void StarDictPlugin::clean() {
-
-}
-
-
Q_EXPORT_PLUGIN2(stardict, StarDictPlugin)
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-
-/*! \file xdxfplugin.h
+/*!
+ \file StarDictPlugin.h
+ \author Jakub Jaszczynski
*/
+
#ifndef STARDICTPLUGIN_H
#define STARDICTPLUGIN_H
//! \returns current plugin settings
Settings* settings();
- //! \returns words count in a dictionary
- long wordsCount();
-
//! Sets new settings
bool setSettings(const Settings*);
plugin should delete any files (eg. cache) that have been created and are ready
to be deleted
*/
- void clean();
+ void clean() {;}
//! scans dictionary file to get information about it
bool getDictionaryInfo();
- //! counts the keys in a starDict file
- int countWords();
-
-
- //! language from which we translate
- QString _langFrom;
- //! language to which we translate
- QString _langTo;
- //! name of a dictionary
- QString _name;
- //! information about dictionary
- QString _infoNote;
-
- //! icon displayed during translations and when a dictionary is chosen
- QIcon _icon;
-
- //! indicates if search is stopped
- volatile bool stopped;
- Settings *_settings;
- StarDictDialog* _dictDialog;
- Settings* _ifoFileSettings;
-
/*!
Reads and process (converting to qstring) data from StarDict dictionary
file (*.dict[.dz])
QString interpret(QByteArray::iterator it, QByteArray::iterator end,
QChar mode,QString key, bool last = false);
+ QString _langFrom;
+ QString _langTo;
+ QString _name;
+ QString _infoNote;
+ QIcon _icon;
+ volatile bool stopped;
+ Settings *_settings;
+ StarDictDialog* _dictDialog;
+ Settings* _ifoFileSettings;
+
friend class StarDictTests;
};
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
/*!
+ \file StarDictReader.h
\author Mateusz Półrola <mateusz.polrola@comarch.pl>
*/
*/
virtual qint64 readInt64BigEndian()=0;
- /*!
- Reads single string from file, end of string is marked as '\0' in file.
- */
+ //! Reads single string from file, end of string is marked as '\0' in file.
virtual QString readKeyword()=0;
- /*!
- Closing file;
- */
+ //! Closing file;
virtual void close()=0;
protected:
*/
virtual bool open(QString file)=0;
- /*!
- Reads single char from file.
- */
+ //! Reads single char from file.
virtual QChar readChar()=0;
};
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-//Created by Mateusz Półrola
+/*!
+ \file StarDictReaderFactory.cpp
+ \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+ */
#include "StarDictReaderFactory.h"
#include "CompressedReader.h"
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-//Created by Mateusz Półrola
+/*!
+ \file StarDictReaderFactory.h
+ \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+ */
#ifndef STARDICTREADERFACTORY_H
#define STARDICTREADERFACTORY_H
Copyright 2010 Comarch S.A.
*******************************************************************************/
-/*! \file TranslationStarDict.cpp
+/*!
+ \file TranslationStarDict.cpp
\author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
*/
Copyright 2010 Comarch S.A.
*******************************************************************************/
-/*! \file TranslationXdxf.h
-*/
+/*!
+ \file TranslationStarDict.h
+ \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+ */
+
#ifndef TRANSLATIONSTARDICT_H
#define TRANSLATIONSTARDICT_H
*/
void add(qint64 offset, qint32 len);
-
-
bool operator==(const TranslationStarDict &key) {
if (this->key() == key.key())
return true;
+/*******************************************************************************
+
+ 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 UncompressedReader.cpp
+ \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+ */
+
#include "UncompressedReader.h"
#include "QDebug"
QString cha;
_stream.readRawData(c,1);
- if(((unsigned char)c[0])>240)
+ if(((unsigned char)c[0])>239)
_stream.readRawData(c+1,3);
- else if(((unsigned char)c[0])>224)
+ else if(((unsigned char)c[0])>223)
_stream.readRawData(c+1,2);
- else if(((unsigned char)c[0])>192)
+ else if(((unsigned char)c[0])>191)
_stream.readRawData(c+1,1);
else if(((unsigned char)c[0])>127)
qDebug()<<"error - starDict - read wordList from UTF-8";
-
- /* if(((unsigned char)c[0])>127){
- _stream.readRawData(c+1,1);
- if(((unsigned char)c[1])>127 && ((unsigned char)c[1])<192){
- _stream.readRawData(c+2,1);
- if(((unsigned char)c[2])>127 && ((unsigned char)c[2])<192)
- _stream.readRawData(c+3,1);
- }
- }
- */
cha=QString::fromUtf8(c);
return cha.at(0);
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-//Created by Mateusz Półrola
+/*!
+ \file UncompressedReader.h
+ \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+ */
#ifndef UNCOMPRESSEDREADER_H
#define UNCOMPRESSEDREADER_H
/*!
- Class implementing StarDictReader interface and handling rading from uncompressed files
+ Class implementing StarDictReader interface and handling
+ rading from uncompressed files
*/
class UncompressedReader : public StarDictReader
{
public:
UncompressedReader(QObject *parent = 0);
- /*!
- Creates new reader and open file with passed filename
- */
+ //! Creates new reader and open file with passed filename
UncompressedReader(QString filename, QObject *parent = 0);
- /*!
- Destructs object and closing file
- */
+ //! Destructs object and closing file
~UncompressedReader();
/*!
*/
QString readKeyword();
-
- /*!
- Closing file;
- */
+ //! Closing file;
void close();
protected:
*/
bool open(QString file);
- /*!
- Reads single char from compressed.
- */
+ //! Reads single char from compressed.
QChar readChar();
private:
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
/*!
- \file DictsModel.cpp
- \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+ \file DictsModel.cpp
+ \author Mateusz Półrola <mateusz.polrola@comarch.pl>
*/
#include "DictsModel.h"
-
DictsModel::DictsModel(QList<DownloadDict> dicts, QObject *parent) :
- QAbstractItemModel(parent)
-{
+ QAbstractItemModel(parent) {
this->dicts = dicts;
-
qSort(this->dicts);
}
return dicts.count();
}
+
int DictsModel::columnCount(const QModelIndex &) const {
return 4;
}
-QVariant DictsModel::data(const QModelIndex &index, int role) const
-{
+
+QVariant DictsModel::data(const QModelIndex &index, int role) const {
if (!index.isValid())
return QVariant();
return QVariant();
}
+
QVariant DictsModel::headerData(int section, Qt::Orientation orientation,
- int role) const
-{
+ int role) const {
if (role != Qt::DisplayRole)
return QVariant();
return QVariant();
}
+
QModelIndex DictsModel::index(int row, int column, const QModelIndex &) const {
return createIndex(row, column, row);
}
+
QModelIndex DictsModel::parent(const QModelIndex &) const {
return QModelIndex();
}
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
/*!
- \file DictsModel.h
- \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+ \file DictsModel.h
+ \author Mateusz Półrola <mateusz.polrola@comarch.pl>
*/
#ifndef DICTSMODEL_H
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
/*!
- \file HttpDownloader.h
- \author Bartosz Szatkowski <bulislaw@linux.com>
+ \file HttpDownloader.h
+ \author Bartosz Szatkowski <bulislaw@linux.com>
*/
-
#include "HttpDownloader.h"
HttpDownloader::HttpDownloader(QObject *parent) {
request.setRawHeader("User-Agent", "Wget/1.12 (linux-gnu)");
currentReply = manager->get(request);
connect(currentReply, SIGNAL(downloadProgress(qint64,qint64)),
- this, SIGNAL(progress(qint64,qint64)));
-
+ this, SIGNAL(progress(qint64,qint64)));
}
-void HttpDownloader::downloadFinished(QNetworkReply *reply) {
+void HttpDownloader::downloadFinished(QNetworkReply *reply) {
disconnect(reply, SIGNAL(downloadProgress(qint64,qint64)),
this, SIGNAL(progress(qint64,qint64)));
if(reply->error() != QNetworkReply::NoError) {
req.setUrl(r);
currentReply = manager->get(req);
connect(currentReply, SIGNAL(downloadProgress(qint64,qint64)),
- this, SIGNAL(progress(qint64,qint64)));
+ this, SIGNAL(progress(qint64,qint64)));
}
else {
QFile resultFile(destFile);
Copyright 2010 Comarch S.A.
*******************************************************************************/
-/*! \file TranslationXdxf.cpp
+/*!
+ \file TranslationXdxf.cpp
\author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
*/
-
#include "TranslationXdxf.h"
#include <QDebug>
xdxfPlugin=0;
}
+
TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo,
XdxfPlugin *xdxfPlugin): _key(_key),_dictionaryInfo(_dictionaryInfo) {
this->xdxfPlugin=xdxfPlugin;
return _key;
}
+
QString TranslationXdxf::toXml() const {
QString result("");
if(!xdxfPlugin)
return result.replace("&","&");
}
+
void TranslationXdxf::setKey(QString _key) {
this->_key=_key;
}
+
void TranslationXdxf::setDictionaryInfo(QString _dictionaryInfo) {
this->_dictionaryInfo=_dictionaryInfo;
}
-
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-/*! \file XdxfCachingDialog.cpp
+/*!
+ \file XdxfCachingDialog.cpp
+ \author Mateusz Półrola
*/
-//Created by Mateusz Półrola
#include "XdxfCachingDialog.h"
#include "xdxfplugin.h"
cachingProgressBar->setTextVisible(true);
cancelButton = new QPushButton(tr("Cancel"),this);
-
-
cachingTimeLabel = new QLabel(this);
cachingTimeLabel->hide();
verticalLayout->addWidget(cachingLabel, 0, Qt::AlignCenter);
#endif
-
verticalLayout->addWidget(cachingTimeLabel);
verticalLayout->addWidget(cachingProgressBar);
verticalLayout->addWidget(cancelButton);
this, SIGNAL(cancelCaching()));
time.start();
-
setModal(true);
}
return;
}
+
void XdxfCachingDialog::updateCachingProgress(int progress, int time) {
cachingProgressBar->setValue(progress);
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-//Created by Mateusz Półrola
+/*!
+ \file XdxfDialog.cpp
+ \author Mateusz Półrola <mateusz.polrola@gmail.com>
+*/
#include "XdxfDialog.h"
#include <QDebug>
XdxfDialog::XdxfDialog(XdxfPlugin *plugin,
XdxfDialogType type,
QWidget *parent) :
- QDialog(parent) {
+ QDialog(parent) {
this->plugin = plugin;
this->type = type;
-
cacheToolTip = tr("Optimize for quicker searches (may take some time)");
accentsToolTip = tr("Strip accents (searching takes more time, but spelling doesn't have to be exact)");
connect(cacheCheckBox, SIGNAL(toggled(bool)),
this, SLOT(setGenerateCache(bool)));
-
connect(accentsCheckBox, SIGNAL(toggled(bool)),
this, SLOT(setAccents(bool)));
#ifdef Q_WS_MAEMO_5
connect(accentsInfoToolButton, SIGNAL(clicked()),
this, SLOT(showAccentsInfo()));
-
connect(cacheInfoToolButton, SIGNAL(clicked()),
this, SLOT(showCacheInfo()));
#endif
if(type == New) {
connect(browseButton, SIGNAL(clicked()),
this, SLOT(selectFile()));
-
connect(downloadButton, SIGNAL(clicked()),
this, SLOT(downloadFile()));
-
connect(&XdxfPlugin::dictDownloader, SIGNAL(fileDownloaded(QString)),
this, SLOT(fileDownloaded(QString)));
}
connect(confirmButton, SIGNAL(clicked()),
this, SLOT(accept()));
-
}
+
void XdxfDialog::fileDownloaded(QString name) {
infoLabel->setText(tr("Dictionary file: %1").arg(XdxfPlugin::dictDownloader.downloadedFile()));
_dictionaryFilePath = XdxfPlugin::dictDownloader.downloadedFile();
mainVerticalLayout->addLayout(cacheLayout);
mainVerticalLayout->addLayout(accentsLayout);
-
//load old setting if exists
if(!plugin) {
cacheCheckBox->setChecked(true);
confirmButton = new QPushButton;
mainVerticalLayout->addWidget(confirmButton);
- if(type == New) {
+ if(type == New)
confirmButton->setText(tr("Add"));
- }
- else {
+ else
confirmButton->setText(tr("Save settings"));
- }
scrollArea = new QScrollArea;
scrollArea->setWidget(widget);
scrollArea->setWidgetResizable(true);
+
#ifdef Q_WS_MAEMO_5
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
#else
scrollArea->setLineWidth(0);
scrollArea->setMidLineWidth(0);
scrollArea->setFrameStyle(QFrame::NoFrame);
-
-
}
_accents = accents;
}
+
void XdxfDialog::setGenerateCache(bool generate) {
_generateCache = generate;
}
else
accentsCheckBox->setChecked(_lastAccents);
-
accentsCheckBox->setEnabled(!generate);
}
+
void XdxfDialog::selectFile() {
QString fileName = QFileDialog::getOpenFileName(this,
tr("Select dictionary file"),
tr("XDXF Files (*.xdxf)"),
NULL,
NULL);
-
if (!fileName.isEmpty()) {
infoLabel->setText(tr("Dictionary file: %1").arg(fileName));
_dictionaryFilePath = fileName;
}
}
+
void XdxfDialog::downloadFile() {
XdxfPlugin::dictDownloader.download(this);
}
+
void XdxfDialog::saveSettings() {
_settings = new Settings;
if(plugin) {
foreach(QString key, plugin->settings()->keys())
_settings->setValue(key, plugin->settings()->value(key));
}
- else {
+ else
_settings->setValue("path", _dictionaryFilePath);
- }
if(_generateCache)
_settings->setValue("generateCache", "true");
_settings->setValue("strip_accents", "false");
}
+
void XdxfDialog::accept() {
if(type == New && _dictionaryFilePath.isEmpty()) {
Q_EMIT notify(Notify::Warning, tr("File path is not set"));
-
return;
}
QDialog::accept();
}
+
Settings* XdxfDialog::getSettings() {
return _settings;
}
+
#ifdef Q_WS_MAEMO_5
void XdxfDialog::showCacheInfo() {
Q_EMIT notify(Notify::Warning, cacheToolTip);
}
+
void XdxfDialog::showAccentsInfo() {
Q_EMIT notify(Notify::Warning, accentsToolTip);
}
*******************************************************************************/
/*!
- \file XdxfDialog.cpp
+ \file XdxfDialog.h
\author Mateusz Półrola <mateusz.polrola@gmail.com>
*/
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-/*! \file XdxfDictDialog.cpp
- \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+/*!
+ \file XdxfDictDialog.cpp
+ \author Mateusz Półrola <mateusz.polrola@comarch.pl>
*/
-
#include "XdxfDictDialog.h"
#include "xdxfplugin.h"
#include "XdxfDialog.h"
_lastDialogParent=0;
}
+
QWidget* XdxfDictDialog::lastDialogParent() {
return _lastDialogParent;
}
+
void XdxfDictDialog::setLastDialogParent(QWidget *w) {
_lastDialogParent = w;
}
+
Settings* XdxfDictDialog::addNewDictionary(QWidget *parent) {
XdxfDialog d(0, XdxfDialog::New, parent);
Copyright 2010 Comarch S.A.
*******************************************************************************/
-/*! \file XdxfDictDialog.h
+/*!
+ \file XdxfDictDialog.h
+ \author Mateusz Półrola <mateusz.polrola@comarch.pl>
*/
-
#ifndef XDXFDICTDIALOG_H
#define XDXFDICTDIALOG_H
class XdxfPlugin;
-
//! Implementation of DictDialog interface for xdxf plugin
class XdxfDictDialog : public DictDialog {
Q_OBJECT
public:
explicit XdxfDictDialog(XdxfPlugin* plugin, QObject *parent = 0);
/*!
- Shows "add new xdxf dictionary" dialog and returns settings of a new dict
- \param parent parent widget on which dialog will be displayed
+ Shows "add new xdxf dictionary" dialog and returns settings of a new dict
+ \param parent parent widget on which dialog will be displayed
*/
Settings* addNewDictionary(QWidget *parent);
/*!
- Shows settings dialog and saves new settings in plugin
- \param parent parent widget on which dialog will be displayed
- */
+ Shows settings dialog and saves new settings in plugin
+ \param parent parent widget on which dialog will be displayed
+ */
void changeSettings(QWidget *parent);
- /*!
- Returns last parent of this dialog
- */
+ //! Returns last parent of this dialog
QWidget* lastDialogParent();
- /*!
- Sets last parent of this dialog
- */
+ //! Sets last parent of this dialog
void setLastDialogParent(QWidget*);
private:
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
/*!
- \file XdxfDictDownloadProgressDialog.cpp
- \author Mateusz Półrola <mateusz.polrola@comarch.com>
- */
+ \file XdxfDictDownloadProgressDialog.cpp
+ \author Mateusz Półrola <mateusz.polrola@comarch.com>
+*/
#include "XdxfDictDownloadProgressDialog.h"
connect(cancelButton, SIGNAL(clicked()),
this, SIGNAL(cancelDownloading()));
-
#ifndef Q_WS_MAEMO_5
downloadLabel = new QLabel(this);
verticalLayout->addWidget(downloadLabel, 0, Qt::AlignCenter);
verticalLayout->addWidget(downloadProgressBar);
verticalLayout->addWidget(cancelButton);
-
setModal(true);
#ifndef Q_WS_MAEMO_5
#endif
}
+
void XdxfDictDownloadProgressDialog::show() {
downloadProgressBar->setMaximum(0);
QDialog::show();
}
+
void XdxfDictDownloadProgressDialog::setText(QString text) {
setWindowTitle(text);
#ifndef Q_WS_MAEMO_5
#endif
}
+
void XdxfDictDownloadProgressDialog::updateProgress(float progress) {
if(downloadProgressBar->maximum() == 0) {
downloadProgressBar->setMaximum(100);
downloadProgressBar->setValue(progress*100);
}
+
void XdxfDictDownloadProgressDialog::reject() {
#ifndef Q_WS_MAEMO_5
Q_EMIT cancelDownloading();
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
/*!
- \file XdxfDictDownloadProgressDialog.h
- \author Mateusz Półrola <mateusz.polrola@comarch.com>
- */
+ \file XdxfDictDownloadProgressDialog.h
+ \author Mateusz Półrola <mateusz.polrola@comarch.com>
+*/
#ifndef XDXFDICTDOWNLOADPROGRESSDIALOG_H
#define XDXFDICTDOWNLOADPROGRESSDIALOG_H
#include <QtGui>
/*!
- Shows downloading progress bar. Currently it displays "busy bar".
- User can cancel current download by pressing cancel button
- */
+ Shows downloading progress bar. Currently it displays "busy bar".
+ User can cancel current download by pressing cancel button
+*/
class XdxfDictDownloadProgressDialog : public QDialog {
Q_OBJECT
public:
//! Set text which will be displayed to user as info about current download
void setText(QString);
+ /*!
+ set parameters of prograsBar(wher "prograss"*100 is value,
+ and maxValue=100
+ */
void updateProgress(float progress);
void show();
//! signal emitted when user cancels downloading of a dictionary
void cancelDownloading();
-
private:
QLabel* downloadLabel;
QProgressBar* downloadProgressBar;
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
/*!
- \file XdxfDictDownloader.cpp
- \author Mateusz Półrola <mateusz.polrola@comarch.com>
- */
+ \file XdxfDictDownloader.cpp
+ \author Mateusz Półrola <mateusz.polrola@comarch.com>
+*/
#include "XdxfDictDownloader.h"
#include "XdxfDictDownloadProgressDialog.h"
#include <QDebug>
#include <QProcess>
-
-
#include <bzlib.h>
#include <libtar.h>
#include <stdio.h>
typedef void BZFILE;
-
-
XdxfDictDownloader::XdxfDictDownloader(QObject *parent) :
QObject(parent) {
parentDialog = 0;
+ progressDialog = 0;
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(dictListReceived(QNetworkReply*)));
-
-
- progressDialog = 0;
- connect(&http, SIGNAL(finished()), this, SLOT(processFinished()));
+ connect(&http, SIGNAL(finished()),
+ this, SLOT(processFinished()));
connect(&http, SIGNAL(error(QString)),
this, SLOT(downloadingError(QString)));
connect(&http, SIGNAL(progress(qint64,qint64)),
this, SLOT(updateDownloadProgress(qint64,qint64)));
-
}
+
void XdxfDictDownloader::download(QWidget *parent) {
parentDialog = parent;
aborted = false;
progressDialog->show();
}
+
QString XdxfDictDownloader::downloadedFile() {
return _downloadedFile;
}
+
void XdxfDictDownloader::updateDownloadProgress(qint64 downloaded,
qint64 total) {
Q_EMIT downloadProgress(float(downloaded) / float(total));
}
+
void XdxfDictDownloader::downloadingError(QString error) {
breakDownloading();
Q_EMIT notify(Notify::Error, error);
}
+
void XdxfDictDownloader::breakDownloading() {
//if user cancel downloading we kill all running processes, hide progress dialog and set flag that user cancel downloading.
aborted = true;
if(progressDialog && progressDialog->isVisible()) {
progressDialog->accept();
}
-
}
+
void XdxfDictDownloader::processFinished() {
//first check if user cancel downloading
if(aborted) return;
downloadComplete();
}
+
void XdxfDictDownloader::downloadComplete() {
if(aborted) return;
// Downloaded tar file name is different than extracted folder so we need
emit fileDownloaded(_downloadedFile);
}
+
void XdxfDictDownloader::dictListReceived(QNetworkReply *reply) {
progressDialog->accept();
- if(aborted) return;
-
-
+ if(aborted)
+ return;
if(reply->error() != QNetworkReply::NoError) {
Q_EMIT notify(Notify::Error, reply->errorString());
return;
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
/*!
- \file XdxfDictDownloader.h
- \author Mateusz Półrola <mateusz.polrola@comarch.pl>
- */
+ \file XdxfDictDownloader.h
+ \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+*/
#ifndef XDXFDICTDOWNLOADER_H
#define XDXFDICTDOWNLOADER_H
#include <string.h>
#include <errno.h>
-/** XdxfDictDownloader is responsible for getting dict list from XDXF website
+/*!
+ XdxfDictDownloader is responsible for getting dict list from XDXF website
and other actions necessary to download and add dictionary
When user want to add dictionary he may choose "browse" or "download",
Q_OBJECT
public:
XdxfDictDownloader(QObject *parent = 0);
+
//! \return name of downloaded file
QString downloadedFile();
Q_SIGNALS:
//! emmited when file download precess is complete
void fileDownloaded(QString);
+
//! emitted to inform user about errors and warnings
void notify(Notify::NotifyType, QString);
+ //! emmited what is update Download Progress
void downloadProgress(float);
private Q_SLOTS:
//! user cancel downloading
void breakDownloading();
+ //! handling a download error
void downloadingError(QString);
+ /*!
+ function divide two qint64 and result emmit in
+ signals downloadProgress(float)
+ */
void updateDownloadProgress(qint64, qint64);
private:
//! dict is downloaded and unpacked
void downloadComplete();
+
QList<DownloadDict> dicts;
QWidget* parentDialog;
QString _downloadedFile;
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
/*!
- \file XdxfDictSelectDialog.cpp
- \author Mateusz Półrola <mateusz.polrola@comarch.com>
- */
+ \file XdxfDictSelectDialog.cpp
+ \author Mateusz Półrola <mateusz.polrola@comarch.com>
+*/
#include "XdxfDictSelectDialog.h"
XdxfDictSelectDialog::XdxfDictSelectDialog(QList<DownloadDict> dicts,
QWidget *parent) :
- QDialog(parent) {
-
-
+ QDialog(parent) {
setWindowTitle(tr("Select dictionary"));
layout = new QVBoxLayout;
proxyModel->setDynamicSortFilter(true);
proxyModel->setSourceModel(model);
-
treeView = new QTreeView;
treeView->setModel(proxyModel);
treeView->setRootIsDecorated(false);
treeView->setColumnWidth(3, 150);
#endif
-
layout->addWidget(treeView);
-
connect(langFrom, SIGNAL(currentIndexChanged(int)),
this, SLOT(refreshDictList()));
void XdxfDictSelectDialog::initializeDicts() {
-
//scan of all languages of dictionaries, using QSet to get only distinct languages
QSet<QString> languagesFrom;
QSet<QString> languagesTo;
}
}
+
void XdxfDictSelectDialog::refreshDictList() {
//if selected language is "Any"(index 0), from filter string is set to empty string, proxy model uses empty string as special case and don't filter by this field.
if(langTo->currentIndex() == 0)
proxyModel->setFrom(langFrom->currentText());
}
+
void XdxfDictSelectDialog::itemClicked(QModelIndex index) {
_link = index.model()->data(index, Qt::UserRole).toString();
accept();
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
/*!
- \file XdxfDictSelectDialog.h
- \author Mateusz Półrola <mateusz.polrola@comarch.com>
- */
+ \file XdxfDictSelectDialog.h
+ \author Mateusz Półrola <mateusz.polrola@comarch.com>
+ */
#ifndef XDXFDICTSELECTDIALOG_H
#define XDXFDICTSELECTDIALOG_H
/*!
- Shows dialog with list of dictionaries and informations about them, allowing user to filter data based on dictionaries languages, and to select one of them.
- */
+ Shows dialog with list of dictionaries and informations about them,
+ allowing user to filter data based on dictionaries languages,
+ and to select one of them.
+*/
class XdxfDictSelectDialog : public QDialog {
Q_OBJECT
public:
/*!
- Constructor
- \param dicts list of DownloadDict objects describing dictionaries.
- */
+ Constructor
+ \param dicts list of DownloadDict objects describing dictionaries.
+ */
XdxfDictSelectDialog(QList<DownloadDict> dicts,
QWidget *parent = 0);
/*!
- Returns download link of dictionary selected by user. This string is set
- only when user select any dictionary (dialog was accepted), otherwise it
- is empty.
- */
+ Returns download link of dictionary selected by user. This string is set
+ only when user select any dictionary (dialog was accepted), otherwise it
+ is empty.
+ */
QString link() { return _link;}
+private Q_SLOTS:
+ //! creates items for comboboxes and creates model with dicts info
+ void initializeDicts();
+
+ //! filters dicts after filtering settings change
+ void refreshDictList();
+
+ //! accept dialog and sets download link of clicked dictionary
+ void itemClicked(QModelIndex);
+
private:
QTreeView* treeView;
DictsModel* model;
- //used by treeView to allow filtering and sorting
- DictsProxyModel *proxyModel;
+ DictsProxyModel *proxyModel; //used by treeView to allow filtering and sorti
QVBoxLayout* layout;
QHBoxLayout* checkBoxLayout;
QComboBox* langFrom;
QComboBox* langTo;
QLabel* langFromLabel;
QLabel* langToLabel;
-
-private Q_SLOTS:
- //creates items for comboboxes and creates model with dicts info
- void initializeDicts();
-
- //filters dicts after filtering settings change
- void refreshDictList();
-
- //accept dialog and sets download link of clicked dictionary
- void itemClicked(QModelIndex);
-
-private:
QList<DownloadDict>* dictList;
QString _link;
};
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-/*! \file xdxfplugin.cpp
-\author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
+/*!
+ \file xdxfplugin.cpp
+ \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
*/
#include "xdxfplugin.h"
XdxfDictDownloader XdxfPlugin::dictDownloader;
+
bool XdxfPlugin::dictDownloaderInitialized = false;
XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
_langFrom(""), _langTo(""),_name(""), _infoNote("") {
-
- //DownloadDict a("<tr><td><img src=\"buf/comn_sdict05_bulg_comp/icon16.png\" alt=\"icon\" /></td><td align=\"center\">English-Bulgarian computer dictionary</td><td align=\"center\"><a href=\"http://downloads.sourceforge.net/xdxf/comn_sdict05_bulg_comp.tar.bz2\" target=\"_blank\">comn_sdict05_bulg_comp.tar.bz2</a></td><td align=\"right\">13,889</td><td align=\"right\">55,094</td><td align=\"right\">523</td><td align=\"center\">English</td><td align=\"center\">Bulgarian</td><td align=\"center\"><a href=\"http://xdxf.revdanica.com/\">Common XDXF</a></td><td align=\"center\">2006-04-23 23:34:40</td></tr>");
- //dictDownloader.download(0);
-
-
_settings = new Settings();
_dictDialog = new XdxfDictDialog(this, this);
connect(_dictDialog, SIGNAL(notify(Notify::NotifyType,QString)),
this, SIGNAL(notify(Notify::NotifyType,QString)));
-
if(!dictDownloaderInitialized) {
connect(&dictDownloader, SIGNAL(notify(Notify::NotifyType,QString)),
this, SIGNAL(notify(Notify::NotifyType,QString)));
dictDownloaderInitialized = true;
}
-
_settings->setValue("type","xdxf");
_icon = QIcon("/usr/share/mdictionary/xdxf.png");
_wordsCount = -1;
initAccents();
}
+
void XdxfPlugin::retranslate() {
QString locale = QLocale::system().name();
-
QTranslator *translator = new QTranslator(this);
if(!translator->load(":/xdxf/translations/" + locale)) {
if((regWord.exactMatch(readKey)
|| regWord.exactMatch(removeAccents(readKey)))
&& (i<limit || limit==0) && !reader.atEnd()) {
- // qDebug()<<readKey;
translations<<(new TranslationXdxf(readKey.toLower(),
_dictionaryInfo,this));
if(translations.size()==limit && limit!=0)
cur.exec();
while(cur.next())
result += cur.value(0).toString();
-
db.close();
return result;
-
}
void XdxfPlugin::stop() {
- //qDebug()<<"stop";
stopped=true;
}
((XdxfDictDialog*)plugin->dictDialog())->setLastDialogParent(_dictDialog->lastDialogParent());
-
-
if(settings && plugin->setSettings(settings)) {
-
disconnect(plugin, SIGNAL(notify(Notify::NotifyType,QString)),
this, SIGNAL(notify(Notify::NotifyType,QString)));
return plugin;
foreach(QString key, _settings->keys())
oldSettings->setValue(key, _settings->value(key));
- foreach(QString key, settings->keys()) {
+ foreach(QString key, settings->keys())
if(key != "generateCache")
_settings->setValue(key, settings->value(key));
- }
if(!getDictionaryInfo()) {
Q_EMIT notify(Notify::Warning,
}
dictionaryFile.seek(0);
-
long wordsCount = 0;
QString line;
bool XdxfPlugin::makeCache(QString) {
-
XdxfCachingDialog d(_dictDialog->lastDialogParent());
-// qDebug()<<_dictDialog->lastDialogParent();
-
connect(&d, SIGNAL(cancelCaching()),
this, SLOT(stop()));
connect(this, SIGNAL(updateCachingProgress(int,int)),
&d, SLOT(updateCachingProgress(int,int)));
d.show();
-
QCoreApplication::processEvents();
QFileInfo dictFileN(_settings->value("path"));
QString cachePathN;
/*add all words to db*/
while (!reader.atEnd() && !stopped) {
-
QCoreApplication::processEvents();
reader.readNext();
if(reader.tokenType() == QXmlStreamReader::StartElement) {
return true;
}
+
void XdxfPlugin::clean() {
if(QFile::exists(_settings->value("cache_path"))) {
QFile(_settings->value("cache_path")).remove();
Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-
-/*! \file xdxfplugin.h
+/*!
+ \file xdxfplugin.h
+ \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
*/
+
#ifndef XDXFPLUGIN_H
#define XDXFPLUGIN_H
-
#include <QObject>
#include <QDialog>
#include <QRegExp>
Q_INTERFACES(CommonDictInterface)
public:
XdxfPlugin(QObject *parent=0);
-
~XdxfPlugin();
//! \returns source language code iso 639-2
//! \returns dictionary type (xdxf, google translate, etc)
QString type() const;
- //! returns information about dictionary in xml (name, authors, etc)
+ //! \returns information about dictionary in xml (name, authors, etc)
QString infoNote() const;
- /*! \returns DictDialog object that creates dialogs
+ /*!
+ \returns DictDialog object that creates dialogs
for adding a new dictionary and changing plugin settings
- */
+ */
DictDialog* dictDialog();
//! \returns new, clean copy of plugin with settings set as in Settings*
//! \returns plugin icon
QIcon* icon();
- /*! plugin should delete any files (eg. cache) that have been created and are ready
+ /*!
+ plugin should delete any files (eg. cache) that have been created and are ready
to be deleted
- */
+ */
void clean();
static XdxfDictDownloader dictDownloader;
public Q_SLOTS:
- /*! performs search in a dictionary
- \param word word to search for in a dictionary
- \param limit limit on number of results
+ /*!
+ performs search in a dictionary
+ \param word word to search for in a dictionary
+ \param limit limit on number of results
- After finishing search it has to emit
- \see CommonDictInterface:finalTranslation finalTranslation
+ After finishing search it has to emit
+ \see CommonDictInterface:finalTranslation finalTranslation
*/
QList<Translation*> searchWordList(QString word, int limit=0);
//! last signal emit
void updateCachingProgress(int, int);
-
private:
-
- static bool dictDownloaderInitialized;
-
-
- /*! \returns true or false depending on whether the dictionary is cached
+ /*!
+ \returns true or false depending on whether the dictionary is cached
or not
- */
+ */
bool isCached();
- /*! searches for a list of words similar to a word in a database file
- \param word key compared with keys in a database
- \param limit limits the number of translations in returned list,
- 0 means unlimited
- \returns list of translations
+ /*!
+ searches for a list of words similar to a word in a database file
+ \param word key compared with keys in a database
+ \param limit limits the number of translations in returned list,
+ 0 means unlimited
+ \returns list of translations
*/
QList<Translation*> searchWordListCache(QString word, int limit=0);
- /*! searches for a list of words similar to a word in a xdxf file
- \param word key compared with keys in a xdxf file
- \param limit limits the number of translations in returned list,
- 0 means unlimited
- \returns list of translations
+ /*!
+ searches for a list of words similar to a word in a xdxf file
+ \param word key compared with keys in a xdxf file
+ \param limit limits the number of translations in returned list,
+ 0 means unlimited
+ \returns list of translations
*/
QList<Translation*> searchWordListFile(QString word, int limit=0);
- /*! searches for a translation of a word which is exactly like a key
- in a xdxf file */
+ /*!
+ searches for a translation of a word which is exactly like a key
+ in a xdxf file
+ */
QString searchFile(QString key);
- /*! searches for a translation of a word which is exactly like a key
- in a database file */
+ /*!
+ searches for a translation of a word which is exactly like a key
+ in a database file
+ */
QString searchCache(QString key);
//! scans dictionary file to get information about it
//! counts the keys in a xdxf file
int countWords();
- /*! transforms xdxf files to database files (caching operation)
- \returns true on success, false on failure */
+ /*!
+ transforms xdxf files to database files (caching operation)
+ \returns true on success, false on failure
+ */
bool makeCache(QString dir);
- //! language from which we translate
+ static bool dictDownloaderInitialized;
+
QString _langFrom;
- //! language to which we translate
QString _langTo;
- //! name of a dictionary
QString _name;
- //! information about dictionary
QString _infoNote;
-
QString _dictionaryInfo;
-
- //! icon displayed during translations and when a dictionary is chosen
QIcon _icon;
QSqlDatabase db;
QString db_name;
- //! number of words in a dictionary
long _wordsCount;
- //! indicates if search is stopped
volatile bool stopped;
Settings *_settings;
XdxfDictDialog* _dictDialog;