Exemplo n.º 1
0
DatabaseWidget::DatabaseWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_DATABASE)
{
  try
  {
    QStringList loc_list, encodings;
    QFrame *frame=nullptr;
    QGridLayout *grid=nullptr;

    Ui_DatabaseWidget::setupUi(this);

    connect(parent_form->apply_ok_btn,SIGNAL(clicked(bool)), this, SLOT(applyConfiguration(void)));
    configureFormLayout(database_grid, OBJ_DATABASE);

    def_schema_sel=new ObjectSelectorWidget(OBJ_SCHEMA, true, this);
    def_collation_sel=new ObjectSelectorWidget(OBJ_COLLATION, true, this);
    def_owner_sel=new ObjectSelectorWidget(OBJ_ROLE, true, this);
    def_tablespace_sel=new ObjectSelectorWidget(OBJ_TABLESPACE, true, this);

    frame=generateInformationFrame(trUtf8("The fields <strong>LC_COLLATE</strong> and <strong>LC_CTYPE</strong> have pre-configured values based upon the running system. You can freely modify those values if you intend to export the model to another host."));
    grid=dynamic_cast<QGridLayout *>(attributes_twg->widget(0)->layout());
    grid->addWidget(frame, grid->count()+1, 0, 1, 0);

    frame=generateInformationFrame(trUtf8("Use the above fields to specify the default attributes assigned to new objects created on the database model. Leaving a field empty will cause PostgreSQL to use the default values when exporting the model."));
    grid=dynamic_cast<QGridLayout *>(attributes_twg->widget(1)->layout());

    grid->addWidget(def_collation_sel, 0, 1);
    grid->addWidget(def_schema_sel, 1, 1);
    grid->addWidget(def_owner_sel, 2, 1);
    grid->addWidget(def_tablespace_sel, 3, 1);
    grid->addWidget(frame, grid->count()+1, 0, 1, 0);
    frame->setParent(attributes_twg->widget(1));

    parent_form->setMinimumWidth(530);
    parent_form->setMinimumHeight(450);
    parent_form->setMaximumHeight(450);

    //Configures the encoding combobox
    EncodingType::getTypes(encodings);
    encodings.push_front(trUtf8("Default"));
    encoding_cmb->addItems(encodings);

    //Configures the localizations combobox
    for(int i=QLocale::C; i <= QLocale::Chewa; i++)
    {
      for(int i1=QLocale::Afghanistan; i1 <= QLocale::Zimbabwe; i1++)
        loc_list.append(QLocale(static_cast<QLocale::Language>(i),static_cast<QLocale::Country>(i1)).name());
    }

    loc_list.removeDuplicates();
    loc_list.sort();
    loc_list.push_front(trUtf8("Default"));

    lccollate_cmb->addItems(loc_list);
    lcctype_cmb->addItems(loc_list);
  }
  catch(Exception &e)
  {
    throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__,&e);
  }
}
Exemplo n.º 2
0
ViewWidget::ViewWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_VIEW)
{
	try
	{
		Ui_ViewWidget::setupUi(this);

		expression_hl=new SyntaxHighlighter(expression_txt, false);
		expression_hl->loadConfiguration(GlobalAttributes::CONFIGURATIONS_DIR +
																		 GlobalAttributes::DIR_SEPARATOR +
																		 GlobalAttributes::SQL_HIGHLIGHT_CONF +
																		 GlobalAttributes::CONFIGURATION_EXT);

		code_hl=new SyntaxHighlighter(code_txt, false);
		code_hl->loadConfiguration(GlobalAttributes::CONFIGURATIONS_DIR +
																			 GlobalAttributes::DIR_SEPARATOR +
																			 GlobalAttributes::SQL_HIGHLIGHT_CONF +
																			 GlobalAttributes::CONFIGURATION_EXT);

		table_sel=new ObjectSelectorWidget(OBJ_TABLE, true, this);
		column_sel=new ObjectSelectorWidget(OBJ_COLUMN, true, this);

		references_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS, true, this);
		references_tab->setColumnCount(4);
		references_tab->setHeaderLabel(trUtf8("Col./Expr."),0);
		references_tab->setHeaderLabel(trUtf8("Alias"),1);
		references_tab->setHeaderLabel(trUtf8("Alias Col."),2);
		references_tab->setHeaderLabel(trUtf8("SF FW AW"),3);

		frame_info=generateInformationFrame(trUtf8("To reference all columns in a table (*) just do not fill the field <strong>Column</strong>, this is the same as write <em><strong>[schema].[tablel].*</strong></em>"));

		referencias_grid->addWidget(table_sel, 2,1,1,2);
		referencias_grid->addWidget(column_sel, 3,1,1,2);
		referencias_grid->addWidget(frame_info, 6, 0, 1, 0);
		referencias_grid->addWidget(references_tab, 7,0,2,0);

		configureFormLayout(view_grid, OBJ_VIEW);

		connect(parent_form->apply_ok_btn,SIGNAL(clicked(bool)), this, SLOT(applyConfiguration(void)));
		connect(ref_type_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(selectReferenceType(void)));
		connect(column_sel, SIGNAL(s_objectSelected(void)), this, SLOT(showObjectName(void)));
		connect(column_sel, SIGNAL(s_selectorCleared(void)), this, SLOT(showObjectName(void)));
		connect(table_sel, SIGNAL(s_objectSelected(void)), this, SLOT(showObjectName(void)));
		connect(references_tab, SIGNAL(s_rowAdded(int)), this, SLOT(handleReference(int)));
		connect(references_tab, SIGNAL(s_rowUpdated(int)), this, SLOT(handleReference(int)));
		connect(references_tab, SIGNAL(s_rowEdited(int)), this, SLOT(editReference(int)));
		connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateCodePreview(void)));

		parent_form->setMinimumSize(650, 630);
		selectReferenceType();
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Exemplo n.º 3
0
RuleWidget::RuleWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_RULE)
{
	try
	{
		QStringList list;
		QFrame *frame=nullptr;

		Ui_RuleWidget::setupUi(this);

		cond_expr_hl=new SyntaxHighlighter(cond_expr_txt, false);
		cond_expr_hl->loadConfiguration(GlobalAttributes::CONFIGURATIONS_DIR +
																						GlobalAttributes::DIR_SEPARATOR +
																						GlobalAttributes::SQL_HIGHLIGHT_CONF +
																						GlobalAttributes::CONFIGURATION_EXT);

		command_hl=new SyntaxHighlighter(comando_txt, false);
		command_hl->loadConfiguration(GlobalAttributes::CONFIGURATIONS_DIR +
																		GlobalAttributes::DIR_SEPARATOR +
																		GlobalAttributes::SQL_HIGHLIGHT_CONF +
																		GlobalAttributes::CONFIGURATION_EXT);

		commands_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS, true, this);
		commands_tab->setHeaderLabel(trUtf8("SQL command"),0);
		commands_tab->setHeaderIcon(QPixmap(":/icones/icones/codigosql.png"),0);
		dynamic_cast<QGridLayout *>(commands_gb->layout())->addWidget(commands_tab, 1, 0, 1, 2);

		frame=generateInformationFrame(trUtf8("To create a rule that does not perform any action (<strong>DO NOTHING</strong>) simply do not specify commands in the SQL commands table."));
		rule_grid->addWidget(frame, rule_grid->count()+1, 0, 1, 0);
		frame->setParent(this);

		configureFormLayout(rule_grid, OBJ_RULE);
		parent_form->setMinimumSize(550, 520);

		EventType::getTypes(list);
		event_cmb->addItems(list);

		ExecutionType::getTypes(list);
		exec_type_cmb->addItems(list);

		connect(parent_form->apply_ok_btn,SIGNAL(clicked(bool)), this, SLOT(applyConfiguration(void)));
		connect(commands_tab, SIGNAL(s_rowAdded(int)), this, SLOT(handleCommand(int)));
		connect(commands_tab, SIGNAL(s_rowUpdated(int)), this, SLOT(handleCommand(int)));
		connect(commands_tab, SIGNAL(s_rowEdited(int)), this, SLOT(editCommand(int)));

		setRequiredField(event_lbl);
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Exemplo n.º 4
0
CollationWidget::CollationWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_COLLATION)
{
	try
	{
		QStringList loc_list, encodings;
		QFrame *frame=nullptr;

		Ui_CollationWidget::setupUi(this);

		frame=generateInformationFrame(trUtf8("The fields <strong><em>Collation</em></strong>, <strong><em>Locale</em></strong>, <strong><em>LC_COLLATE & LC_CTYPE</em></strong> are mutually exclusive, so you have to set only one of them in order to properly handle a collation."));
		collation_grid->addWidget(frame, collation_grid->count()+1, 0, 1, 0);
		frame->setParent(this);

		configureFormLayout(collation_grid, OBJ_COLLATION);

		//Configures the encoding combobox
		EncodingType::getTypes(encodings);
		encodings.push_front(trUtf8("Not defined"));
		encoding_cmb->addItems(encodings);

		//Configures the localizations combobox
		for(int i=QLocale::C; i <= QLocale::Chewa; i++)
		{
			for(int i1=QLocale::Afghanistan; i1 <= QLocale::Zimbabwe; i1++)
				loc_list.append(QLocale(static_cast<QLocale::Language>(i),static_cast<QLocale::Country>(i1)).name());
		}

		loc_list.removeDuplicates();
		loc_list.sort();
		loc_list.push_front(trUtf8("Not defined"));

		lccollate_cmb->addItems(loc_list);
		lcctype_cmb->addItems(loc_list);
		locale_cmb->addItems(loc_list);

		parent_form->setMinimumSize(520, 415);
		parent_form->setMaximumHeight(415);

		connect(collation_sel, SIGNAL(s_objectSelected(void)), this, SLOT(resetFields(void)));
		connect(collation_sel, SIGNAL(s_selectorCleared(void)), this, SLOT(resetFields(void)));
		connect(locale_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(resetFields(void)));
		connect(lcctype_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(resetFields(void)));
		connect(lccollate_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(resetFields(void)));
		connect(parent_form->apply_ok_btn,SIGNAL(clicked(bool)), this, SLOT(applyConfiguration(void)));
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Exemplo n.º 5
0
CastWidget::CastWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_CAST)
{
	try
	{
		QFont font;
		QFrame *frame=nullptr;
		QSpacerItem *spacer=new QSpacerItem(10,1,QSizePolicy::Fixed,QSizePolicy::Expanding);

		Ui_CastWidget::setupUi(this);

		src_datatype=new PgSQLTypeWidget(this, trUtf8("Source data type"));
		trg_datatype=new PgSQLTypeWidget(this, trUtf8("Target data type"));
		conv_func_sel=new ObjectSelectorWidget(OBJ_FUNCTION, true, this);

		cast_grid->addWidget(conv_func_sel,1,1,1,4);
		cast_grid->addWidget(src_datatype,2,0,1,5);
		cast_grid->addWidget(trg_datatype,3,0,1,5);

		configureFormLayout(cast_grid, OBJ_CAST);

		name_edt->setReadOnly(true);
		font=name_edt->font();
		font.setItalic(true);
		name_edt->setFont(font);

		frame=generateInformationFrame(trUtf8("The function to be assigned to a cast from <em><strong>typeA</strong></em> to <em><strong>typeB</strong></em> must have the following signature: <em><strong>typeB</strong> function(<strong>typeA</strong>, integer, boolean)</em>."));
		cast_grid->addWidget(frame, cast_grid->count()+1, 0, 1, 0);
		cast_grid->addItem(spacer, cast_grid->count()+1, 0, 1, 0);
		frame->setParent(this);

		connect(parent_form->apply_ok_btn,SIGNAL(clicked(bool)), this, SLOT(applyConfiguration(void)));
		connect(input_output_chk, SIGNAL(toggled(bool)), conv_func_sel, SLOT(setDisabled(bool)));
		connect(input_output_chk, SIGNAL(toggled(bool)), conv_func_sel, SLOT(clearSelector(void)));

		parent_form->setMinimumSize(530, 520);
		parent_form->setMaximumHeight(520);

		setRequiredField(src_datatype);
		setRequiredField(trg_datatype);

    configureTabOrder({ explicit_rb, implicit_rb, assignment_rb, input_output_chk,
                        conv_func_sel, src_datatype, trg_datatype });
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Exemplo n.º 6
0
ConversionWidget::ConversionWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_CONVERSION)
{
	try
	{
		QFrame *frame=nullptr;
		QStringList encodings;

		Ui_ConversionWidget::setupUi(this);

		conv_func_sel=nullptr;
		conv_func_sel=new ObjectSelectorWidget(OBJ_FUNCTION, true, this);
		convcod_grid->addWidget(conv_func_sel,1,1,1,3);

    setRequiredField(src_encoding_lbl);
    setRequiredField(trg_encoding_lbl);
    setRequiredField(conv_func_lbl);
    setRequiredField(conv_func_sel);

		configureFormLayout(convcod_grid, OBJ_CONVERSION);
		frame=generateInformationFrame(trUtf8("The function to be assigned to an encoding conversion must have the following signature: <em>void function(integer, integer, cstring, internal, integer)</em>."));
		convcod_grid->addWidget(frame, convcod_grid->count()+1, 0, 1, 0);
		frame->setParent(this);

		EncodingType::getTypes(encodings);
		src_encoding_cmb->addItems(encodings);
		trg_encoding_cmb->addItems(encodings);

		connect(parent_form->apply_ok_btn,SIGNAL(clicked(bool)), this, SLOT(applyConfiguration(void)));

		parent_form->setMinimumSize(600, 360);
		parent_form->setMaximumHeight(360);

    configureTabOrder({ src_encoding_cmb, trg_encoding_cmb, conv_func_sel });
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Exemplo n.º 7
0
AggregateWidget::AggregateWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_AGGREGATE)
{
	try
	{
		QGridLayout *grid=nullptr;
		Ui_AggregateWidget::setupUi(this);
		QSpacerItem *spacer=nullptr;
		QFrame *frame=nullptr;

    initial_cond_hl=new SyntaxHighlighter(initial_cond_txt);
    initial_cond_hl->loadConfiguration(GlobalAttributes::SQL_HIGHLIGHT_CONF_PATH);

    final_func_sel=new ObjectSelectorWidget(OBJ_FUNCTION, true, this);
    transition_func_sel=new ObjectSelectorWidget(OBJ_FUNCTION, true, this);
    sort_op_sel=new ObjectSelectorWidget(OBJ_OPERATOR, true, this);

		input_type=new PgSQLTypeWidget(this, trUtf8("Input Data Type"));
		state_type=new PgSQLTypeWidget(this, trUtf8("State Data Type"));

		input_types_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS ^
                                          ObjectTableWidget::EDIT_BUTTON, true, this);
		input_types_tab->setColumnCount(1);

    funcaoagregacao_grid->addWidget(final_func_sel,0,1,1,1);
    funcaoagregacao_grid->addWidget(transition_func_sel,1,1,1,1);
    funcaoagregacao_grid->addWidget(sort_op_sel,2,1,1,1);

		grid=new QGridLayout;
		grid->setContentsMargins(2,2,2,2);
		grid->addWidget(input_type,0,0);
		grid->addWidget(input_types_tab,1,0);
		state_input_types_twg->widget(0)->setLayout(grid);

		grid=new QGridLayout;
		spacer=new QSpacerItem(20, 1, QSizePolicy::Minimum, QSizePolicy::Expanding);

		grid->setContentsMargins(2,2,2,2);
		grid->addWidget(state_type,0,0);
		grid->addItem(spacer,1,0);
		state_input_types_twg->widget(1)->setLayout(grid);

		frame=generateInformationFrame(trUtf8("An aggregate function that accepts the types <em><strong>typeA</strong></em> and <em><strong>typeB</strong></em> as input types and which type of state is <em><strong>state_type</strong></em>, must obey the following rules: <br/><br/> <strong> &nbsp;&nbsp;&nbsp;• Final Function:</strong> <em>void final_function(<strong>state_type</strong>)</em><br/>  <strong> &nbsp;&nbsp;&nbsp;• Transition Function:</strong> <em><strong>state_type</strong> transition_function(<strong>state_type</strong>, <strong>typeA</strong>, <strong>typeB</strong>)</em>"));
		funcaoagregacao_grid->addWidget(frame, funcaoagregacao_grid->count()+1, 0, 1, 2);
		frame->setParent(this);

		configureFormLayout(funcaoagregacao_grid, OBJ_AGGREGATE);
		parent_form->setMinimumSize(645, 750);

		connect(parent_form->apply_ok_btn,SIGNAL(clicked(bool)), this, SLOT(applyConfiguration(void)));
		connect(input_types_tab, SIGNAL(s_rowAdded(int)), this, SLOT(handleDataType(int)));
		connect(input_types_tab, SIGNAL(s_rowUpdated(int)), this, SLOT(handleDataType(int)));

		setRequiredField(state_type);
		setRequiredField(input_type);
		setRequiredField(transition_func_sel);
    setRequiredField(transition_func_lbl);

    configureTabOrder({ final_func_sel, transition_func_sel, sort_op_sel });
  }
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Exemplo n.º 8
0
PermissionWidget::PermissionWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_PERMISSION)
{
	QGridLayout *grid=nullptr;
	QFrame *frame=nullptr;
	QFont font;
	QCheckBox *check=nullptr;
	unsigned i;
	QString privs[]={ ParsersAttributes::SELECT_PRIV, ParsersAttributes::INSERT_PRIV,
										ParsersAttributes::UPDATE_PRIV, ParsersAttributes::DELETE_PRIV,
										ParsersAttributes::TRUNCATE_PRIV, ParsersAttributes::REFERENCES_PRIV,
										ParsersAttributes::TRIGGER_PRIV, ParsersAttributes::CREATE_PRIV,
										ParsersAttributes::CONNECT_PRIV, ParsersAttributes::TEMPORARY_PRIV,
										ParsersAttributes::EXECUTE_PRIV, ParsersAttributes::USAGE_PRIV };

	Ui_PermissionWidget::setupUi(this);

  code_hl=new SyntaxHighlighter(code_txt, false);
  code_hl->loadConfiguration(GlobalAttributes::SQL_HIGHLIGHT_CONF_PATH);

	object_selection_wgt=new ModelObjectsWidget(true);
	permission=nullptr;

	parent_form->generalwidget_wgt->insertWidget(0, this);
	parent_form->generalwidget_wgt->setCurrentIndex(0);
	parent_form->setButtonConfiguration(Messagebox::OK_BUTTON);
	connect(parent_form->apply_ok_btn, SIGNAL(clicked(bool)), parent_form, SLOT(close(void)));

  parent_form->setMinimumSize(670, 580);
  parent_form->resize(670, 580);

	comment_lbl->setText(trUtf8("Type:"));
	font=name_edt->font();
	font.setItalic(true);
	comment_edt->setFont(font);
	comment_edt->setReadOnly(true);
	name_edt->setFont(font);
	name_edt->setReadOnly(true);

	configureFormLayout(permission_grid, OBJ_PERMISSION);

	roles_tab=new ObjectTableWidget(ObjectTableWidget::ADD_BUTTON |
																	ObjectTableWidget::REMOVE_BUTTON |
																	ObjectTableWidget::EDIT_BUTTON, false, this);
	roles_tab->setColumnCount(1);
	roles_tab->setHeaderLabel(trUtf8("Role"),0);
  roles_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/role.png")),0);

	grid=new QGridLayout;
	grid->addWidget(roles_tab,0,0,1,1);
	grid->setContentsMargins(2,2,2,2);
	roles_gb->setLayout(grid);

	permissions_tab=new ObjectTableWidget(ObjectTableWidget::REMOVE_BUTTON |
																				ObjectTableWidget::EDIT_BUTTON |
																				ObjectTableWidget::REMOVE_ALL_BUTTON, true, this);
	permissions_tab->setColumnCount(3);
	permissions_tab->setHeaderLabel(trUtf8("Id"),0);
  permissions_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/uid.png")),0);
	permissions_tab->setHeaderLabel(trUtf8("Roles"),1);
  permissions_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/role.png")),1);
	permissions_tab->setHeaderLabel(trUtf8("Privileges"),2);
  permissions_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/grant.png")),2);

	grid=new QGridLayout;
	grid->addWidget(permissions_tab,0,0,1,1);
	grid->setContentsMargins(2,2,2,2);
	permissions_gb->setLayout(grid);

	for(i=Permission::PRIV_SELECT; i<=Permission::PRIV_USAGE; i++)
	{
		check=new QCheckBox;
		check->setText(privs[i].toUpper());
		privileges_tbw->insertRow(i);
		privileges_tbw->setCellWidget(i,0,check);
		connect(check, SIGNAL(clicked(bool)), this, SLOT(checkPrivilege(void)));

		check=new QCheckBox;
    check->setText(QString("GRANT OPTION"));
		check->setEnabled(false);
		privileges_tbw->setCellWidget(i,1,check);
		connect(check, SIGNAL(clicked(bool)), this, SLOT(checkPrivilege(void)));
	}

	frame=generateInformationFrame(trUtf8("Leave the <em><strong>Roles</strong></em> empty to create a permission applicable to <strong><em>PUBLIC</em></strong>."));
	permission_grid->addWidget(frame, permission_grid->count()+1, 0, 1, 0);
	frame->setParent(this);

	connect(roles_tab, SIGNAL(s_rowAdded(int)), roles_tab, SLOT(selectRow(int)));
	connect(roles_tab, SIGNAL(s_rowEdited(int)), this, SLOT(selectRole(void)));
	connect(roles_tab, SIGNAL(s_rowRemoved(int)), this, SLOT(enableEditButtons(void)));
	connect(roles_tab, SIGNAL(s_rowAdded(int)), this, SLOT(enableEditButtons(void)));

	connect(roles_tab, SIGNAL(s_rowRemoved(int)), this, SLOT(disableGrantOptions(void)));
	connect(roles_tab, SIGNAL(s_rowAdded(int)), this, SLOT(disableGrantOptions(void)));

  connect(permissions_tab, SIGNAL(s_rowRemoved(int)), this, SLOT(removePermission(int)));
	connect(permissions_tab, SIGNAL(s_rowEdited(int)), this, SLOT(editPermission(void)));
	connect(permissions_tab, SIGNAL(s_rowSelected(int)), this, SLOT(selectPermission(int)));

	connect(cancel_tb, SIGNAL(clicked(bool)), this, SLOT(cancelOperation(void)));
	connect(add_perm_tb, SIGNAL(clicked(bool)), this, SLOT(addPermission(void)));
	connect(upd_perm_tb, SIGNAL(clicked(bool)), this, SLOT(updatePermission(void)));

	connect(revoke_rb, SIGNAL(toggled(bool)), cascade_chk, SLOT(setEnabled(bool)));
	connect(revoke_rb, SIGNAL(toggled(bool)), this, SLOT(disableGrantOptions(void)));
	connect(grant_rb, SIGNAL(toggled(bool)), this, SLOT(disableGrantOptions(void)));
}
Exemplo n.º 9
0
ConstraintWidget::ConstraintWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_CONSTRAINT)
{
	try
	{
		QStringList list;
		map<QString, vector<QWidget *> > fields_map;
		QGridLayout *grid=nullptr;

		Ui_ConstraintWidget::setupUi(this);

		excl_elems_wgt=new ElementsWidget(this);
		grid=new QGridLayout;
		grid->setContentsMargins(4,4,4,4);
		grid->addWidget(excl_elems_wgt,0,0);
		excl_elems_grp->setLayout(grid);

    expression_hl=new SyntaxHighlighter(expression_txt);
    expression_hl->loadConfiguration(GlobalAttributes::SQL_HIGHLIGHT_CONF_PATH);

		columns_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS ^
																				(ObjectTableWidget::EDIT_BUTTON |
																				 ObjectTableWidget::UPDATE_BUTTON), true, this);

		ref_columns_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS ^
																						(ObjectTableWidget::EDIT_BUTTON |
																						 ObjectTableWidget::UPDATE_BUTTON), true, this);

		ref_table_sel=new ObjectSelectorWidget(OBJ_TABLE, true, this);

		columns_tab->setColumnCount(2);
		columns_tab->setHeaderLabel(trUtf8("Column"), 0);
    columns_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/column.png")),0);
		columns_tab->setHeaderLabel(trUtf8("Type"), 1);
    columns_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/usertype.png")),1);

		ref_columns_tab->setEnabled(false);
		ref_columns_tab->setColumnCount(2);
		ref_columns_tab->setHeaderLabel(trUtf8("Column"), 0);
    ref_columns_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/column.png")),0);
		ref_columns_tab->setHeaderLabel(trUtf8("Type"), 1);
    ref_columns_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/usertype.png")),1);

		dynamic_cast<QGridLayout *>(columns_tbw->widget(0)->layout())->addWidget(columns_tab, 1,0,1,3);
		dynamic_cast<QGridLayout *>(columns_tbw->widget(1)->layout())->addWidget(ref_table_sel, 0,1,1,2);
		dynamic_cast<QGridLayout *>(columns_tbw->widget(1)->layout())->addWidget(ref_columns_tab, 3,0,1,3);

		configureFormLayout(constraint_grid, OBJ_CONSTRAINT);

		ConstraintType::getTypes(list);
		constr_type_cmb->addItems(list);

		MatchType::getTypes(list);
		match_cmb->addItems(list);

		DeferralType::getTypes(list);
		deferral_cmb->addItems(list);

		ActionType::getTypes(list);
		on_delete_cmb->addItems(list);
		on_update_cmb->addItems(list);

		IndexingType::getTypes(list);
		indexing_cmb->addItems(list);

		info_frm=generateInformationFrame(trUtf8("Columns which were included by relationship can not be added / removed manually from the primary key. If done such changes they can raise errors. To create primary key using columns included by relationship use the following options: identifier field, attributes & constraints tab or primary key tab on the relationship form."));
		constraint_grid->addWidget(info_frm, constraint_grid->count()+1, 0, 1, 0);
		info_frm->setParent(this);

    fields_map[generateVersionsInterval(AFTER_VERSION, PgSQLVersions::PGSQL_VERSION_92)].push_back(no_inherit_lbl);
		warn_frm=generateVersionWarningFrame(fields_map);
		constraint_grid->addWidget(warn_frm, constraint_grid->count()+1, 0, 1, 0);
		warn_frm->setParent(this);

		connect(parent_form->apply_ok_btn,SIGNAL(clicked(bool)), this, SLOT(applyConfiguration(void)));
		connect(constr_type_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(selectConstraintType(void)));
		connect(deferrable_chk, SIGNAL(toggled(bool)), deferral_cmb, SLOT(setEnabled(bool)));
		connect(deferrable_chk, SIGNAL(toggled(bool)), deferral_lbl, SLOT(setEnabled(bool)));
		connect(indexing_chk, SIGNAL(toggled(bool)), indexing_cmb, SLOT(setEnabled(bool)));
		connect(columns_tab, SIGNAL(s_rowAdded(int)), this, SLOT(addColumn(int)));
		connect(columns_tab, SIGNAL(s_rowRemoved(int)), this, SLOT(removeColumn(int)));
		connect(columns_tab, SIGNAL(s_rowsRemoved(void)), this, SLOT(removeColumns(void)));
		connect(ref_columns_tab, SIGNAL(s_rowAdded(int)), this, SLOT(addColumn(int)));
		connect(ref_columns_tab, SIGNAL(s_rowRemoved(int)), this, SLOT(removeColumn(int)));
		connect(ref_columns_tab, SIGNAL(s_rowsRemoved(void)), this, SLOT(removeColumns(void)));
		connect(ref_table_sel, SIGNAL(s_selectorCleared(void)), this, SLOT(selectReferencedTable(void)));
		connect(ref_table_sel, SIGNAL(s_objectSelected(void)), this, SLOT(selectReferencedTable(void)));
		connect(fill_factor_chk, SIGNAL(toggled(bool)), fill_factor_sb, SLOT(setEnabled(bool)));

		parent_form->setMinimumSize(600, 640);

    selectConstraintType();

    configureTabOrder();
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Exemplo n.º 10
0
TypeWidget::TypeWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_TYPE)
{
	try
	{
		QGridLayout *grid=nullptr;
		QFrame *frame=nullptr;
		QStringList list;
		unsigned i,i1;

		Ui_TypeWidget::setupUi(this);
		configureFormLayout(type_grid, OBJ_TYPE);

		like_type=new PgSQLTypeWidget(this, trUtf8("Like Type"));
		element_type=new PgSQLTypeWidget(this, trUtf8("Element Type"));
		range_subtype=new PgSQLTypeWidget(this, trUtf8("Subtype"));

		grid=dynamic_cast<QGridLayout *>(base_attribs_twg->widget(1)->layout());
		grid->addWidget(like_type,6,0,1,0);
		grid->addWidget(element_type,7,0,1,0);
		grid->addItem(new QSpacerItem(20, 1, QSizePolicy::Minimum, QSizePolicy::Expanding),8,0);

		grid=dynamic_cast<QGridLayout *>(base_attribs_twg->widget(0)->layout());
		for(i=Type::INPUT_FUNC; i <= Type::ANALYZE_FUNC; i++)
		{
			functions_sel[i]=nullptr;
			functions_sel[i]=new ObjectSelectorWidget(OBJ_FUNCTION, true, this);
			grid->addWidget(functions_sel[i],i,1,1,1);
		}

		enumerations_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS ^
												 (ObjectTableWidget::EDIT_BUTTON | ObjectTableWidget::DUPLICATE_BUTTON), true, this);
		grid=dynamic_cast<QGridLayout *>(enumerations_gb->layout());
		grid->addWidget(enumerations_tab,1,0,1,2);
		enumerations_gb->setVisible(false);

		attributes_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS ^ ObjectTableWidget::DUPLICATE_BUTTON, true, this);
		attributes_tab->setColumnCount(3);
		attributes_tab->setHeaderLabel(trUtf8("Name"),0);
		attributes_tab->setHeaderIcon(QPixmap(PgModelerUiNS::getIconPath("uid")),0);
		attributes_tab->setHeaderLabel(trUtf8("Type"),1);
		attributes_tab->setHeaderIcon(QPixmap(PgModelerUiNS::getIconPath("usertype")),1);
		attributes_tab->setHeaderLabel(trUtf8("Collation"),2);
		attributes_tab->setHeaderIcon(QPixmap(PgModelerUiNS::getIconPath("collation")),2);

		grid=dynamic_cast<QGridLayout *>(attributes_gb->layout());

		attrib_collation_sel=new ObjectSelectorWidget(OBJ_COLLATION, true, this);
		grid->addWidget(attrib_collation_sel, 1,1,1,2);

		attrib_type_wgt=new PgSQLTypeWidget(this);
		grid->addWidget(attrib_type_wgt,2,0,1,2);

		grid->addWidget(attributes_tab,3,0,1,2);
		attributes_gb->setVisible(false);

		grid=dynamic_cast<QGridLayout *>(base_attribs_twg->widget(0)->layout());
		frame=generateInformationFrame(trUtf8("The functions to be assigned to a type should be written in C language and possess, respectively, the following signatures:<br/>  <table>   <tr>    <td><strong>INPUT:</strong> <em>any function(cstring, oid, integer)</em></td>    <td><strong>OUTPUT:</strong> <em>cstring function(any)</em></td>   </tr>   <tr>    <td><strong>SEND:</strong> <em>byta function(any)</em></td>    <td><strong>RECV:</strong> <em>any function(internal, oid, integer)</em></td>   </tr>   <tr>    <td><strong>TPMOD_IN:</strong> <em>integer function(cstring[])</em></td>    <td><strong>TPMOD_OUT:</strong> <em>cstring function(integer)</em></td>   </tr>   <tr>    <td><strong>ANALYZE:</strong> <em>boolean function(internal)</em></td>    <tr>  </table>"));

		grid->addItem(new QSpacerItem(20, 1, QSizePolicy::Minimum, QSizePolicy::Expanding), grid->count()+1,0);
		grid->addWidget(frame, grid->count()+1, 0, 1, 0);
		frame->setParent(base_attribs_twg->widget(0));

		grid=dynamic_cast<QGridLayout *>(range_attribs_gb->layout());
		opclass_sel=new ObjectSelectorWidget(OBJ_OPCLASS, true, this);
		grid->addWidget(opclass_sel,0,1,1,1);

		for(i1=1, i=Type::CANONICAL_FUNC; i <= Type::SUBTYPE_DIFF_FUNC; i++,i1++)
		{
			functions_sel[i]=nullptr;
			functions_sel[i]=new ObjectSelectorWidget(OBJ_FUNCTION, true, this);
			grid->addWidget(functions_sel[i],i1,1,1,1);
		}

		grid->addWidget(range_subtype,3,0,1,2);
		frame=generateInformationFrame(trUtf8("The functions to be assigned to a range type should have the following signatures:<br/><br/><strong>Canonical:</strong> <em>any function(any)</em> <br/><strong>Subtype Diff:</strong> <em>double precision function(subtype, subtype)</em>"));
		grid->addItem(new QSpacerItem(20, 1, QSizePolicy::Minimum, QSizePolicy::Expanding),4,0);
		grid->addWidget(frame, 5, 0, 1, 0);

		range_attribs_gb->setVisible(false);

		//connect(parent_form->apply_ok_btn,SIGNAL(clicked(bool)), this, SLOT(applyConfiguration(void)));
		connect(base_type_rb, SIGNAL(toggled(bool)), this, SLOT(selectTypeConfiguration(void)));
		connect(composite_rb, SIGNAL(toggled(bool)), this, SLOT(selectTypeConfiguration(void)));
		connect(enumeration_rb, SIGNAL(toggled(bool)), this, SLOT(selectTypeConfiguration(void)));
		connect(enumerations_tab, SIGNAL(s_rowAdded(int)), this, SLOT(handleEnumeration(int)));
		connect(enumerations_tab, SIGNAL(s_rowUpdated(int)), this, SLOT(handleEnumeration(int)));
		connect(attributes_tab, SIGNAL(s_rowAdded(int)), this, SLOT(handleAttribute(int)));
		connect(attributes_tab, SIGNAL(s_rowUpdated(int)), this, SLOT(handleAttribute(int)));
		connect(attributes_tab, SIGNAL(s_rowEdited(int)), this, SLOT(editAttribute(int)));

		StorageType::getTypes(list);
		storage_cmb->addItems(list);

		CategoryType::getTypes(list);
		category_cmb->addItems(list);

		setRequiredField(range_subtype);
		setRequiredField(input_lbl);
		setRequiredField(output_lbl);
		setRequiredField(functions_sel[Type::INPUT_FUNC]);
		setRequiredField(functions_sel[Type::OUTPUT_FUNC]);
		setRequiredField(enumerations_gb);
		setRequiredField(attributes_gb);

		configureTabOrder({base_type_rb, enumeration_rb, composite_rb, range_rb,
						   enum_name_edt, attrib_name_edt, attrib_collation_sel, attrib_type_wgt,
						   opclass_sel, functions_sel[Type::CANONICAL_FUNC], functions_sel[Type::SUBTYPE_DIFF_FUNC],
						   base_attribs_twg});

		setMinimumSize(620, 750);
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Exemplo n.º 11
0
OperatorWidget::OperatorWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_OPERATOR)
{
	try
	{
		QGridLayout *grid=nullptr;
		unsigned i, i1;
		map<QString, vector<QWidget *> > field_map;
		QFrame *frame=nullptr;

		Ui_OperatorWidget::setupUi(this);

		arg_types[0]=nullptr;
		arg_types[0]=new PgSQLTypeWidget(this, trUtf8("Left Argument Type"));
		arg_types[1]=nullptr;
		arg_types[1]=new PgSQLTypeWidget(this, trUtf8("Right Argument Type"));

		grid=new QGridLayout;
		grid->setContentsMargins(4,4,4,4);
		grid->addWidget(arg_types[0],0,0);
		grid->addWidget(arg_types[1],1,0);

		frame=generateInformationFrame(trUtf8("To create a unary operator it is necessary to specify as <strong><em>'any'</em></strong> one of its arguments. Additionally, the function that defines the operator must have only one parameter and this, in turn, must have the same data type of the the argument of unary operator."));
		grid->addWidget(frame, 2, 0);
		attributes_twg->widget(0)->setLayout(grid);


		grid=dynamic_cast<QGridLayout *>(attributes_twg->widget(1)->layout());
		for(i=Operator::FUNC_OPERATOR; i <= Operator::FUNC_RESTRICT; i++)
		{
			functions_sel[i]=nullptr;
			functions_sel[i]=new ObjectSelectorWidget(OBJ_FUNCTION, true, this);

			if(i!=Operator::FUNC_OPERATOR)
				grid->addWidget(functions_sel[i],i,1,1,1);
		}

		//grid=dynamic_cast<QGridLayout *>(attributes_twg->widget(2)->layout());
		for(i=Operator::OPER_COMMUTATOR, i1=3; i <= Operator::OPER_NEGATOR; i++,i1++)
		{
			operators_sel[i]=nullptr;
			operators_sel[i]=new ObjectSelectorWidget(OBJ_OPERATOR, true, this);
			grid->addWidget(operators_sel[i],i1,1,1,1);
		}

		operator_grid->addWidget(functions_sel[0],0,1,1,3);

		/*field_map[generateVersionsInterval(UNTIL_VERSION, SchemaParser::PGSQL_VERSION_82)].push_back(sort1_op_lbl);
		field_map[generateVersionsInterval(UNTIL_VERSION, SchemaParser::PGSQL_VERSION_82)].push_back(sort2_op_lbl);
		field_map[generateVersionsInterval(UNTIL_VERSION, SchemaParser::PGSQL_VERSION_82)].push_back(lessthan_op_lbl);
		field_map[generateVersionsInterval(UNTIL_VERSION, SchemaParser::PGSQL_VERSION_82)].push_back(greaterthan_op_lbl);
		frame=generateVersionWarningFrame(field_map);
		grid->addWidget(frame, grid->count()+1, 0, 1, 0);
		frame->setParent(attributes_twg->widget(2)); */

		configureFormLayout(operator_grid, OBJ_OPERATOR);

		connect(parent_form->apply_ok_btn,SIGNAL(clicked(bool)), this, SLOT(applyConfiguration(void)));

		parent_form->resize(530, 590);
		parent_form->setMinimumWidth(530);
		parent_form->setMinimumHeight(590);

		setRequiredField(operator_func_lbl);
		setRequiredField(functions_sel[0]);
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Exemplo n.º 12
0
ConstraintWidget::ConstraintWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_CONSTRAINT)
{
	try
	{
		QStringList list;

		Ui_ConstraintWidget::setupUi(this);

		check_expr_hl=new SyntaxHighlighter(check_expr_txt, false);
		check_expr_hl->loadConfiguration(GlobalAttributes::CONFIGURATIONS_DIR +
																				 GlobalAttributes::DIR_SEPARATOR +
																				 GlobalAttributes::SQL_HIGHLIGHT_CONF +
																				 GlobalAttributes::CONFIGURATION_EXT);

		columns_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS ^
																				(ObjectTableWidget::EDIT_BUTTON |
																				 ObjectTableWidget::UPDATE_BUTTON), true, this);

		ref_columns_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS ^
																						(ObjectTableWidget::EDIT_BUTTON |
																						 ObjectTableWidget::UPDATE_BUTTON), true, this);

		ref_table_sel=new ObjectSelectorWidget(OBJ_TABLE, true, this);

		columns_tab->setColumnCount(2);
		columns_tab->setHeaderLabel(trUtf8("Column"), 0);
		columns_tab->setHeaderIcon(QPixmap(":/icones/icones/column.png"),0);
		columns_tab->setHeaderLabel(trUtf8("Type"), 1);
		columns_tab->setHeaderIcon(QPixmap(":/icones/icones/usertype.png"),1);

		ref_columns_tab->setEnabled(false);
		ref_columns_tab->setColumnCount(2);
		ref_columns_tab->setHeaderLabel(trUtf8("Column"), 0);
		ref_columns_tab->setHeaderIcon(QPixmap(":/icones/icones/column.png"),0);
		ref_columns_tab->setHeaderLabel(trUtf8("Type"), 1);
		ref_columns_tab->setHeaderIcon(QPixmap(":/icones/icones/usertype.png"),1);

		dynamic_cast<QGridLayout *>(columns_tbw->widget(0)->layout())->addWidget(columns_tab, 1,0,1,3);
		dynamic_cast<QGridLayout *>(columns_tbw->widget(1)->layout())->addWidget(ref_table_sel, 0,1,1,2);
		dynamic_cast<QGridLayout *>(columns_tbw->widget(1)->layout())->addWidget(ref_columns_tab, 3,0,1,3);

		configureFormLayout(constraint_grid, OBJ_CONSTRAINT);
		parent_form->setMinimumSize(580, 560);

		ConstraintType::getTypes(list);
		constr_type_cmb->addItems(list);
		selectConstraintType();

		MatchType::getTypes(list);
		match_cmb->addItems(list);

		DeferralType::getTypes(list);
		deferral_cmb->addItems(list);

		ActionType::getTypes(list);
		on_delete_cmb->addItems(list);
		on_update_cmb->addItems(list);

		info_frm=generateInformationFrame(trUtf8("Columns which were included by relationship can not be added / removed manually from the primary key. If done such changes they will be ignored. To create primary key using columns included by relationship use the feature attributes, constraints and primary key on the relationship form."));
		constraint_grid->addWidget(info_frm, constraint_grid->count()+1, 0, 1, 0);
		info_frm->setParent(this);

		connect(parent_form->apply_ok_btn,SIGNAL(clicked(bool)), this, SLOT(applyConfiguration(void)));
		connect(constr_type_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(selectConstraintType(void)));
		connect(deferrable_chk, SIGNAL(toggled(bool)), deferral_cmb, SLOT(setEnabled(bool)));
		connect(deferrable_chk, SIGNAL(toggled(bool)), deferral_lbl, SLOT(setEnabled(bool)));
		connect(columns_tab, SIGNAL(s_rowAdded(int)), this, SLOT(addColumn(int)));
		connect(columns_tab, SIGNAL(s_rowRemoved(int)), this, SLOT(removeColumn(int)));
		connect(columns_tab, SIGNAL(s_rowsRemoved(void)), this, SLOT(removeColumns(void)));
		connect(ref_columns_tab, SIGNAL(s_rowAdded(int)), this, SLOT(addColumn(int)));
		connect(ref_columns_tab, SIGNAL(s_rowRemoved(int)), this, SLOT(removeColumn(int)));
		connect(ref_columns_tab, SIGNAL(s_rowsRemoved(void)), this, SLOT(removeColumns(void)));
		connect(ref_table_sel, SIGNAL(s_selectorCleared(void)), this, SLOT(selectReferencedTable(void)));
		connect(ref_table_sel, SIGNAL(s_objectSelected(void)), this, SLOT(selectReferencedTable(void)));
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}