ConstraintsIndexesPropertyDialog.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/property/ConstraintsIndexesPropertyDialog.cpp
22 
23  \brief A class used to define a constraint or index property creator.
24 */
25 
26 // TerraLib
27 #include "../../../dataaccess/dataset/DataSetType.h"
28 #include "../../../dataaccess/dataset/PrimaryKey.h"
29 #include "../../../dataaccess/dataset/Index.h"
30 #include "../../../dataaccess/dataset/UniqueKey.h"
32 #include "IndexWidget.h"
35 #include "ui_ConstraintsIndexesPropertyDialogForm.h"
36 
37 
39  : QDialog(parent, f),
40  m_ui(new Ui::ConstraintsIndexesPropertyDialogForm),
41  m_pkConstraintWidget(nullptr),
42  m_ukConstraintWidget(nullptr),
43  m_indexWidget(nullptr)
44 {
45  m_ui->setupUi(this);
46 
47  m_dsType = dsType;
48 
49  //set layout
50  m_widgetLayout = new QGridLayout(m_ui->m_widget);
51 
52  //connects
53  connect(m_ui->m_pkRadioButton, SIGNAL(toggled(bool)), this, SLOT(onpkRadioButtonToggled(bool)));
54  connect(m_ui->m_ukRadioButton, SIGNAL(toggled(bool)), this, SLOT(onukRadioButtonToggled(bool)));
55  connect(m_ui->m_idxRadioButton, SIGNAL(toggled(bool)), this, SLOT(onidxRadioButtonToggled(bool)));
56  connect(m_ui->m_okPushButton, SIGNAL(clicked()), this, SLOT(onokPushButtonClicked()));
57 
58  m_ui->m_helpPushButton->setPageReference("widgets/property/constraints_indexes.html");
59 }
60 
63 
65 {
66  if(status == false)
67  return;
68 
69  freeWidget();
70 
72 
74 }
75 
77 {
78  if(status == false)
79  return;
80 
81  freeWidget();
82 
84 
86 }
87 
89 {
90  if(status == false)
91  return;
92 
93  freeWidget();
94 
96 
97  m_widgetLayout->addWidget(m_indexWidget);
98 }
99 
101 {
102  m_ui->m_okPushButton->setText(tr("Edit"));
103 
104  te::da::PrimaryKey* pk = dynamic_cast<te::da::PrimaryKey*>(constraint);
105  te::da::UniqueKey* uk = dynamic_cast<te::da::UniqueKey*>(constraint);
106 
107  if(pk)
108  {
109  m_ui->m_pkRadioButton->setChecked(true);
111  }
112  else if(uk)
113  {
114  m_ui->m_ukRadioButton->setChecked(true);
116  }
117 
118  m_ui->m_okPushButton->setEnabled(true);
119 }
120 
122 {
123  m_ui->m_okPushButton->setText(tr("Edit"));
124 
125  m_ui->m_idxRadioButton->setChecked(true);
126  m_ui->m_okPushButton->setEnabled(true);
127  m_indexWidget->setIndex(index);
128 
129  m_ui->m_okPushButton->setEnabled(true);
130 
131 }
132 
134 {
135  if(m_ui->m_pkRadioButton->isChecked())
136  {
137  if(m_pkConstraintWidget->checkParameters() == false)
138  return;
139 
141  }
142  else if(m_ui->m_ukRadioButton->isChecked())
143  {
144  if(m_ukConstraintWidget->checkParameters() == false)
145  return;
146 
148  }
149  else if(m_ui->m_idxRadioButton->isChecked())
150  {
151  if(m_indexWidget->checkParameters() == false)
152  return;
153 
155  }
156  else
157  {
158  return;
159  }
160 
161  accept();
162 }
163 
165 {
166  if(m_indexWidget)
167  {
168  m_widgetLayout->removeWidget(m_indexWidget);
169  delete m_indexWidget;
170  m_indexWidget = nullptr;
171  }
172 
174  {
175  m_widgetLayout->removeWidget(m_pkConstraintWidget);
176  delete m_pkConstraintWidget;
177  m_pkConstraintWidget = nullptr;
178  }
179 
181  {
182  m_widgetLayout->removeWidget(m_ukConstraintWidget);
183  delete m_ukConstraintWidget;
184  m_ukConstraintWidget = nullptr;
185  }
186 }
virtual te::da::Constraint * getConstraint()
It returns the Constraint DataSet class object.
virtual void setConstraint(te::da::Constraint *constraint)
te::qt::widgets::UniqueKeyConstraintWidget * m_ukConstraintWidget
This class is used to define a Unique Key Constraint DataSet class object.
virtual te::da::Constraint * getConstraint()
It returns the Constraint DataSet class object.
This class is used to define a Index DataSet class object.
Definition: IndexWidget.h:55
A class that models the description of a dataset.
Definition: DataSetType.h:72
te::qt::widgets::PrimaryKeyConstraintWidget * m_pkConstraintWidget
std::unique_ptr< Ui::ConstraintsIndexesPropertyDialogForm > m_ui
ConstraintsIndexesPropertyDialog(te::da::DataSetType *dsType, QWidget *parent=0, Qt::WindowFlags f=0)
bool checkParameters()
Check the interface parameters.
te::da::Index * getIndex()
It returns the Index DataSet class object.
Definition: IndexWidget.cpp:82
A class used to define a constraint or index property creator.
This file has the IndexWidget class.
This file has the PrimaryKeyConstraintWidget class.
void setIndex(te::da::Index *idx)
It describes a unique key (uk) constraint.
Definition: UniqueKey.h:53
virtual void setConstraint(te::da::Constraint *constraint)
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
bool checkParameters()
Check the interface parameters.
It describes an index associated to a DataSetType.
This class is used to define a Primare Key Constraint DataSet class object.