All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AddIndex.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 "AddIndex.h"
29 
31  : QDialog(parent),
32  m_ds(ds),
33  m_index(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(addToIndexPropertiesPushButton, SIGNAL(clicked()), this, SLOT(addToIndexPropertiesPushButtonClicked()));
56  connect(removeFromIndexPropertiesPushButton, SIGNAL(clicked()), this, SLOT(removefromIndexPropertiesPushButtonClicked()));
57  connect(okPushButton, SIGNAL(clicked()), this, SLOT(okPushButtonClicked()));
58  connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancelPushButtonClicked()));
59  connect(helpPushButton, SIGNAL(clicked()), this, SLOT(helpPushButtonClicked()));
60 }
61 
63 {
64 }
65 
66 void te::qt::widgets::AddIndex::dataSetComboBoxChanged(const QString& datasetNames)
67 {
68  dataSetPropertiesListWidget->clear();
69  indexPropertiesListWidget->clear();
70 
71  std::auto_ptr<te::da::DataSetType> dt;
72 
73  // Get the DataSetType associated to the dataset selected
74  if(dataSetComboBox->currentText().isEmpty() == false)
75  dt = m_ds->getDataSetType(datasetNames.toStdString());
76 
77  // Fill the dataSetPropertiesListWidget with the names of the properties of the dataset selected
78  size_t numProperties = dt->size();
79 
80  for (size_t i = 0; i < numProperties; ++i)
81  dataSetPropertiesListWidget->addItem(dt->getProperty(i)->getName().c_str());
82 }
83 
85 {
86 }
87 
88 
90 {
91 }
92 
93 
95 {
96  accept();
97 }
98 
100 {
101  reject();
102 }
103 
105 {
106 }
107 
109 {
110 }
It adds an index associated to a DataSetType.
virtual std::vector< std::string > getDataSetNames()
It gets the dataset names available in the data source.
Definition: DataSource.cpp:143
te::da::DataSource * m_ds
Definition: AddIndex.h:72
void addToIndexPropertiesPushButtonClicked()
Definition: AddIndex.cpp:84
void closeEvent(QCloseEvent *e)
Definition: AddIndex.cpp:108
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:116
void removeFromIndexPropertiesPushButtonClicked()
Definition: AddIndex.cpp:89
AddIndex(te::da::DataSource *ds, QWidget *parent=0)
Definition: AddIndex.cpp:30
void dataSetComboBoxChanged(const QString &dataSet)
Definition: AddIndex.cpp:66