All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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(0),
42  m_ukConstraintWidget(0),
43  m_indexWidget(0)
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 
62 {
63 }
64 
66 {
67  if(status == false)
68  return;
69 
70  freeWidget();
71 
72  m_pkConstraintWidget = new te::qt::widgets::PrimaryKeyConstraintWidget(m_dsType, m_ui->m_widget);
73 
74  m_widgetLayout->addWidget(m_pkConstraintWidget);
75 }
76 
78 {
79  if(status == false)
80  return;
81 
82  freeWidget();
83 
84  m_ukConstraintWidget = new te::qt::widgets::UniqueKeyConstraintWidget(m_dsType, m_ui->m_widget);
85 
86  m_widgetLayout->addWidget(m_ukConstraintWidget);
87 }
88 
90 {
91  if(status == false)
92  return;
93 
94  freeWidget();
95 
96  m_indexWidget = new te::qt::widgets::IndexWidget(m_dsType, m_ui->m_widget);
97 
98  m_widgetLayout->addWidget(m_indexWidget);
99 }
100 
102 {
103  m_ui->m_okPushButton->setText(tr("Edit"));
104 
105  te::da::PrimaryKey* pk = dynamic_cast<te::da::PrimaryKey*>(constraint);
106  te::da::UniqueKey* uk = dynamic_cast<te::da::UniqueKey*>(constraint);
107 
108  if(pk)
109  {
110  m_ui->m_pkRadioButton->setChecked(true);
111  m_pkConstraintWidget->setConstraint(pk);
112  }
113  else if(uk)
114  {
115  m_ui->m_ukRadioButton->setChecked(true);
116  m_ukConstraintWidget->setConstraint(uk);
117  }
118 
119  m_ui->m_okPushButton->setEnabled(true);
120 }
121 
123 {
124  m_ui->m_okPushButton->setText(tr("Edit"));
125 
126  m_ui->m_idxRadioButton->setChecked(true);
127  m_ui->m_okPushButton->setEnabled(true);
128  m_indexWidget->setIndex(index);
129 
130  m_ui->m_okPushButton->setEnabled(true);
131 
132 }
133 
135 {
136  if(m_ui->m_pkRadioButton->isChecked())
137  {
138  if(m_pkConstraintWidget->checkParameters() == false)
139  return;
140 
141  m_pkConstraintWidget->getConstraint();
142  }
143  else if(m_ui->m_ukRadioButton->isChecked())
144  {
145  if(m_ukConstraintWidget->checkParameters() == false)
146  return;
147 
148  m_ukConstraintWidget->getConstraint();
149  }
150  else if(m_ui->m_idxRadioButton->isChecked())
151  {
152  if(m_indexWidget->checkParameters() == false)
153  return;
154 
155  m_indexWidget->getIndex();
156  }
157  else
158  {
159  return;
160  }
161 
162  accept();
163 }
164 
166 {
167  if(m_indexWidget)
168  {
169  m_widgetLayout->removeWidget(m_indexWidget);
170  delete m_indexWidget;
171  m_indexWidget = 0;
172  }
173 
174  if(m_pkConstraintWidget)
175  {
176  m_widgetLayout->removeWidget(m_pkConstraintWidget);
177  delete m_pkConstraintWidget;
178  m_pkConstraintWidget = 0;
179  }
180 
181  if(m_ukConstraintWidget)
182  {
183  m_widgetLayout->removeWidget(m_ukConstraintWidget);
184  delete m_ukConstraintWidget;
185  m_ukConstraintWidget = 0;
186  }
187 }
This class is used to define a Unique Key Constraint DataSet class object.
This class is used to define a Index DataSet class object.
Definition: IndexWidget.h:53
A class that models the description of a dataset.
Definition: DataSetType.h:72
ConstraintsIndexesPropertyDialog(te::da::DataSetType *dsType, QWidget *parent=0, Qt::WindowFlags f=0)
A class used to define a constraint or index property creator.
This file has the IndexWidget class.
This file has the PrimaryKeyConstraintWidget class.
This file has the UniqueKeyConstraintWidget class.
std::auto_ptr< Ui::ConstraintsIndexesPropertyDialogForm > m_ui
It describes a unique key (uk) constraint.
Definition: UniqueKey.h:53
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
It describes an index associated to a DataSetType.
Definition: Index.h:54
This class is used to define a Primare Key Constraint DataSet class object.