fix small bug(wildcard), and change some comments
[mdictionary] / src / plugins / xdxf / XdxfDialog.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 /*!
23     \file XdxfDialog.h
24     \author Mateusz Półrola <mateusz.polrola@gmail.com>
25 */
26
27 #ifndef XDXFDIALOG_H
28 #define XDXFDIALOG_H
29
30 #include <QDialog>
31 #include "../../include/settings.h"
32 #include <QtGui>
33 #include "xdxfplugin.h"
34
35
36 //! Implementation of xdxf plugin's dialogs.
37 /*!
38     This class can create dialogs for adding a new dictionary or changing settings
39      of an existing one, based on dialog type passed to contructor.
40     When adding a new dictionary dialog contains a button to browse file system and
41     select a dictionary file. When changing settings dialog displays basic
42     information about dictionary i. e. name, languages and license info.
43     In both types of dialogs there are comboboxes with "cache" and "remove accents"
44      options. On maemo right next to comboboxes are tool buttons which allow to
45      see more information about these options, on desktop the same information is
46      displayed as a tool tip.
47     All contents of a dialog are in a scroll area.
48 */
49 class XdxfDialog : public QDialog
50 {
51     Q_OBJECT
52 public:
53     /*!
54       Describes type of dialog. New means that dialog contains widgets to browse
55         file system and select dictionary file. Change means that dialog displays
56      information about dictionary.
57       In both types dialog provides widgets to create or delete cache and remove
58      or keep accents.
59     */
60     enum XdxfDialogType {New, Change};
61
62     //! Constructor
63     /*!
64         Creates new xdxf dialog
65         \param plugin if created dialog is of type Change it must be set to
66             point to plugin whose settings will be changed
67         \param type describes type of created dialog
68         \param parent parent widget of created dialog
69     */
70     explicit XdxfDialog(XdxfPlugin* plugin = 0,
71                         XdxfDialogType type = New,
72                         QWidget* parent = 0);
73
74     //! \returns settings of plugin
75     /*!
76         After acceptance of dialog this method returns plugin's settings based on
77          user's choices in dialog.
78     */
79     Settings* getSettings();
80
81 Q_SIGNALS:
82     //! Requests to show notification
83     void notify(Notify::NotifyType, QString);
84
85 public Q_SLOTS:
86     //! Reimplemented accept method, to check if all necessary fields in
87     //! dialog are correct e. g. dictionary file path
88     //! and saves new settings
89     void accept();
90
91 private Q_SLOTS:
92     //! displays dialog to browse and select file
93     void selectFile();
94     void downloadFile();
95     void setGenerateCache(bool);
96     void setAccents(bool);
97     void fileDownloaded(QString);
98
99     #ifdef Q_WS_MAEMO_5
100         //! on maemo shows information about checkboxes
101         void showCacheInfo();
102         void showAccentsInfo();
103     #endif
104
105
106 private:
107     void initializeUI();
108
109     //! saves new settings after acceptance of dialog
110     void saveSettings();
111
112     QLabel* infoLabel;
113     QPushButton* browseButton;
114     QPushButton* downloadButton;
115     QHBoxLayout* browseLayout;
116     QHBoxLayout* infoLayout;
117
118     QCheckBox* cacheCheckBox;
119     QCheckBox* accentsCheckBox;
120     QHBoxLayout* cacheLayout;
121     QHBoxLayout* accentsLayout;
122
123     QString cacheToolTip;
124     QString accentsToolTip;
125
126     #ifdef Q_WS_MAEMO_5
127         QToolButton* cacheInfoToolButton;
128         QToolButton* accentsInfoToolButton;
129     #endif
130
131
132     QPushButton* confirmButton;
133
134     QString _dictionaryFilePath;
135
136     QScrollArea* scrollArea;
137
138     QWidget* widget;
139     QHBoxLayout* layout;
140
141     QVBoxLayout* mainVerticalLayout;
142     bool _generateCache;
143     bool _accents;
144     bool _lastAccents;
145
146     Settings* _settings;
147
148     XdxfPlugin* plugin;
149     XdxfDialogType type;
150 };
151
152 #endif // XDXFDIALOG_H