All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RenameProperty.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2011 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 // Qt
21 #include <QtGui/QtGui>
22 #include <QtGui/QComboBox>
23 #include <QtGui/QMessageBox>
24 
25 // TerraLib
26 #include "../../../dataaccess.h"
27 
28 #include "RenameProperty.h"
29 
31  : QDialog(parent),
32  m_ds(ds),
33  m_property(0)
34 {
35  if (m_ds == 0)
36  QMessageBox::critical(this, tr("Missing a Valid Data Source"), tr("Provide a valid data source!"));
37 
38  setupUi(this);
39 
40  // Get the dataset names of the data source
41  std::vector<std::string> datasetNames = m_ds->getDataSetNames();
42 
43  // Fill alphabetically the dataSetCombobox with the dataset names of the data source
44  QStringList dataSetList;
45 
46  size_t numDataSets = datasetNames.size();
47  for (size_t i = 0; i < numDataSets; ++i)
48  dataSetList << (datasetNames[i]).c_str();
49 
50  dataSetList.sort();
51  dataSetComboBox->addItems(dataSetList);
52 
53  // Connect the signals/slots
54  connect(dataSetComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(dataSetComboBoxChanged(const QString&)));
55  connect(okPushButton, SIGNAL(clicked()), this, SLOT(okPushButtonClicked()));
56  connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancelPushButtonClicked()));
57  connect(helpPushButton, SIGNAL(clicked()), this, SLOT(helpPushButtonClicked()));
58 
59  dataSetComboBoxChanged(dataSetComboBox->currentText());
60 }
61 
63 {
64 }
65 
67 {
68  return m_property->getName();
69 }
70 
72 {
73  return newPropertyNameLineEdit->text().toStdString();
74 }
75 
77 {
78  propertiesComboBox->clear();
79 
80  std::vector<std::string> pNames = m_ds->getPropertyNames(datasetName.toStdString());
81 
82  for (size_t i = 0; i < pNames.size(); ++i)
83  propertiesComboBox->addItem(pNames[i].c_str());
84 }
85 
87 {
88  // Get the property selected
89  int propertyPos = propertiesComboBox->currentIndex();
90 
91  m_property = m_ds->getProperty(dataSetComboBox->currentText().toStdString(), propertyPos).get();
92 
93  accept();
94 }
95 
97 {
98  reject();
99 }
100 
102 {
103 }
104 
106 {
107 }
virtual std::vector< std::string > getDataSetNames()
It gets the dataset names available in the data source.
Definition: DataSource.cpp:143
void dataSetComboBoxChanged(const QString &dataSet)
RenameProperty(te::da::DataSource *ds, QWidget *parent=0)
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:116
It changes the name of a property.