All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RetypeColumnDialog.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 #include "RetypeColumnDialog.h"
21 
22 #include <ui_RetypeColumnDialogForm.h>
23 
24 // TerraLib
31 
32 
33 int GetType(const int& te_type)
34 {
35  switch (te_type)
36  {
37  case te::dt::CHAR_TYPE:
38  case te::dt::UCHAR_TYPE:
40 
41  return 2;
42  break;
43 
44  case te::dt::INT16_TYPE:
46  case te::dt::INT32_TYPE:
48  case te::dt::INT64_TYPE:
50  return 0;
51  break;
52 
53  case te::dt::FLOAT_TYPE:
56  return 1;
57  break;
58 
60  return 3;
61  break;
62 
63  default:
64  return 4;
65  };
66 
67 }
68 
69 QString GetSType(const int& te_type)
70 {
71  int type = GetType(te_type);
72 
73  switch(type)
74  {
75  case 0:
76  return "INT";
77  break;
78 
79  case 1:
80  return "REAL";
81  break;
82 
83  case 2:
84  return "STRING";
85  break;
86 
87  case 3:
88  return "DATETIME";
89  break;
90 
91  default:
92  return "UNKNOWN TYPE";
93  break;
94  };
95 }
96 
97 int GetIType (const int& type)
98 {
99  switch (type)
100  {
101  case 0:
102  return te::dt::INT32_TYPE;
103  break;
104 
105  case 1:
106  return te::dt::DOUBLE_TYPE;
107  break;
108 
109  case 2:
110  return te::dt::STRING_TYPE;
111  break;
112 
113  case 3:
114  return te::dt::DATETIME_TYPE;
115  break;
116  };
117 
118  return -1;
119 }
120 
122 QDialog(parent)
123 {
124  m_ui.reset(new Ui::RetypeColumnDialogForm);
125  m_ui->setupUi(this);
126 
127  connect (m_ui->m_okPushButton, SIGNAL(pressed()), SLOT(accept()));
128  connect (m_ui->m_cancelPushButton, SIGNAL(pressed()), SLOT(reject()));
129 }
130 
132 {
133 }
134 
136 {
137  m_ui->m_tableNameLineEdit->setText(name);
138 }
139 
141 {
142  m_ui->m_typeLineEdit->setText(GetSType(type));
143 }
144 
146 {
147  m_ui->m_columnNameLineEdit->setText(name);
148 }
149 
151 {
152  m_ui->m_sizeLineEdit->setText(QString::number(size));
153 }
154 
156 {
157  return GetIType(m_ui->m_typeComboBox->currentIndex());
158 }
159 
161 {
162  return m_ui->m_sizeComboBox->currentText().toInt();
163 }
164 
165 std::auto_ptr<te::dt::Property> te::qt::widgets::RetypeColumnDialog::getProperty()
166 {
167  std::auto_ptr<te::dt::Property> res;
168  std::string name = m_ui->m_columnNameLineEdit->text().toStdString();
169 
170  int cType = getColumnType();
171 
172  switch (cType)
173  {
174  case te::dt::INT32_TYPE:
175  case te::dt::DOUBLE_TYPE:
176  res.reset(new te::dt::SimpleProperty(name, cType));
177  break;
178 
179  case te::dt::STRING_TYPE:
180  res.reset(new te::dt::StringProperty(name, te::dt::STRING));
181  break;
182 
184  res.reset(new te::dt::DateTimeProperty(name, te::dt::DATE_PERIOD));
185  break;
186  };
187 
188  return res;
189 }
std::auto_ptr< te::dt::Property > getProperty()
An atomic property like an integer or double.
void setTableName(const QString &name)
The type for arbitrary precision numbers, like numeric(p, q).
std::auto_ptr< Ui::RetypeColumnDialogForm > m_ui
void setColumnName(const QString &name)
The type for string types: FIXED_STRING, VAR_STRING or STRING.
The type for string types: FIXED_STRING, VAR_STRING or STRING.
QString GetSType(const int &te_type)
int GetType(const int &te_type)
The type for date and time types: date, date period, date duration, time duration, time instant, time period, time instant with time zone or time period with time zone.
The type for date and time types.
An atomic property like an integer or double.
General enumerations for the data type module.
It models a property definition.
int GetIType(const int &type)