Loading...
Searching...
No Matches
AbstractSettingWidget.h
Go to the documentation of this file.
1/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2
3 This file is part of the TerraLib - a Framework for building GIS enabled applications.
4
5 TerraLib is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 TerraLib 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with TerraLib. See COPYING. If not, write to
17 TerraLib Team at <terralib-team@terralib.org>.
18 */
19
20/*!
21 \file AbstractSettingWidget.h
22
23 \brief An abstraction for setting widgets.
24*/
25
26#ifndef __TERRALIB_QT_AF_ABSTRACTSETTINGWIDGET_H
27#define __TERRALIB_QT_AF_ABSTRACTSETTINGWIDGET_H
28
29// TerraLib
30#include "../ApplicationController.h"
31
32// Qt
33#include <QWidget>
34#include <QMessageBox>
35
36namespace te
37{
38 namespace qt
39 {
40 namespace af
41 {
42 /*!
43 \class AbstractSettingWidget
44
45 \brief A frame for setting Table options.
46 */
47 class TEQTAFEXPORT AbstractSettingWidget : public QWidget
48 {
49 Q_OBJECT
50
51 public:
52
53 /*!
54 \brief
55 */
56 AbstractSettingWidget(QWidget* parent = 0);
57
58 /*!
59 \brief
60 */
61 virtual ~AbstractSettingWidget();
62
63 /*!
64 \brief
65 */
66 virtual void saveChanges() = 0;
67
68 /*!
69 \brief
70 */
71 virtual void resetState() = 0;
72
73 /*!
74 \brief
75 */
76 virtual void getHelpInformations(QString& ns, QString& helpFile) = 0;
77
78 /*!
79 \brief
80 */
81 QString getResumeText();
82
83 /*!
84 \brief
85 */
86 bool hasChanges();
87
88 /*!
89 \brief
90 */
91 virtual void setApplicationController(te::qt::af::ApplicationController* app);
92
93 public slots:
94
95 virtual void onApplyButtonClicked();
96
97 signals:
98
99 /*!
100 \brief Signal must be emited when some settings has been changed. Use the argument to tell if the
101 */
102 void updateApplyButtonState(const bool&);
103
104 protected:
105
106 virtual void hideEvent(QHideEvent * event);
107
108 /*!
109 \brief Indicates that there's unsaved information. Use this method after each change in informations of the widget.
110
111 \param state If true indicates that there are unsave information.
112 */
113 virtual void changeApplyButtonState(const bool& state);
114
115 bool m_hasChanged; //!< Flag that defines if the widget has changes to apply.
116
118
120 };
121
123 QWidget(parent),
124 m_hasChanged(false),
125 m_app(0)
126 {
127 }
128
130 {
131 }
132
134 {
135 return m_resumeText;
136 }
137
139 {
140 return m_hasChanged;
141 }
142
144 {
145 m_app = app;
146 }
147
149 {
150 saveChanges();
151
153 }
154
155 inline void AbstractSettingWidget::hideEvent(QHideEvent * event)
156 {
157 if(m_hasChanged)
158 {
159 QString msg = tr("There are unsaved changes. Do you want to save it?");
160
161 if(QMessageBox::question(this, tr("Application settings customization"), msg, QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
162 saveChanges();
163 else
164 resetState();
165 }
166
167 m_hasChanged = false;
168
169 QWidget::hideEvent(event);
170 }
171
173 {
174 m_hasChanged = state;
176 }
177 } // end namespace af
178 } // end namespace qt
179} // end namespace te
180
181#endif // __TERRALIB_QT_AF_ABSTRACTSETTINGWIDGET_H
182
A frame for setting Table options.
virtual void getHelpInformations(QString &ns, QString &helpFile)=0
void updateApplyButtonState(const bool &)
Signal must be emited when some settings has been changed. Use the argument to tell if the.
te::qt::af::ApplicationController * m_app
bool m_hasChanged
Flag that defines if the widget has changes to apply.
virtual void setApplicationController(te::qt::af::ApplicationController *app)
virtual void hideEvent(QHideEvent *event)
virtual void changeApplyButtonState(const bool &state)
Indicates that there's unsaved information. Use this method after each change in informations of the ...
The base API for TerraLib applications.
TerraLib.
#define slots
#define TEQTAFEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:71