AddColumnDialog.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 "AddColumnDialog.h"
21 
22 #include "../../../datatype/DateTimeProperty.h"
23 #include "../../../datatype/SimpleProperty.h"
24 
25 #include <ui_AddColumnDialogForm.h>
26 
27 te::dt::Property* GetProperty(const int& propertyType)
28 {
29  if (propertyType == te::dt::DATETIME_TYPE)
30  {
31  return new te::dt::DateTimeProperty("");
32  }
33  else
34  {
35  return new te::dt::SimpleProperty("", propertyType);
36  }
37 }
38 
40 QDialog(parent)
41 {
42  m_ui.reset(new Ui::AddColumnDialogForm);
43  m_ui->setupUi(this);
44 
45  m_ui->m_helpBTN->setPageReference("widgets/table/addColumn.html");
46 
47  fillTypes();
48 
49  connect(m_ui->m_cancelBTN, SIGNAL(pressed()), SLOT(reject()));
50  connect(m_ui->m_okBTN, SIGNAL(pressed()), SLOT(accept()));
51 }
52 
54 
56 {
57  m_ui->m_colTypeCBB->addItem(tr("Integer"), QVariant(te::dt::INT32_TYPE));
58  m_ui->m_colTypeCBB->addItem(tr("Real"), QVariant(te::dt::DOUBLE_TYPE));
59  m_ui->m_colTypeCBB->addItem(tr("String"), QVariant(te::dt::STRING_TYPE));
60  m_ui->m_colTypeCBB->addItem(tr("Date"), QVariant(te::dt::DATETIME_TYPE));
61 }
62 
64 {
65  te::dt::Property* pr = GetProperty(m_ui->m_colTypeCBB->itemData(m_ui->m_colTypeCBB->currentIndex(), Qt::UserRole).toInt());
66 
67  pr->setName(m_ui->m_colNameLNE->text().toUtf8().data());
68 
69  return pr;
70 }
71 
73 {
74  m_ui->m_tblNameCBB->addItem(name.c_str());
75 }
An atomic property like an integer or double.
void setTableName(const std::string &name)
It models a property definition.
Definition: Property.h:59
te::dt::Property * GetProperty(const int &propertyType)
void setName(const std::string &name)
It sets the property name.
Definition: Property.h:137
te::dt::Property * getNewProperty() const
A Qt dialog for inserting columns into a table.
std::unique_ptr< Ui::AddColumnDialogForm > m_ui
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.