All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DataSetSelectorDialog.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/dataset/selector/DataSetSelectorDialog.cpp
22 
23  \brief ....
24 */
25 
26 // TerraLib
27 #include "../../datasource/core/DataSourceType.h"
28 #include "../../datasource/core/DataSourceTypeManager.h"
29 #include "../../datasource/explorer/DataSetItem.h"
30 #include "../explorer/DataSetTreeView.h"
31 #include "DataSetSelectorDialog.h"
32 #include "DataSetSelectorWidget.h"
33 #include "ui_DataSetSelectorDialogForm.h"
34 
35 // Qt
36 #include <QMessageBox>
37 
39  : QDialog(parent, f),
40  m_ui(new Ui::DataSetSelectorDialogForm),
41  m_selectMode(CHECKED_ITEMS)
42 {
43 // add controls
44  m_ui->setupUi(this);
45 
46 // init controls
47  m_selectorW.reset(new DataSetSelectorWidget(this));
48  m_ui->m_selectorWidgetLayout->addWidget(m_selectorW.get(), 1);
49 
50 // connect signals and slots
51  connect(m_selectorW->getTreeView(), SIGNAL(toggled(DataSetItem*)), this, SLOT(onDataSetToggled(DataSetItem*)));
52  connect(m_selectorW->getTreeView(), SIGNAL(clicked(DataSetItem*)), this, SLOT(onDataSetClicked(DataSetItem*)));
53  connect(m_selectorW->getTreeView(), SIGNAL(toggled(DataSetGroupItem*)), this, SLOT(onDataSetGroupToggled(DataSetGroupItem*)));
54  connect(m_selectorW->getTreeView(), SIGNAL(clicked(DataSetGroupItem*)), this, SLOT(onDataSetGroupClicked(DataSetGroupItem*)));
55 
56  m_ui->m_helpPushButton->setPageReference("widgets/dataset_selector/dataset_selector.html");
57 }
58 
60 {
61 }
62 
64 {
65  m_selectorW->set(ds, useCheckableItems);
66 
67  if(ds.get() == 0)
68  return;
69 
70  QString title(tr("Dataset Selection - %1"));
71  title = title.arg(QString::fromStdString(ds->getTitle()));
72 
73  setWindowTitle(title);
74 
75  const DataSourceType* dsType = DataSourceTypeManager::getInstance().get(ds->getType());
76 
77  if(dsType == 0)
78  return;
79 
80  title = tr("%1 - %2");
81  title = title.arg(QString::fromStdString(dsType->getTitle())).arg(QString::fromStdString(ds->getTitle()));
82 
83  m_ui->m_titleLabel->setText(title);
84 }
85 
86 std::list<te::da::DataSetTypePtr> te::qt::widgets::DataSetSelectorDialog::getCheckedDataSets() const
87 {
88  return m_selectorW->getCheckedDataSets();
89 }
90 
92 {
93  return m_selectorW->getCheckedGeomProperties();
94 }
95 
96 std::list<te::da::DataSetTypePtr> te::qt::widgets::DataSetSelectorDialog::getSelectedDataSets() const
97 {
98  return m_selectorW->getSelectedDataSets();
99 }
100 
102 {
103  return m_selectorW->getSelectedGeomProperties();
104 }
105 
107 {
108  m_selectMode = m;
109 }
110 
112 {
113  return m_selectorW.get();
114 }
115 
117 {
118  updateSelectPushButton();
119 }
120 
122 {
123  updateSelectPushButton();
124 }
125 
127 {
128  updateSelectPushButton();
129 }
130 
132 {
133  updateSelectPushButton();
134 }
135 
137 {
138  if(m_selectMode == CHECKED_ITEMS)
139  m_ui->m_selectPushButton->setEnabled(m_selectorW->hasCheckedDataSets());
140  else //if(m_selectMode == SELECTED_ITEMS)
141  m_ui->m_selectPushButton->setEnabled(m_selectorW->hasSelectedDataSets());
142 }
std::auto_ptr< Ui::DataSetSelectorDialogForm > m_ui
void onDataSetGroupClicked(DataSetGroupItem *item)
std::list< te::da::DataSetTypePtr > getSelectedDataSets() const
virtual std::string getTitle() const =0
A wizard for selecting datasets from a data source.
void onDataSetGroupToggled(DataSetGroupItem *item)
DataSetSelectorWidget * getSelectorWidget() const
std::list< std::string > getCheckedGeomProperties() const
std::list< std::string > getSelectedGeomProperties() const
static DataSourceTypeManager & getInstance()
It returns a reference to the singleton instance.
void set(const te::da::DataSourceInfoPtr &ds, bool useCheckableItems=false)
DataSetSelectorDialog(QWidget *parent=0, Qt::WindowFlags f=0)
std::list< te::da::DataSetTypePtr > getCheckedDataSets() const
A wizard for selecting datasets from a data source.
const DataSourceType * get(const std::string &name) const
std::auto_ptr< DataSetSelectorWidget > m_selectorW
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
A base class for the suppported types of data source.