All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HorizontalSliderWidget.cpp
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 terralib/qt/widgets/utils/HorizontalSliderWidget.cpp
22 
23  \brief ...
24 */
25 
26 // TerraLib
27 #include "../../../common/Translator.h"
28 #include "ui_HorizontalSliderWidgetForm.h"
29 #include "HorizontalSliderWidget.h"
30 
31 // Qt
32 #include <QPushButton>
33 
34 
35 
37  : QWidget(parent, f),
38  m_ui(new Ui::HorizontalSliderWidgetForm)
39 {
40  m_ui->setupUi(this);
41 
42 // default values
43  m_minValue = 0;
44  m_maxValue = 99;
45  m_defaultValue = 0;
46 
47  m_ui->m_defaultPushButton->setIcon(QIcon::fromTheme("edit-undo"));
48  m_ui->m_defaultPushButton->setIconSize(QSize(16,16));
49 
50 // connect signals and slots
51  connect(m_ui->m_defaultPushButton, SIGNAL(released()), this, SLOT(onDefaultButtonPressed()));
52  connect(m_ui->m_slider, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
53  connect(m_ui->m_slider, SIGNAL(sliderReleased()), this, SLOT(onSliderReleased()));
54 }
55 
57 {
58 }
59 
60 Ui::HorizontalSliderWidgetForm* te::qt::widgets::HorizontalSliderWidget::getForm() const
61 {
62  return m_ui.get();
63 }
64 
66 {
67  m_ui->m_groupBox->setTitle(value);
68 }
69 
71 {
72  m_minValue = min;
73  m_ui->m_slider->setMinimum(m_minValue);
74 
75  m_maxValue = max;
76  m_ui->m_slider->setMaximum(m_maxValue);
77 }
78 
80 {
81  m_defaultValue = value;
82 
83  m_ui->m_sliderLabel->setNum(m_defaultValue);
84 
85  m_ui->m_slider->setValue(m_defaultValue);
86 }
87 
89 {
90  m_ui->m_sliderLabel->setNum(value);
91 
92  m_ui->m_slider->setValue(value);
93 }
94 
96 {
97  return m_ui->m_slider->value();
98 }
99 
101 {
102  m_ui->m_defaultPushButton->setVisible(visible);
103 }
104 
106 {
107  m_ui->m_sliderLabel->setVisible(visible);
108 }
109 
111 {
112  m_ui->m_slider->setValue(m_defaultValue);
113 
114  onValueChanged(m_defaultValue);
115 
116  onSliderReleased();
117 }
118 
120 {
121  m_ui->m_sliderLabel->setNum(value);
122 
123  emit sliderValueChanged(value);
124 }
125 
127 {
128  emit sliderReleased();
129 }
int m_defaultValue
Slider default value (default 0)
int m_minValue
Slider Minimum value (default 0)
int m_maxValue
Slider Maximum value (default 99)
HorizontalSliderWidget(QWidget *parent=0, Qt::WindowFlags f=0)
std::auto_ptr< Ui::HorizontalSliderWidgetForm > m_ui
Ui::HorizontalSliderWidgetForm * getForm() const