TemporalPropertiesWidget.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/st/TimePropertiesWidget.cpp
22 
23  \brief A widget used to adjust a temporal layer's properties
24 */
25 
26 //Terralib
27 #include "../../../dataaccess.h"
28 #include "../../../datatype/Enums.h"
29 #include "../../../datatype/Property.h"
31 #include "ui_TemporalPropertiesWidgetForm.h"
32 
33 //QT
34 #include <QWidget>
35 
37 : QWidget(parent, f),
38  m_ui(new Ui::TemporalPropertiesWidgetForm)
39 {
40  m_ui->setupUi(this);
41 
42  m_ui->m_typeComboBox->addItem(tr("Date Time"), QVariant(te::dt::DATETIME_TYPE));
43  m_ui->m_typeComboBox->addItem(tr("Ordinal"), QVariant(te::dt::ORDINAL_TIME_INSTANT));
44  m_ui->m_typeComboBox->addItem(tr("String"), QVariant(te::dt::STRING_TYPE));
45 
46  m_ui->m_ordTypeComboBox->addItem(tr("Ordinal Instant"), QVariant(te::dt::ORDINAL_TIME_INSTANT));
47  m_ui->m_ordTypeComboBox->addItem(tr("Ordinal Period"), QVariant(te::dt::ORDINAL_TIME_PERIOD));
48  m_ui->m_ordTypeComboBox->addItem(tr("User defined"), QVariant(-1));
49 
50  m_ui->m_tempUnitComboBox->addItem(tr("Year"), QVariant(te::dt::YEAR));
51  m_ui->m_tempUnitComboBox->addItem(tr("Month"), QVariant(te::dt::MONTH));
52  m_ui->m_tempUnitComboBox->addItem(tr("Day"), QVariant(te::dt::DAY));
53  m_ui->m_tempUnitComboBox->addItem(tr("Hour"), QVariant(te::dt::HOUR));
54  m_ui->m_tempUnitComboBox->addItem(tr("Minute"), QVariant(te::dt::MINUTE));
55  m_ui->m_tempUnitComboBox->addItem(tr("Second"), QVariant(te::dt::SECOND));
56  m_ui->m_tempUnitComboBox->addItem(tr("Week"), QVariant(te::dt::WEEK));
57  m_ui->m_tempUnitComboBox->addItem(tr("Day of the Week"), QVariant(te::dt::DAY_OF_WEEK));
58  m_ui->m_tempUnitComboBox->addItem(tr("Day of the Year"), QVariant(te::dt::DAY_OF_YEAR));
59  m_ui->m_tempUnitComboBox->addItem(tr("Unknown")), QVariant(te::dt::UNKNOWN);
60 
61  m_ui->m_formatComboBox->addItem(QString::fromUtf8("YYYY"), QVariant(te::dt::YYYY));
62  m_ui->m_formatComboBox->addItem(QString::fromUtf8("YY"), QVariant(te::dt::YY));
63  m_ui->m_formatComboBox->addItem(QString::fromUtf8("YYYYMM"), QVariant(te::dt::YYYYMM));
64  m_ui->m_formatComboBox->addItem(QString::fromUtf8("YYYYDDD"), QVariant(te::dt::YYYYDDD));
65 
66  // connect signal and slots
67  connect(m_ui->m_typeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTypeCBCurrentIndexChanged(int)));
68  connect(m_ui->m_ordTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onOrdTypeCBCurrentIndexChanged(int)));
69  connect(m_ui->m_tempUnitComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onUnitTypeCBCurrentIndexChanged(int)));
70 }
71 
73  default;
74 
75 Ui::TemporalPropertiesWidgetForm* te::qt::widgets::TemporalPropertiesWidget::getForm()
76 {
77  return m_ui.get();
78 }
79 
81 {
82  return m_ui->m_phenomenomComboBox->currentText().toUtf8().data();
83 }
84 
86 {
87  return m_ui->m_resultComboBox->currentText().toUtf8().data();
88 }
89 
91 {
92  return m_ui->m_validComboBox->currentText().toUtf8().data();
93 }
94 
96 {
97  return m_ui->m_typeComboBox->currentIndex();
98 }
99 
101 {
102  return m_ui->m_ordTypeComboBox->currentIndex();
103 }
104 
106 {
107  return m_ui->m_tempUnitComboBox->currentIndex();
108 }
109 
111 {
112  return m_ui->m_tempValueLineEdit->text().toUtf8().data();
113 }
114 
116 {
117  return m_ui->m_ordinalLineEdit->text().toUtf8().data();
118 }
119 
121 {
122  return m_ui->m_formatComboBox->itemData(m_ui->m_formatComboBox->currentIndex()).toInt();
123 }
124 
126 {
127  if(m_ui->m_typeComboBox->itemData(index).toInt() == te::dt::STRING_TYPE)
128  {
129  m_ui->m_formatComboBox->setEnabled(true);
130  m_ui->m_ordTypeComboBox->setEnabled(false);
131  }
132  else if(m_ui->m_typeComboBox->itemData(index).toInt() == te::dt::ORDINAL_TIME_INSTANT)
133  {
134  m_ui->m_ordTypeComboBox->setEnabled(true);
135  m_ui->m_formatComboBox->setEnabled(false);
136  }
137  else
138  {
139  m_ui->m_formatComboBox->setEnabled(false);
140  m_ui->m_ordTypeComboBox->setEnabled(false);
141  }
142 }
143 
145 {
146  if(m_ui->m_ordTypeComboBox->itemData(index).toInt() == -1)
147  m_ui->m_ordinalLineEdit->setEnabled(true);
148  else
149  m_ui->m_ordinalLineEdit->setEnabled(false);
150 }
151 
153 {
154  if(m_ui->m_tempUnitComboBox->itemData(index).toInt() == te::dt::UNKNOWN)
155  m_ui->m_tempValueLineEdit->setEnabled(true);
156  else
157  m_ui->m_tempValueLineEdit->setEnabled(false);
158 }
159 
161 {
162  QString item;
163  m_dataType = dataType;
164 
165  const std::vector<te::dt::Property*>& properties = dataType.get()->getProperties();
166 
167  for (std::size_t i = 0; i < properties.size(); i++)
168  {
169  if(properties.at(i)->getType() == te::dt::DATETIME_TYPE)
170  {
171  item = QString::fromUtf8(properties.at(i)->getName().c_str());
172  m_ui->m_phenomenomComboBox->addItem(item);
173  m_ui->m_resultComboBox->addItem(item);
174  m_ui->m_validComboBox->addItem(item);
175  }
176  }
177 }
boost::shared_ptr< DataSetType > DataSetTypePtr
Definition: DataSetType.h:653
int getDateFormat()
Returns the format that the indicates how the date will be displayed.
std::unique_ptr< Ui::TemporalPropertiesWidgetForm > m_ui
The widget&#39;s form.
void setUp(const te::da::DataSetTypePtr dataType)
Adjusts the widget values according to the given datasettype.
int getOrdinalType()
Returns the selected ordinal type.
Ui::TemporalPropertiesWidgetForm * getForm()
Returns a pointer to the widget&#39;s form.
int getTemporalUnit()
Returns the selected temporal unit.
te::da::DataSetTypePtr m_dataType
The datasetType that will be used to generate the spatio-temporal layer.
std::string getPhenomenonTime()
Returns the name of the property that holds the Phenomenom Time.
int getDateType()
Returns the index of the datetime type.
std::string getUserOrdinalType()
Returns a custom (user-defined) Ordinal Type.
std::string getTemporalValue()
Returns a custom (user-defined) temporal unit.
std::string getResultTime()
Returns the name of the property that holds the Result Time.
TemporalPropertiesWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructor.
std::string getValidTime()
Returns the name of the property that holds the Valid Time.