DataSourceExplorerDialog.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/connector/DataSourceExplorerDialog.cpp
22 
23  \brief A dialog for connecting to a data source.
24 */
25 
26 // TerraLib
27 #include "../../../../core/translator/Translator.h"
28 #include "../../Exception.h"
31 #include "ui_DataSourceExplorerDialogForm.h"
32 #include "ui_DataSourceSelectorWidgetForm.h"
33 
34 // Qt
35 #include <QMessageBox>
36 #include <QVBoxLayout>
37 
39  : QDialog(parent, f),
40  m_ui(new Ui::DataSourceExplorerDialogForm)
41 {
42 // add controls
43  m_ui->setupUi(this);
44 
45  m_selectorWidget.reset(new DataSourceSelectorWidget(this, f));
46 
47  QVBoxLayout* layout = new QVBoxLayout(this);
48  layout->addWidget(m_selectorWidget.get(), 1);
49  layout->addWidget(m_ui->layoutWidget, 0);
50 
51 // connect signal and slots
52  connect(m_ui->m_okPushButton, SIGNAL(pressed()), this, SLOT(okPushButtonPressed()));
53  connect(m_selectorWidget->getForm()->m_datasourceListWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(okPushButtonPressed()));
54 
55  m_ui->m_helpPushButton->setPageReference("widgets/datasource_explorer/datasource_explorer.html");
56 }
57 
59  default;
60 
62 {
63  m_selectorWidget.get()->setDataSource(dsType);
64 }
65 
66 const std::list<te::da::DataSourceInfoPtr>& te::qt::widgets::DataSourceExplorerDialog::getSelecteds() const
67 {
68  return m_selecteds;
69 }
70 
72 {
73  return m_selectorWidget.get();
74 }
75 
77 {
78  try
79  {
80  m_selecteds = m_selectorWidget->getSelecteds();
81 
82  accept();
83  }
84  catch(const std::exception& e)
85  {
86  QMessageBox::warning(this,
87  tr("TerraLib Qt Components"),
88  tr(e.what()));
89 
90  m_selecteds.clear();
91  }
92  catch(...)
93  {
94  QMessageBox::warning(this,
95  tr("TerraLib Qt Components"),
96  tr("Unknown error while selecting a data source!"));
97 
98  m_selecteds.clear();
99  }
100 }
std::unique_ptr< Ui::DataSourceExplorerDialogForm > m_ui
std::list< te::da::DataSourceInfoPtr > m_selecteds
A dialog for selecting a data source.
std::unique_ptr< DataSourceSelectorWidget > m_selectorWidget
A dialog for selecting a data source.
DataSourceSelectorWidget * getSelectorWidget() const
A dialog for selecting a data source.
const std::list< te::da::DataSourceInfoPtr > & getSelecteds() const
DataSourceExplorerDialog(QWidget *parent=0, Qt::WindowFlags f=0)