All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ConstraintWidget.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/ConstraintWidget.cpp
22 
23  \brief This file has the ConstraintWidget class.
24 */
25 
26 // TerraLib
27 #include "../../../dataaccess/dataset/DataSetType.h"
28 #include "../utils/DoubleListWidget.h"
29 #include "ConstraintWidget.h"
30 #include "ui_ConstraintWidgetForm.h"
31 #include "ui_DoubleListWidgetForm.h"
32 
33 // Qt
34 #include <QMessageBox>
35 
37  : QWidget(parent, f),
38  m_ui(new Ui::ConstraintWidgetForm)
39 {
40  m_ui->setupUi(this);
41 
42  //add double list widget to this form
43  m_doubleListWidget = new DoubleListWidget(m_ui->m_widget);
44  m_doubleListWidget->getForm()->m_leftItemsLabel->setText(tr("Available Properties"));
45  m_doubleListWidget->getForm()->m_rightItemsLabel->setText(tr("Selected Properties"));
46 
47  QGridLayout* layout = new QGridLayout(m_ui->m_widget);
48  layout->addWidget(m_doubleListWidget);
49 
50  //set properties names
51  m_dsType = dsType;
52 
53  if(m_dsType)
54  {
55  std::vector<std::string> propValues;
56 
57  for(size_t t = 0; t < m_dsType->getProperties().size(); ++t)
58  {
59  propValues.push_back(m_dsType->getProperty(t)->getName());
60  }
61 
63  }
64 }
65 
67 {
68 }
69 
70 Ui::ConstraintWidgetForm* te::qt::widgets::ConstraintWidget::getForm() const
71 {
72  return m_ui.get();
73 }
74 
76 {
77 //get index name
78  if(m_ui->m_nameLineEdit->text().isEmpty())
79  {
80  QMessageBox::warning(this, tr("Warning"), tr("Constraint name not defined."));
81  return false;
82  }
83 
84  std::string constraintName = m_ui->m_nameLineEdit->text().toStdString();
85 
86 //get properties
87  std::vector<std::string> vec = m_doubleListWidget->getOutputValues();
88 
89  if(vec.empty())
90  {
91  QMessageBox::warning(this, tr("Warning"), tr("No property selected."));
92  return false;
93  }
94 
95  return true;
96 }
97 
Property * getProperty(std::size_t i) const
It returns the i-th property.
std::auto_ptr< Ui::ConstraintWidgetForm > m_ui
te::qt::widgets::DoubleListWidget * m_doubleListWidget
This file has the ConstraintWidget class.
A class that models the description of a dataset.
Definition: DataSetType.h:72
void setInputValues(std::vector< std::string > values)
const std::vector< Property * > & getProperties() const
It returns the list of properties describing the CompositeProperty.
Ui::ConstraintWidgetForm * getForm() const
ConstraintWidget(te::da::DataSetType *dsType, QWidget *parent=0, Qt::WindowFlags f=0)
Ui::DoubleListWidgetForm * getForm() const
bool checkParameters()
Check the interface parameters.
const std::string & getName() const
It returns the property name.
Definition: Property.h:127