All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 // Qt
30 #include <QWidget>
31 #include <QMessageBox>
32 
33 namespace te
34 {
35  namespace qt
36  {
37  namespace af
38  {
39  /*!
40  \class AbstractSettingWidget
41 
42  \brief A frame for setting Table options.
43  */
44  class AbstractSettingWidget : public QWidget
45  {
46  Q_OBJECT
47 
48  public:
49 
50  /*!
51  \brief
52  */
53  AbstractSettingWidget(QWidget* parent = 0);
54 
55  /*!
56  \brief
57  */
58  virtual ~AbstractSettingWidget();
59 
60  /*!
61  \brief
62  */
63  virtual void saveChanges() = 0;
64 
65  /*!
66  \brief
67  */
68  virtual void resetState() = 0;
69 
70  /*!
71  \brief
72  */
73  virtual void getHelpInformations(QString& ns, QString& helpFile) = 0;
74 
75  /*!
76  \brief
77  */
78  QString getResumeText();
79 
80  /*!
81  \brief
82  */
83  bool hasChanges();
84 
85  public slots:
86 
87  virtual void onApplyButtonClicked();
88 
89  signals:
90 
91  /*!
92  \brief Signal must be emited when some settings has been changed. Use the argument to tell if the
93  */
94  void updateApplyButtonState(const bool&);
95 
96  protected:
97 
98  virtual void hideEvent(QHideEvent * event);
99 
100  /*!
101  \brief Indicates that there's unsaved information. Use this method after each change in informations of the widget.
102 
103  \param state If true indicates that there are unsave information.
104  */
105  virtual void changeApplyButtonState(const bool& state);
106 
107  bool m_hasChanged; //!< Flag that defines if the widget has changes to apply.
108 
109  QString m_resumeText;
110  };
111 
113  QWidget(parent),
114  m_hasChanged(false)
115  {
116  }
117 
119  {
120  }
121 
123  {
124  return m_resumeText;
125  }
126 
128  {
129  return m_hasChanged;
130  }
131 
133  {
134  saveChanges();
135 
136  changeApplyButtonState(false);
137  }
138 
139  inline void AbstractSettingWidget::hideEvent(QHideEvent * event)
140  {
141  if(m_hasChanged)
142  {
143  QString msg = tr("There are unsaved changes. Do you want to save it?");
144 
145  if(QMessageBox::question(this, tr("Application settings customization"), msg, QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
146  saveChanges();
147  else
148  resetState();
149  }
150 
151  m_hasChanged = false;
152 
153  QWidget::hideEvent(event);
154  }
155 
156  inline void AbstractSettingWidget::changeApplyButtonState(const bool& state)
157  {
158  m_hasChanged = state;
160  }
161  } // end namespace af
162  } // end namespace qt
163 } // end namespace te
164 
165 #endif // __TERRALIB_QT_AF_ABSTRACTSETTINGWIDGET_H
166 
void updateApplyButtonState(const bool &)
Signal must be emited when some settings has been changed. Use the argument to tell if the...
virtual void hideEvent(QHideEvent *event)
A frame for setting Table options.
virtual void getHelpInformations(QString &ns, QString &helpFile)=0
bool m_hasChanged
Flag that defines if the widget has changes to apply.
virtual void changeApplyButtonState(const bool &state)
Indicates that there's unsaved information. Use this method after each change in informations of the ...