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 "../../../core/translator/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 Ui::HorizontalSliderWidgetForm* te::qt::widgets::HorizontalSliderWidget::getForm() const
59 {
60  return m_ui.get();
61 }
62 
64 {
65  m_ui->m_groupBox->setTitle(value);
66 }
67 
69 {
70  m_minValue = min;
71  m_ui->m_slider->setMinimum(m_minValue);
72 
73  m_maxValue = max;
74  m_ui->m_slider->setMaximum(m_maxValue);
75 }
76 
78 {
79  m_defaultValue = value;
80 
81  m_ui->m_sliderLabel->setNum(m_defaultValue);
82 
83  m_ui->m_slider->setValue(m_defaultValue);
84 }
85 
87 {
88  m_ui->m_sliderLabel->setNum(value);
89 
90  m_ui->m_slider->setValue(value);
91 }
92 
94 {
95  return m_ui->m_slider->value();
96 }
97 
99 {
100  m_ui->m_defaultPushButton->setVisible(visible);
101 }
102 
104 {
105  m_ui->m_sliderLabel->setVisible(visible);
106 }
107 
109 {
110  m_ui->m_slider->setValue(m_defaultValue);
111 
113 
115 }
116 
118 {
119  m_ui->m_sliderLabel->setNum(value);
120 
121  emit sliderValueChanged(value);
122 }
123 
125 {
126  emit sliderReleased();
127 }
std::unique_ptr< Ui::HorizontalSliderWidgetForm > m_ui
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)
Ui::HorizontalSliderWidgetForm * getForm() const