All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "../../../../common/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 {
60 }
61 
63 {
64  m_selectorWidget.get()->setDataSource(dsType);
65 }
66 
67 const std::list<te::da::DataSourceInfoPtr>& te::qt::widgets::DataSourceExplorerDialog::getSelecteds() const
68 {
69  return m_selecteds;
70 }
71 
73 {
74  return m_selectorWidget.get();
75 }
76 
78 {
79  try
80  {
81  m_selecteds = m_selectorWidget->getSelecteds();
82 
83  accept();
84  }
85  catch(const std::exception& e)
86  {
87  QMessageBox::warning(this,
88  tr("TerraLib Qt Components"),
89  tr(e.what()));
90 
91  m_selecteds.clear();
92  }
93  catch(...)
94  {
95  QMessageBox::warning(this,
96  tr("TerraLib Qt Components"),
97  tr("Unknown error while selecting a data source!"));
98 
99  m_selecteds.clear();
100  }
101 }
A dialog for selecting a data source.
A dialog for selecting a data source.
DataSourceSelectorWidget * getSelectorWidget() const
A dialog for selecting a data source.
std::auto_ptr< Ui::DataSourceExplorerDialogForm > m_ui
const std::list< te::da::DataSourceInfoPtr > & getSelecteds() const
DataSourceExplorerDialog(QWidget *parent=0, Qt::WindowFlags f=0)
std::auto_ptr< DataSourceSelectorWidget > m_selectorWidget