SelectPKey.cpp
Go to the documentation of this file.
1 #include "SelectPKey.h"
2 
3 #include <ui_SelectPKey.h>
4 
5 //TerraLib include files
9 
10 //Qt include files
11 #include <QCheckBox>
12 
13 
14 void updateChecks(QTableWidget* tab, const bool& status)
15 {
16  int nrows = tab->rowCount();
17 
18  for(int i=0; i<nrows; i++)
19  ((QCheckBox*)tab->cellWidget(i, 1))->setChecked(status);
20 }
21 
23 QWidget(parent),
24  m_ui(new Ui::SelectPKey)
25 {
26  m_ui->setupUi(this);
27 }
28 
30 {
31  delete m_ui;
32 }
33 
35 {
36  updateChecks(m_ui->m_columnsTable, true);
37 }
38 
40 {
41  updateChecks(m_ui->m_columnsTable, false);
42 }
43 
45 {
46  int nrows = m_ui->m_columnsTable->rowCount();
47  std::vector<size_t> pkeys;
48 
49  for(int i=0; i<nrows; i++)
50  if(((QCheckBox*)m_ui->m_columnsTable->cellWidget((int)i, 1))->isChecked())
51  pkeys.push_back(i);
52 
53  if(!pkeys.empty())
54  emit pkeysChanged(pkeys);
55 }
56 
58 {
59  m_ui->m_columnsTable->clearContents();
60  m_ui->m_columnsTable->setRowCount(0);
61 
62  std::size_t numProperties = dset->getNumProperties();
63 
64  for(std::size_t i = 0; i < numProperties; ++i)
65  {
66  int propertyType = dset->getPropertyDataType(i);
67 
68  if(propertyType != te::dt::GEOMETRY_TYPE)
69  {
70  int nRows = m_ui->m_columnsTable->rowCount();
71  m_ui->m_columnsTable->insertRow(nRows);
72 
73  m_ui->m_columnsTable->setItem(nRows, 0, new QTableWidgetItem(dset->getPropertyName(i).c_str()));
74  m_ui->m_columnsTable->setCellWidget(nRows, 1, new QCheckBox(tr("primary key"), this));
75  }
76  }
77 }
void on_m_selectAllPushButton_clicked()
Definition: SelectPKey.cpp:34
void pkeysChanged(const std::vector< size_t > &)
It models a property definition.
Ui::SelectPKey * m_ui
Definition: SelectPKey.h:64
void on_m_updateKeysPushButton_clicked()
Definition: SelectPKey.cpp:44
void updateColumns(te::da::DataSet *dset)
Definition: SelectPKey.cpp:57
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
A dataset is the unit of information manipulated by the data access module of TerraLib.
A class that models the description of a dataset.
void updateChecks(QTableWidget *tab, const bool &status)
Definition: SelectPKey.cpp:14
A dataset is the unit of information manipulated by the data access module of TerraLib.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
void on_m_unselectAllPushButton_clicked()
Definition: SelectPKey.cpp:39
SelectPKey(QWidget *parent=0)
Definition: SelectPKey.cpp:22