fa80275e0c44c030965f06e3e15b3aef5d1a4856
[mdictionary] / trunk / src / base / gui / DictManagerWidget.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 DictManagerWidget.h
23 //! \brief Dictionary management widget
24 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
25
26 #ifndef DICTMANAGERWIDGET_H
27 #define DICTMANAGERWIDGET_H
28
29 #include <QWidget>
30 #include <QtGui>
31 #include "../../includes/GUIInterface.h"
32
33
34 //! Implements dictionaries management widget
35 /*!
36   Shows list of loaded dictionaries and their states (active/inactive).
37   It allow to change dicts states, add new dict, remove selected one or
38   change settings of selected dict. All changes are saved automatically after
39   hiding of this widget.
40   */
41 class DictManagerWidget : public QDialog {
42     Q_OBJECT
43 public:
44     //! Constructor
45     /*!
46       \param parent parent of this widget, which must be subclass of
47       GUIInterface, because it will use it to get info about loaded plugins
48       and dicts.
49       */
50     explicit DictManagerWidget(GUIInterface *parent = 0);
51
52 protected:
53     void showEvent(QShowEvent *e);
54     void hideEvent(QHideEvent *e);
55
56 Q_SIGNALS:
57     //! Emited when hiding widget, it will save states of dictionaries
58     /*! \param list of only active dictionaries
59       */
60     void selectedDictionaries(QList<CommonDictInterface*>);
61
62     //! Emited when user wants to add new dictionary
63     /*! \param new dictionary returned by specyfic plugin dialog
64       */
65     void addDictionary(CommonDictInterface*);
66
67     //! Emited when user wants to remove dictionary
68     /*! \param dictionary which will be removed
69       */
70     void removeDictionary(CommonDictInterface*);
71
72
73
74 private Q_SLOTS:
75     /*! Shows plugin select dialog and then specific plugin add new dictionary
76         dialog, which will return new CommonDictInterface* object, which is
77         later passed as parameter of addDictionary signal*/
78     void addNewDictButtonClicked();
79
80     /*! Pass selected dictionary from list as parameter of removeDictionary
81         signal */
82     void removeButtonClicked();
83     void itemSelected(QListWidgetItem*);
84
85     /*! Shows plugin's settings dialog*/
86     void settingsButtonClicked();
87
88     //! Each change of state (that needs to be saved) should call this to indicate state change
89     void changed();
90
91 private:
92     QPushButton* addNewDictButton;
93     QPushButton* removeDictButton;
94     QPushButton* settingsButton;
95
96     QVBoxLayout* verticalLayout;
97     QHBoxLayout* buttonGroup;
98     QListWidget* dictListWidget;
99
100     //holds association between items on list and CommonDictInterface objects
101     QHash<QListWidgetItem*, CommonDictInterface*> dictsHash;
102     GUIInterface* guiInterface;
103     bool _changed;
104
105     void refreshDictsList();
106     #ifndef Q_WS_MAEMO_5
107         QPushButton* closeButton;
108         bool _save;
109
110         public Q_SLOTS:
111             void save();
112     #endif
113 };
114
115 #endif // DICTMANAGERWIDGET_H