From: Mateusz Półrola Date: Fri, 1 Oct 2010 09:29:47 +0000 (+0200) Subject: Add comments and translations for xdxf downloading dialog X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=629196c81cb8d3008e9beadfa0ede4cda602460e;p=mdictionary Add comments and translations for xdxf downloading dialog --- diff --git a/src/plugins/xdxf/DictsModel.cpp b/src/plugins/xdxf/DictsModel.cpp index c92ed57..68987d0 100644 --- a/src/plugins/xdxf/DictsModel.cpp +++ b/src/plugins/xdxf/DictsModel.cpp @@ -24,6 +24,8 @@ \author Mateusz Półrola */ +#include "DictsModel.h" + DictsModel::DictsModel(QList dicts, QObject *parent) : QAbstractItemModel(parent) diff --git a/src/plugins/xdxf/DictsProxyModel.h b/src/plugins/xdxf/DictsProxyModel.h index 79804a7..7f99271 100644 --- a/src/plugins/xdxf/DictsProxyModel.h +++ b/src/plugins/xdxf/DictsProxyModel.h @@ -19,7 +19,10 @@ *******************************************************************************/ -//Created by Mateusz Półrola +/*! + \file DictsProxyModel.h + \author Mateusz Półrola + */ #ifndef DICTSPROXYMODEL_H #define DICTSPROXYMODEL_H @@ -27,6 +30,11 @@ #include #include + +/*! + Proxy model used for filtering and sorting informations about xdxf dictionaries. +It allow to filter dictionaries based on their langages +*/ class DictsProxyModel : public QSortFilterProxyModel { Q_OBJECT @@ -35,13 +43,21 @@ public: } + /*! Returns currently setted language used to filter dictionaries based on dictionarie's language from*/ QString from() { return _from;} + + /*! Returns currently setted language used to filter dictionaries based on dictionarie's language to*/ QString to() {return _to;} + + /*! Sets currently setted language used to filter dictionaries based on dictionarie's language from*/ void setFrom(QString from) { _from = from; invalidateFilter(); } + + /*! Sets currently setted language used to filter dictionaries based on dictionarie's language to*/ void setTo(QString to) {_to = to; invalidateFilter();} protected: + /*! Filtering passed row*/ bool filterAcceptsRow(int source_row, const QModelIndex&) const { QString sourceFrom = sourceModel()->data( sourceModel()->index(source_row, 0)).toString(); @@ -52,6 +68,7 @@ protected: (_to.isEmpty() || sourceTo == _to)); } + /*! Sorting, if sort column is set to column containing size of dictionary, string containing size of it is converted to fload and compared to other dict size*/ bool lessThan(const QModelIndex &left, const QModelIndex &right) const { if(sortColumn() == 3) { QString l = left.model()->data(left).toString(); diff --git a/src/plugins/xdxf/XdxfDictDialog.cpp b/src/plugins/xdxf/XdxfDictDialog.cpp index 62e1f3d..6ba1e27 100644 --- a/src/plugins/xdxf/XdxfDictDialog.cpp +++ b/src/plugins/xdxf/XdxfDictDialog.cpp @@ -20,8 +20,9 @@ *******************************************************************************/ /*! \file XdxfDictDialog.cpp + \author Mateusz Półrola */ -//Created by Mateusz Półrola + #include "XdxfDictDialog.h" #include "xdxfplugin.h" diff --git a/src/plugins/xdxf/XdxfDictDialog.h b/src/plugins/xdxf/XdxfDictDialog.h index c34f211..92c30cc 100644 --- a/src/plugins/xdxf/XdxfDictDialog.h +++ b/src/plugins/xdxf/XdxfDictDialog.h @@ -47,8 +47,14 @@ public: */ void changeSettings(QWidget *parent); + /*! + Returns last parent of this dialog + */ QWidget* lastDialogParent(); + /*! + Sets last parent of this dialog + */ void setLastDialogParent(QWidget*); private: diff --git a/src/plugins/xdxf/XdxfDictDownloadProgressDialog.cpp b/src/plugins/xdxf/XdxfDictDownloadProgressDialog.cpp index 8a34fce..191ac97 100644 --- a/src/plugins/xdxf/XdxfDictDownloadProgressDialog.cpp +++ b/src/plugins/xdxf/XdxfDictDownloadProgressDialog.cpp @@ -19,7 +19,10 @@ *******************************************************************************/ -//Created by Mateusz Półrola +/*! + \file XdxfDictDownloadProgressDialog.cpp + \author Mateusz Półrola + */ #include "XdxfDictDownloadProgressDialog.h" diff --git a/src/plugins/xdxf/XdxfDictDownloadProgressDialog.h b/src/plugins/xdxf/XdxfDictDownloadProgressDialog.h index 18be373..bce23c0 100644 --- a/src/plugins/xdxf/XdxfDictDownloadProgressDialog.h +++ b/src/plugins/xdxf/XdxfDictDownloadProgressDialog.h @@ -19,7 +19,10 @@ *******************************************************************************/ -//Created by Mateusz Półrola +/*! + \file XdxfDictDownloadProgressDialog.h + \author Mateusz Półrola + */ #ifndef XDXFDICTDOWNLOADPROGRESSDIALOG_H #define XDXFDICTDOWNLOADPROGRESSDIALOG_H @@ -27,13 +30,20 @@ #include #include +/*! + 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: XdxfDictDownloadProgressDialog(QWidget *parent = 0); public Q_SLOTS: + //! Reimplemented to block rejecting on maemo. User must cancel. void reject(); + + //! Set text which will be displayed to user as info about current download void setText(QString); Q_SIGNALS: @@ -45,7 +55,6 @@ private: QProgressBar* downloadProgressBar; QPushButton* cancelButton; QVBoxLayout* verticalLayout; - //! used to check the progress of dictionary downloading }; #endif // XDXFDICTDOWNLOADPROGRESSDIALOG_H diff --git a/src/plugins/xdxf/XdxfDictDownloader.cpp b/src/plugins/xdxf/XdxfDictDownloader.cpp index d65fbe9..2b62ff6 100644 --- a/src/plugins/xdxf/XdxfDictDownloader.cpp +++ b/src/plugins/xdxf/XdxfDictDownloader.cpp @@ -19,7 +19,10 @@ *******************************************************************************/ -//Created by Mateusz Półrola +/*! + \file XdxfDictDownloader.cpp + \author Mateusz Półrola + */ #include "XdxfDictDownloader.h" #include "XdxfDictDownloadProgressDialog.h" @@ -30,7 +33,10 @@ XdxfDictDownloader::XdxfDictDownloader(QObject *parent) : QObject(parent) { parentDialog = 0; process = new QProcess(this); + manager = new QNetworkAccessManager(this); + connect(manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(dictListReceived(QNetworkReply*))); connect(process, SIGNAL(finished(int)), this, SLOT(processFinished(int))); @@ -38,19 +44,9 @@ XdxfDictDownloader::XdxfDictDownloader(QObject *parent) : progressDialog = 0; } -XdxfDictDownloader::~XdxfDictDownloader() { - -} - - - void XdxfDictDownloader::download(QWidget *parent) { parentDialog = parent; aborted = false; - QNetworkAccessManager *manager = new QNetworkAccessManager(this); - - connect(manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(dictListReceived(QNetworkReply*))); manager->get(QNetworkRequest(QUrl("http://xdxf.revdanica.com/down/"))); @@ -68,6 +64,7 @@ QString XdxfDictDownloader::downloadedFile() { 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(process->state() != QProcess::NotRunning) { process->kill(); @@ -77,14 +74,19 @@ void XdxfDictDownloader::breakDownloading() { progressDialog->accept(); } - Q_EMIT notify(Notify::Info, tr("Downloading canceled")); } void XdxfDictDownloader::processFinished(int exitcode) { + //first check if user cancel downloading if(aborted) return; + + //if error of proces, notify user about this if(exitcode != 0) { Q_EMIT notify(Notify::Error, tr("Error while downloading or processing dictionary")); + breakDownloading(); + return; } + //if there are any left commands, execute next if(++currentCommandstart(commands[currentCommand]); } @@ -94,7 +96,6 @@ void XdxfDictDownloader::processFinished(int exitcode) { } void XdxfDictDownloader::downloadComplete() { -<<<<<<< HEAD if(aborted) return; // Downloaded tar file name is different than extracted folder so we need // some clean directory to identify extracted files @@ -163,6 +164,7 @@ void XdxfDictDownloader::dictListReceived(QNetworkReply *reply) { // to call commands via shell, each command from list is called after // previous call returns 0 + currentCommand = 0; commands.clear(); commands.push_back("rm -rf /tmp/mdict"); commands.push_back("mkdir /tmp/mdict"); diff --git a/src/plugins/xdxf/XdxfDictDownloader.h b/src/plugins/xdxf/XdxfDictDownloader.h index 629f57d..3a74b20 100644 --- a/src/plugins/xdxf/XdxfDictDownloader.h +++ b/src/plugins/xdxf/XdxfDictDownloader.h @@ -19,7 +19,10 @@ *******************************************************************************/ -//Created by Mateusz Półrola +/*! + \file XdxfDictDownloader.h + \author Mateusz Półrola + */ #ifndef XDXFDICTDOWNLOADER_H #define XDXFDICTDOWNLOADER_H @@ -47,7 +50,6 @@ public: XdxfDictDownloader(QObject *parent = 0); //! \return name of downloaded file QString downloadedFile(); - ~XdxfDictDownloader(); public Q_SLOTS: //! downloads dictionaries list from xdxf website @@ -56,14 +58,21 @@ public Q_SLOTS: 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); private Q_SLOTS: + //! obtained list of dictionaries from website void dictListReceived(QNetworkReply*); + + //! one of system processes finished void processFinished(int); + + //! user cancel downloading void breakDownloading(); private: + //! dict is downloaded and unpacked void downloadComplete(); QList dicts; QWidget* parentDialog; @@ -75,6 +84,7 @@ private: QString _fileName; bool downloadError; bool aborted; + QNetworkAccessManager *manager; }; #endif // XDXFDICTDOWNLOADER_H diff --git a/src/plugins/xdxf/XdxfDictSelectDialog.cpp b/src/plugins/xdxf/XdxfDictSelectDialog.cpp index db6505c..0ef30f2 100644 --- a/src/plugins/xdxf/XdxfDictSelectDialog.cpp +++ b/src/plugins/xdxf/XdxfDictSelectDialog.cpp @@ -19,7 +19,10 @@ *******************************************************************************/ -//Created by Mateusz Półrola +/*! + \file XdxfDictSelectDialog.cpp + \author Mateusz Półrola + */ #include "XdxfDictSelectDialog.h" @@ -104,6 +107,7 @@ XdxfDictSelectDialog::XdxfDictSelectDialog(QList dicts, void XdxfDictSelectDialog::initializeDicts() { + //scan of all languages of dictionaries, using QSet to get only distinct languages QSet languagesFrom; QSet languagesTo; @@ -114,15 +118,19 @@ void XdxfDictSelectDialog::initializeDicts() { model->data(model->index(i, 1, QModelIndex())).toString()); } + //removes one dictionary which from and to languages are empty.... + //bug in site with dictionaries languagesFrom.remove(QString()); languagesTo.remove(QString()); + //sorting of found languages QList langFromList = languagesFrom.toList(); qSort(langFromList); QList langToList = languagesTo.toList(); qSort(langToList); + //and adding them to combobox, first item in each combobox is "Any" langFrom->addItem(tr("Any")); for(int i=0; i < langFromList.count(); i++) { langFrom->addItem(langFromList.at(i)); @@ -135,6 +143,7 @@ void XdxfDictSelectDialog::initializeDicts() { } 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->setTo(QString()); else diff --git a/src/plugins/xdxf/XdxfDictSelectDialog.h b/src/plugins/xdxf/XdxfDictSelectDialog.h index 5f6dfcc..996cee8 100644 --- a/src/plugins/xdxf/XdxfDictSelectDialog.h +++ b/src/plugins/xdxf/XdxfDictSelectDialog.h @@ -19,7 +19,10 @@ *******************************************************************************/ -//Created by Mateusz Półrola +/*! + \file XdxfDictSelectDialog.h + \author Mateusz Półrola + */ #ifndef XDXFDICTSELECTDIALOG_H #define XDXFDICTSELECTDIALOG_H @@ -30,16 +33,31 @@ #include "DictsModel.h" #include "DictsProxyModel.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. + */ class XdxfDictSelectDialog : public QDialog { Q_OBJECT public: - explicit XdxfDictSelectDialog(QList dicts, + /*! + Constructor + \param dicts list of DownloadDict objects describing dictionaries. + */ + XdxfDictSelectDialog(QList 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. + */ QString link() { return _link;} private: QTreeView* treeView; DictsModel* model; + //used by treeView to allow filtering and sorting DictsProxyModel *proxyModel; QVBoxLayout* layout; QHBoxLayout* checkBoxLayout; @@ -49,8 +67,13 @@ private: 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: diff --git a/src/plugins/xdxf/en_US.ts b/src/plugins/xdxf/en_US.ts index 64c07a0..ecd10d4 100644 --- a/src/plugins/xdxf/en_US.ts +++ b/src/plugins/xdxf/en_US.ts @@ -2,6 +2,29 @@ + DictsModel + + + From + + + + + To + + + + + Name + + + + + Size + + + + XdxfCachingDialog @@ -41,119 +64,175 @@ - + Add new XDXF dictionary - + Browse - + + Download + + + + Dictionary file: not selected - + XDXF Settings - + Plugin: - + From: - + To: - + Description: - + Strip accents - + Optimize - + Add - + Save settings - + Select dictionary file - + XDXF Files (*.xdxf) - + + Dictionary file: %1 - + File path is not set + XdxfDictDownloadProgressDialog + + + Cancel + + + + + XdxfDictDownloader + + + Downloading dictionaries list + + + + + Error while downloading or processing dictionary + + + + + Downloading dictionary + + + + + XdxfDictSelectDialog + + + Select dictionary + + + + + From + + + + + To + + + + + + Any + + + + XdxfPlugin - - - + + + Cache database cannot be opened for %1 dictionary. Searching in XDXF file. You may want to recache. - - + + XDXF file cannot be read for %1 - + XDXF file is in wrong format - + XDXF dictionary cannot be read from file - - + + XDXF file cannot be read for %1 dictionary - + Database caching error, please try again. diff --git a/src/plugins/xdxf/pl_PL.ts b/src/plugins/xdxf/pl_PL.ts index 9800a1c..3350b84 100644 --- a/src/plugins/xdxf/pl_PL.ts +++ b/src/plugins/xdxf/pl_PL.ts @@ -2,6 +2,29 @@ + DictsModel + + + From + Z + + + + To + Na + + + + Name + Nazwa + + + + Size + Rozmiar + + + XdxfCachingDialog @@ -42,119 +65,175 @@ Usuń akcenty (wyszukiwanie trwa dłużej, ale szukane słowo nie musi być wpisane dokładnie) - + Add new XDXF dictionary Dodaj nowy słownik XDXF - + Browse Przeglądaj - + + Download + Pobierz + + + Dictionary file: not selected Plik ze słownikiem nie został wybrany - + XDXF Settings Ustawienia XDXF - + Plugin: - + - + From: Z: - + To: Na: - + Description: Opis: - + Strip accents Usuń akcenty - + Optimize Optymalizuj - + Add Dodaj - + Save settings Zapisz ustawienia - + Select dictionary file Wybierz plik ze słownikiem - + XDXF Files (*.xdxf) Pliki XDXF (*.xdxf) - + + Dictionary file: %1 Plik ze słownikiem: %1 - + File path is not set Ścieżka do pliku nie jest ustawiona + XdxfDictDownloadProgressDialog + + + Cancel + Anuluj + + + + XdxfDictDownloader + + + Downloading dictionaries list + Pobieranie listy słowników + + + + Error while downloading or processing dictionary + Błąd podczas poierania lub przetwarzania słownika + + + + Downloading dictionary + Pobieranie słownika + + + + XdxfDictSelectDialog + + + Select dictionary + Wybierz słownik + + + + From + Z + + + + To + Na + + + + + Any + Dowolny + + + XdxfPlugin - - - + + + Cache database cannot be opened for %1 dictionary. Searching in XDXF file. You may want to recache. Nie można otworzyć bazy danych dla słownika %1. Szukanie w pliku XDXF. Możesz spróbować ponownie włączyć optymalizację. - - + + XDXF file cannot be read for %1 Nie można odczytać pliku XDXF dla %1 - + XDXF file is in wrong format Niewłaściwy format pliku XDXF - + XDXF dictionary cannot be read from file Nie można odczytać słownika XDXF z pliku - - + + XDXF file cannot be read for %1 dictionary Nie mozna odczytać pliku XDXF dla słownika %1 - + Database caching error, please try again. Błąd optymalizacji, proszę spróbować ponownie. diff --git a/src/plugins/xdxf/translations/pl_PL.qm b/src/plugins/xdxf/translations/pl_PL.qm index 07a9e30..4a74114 100644 Binary files a/src/plugins/xdxf/translations/pl_PL.qm and b/src/plugins/xdxf/translations/pl_PL.qm differ