All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::fromStdString("YYYY"), QVariant(te::dt::YYYY));
62  m_ui->m_formatComboBox->addItem(QString::fromStdString("YY"), QVariant(te::dt::YY));
63  m_ui->m_formatComboBox->addItem(QString::fromStdString("YYYYMM"), QVariant(te::dt::YYYYMM));
64  m_ui->m_formatComboBox->addItem(QString::fromStdString("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 {
74 }
75 
76 Ui::TemporalPropertiesWidgetForm* te::qt::widgets::TemporalPropertiesWidget::getForm()
77 {
78  return m_ui.get();
79 }
80 
82 {
83  return m_ui->m_phenomenomComboBox->currentText().toStdString();
84 }
85 
87 {
88  return m_ui->m_resultComboBox->currentText().toStdString();
89 }
90 
92 {
93  return m_ui->m_validComboBox->currentText().toStdString();
94 }
95 
97 {
98  return m_ui->m_typeComboBox->currentIndex();
99 }
100 
102 {
103  return m_ui->m_ordTypeComboBox->currentIndex();
104 }
105 
107 {
108  return m_ui->m_tempUnitComboBox->currentIndex();
109 }
110 
112 {
113  return m_ui->m_tempValueLineEdit->text().toStdString();
114 }
115 
117 {
118  return m_ui->m_ordinalLineEdit->text().toStdString();
119 }
120 
122 {
123  return m_ui->m_formatComboBox->currentData().toInt();
124 }
125 
127 {
128  if(m_ui->m_typeComboBox->itemData(index).toInt() == te::dt::STRING_TYPE)
129  {
130  m_ui->m_formatComboBox->setEnabled(true);
131  m_ui->m_ordTypeComboBox->setEnabled(false);
132  }
133  else if(m_ui->m_typeComboBox->itemData(index).toInt() == te::dt::ORDINAL_TIME_INSTANT)
134  {
135  m_ui->m_ordTypeComboBox->setEnabled(true);
136  m_ui->m_formatComboBox->setEnabled(false);
137  }
138  else
139  {
140  m_ui->m_formatComboBox->setEnabled(false);
141  m_ui->m_ordTypeComboBox->setEnabled(false);
142  }
143 }
144 
146 {
147  if(m_ui->m_ordTypeComboBox->itemData(index).toInt() == -1)
148  m_ui->m_ordinalLineEdit->setEnabled(true);
149  else
150  m_ui->m_ordinalLineEdit->setEnabled(false);
151 }
152 
154 {
155  if(m_ui->m_tempUnitComboBox->itemData(index).toInt() == te::dt::UNKNOWN)
156  m_ui->m_tempValueLineEdit->setEnabled(true);
157  else
158  m_ui->m_tempValueLineEdit->setEnabled(false);
159 }
160 
162 {
163  QString item;
164  m_dataType = dataType;
165 
166  const std::vector<te::dt::Property*>& properties = dataType.get()->getProperties();
167 
168  for (std::size_t i = 0; i < properties.size(); i++)
169  {
170  if(properties.at(i)->getType() == te::dt::DATETIME_TYPE)
171  {
172  item = QString::fromStdString(properties.at(i)->getName());
173  m_ui->m_phenomenomComboBox->addItem(item);
174  m_ui->m_resultComboBox->addItem(item);
175  m_ui->m_validComboBox->addItem(item);
176  }
177  }
178 }
boost::shared_ptr< DataSetType > DataSetTypePtr
Definition: DataSetType.h:653
int getDateFormat()
Returns the format that the indicates how the date will be displayed.
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's form.
int getTemporalUnit()
Returns the selected temporal unit.
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::auto_ptr< Ui::TemporalPropertiesWidgetForm > m_ui
The widget's form.
std::string getValidTime()
Returns the name of the property that holds the Valid Time.