All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FieldsDialog.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/externaltable/FieldsDialog.cpp
22 
23  \brief A Qt Dilaog that allows users to modify which fields will be included in a query
24 */
25 
26 // TerraLib
27 #include "../../../dataaccess/query/Field.h"
28 #include "../../../dataaccess/query/PropertyName.h"
29 #include "../utils/DoubleListWidget.h"
30 #include "FieldsDialog.h"
31 #include "ui_FieldsDialogForm.h"
32 
33 //QT
34 #include <QMessageBox>
35 
36 // STL
37 #include <cassert>
38 
39 te::qt::widgets::FieldsDialog::FieldsDialog(QWidget* parent, Qt::WindowFlags f)
40  : QDialog(parent, f),
41  m_ui(new Ui::FieldsDialogForm)
42 {
43  m_ui->setupUi(this);
44 
45  //Adjusting the doubleListWidget that will be used to configure the query's fields.
46  m_fieldsWidget.reset(new DoubleListWidget(m_ui->m_FieldsFrame));
47  QGridLayout* fieldsLayout = new QGridLayout(m_ui->m_FieldsFrame);
48  fieldsLayout->addWidget(m_fieldsWidget.get());
49  fieldsLayout->setContentsMargins(0, 0, 0, 0);
50 
51  m_ui->m_helpPushButton->setPageReference("widgets/external_table/fields_dialog.html");
52 
53  //Connecting signals and slots
54  connect(m_ui->m_OkPushButton, SIGNAL(clicked()), this, SLOT(onOkPushButtonClicked()));
55  connect(m_ui->m_CancelPushButton, SIGNAL(clicked()), this, SLOT(onCancelPushButtonClicked()));
56 }
57 
59 {
60 }
61 
63 {
64  m_fieldsWidget->clearInputValues();
65 }
66 
68 {
69  m_fieldsWidget->clearOutputValues();
70 }
71 
72 void te::qt::widgets::FieldsDialog::setInputValues(std::vector<std::string> values)
73 {
74  m_fieldsWidget->setInputValues(values);
75 }
76 
77 void te::qt::widgets::FieldsDialog::setOutputValues(std::vector<std::string> values)
78 {
79  m_fieldsWidget->setOutputValues(values);
80 }
81 
82 void te::qt::widgets::FieldsDialog::setFixedOutputValues(std::vector<std::string> values, std::string iconName)
83 {
84  m_fieldsWidget->setFixedOutputValues(values, iconName);
85 }
86 
88 {
89  m_fieldsWidget->setLeftLabel(value);
90 }
91 
93 {
94  m_fieldsWidget->setRightLabel(value);
95 }
96 
98 {
99  te::da::Fields* fields = new te::da::Fields;
100 
101  std::vector<std::string> values = m_fieldsWidget->getOutputValues();
102 
103  for(size_t t = 0; t < values.size(); ++t)
104  {
105  te::da::Field* f = new te::da::Field(new te::da::PropertyName(values[t]));
106 
107  fields->push_back(f);
108  }
109 
110  return fields;
111 }
112 
114 {
115  if(m_ui->m_rightRadioButton->isChecked())
116  return te::da::RIGHT_JOIN;
117  else if(m_ui->m_joinRadioButton->isChecked())
118  return te::da::JOIN;
119  else
120  return te::da::LEFT_JOIN;
121 }
122 
124 {
125  this->accept();
126 }
127 
129 {
130  m_ui->m_leftRadioButton->setChecked(true);
131  m_fieldsWidget->clearInputValues();
132  m_fieldsWidget->clearOutputValues();
133  this->reject();
134 }
void setInputValues(std::vector< std::string > values)
Sets the input values list.
The Field class can be used to model an expression that takes part of the output items of a SELECT...
Definition: Field.h:50
A class that models the name of any property of an object.
Definition: PropertyName.h:50
te::da::JoinType getJoinType()
Returns the selected JoinType.
te::da::Fields * getFields()
Returns the selected fields.
std::auto_ptr< DoubleListWidget > m_fieldsWidget
The widget used to select which fields will be added to the query.
Definition: FieldsDialog.h:132
void setRightLabel(std::string value)
Sets the label displayed above the right list widget.
void clearOutputValues()
Clears the output values list.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
Definition: Fields.h:37
JoinType
The type of join in a query.
Definition: Enums.h:49
void setOutputValues(std::vector< std::string > values)
Sets the output values list.
FieldsDialog(QWidget *parent=0, Qt::WindowFlags f=0)
Constructor.
void setLeftLabel(std::string value)
Sets the label displayed above the left list widget.
void clearInputValues()
Clears the input values list.
std::auto_ptr< Ui::FieldsDialogForm > m_ui
The widget's form.
Definition: FieldsDialog.h:133
A Qt Dialog that allows users to modify which fields will be included in a query. ...
void setFixedOutputValues(std::vector< std::string > values, std::string iconName)
Sets the fixed output values list.