InputLayerWidget.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/rp/InputLayerWidget.cpp
22 
23  \brief This file has the InputLayerWidget class.
24 */
25 
26 // TerraLib
27 #include "../../../dataaccess/datasource/DataSourceInfo.h"
28 #include "../datasource/selector/DataSourceSelectorDialog.h"
29 #include "../layer/search/LayerSearchDialog.h"
30 #include "../layer/search/LayerSearchWidget.h"
31 #include "../Utils.h"
32 #include "InputLayerWidget.h"
33 #include "ui_InputLayerWidgetForm.h"
34 
35 // BOOST Includes
36 #include <boost/filesystem.hpp>
37 
38 // QT
39 #include <QFileDialog>
40 
41 
43  : QWidget(parent, f),
44  m_ui(new Ui::InputLayerWidgetForm)
45 {
46  m_ui->setupUi(this);
47 
48  m_layer = nullptr;
49 
50  connect(m_ui->m_searchLayerToolButton, SIGNAL(clicked()), this, SLOT(onSearchLayerToolButtonClicked()));
51  connect(m_ui->m_layersComboBox, SIGNAL(activated(int)), this, SLOT(onLayersComboBoxActivated(int)));
52 }
53 
55 
56 Ui::InputLayerWidgetForm* te::qt::widgets::InputLayerWidget::getForm() const
57 {
58  return m_ui.get();
59 }
60 
62 {
63  return m_layer;
64 }
65 
67 {
68  return "GDAL";
69 }
70 
71 std::map<std::string, std::string> te::qt::widgets::InputLayerWidget::getInfo() const
72 {
73  std::map<std::string, std::string> rinfo;
74 
75  //rinfo["URI"] = m_ui->m_repositoryLineEdit->text().toUtf8().data();
76 
77  return rinfo;
78 }
79 
81 {
82  m_layer = layer;
83 }
84 
85 void te::qt::widgets::InputLayerWidget::setLayerList(std::list<te::map::AbstractLayerPtr> list)
86 {
87  m_layerList = list;
88 
89  int i = 0;
90 
91  std::list<te::map::AbstractLayerPtr>::iterator it = list.begin();
92  while (it != list.end())
93  {
94  m_ui->m_layersComboBox->insertItem(i, it->get()->getTitle().c_str());
95 
96  it++;
97  i++;
98  }
99 
100  if(!m_layerList.empty())
102 }
103 
105 {
107  dlg->getWidget()->filterOnlyByRaster();
108  dlg->getWidget()->setList(m_layerList);
109  if (dlg->exec())
110  {
111  std::list<te::map::AbstractLayerPtr> layerList = dlg->getWidget()->getSelecteds();
112 
113  std::list<te::map::AbstractLayerPtr>::iterator it = layerList.begin();
114 
115  m_layer = *it;
116 
117  std::list<te::map::AbstractLayerPtr>::iterator itLayer = std::find(m_layerList.begin(), m_layerList.end(), *it);
118  const int pos = std::distance(m_layerList.begin(), itLayer);
119  m_ui->m_layersComboBox->setCurrentIndex(pos);
120 
121  emit layerChanged();
122  }
123 }
124 
126 {
127  auto l_front = m_layerList.begin();
128 
129  std::advance(l_front, index);
130  m_layer = *l_front;
131 
132  emit layerChanged();
133 }
std::unique_ptr< Ui::InputLayerWidgetForm > m_ui
std::list< te::map::AbstractLayerPtr > getSelecteds() const
This class is a dialog for the LayerSearchWidget.
std::map< std::string, std::string > getInfo() const
te::map::AbstractLayerPtr m_layer
InputLayerWidget(QWidget *parent=0, Qt::WindowFlags f=0)
This file has the InputLayerWidget class.
te::map::AbstractLayerPtr getInputLayer()
std::list< te::map::AbstractLayerPtr > m_layerList
Ui::InputLayerWidgetForm * getForm() const
void setList(std::list< te::map::AbstractLayerPtr > &layerList)
void setLayerList(std::list< te::map::AbstractLayerPtr > list)
void setInputLayer(te::map::AbstractLayerPtr layer)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr