Added decomentation and some explenation to dict download mechanism
[mdictionary] / src / plugins / xdxf / XdxfDictDownloader.h
1 /*******************************************************************************
2
3     This file is part of mDictionary.
4
5     mDictionary is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9
10     mDictionary is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
17
18     Copyright 2010 Comarch S.A.
19
20 *******************************************************************************/
21
22 //Created by Mateusz Półrola
23
24 #ifndef XDXFDICTDOWNLOADER_H
25 #define XDXFDICTDOWNLOADER_H
26
27 #include <QObject>
28 #include "XdxfDictSelectDialog.h"
29 #include <QTimer>
30 #include <QNetworkAccessManager>
31 #include <QNetworkReply>
32 #include <DownloadDict.h>
33 #include "XdxfDictDownloadProgressDialog.h"
34
35 /** XdxfDictDownloader is responsible for getting dict list from XDXF website
36     and other actions necessary to download and add dictionary
37
38     When user want to add dictionary he may choose "browse" or "download",
39     after selecting "download"  XDXFDictDownloader would present him list of
40     dictionaries and when he select one downloading would be started. Next
41     step is to extract archive and move file to ~/.mdictionary
42 */
43 class XdxfDictDownloader : public QObject {
44     Q_OBJECT
45 public:
46     XdxfDictDownloader(QObject *parent = 0);
47     //! \return name of downloaded file
48     QString downloadedFile();
49
50 public Q_SLOTS:
51     //! downloads dictionaries list from xdxf website
52     void download(QWidget* parent);
53
54 Q_SIGNALS:
55     //! emmited when file download precess is complete
56     void fileDownloaded(QString);
57
58 private Q_SLOTS:
59     void dictListReceived(QNetworkReply*);
60     void processFinished(int);
61
62 private:
63     void downloadComplete();
64     QList<DownloadDict> dicts;
65     QWidget* parentDialog;
66     QString _downloadedFile;
67     XdxfDictDownloadProgressDialog* progressDialog;
68     QStringList commands;
69     int currentCommand;
70     QProcess* process;
71     QString _fileName;
72 };
73
74 #endif // XDXFDICTDOWNLOADER_H