src/terralib/ws/ogc/wcs/qt/WCSConnector.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/ws/ogc/wcs/qt/WCSConnector.cpp
22 
23  \brief OGC Web Coverage Service (WCS) connector implementation for the Qt data source widget.
24 */
25 
26 #include "WCSConnector.h"
27 #include "WCSConnectorDialog.h"
28 
29 // TerraLib
30 #include "../../../../dataaccess/datasource/DataSource.h"
31 #include "../../../../dataaccess/datasource/DataSourceInfoManager.h"
32 #include "../../../../dataaccess/datasource/DataSourceManager.h"
33 
34 // Qt
35 #include <QFileDialog>
36 #include <QMessageBox>
37 
39  : te::qt::widgets::AbstractDataSourceConnector(parent, f)
40 {
41 }
42 
44 
45 void te::ws::ogc::wcs::qt::WCSConnector::connect(std::list<te::da::DataSourceInfoPtr>& datasources)
46 {
47  std::unique_ptr<WCSConnectorDialog> cdialog(new WCSConnectorDialog(static_cast<QWidget*>(parent())));
48 
49  cdialog->exec();
50 
51  te::da::DataSourceInfoPtr ds = cdialog->getDataSource();
52 
53  if(ds.get() != nullptr)
54  {
56  datasources.push_back(ds);
57 
58  te::da::DataSourceManager::getInstance().make(ds->getId(), ds->getType(), ds->getConnInfo());
59  }
60 }
61 
63  std::list<te::da::DataSourceInfoPtr>& /*datasources*/)
64 {
65  QMessageBox::warning(this,
66  tr("TerraLib Qt Components"),
67  tr("Not implemented yet!\nWe will provide it soon!"));
68 }
69 
70 void te::ws::ogc::wcs::qt::WCSConnector::update(std::list<te::da::DataSourceInfoPtr>& datasources)
71 {
72  for(std::list<te::da::DataSourceInfoPtr>::iterator it = datasources.begin(); it != datasources.end(); ++it)
73  {
74  if(it->get() == nullptr)
75  continue;
76 
77  std::unique_ptr<WCSConnectorDialog> cdialog(new WCSConnectorDialog(static_cast<QWidget*>(parent())));
78 
79  cdialog->set(*it);
80 
81  int retval = cdialog->exec();
82 
83  if(retval == QDialog::Rejected)
84  continue;
85 
86  // Don't forget to replace the driver
87  te::da::DataSourcePtr driver = cdialog->getDriver();
88 
89  if(driver.get() != nullptr)
90  {
91  if(te::da::DataSourceManager::getInstance().find(driver->getId()) != nullptr)
92  te::da::DataSourceManager::getInstance().detach(driver->getId());
93 
95  }
96  }
97 }
98 
99 void te::ws::ogc::wcs::qt::WCSConnector::remove(std::list<te::da::DataSourceInfoPtr>& datasources)
100 {
101  for(std::list<te::da::DataSourceInfoPtr>::iterator it = datasources.begin(); it != datasources.end(); ++it)
102  {
103  if(it->get() == nullptr)
104  continue;
105 
106  // First remove driver
108 
109  if(rds.get())
110  {
112  rds.reset();
113  }
114 
115  // Then remove data source
116  te::da::DataSourceInfoManager::getInstance().remove((*it)->getId());
117  }
118 }
A dialog window for showing the WCS connector widget.
WCSConnector(QWidget *parent=0, Qt::WindowFlags f=0)
boost::shared_ptr< DataSource > DataSourcePtr
A dialog window for showing the WCS connector widget.
static te::dt::Date ds(2010, 01, 01)
void update(std::list< te::da::DataSourceInfoPtr > &datasources)
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
URI C++ Library.
Definition: Attributes.h:37
void create(std::list< te::da::DataSourceInfoPtr > &datasources)
OGC Web Coverage Service (WCS) connector implementation for the Qt data source widget.
void connect(std::list< te::da::DataSourceInfoPtr > &datasources)
void remove(std::list< te::da::DataSourceInfoPtr > &datasources)
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr