27 #include "../../../common/STLUtils.h" 28 #include "../../../dataaccess/dataset/Constraint.h" 29 #include "../../../dataaccess/dataset/DataSetType.h" 30 #include "../../../dataaccess/dataset/Index.h" 31 #include "../../../dataaccess/dataset/PrimaryKey.h" 32 #include "../../../dataaccess/dataset/UniqueKey.h" 33 #include "../../../datatype/Property.h" 36 #include "ui_ConstraintsIndexesListWidgetForm.h" 38 #define CONSTRAINT_PK_TYPE "Primary Key" 39 #define CONSTRAINT_UK_TYPE "Unique Key" 40 #define CONSTRAINT_UNKNOWN_TYPE "Unknown" 41 #define INDEX_TYPE "Index" 46 m_ui(new
Ui::ConstraintsIndexesListWidgetForm)
51 m_ui->m_addToolButton->setIcon(QIcon::fromTheme(
"list-add"));
52 m_ui->m_removeToolButton->setIcon(QIcon::fromTheme(
"list-remove"));
53 m_ui->m_editToolButton->setIcon(QIcon::fromTheme(
"preferences-system"));
58 connect(
m_ui->m_tableWidget, SIGNAL(cellClicked(
int,
int)),
this, SLOT(
onCellClicked(
int,
int)));
83 if(w.exec() == QDialog::Accepted)
93 int row =
m_ui->m_tableWidget->currentRow();
98 std::string type =
m_ui->m_tableWidget->item(row, 1)->text().toUtf8().data();
99 std::string name =
m_ui->m_tableWidget->item(row, 0)->text().toUtf8().data();
114 m_ui->m_removeToolButton->setEnabled(
false);
123 if(!
m_ui->m_tableWidget->currentItem())
126 std::string constIndxName =
m_ui->m_tableWidget->item(
m_ui->m_tableWidget->currentRow(), 0)->text().toUtf8().data();
134 if(pk->
getName() == constIndxName)
147 if(w.exec() == QDialog::Accepted)
159 m_ui->m_removeToolButton->setEnabled(
true);
166 m_ui->m_tableWidget->setRowCount(0);
178 for(
size_t t = 0; t < size; ++t)
187 for(
size_t t = 0; t < size; ++t)
193 m_ui->m_tableWidget->resizeColumnsToContents();
197 m_ui->m_editToolButton->setEnabled(
true);
203 std::string name = c->
getName();
205 std::string properties;
210 properties =
getPropertiesStr(dynamic_cast<te::da::PrimaryKey*>(c)->getProperties());
215 properties =
getPropertiesStr(dynamic_cast<te::da::UniqueKey*>(c)->getProperties());
227 std::string name = i->
getName();
228 std::string type = tr(
INDEX_TYPE).toUtf8().data();
238 if(pk && pk->
getName() == name)
248 for(
size_t t = 0; t < size; ++t)
264 for(
size_t t = 0; t < size; ++t)
279 int newrow =
m_ui->m_tableWidget->rowCount();
281 m_ui->m_tableWidget->insertRow(newrow);
283 QTableWidgetItem* itemName =
new QTableWidgetItem(QString::fromUtf8(name.c_str()));
284 m_ui->m_tableWidget->setItem(newrow, 0, itemName);
285 itemName->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
287 QTableWidgetItem* itemType =
new QTableWidgetItem(QString::fromUtf8(type.c_str()));
288 m_ui->m_tableWidget->setItem(newrow, 1, itemType);
289 itemType->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
291 QTableWidgetItem* itemProp =
new QTableWidgetItem(QString::fromUtf8(properties.c_str()));
292 m_ui->m_tableWidget->setItem(newrow, 2, itemProp);
293 itemProp->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
300 for(
size_t t = 0; t < vec.size(); ++t)
302 str += vec[t]->getName();
A class that models the description of a dataset.
std::size_t getNumberOfUniqueKeys() const
It returns the number of unique keys defined for the dataset type.
PrimaryKey * getPrimaryKey() const
It returns the primary key associated to the dataset type.
A class used to define a constraint or index property creator.
Index * getIndex(std::size_t i) const
It returns the i-th index associated to the dataset type.
virtual ConstraintType getType() const =0
It returns the constraint type.
void remove(Constraint *c)
It removes the constraint.
std::size_t getNumberOfIndexes() const
It returns the number of indexes defined for the dataset type.
It describes a unique key (uk) constraint.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the index.
It describes a primary key (pk) constraint.
virtual const std::string & getName() const
It returns the constraint name.
It describes an index associated to a DataSetType.
UniqueKey * getUniqueKey(std::size_t i) const
It returns the i-th unique key.
const std::string & getName() const
It returns the index name.