All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TL4LayerSelectionWizardPage.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 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/plugins/terralib4/TL4LayerSelectionWizardPage.cpp
22 
23  \brief A wizard page for selecting the TerraLib 4.x.
24 */
25 
26 // TerraLib
27 #include "ui_TL4LayerSelectionWizardPageForm.h"
29 
30 // Qt
31 #include<QIcon>
32 #include<QListWidgetItem>
33 
34 QIcon getImage(int type)
35 {
36  switch(type)
37  {
38  case 0:
39  return QIcon::fromTheme("tl4-layer").pixmap(16,16);
40 
41  case 1:
42  return QIcon::fromTheme("tl4-theme").pixmap(16,16);
43 
44  case 2:
45  return QIcon::fromTheme("tl4-table").pixmap(16,16);
46 
47  default:
48  return QIcon::fromTheme("tl4-layer").pixmap(16,16);
49  }
50 }
51 
53  : QWizardPage(parent),
54  m_ui(new Ui::TL4LayerSelectionWizardPageForm)
55 {
56 // setup controls
57  m_ui->setupUi(this);
58 
59  connect(m_ui->m_selectAllPushButton, SIGNAL(clicked()), this, SLOT(onSelectAllPushButtonClicked()));
60  connect(m_ui->m_deselectAllPushButton, SIGNAL(clicked()), this, SLOT(onDeselectAllPushButtonClicked()));
61 
62 }
63 
65 {
66 }
67 
69  std::vector<std::string> tables)
70 {
71  m_ui->m_layersListWidget->clear();
72 
73  setTL4Layers(layers);
74  setTL4Tables(tables);
75 }
76 
78 {
79  for(std::size_t i = 0; i < layers.size(); ++i)
80  {
81  QListWidgetItem* item = new QListWidgetItem(getImage(LAYER), layers[i].c_str(), m_ui->m_layersListWidget, LAYER);
82  item->setCheckState(Qt::Checked);
83  m_ui->m_layersListWidget->addItem(item);
84  }
85 }
86 
88 {
89  for(std::size_t i = 0; i < tables.size(); ++i)
90  {
91  QListWidgetItem* item = new QListWidgetItem(getImage(TABLE), tables[i].c_str(), m_ui->m_layersListWidget, TABLE);
92  item->setCheckState(Qt::Checked);
93  m_ui->m_layersListWidget->addItem(item);
94  }
95 }
96 
98 {
99  std::vector<std::string> checked;
100  for(int i = 0; i < m_ui->m_layersListWidget->count(); ++i)
101  {
102  if(m_ui->m_layersListWidget->item(i)->checkState() == Qt::Checked)
103  checked.push_back(m_ui->m_layersListWidget->item(i)->text().toStdString());
104  }
105 
106  return checked;
107 }
108 
110 {
111  for(int i = 0; i < m_ui->m_layersListWidget->count(); ++i)
112  {
113  if(m_ui->m_layersListWidget->item(i)->checkState() == Qt::Checked)
114  return true;
115  }
116 
117  return false;
118 }
119 
121 {
122  for(int i = 0; i < m_ui->m_layersListWidget->count(); ++i)
123  {
124  Qt::CheckState state = m_ui->m_layersListWidget->item(i)->checkState();
125  if(state != Qt::Checked)
126  m_ui->m_layersListWidget->item(i)->setCheckState(Qt::Checked);
127  }
128 }
129 
131 {
132  for(int i = 0; i < m_ui->m_layersListWidget->count(); ++i)
133  {
134  Qt::CheckState state = m_ui->m_layersListWidget->item(i)->checkState();
135  if(state == Qt::Checked)
136  m_ui->m_layersListWidget->item(i)->setCheckState(Qt::Unchecked);
137  }
138 }
139 
141 {
142  std::vector<QListWidgetItem*> checked;
143  for(int i = 0; i < m_ui->m_layersListWidget->count(); ++i)
144  {
145  if(m_ui->m_layersListWidget->item(i)->checkState() == Qt::Checked)
146  checked.push_back(m_ui->m_layersListWidget->item(i));
147  }
148 
149  return checked;
150 }
std::auto_ptr< Ui::TL4LayerSelectionWizardPageForm > m_ui
void setDatasets(std::vector< std::string > layers, std::vector< std::string > tables)
QIcon getImage(int type)