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