9f19edac736d0d47421ef2e58b115b10605e5a34
[mdictionary] / src / plugins / xdxf / XdxfDictSelectDialog.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     \file XdxfDictSelectDialog.h
23     \author Mateusz Półrola <mateusz.polrola@comarch.com>
24  */
25
26 #ifndef XDXFDICTSELECTDIALOG_H
27 #define XDXFDICTSELECTDIALOG_H
28
29 #include <QDialog>
30 #include <QtGui>
31 #include <QFile>
32 #include <QDir>
33 #include "DownloadDict.h"
34 #include "DictsModel.h"
35 #include "DictsProxyModel.h"
36
37
38 /*!
39   Shows dialog with list of dictionaries and informations about them,
40   allowing user to filter data based on dictionaries languages,
41   and to select one of them.
42 */
43 class XdxfDictSelectDialog : public QDialog {
44     Q_OBJECT
45 public:
46     /*!
47         Constructor
48         \param dicts list of DownloadDict objects describing dictionaries.
49     */
50     XdxfDictSelectDialog(QList<DownloadDict> dicts,
51                                   QWidget *parent = 0);
52
53     /*!
54         Returns download link of dictionary selected by user. This string is set
55         only when user select any dictionary (dialog was accepted), otherwise it
56         is empty.
57     */
58     QString link() { return _link;}
59
60 private Q_SLOTS:
61     //! creates items for comboboxes and creates model with dicts info
62     void initializeDicts();
63
64     //! filters dicts after filtering settings change
65     void refreshDictList();
66
67     //! accept dialog and sets download link of clicked dictionary
68     void itemClicked(QModelIndex);
69
70 private:
71     QTreeView* treeView;
72     DictsModel* model;
73     DictsProxyModel *proxyModel; //used by treeView to allow filtering and sorti
74     QVBoxLayout* layout;
75     QHBoxLayout* checkBoxLayout;
76     QComboBox* langFrom;
77     QComboBox* langTo;
78     QLabel* langFromLabel;
79     QLabel* langToLabel;
80     QList<DownloadDict>* dictList;
81     QString _link;
82 };
83
84 #endif // XDXFDICTSELECTDIALOG_H