All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StringPropertyWidget.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/property/StringPropertyWidget.h
22 
23  \brief Defines the StringPropertyWidget class.
24 */
25 
26 // Terralib
27 #include "../../../datatype/Enums.h"
28 #include "../../../datatype/StringProperty.h"
29 #include "StringPropertyWidget.h"
30 #include "ui_StringPropertyWidgetForm.h"
31 
32 
34  : SimplePropertyWidget(parent),
35  m_ui(new Ui::StringPropertyWidgetForm)
36 {
37  m_ui->setupUi(this);
38 
39  //fill combo box
40  m_ui->m_typeComboBox->addItem(tr("String"), te::dt::STRING);
41  m_ui->m_typeComboBox->addItem(tr("Fixed String"), te::dt::FIXED_STRING);
42  m_ui->m_typeComboBox->addItem(tr("Var String"), te::dt::VAR_STRING);
43 }
44 
46 {
47 
48 }
49 
51 {
52  int index = m_ui->m_typeComboBox->currentIndex();
53  int type = m_ui->m_typeComboBox->itemData(index).toInt();
54 
55  te::dt::StringProperty* strP = dynamic_cast<te::dt::StringProperty*>(sp);
56 
57  if(strP)
58  {
59  strP->setSubtype((te::dt::StringType)type);
60 
61  if(m_ui->m_sizeLineEdit->text().isEmpty() == false)
62  {
63  bool ok = false;
64  unsigned int size = m_ui->m_sizeLineEdit->text().toUInt(&ok);
65 
66  if(ok)
67  strP->setSize(size);
68  }
69  }
70 }
StringType
The subtype of string property.
Definition: Enums.h:171
A base widget for simple properties.
An atomic property like an integer or double.
std::auto_ptr< Ui::StringPropertyWidgetForm > m_ui
void setSubtype(StringType t)
It sets the string property sub type.
void setSize(std::size_t s)
It sets the maximum number of characters for a varying string, or the number of characters for a fixe...
Defines the StringPropertyWidget class.
virtual void fillProperty(te::dt::SimpleProperty *sp)
The type for string types: FIXED_STRING, VAR_STRING or STRING.