All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FieldsWizardPage.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/query/FieldsWizardPage.cpp
22 
23  \brief This file has the FieldsWizardPage class.
24 */
25 
26 // TerraLib
27 #include "../../../dataaccess/query/Field.h"
28 #include "../../../dataaccess/query/PropertyName.h"
29 #include "../utils/DoubleListWidget.h"
30 #include "FieldsWizardPage.h"
31 #include "ui_DoubleListWidgetForm.h"
32 
33 // Qt
34 #include <QGridLayout>
35 
36 
38  : QWizardPage(parent)
39 {
40  m_widget.reset(new DoubleListWidget(this));
41 
42  QGridLayout* layout = new QGridLayout(this);
43 
44  layout->addWidget(m_widget.get());
45 
46  //configure page
47  this->setTitle(tr("Attribute Selection"));
48  this->setSubTitle(tr("Select the attributes to be listed."));
49 
50  m_widget->getForm()->m_leftItemsLabel->setText(tr("Available Properties"));
51  m_widget->getForm()->m_rightItemsLabel->setText(tr("Used Properties"));
52 
53  //connect slots
54  connect(m_widget.get(), SIGNAL(itemChanged()), this, SLOT(onItemChanged()));
55 }
56 
58 {
59 }
60 
62 {
63  if(m_widget->getOutputValues().empty())
64  return false;
65 
66  return true;
67 }
68 
70 {
71  return m_widget.get();
72 }
73 
75 {
76  te::da::Fields* fields = new te::da::Fields;
77 
78  std::vector<std::string> values = m_widget->getOutputValues();
79 
80  for(size_t t = 0; t < values.size(); ++t)
81  {
82  te::da::Field* f = new te::da::Field(new te::da::PropertyName(values[t]));
83 
84  fields->push_back(f);
85  }
86 
87  return fields;
88 }
89 
91 {
92  std::vector<std::string> values;
93 
94  for(std::size_t i = 0; i < fields->size(); ++i)
95  {
96  te::da::Field f = fields->at(i);
97 
99 
100  values.push_back(p->getName());
101  }
102 
103  m_widget->setOutputValues(values);
104 }
105 
107 {
108  emit completeChanged();
109 }
const std::string & getName() const
It returns the property name.
Definition: PropertyName.h:80
The Field class can be used to model an expression that takes part of the output items of a SELECT...
Definition: Field.h:50
DoubleListWidget * getWidget() const
std::auto_ptr< DoubleListWidget > m_widget
A class that models the name of any property of an object.
Definition: PropertyName.h:50
Expression * getExpression() const
It returns the expression set for an output select query.
Definition: Field.cpp:80
This file has the FieldsWizardPage class.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
Definition: Fields.h:37
void setFields(const te::da::Fields *fields)