1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
#include "constraintpanel.h"
#include "common/unused.h"
#include "constraints/tableprimarykeypanel.h"
#include "constraints/tableforeignkeypanel.h"
#include "constraints/tableuniquepanel.h"
#include "constraints/tablecheckpanel.h"
#include "constraints/columncheckpanel.h"
#include "constraints/columncollatepanel.h"
#include "constraints/columngeneratedpanel.h"
#include "constraints/columndefaultpanel.h"
#include "constraints/columnforeignkeypanel.h"
#include "constraints/columnnotnullpanel.h"
#include "constraints/columnprimarykeypanel.h"
#include "constraints/columnuniquepanel.h"
#include <QDebug>
ConstraintPanel::ConstraintPanel(QWidget *parent) :
QWidget(parent)
{
}
ConstraintPanel::~ConstraintPanel()
{
}
void ConstraintPanel::setConstraint(SqliteStatement* stmt)
{
constraint = stmt;
constraintAvailable();
}
void ConstraintPanel::setCreateTableStmt(SqliteCreateTable *stmt)
{
createTableStmt = stmt;
}
void ConstraintPanel::setColumnStmt(SqliteCreateTable::Column *stmt)
{
columnStmt = stmt;
}
void ConstraintPanel::storeDefinition()
{
storeConfiguration();
constraint->rebuildTokens();
}
void ConstraintPanel::setDb(Db* value)
{
db = value;
}
bool ConstraintPanel::validateOnly()
{
return validate();
}
ConstraintPanel* ConstraintPanel::produce(SqliteCreateTable::Constraint* constr)
{
switch (constr->type)
{
case SqliteCreateTable::Constraint::PRIMARY_KEY:
return new TablePrimaryKeyPanel();
case SqliteCreateTable::Constraint::UNIQUE:
return new TableUniquePanel();
case SqliteCreateTable::Constraint::CHECK:
return new TableCheckPanel();
case SqliteCreateTable::Constraint::FOREIGN_KEY:
return new TableForeignKeyPanel();
case SqliteCreateTable::Constraint::NAME_ONLY:
break;
}
qCritical() << "No panel defined in ConstraintPanel::createConstraintPanel()!";
Q_ASSERT_X(true, "ConstraintPanel::produce()", "No panel defined!");
return nullptr;
}
ConstraintPanel* ConstraintPanel::produce(SqliteCreateTable::Column::Constraint* constr)
{
switch (constr->type)
{
case SqliteCreateTable::Column::Constraint::PRIMARY_KEY:
return new ColumnPrimaryKeyPanel();
case SqliteCreateTable::Column::Constraint::NOT_NULL:
return new ColumnNotNullPanel();
case SqliteCreateTable::Column::Constraint::UNIQUE:
return new ColumnUniquePanel();
case SqliteCreateTable::Column::Constraint::CHECK:
return new ColumnCheckPanel();
case SqliteCreateTable::Column::Constraint::DEFAULT:
return new ColumnDefaultPanel();
case SqliteCreateTable::Column::Constraint::COLLATE:
return new ColumnCollatePanel();
case SqliteCreateTable::Column::Constraint::GENERATED:
return new ColumnGeneratedPanel();
case SqliteCreateTable::Column::Constraint::FOREIGN_KEY:
return new ColumnForeignKeyPanel();
case SqliteCreateTable::Column::Constraint::NULL_:
case SqliteCreateTable::Column::Constraint::NAME_ONLY:
case SqliteCreateTable::Column::Constraint::DEFERRABLE_ONLY:
break;
}
qCritical() << "No panel defined in ConstraintPanel::createConstraintPanel()!";
Q_ASSERT_X(true, "ConstraintPanel::produce()", "No panel defined");
return nullptr;
}
|