Example #1
0
void TableWidget::setAttributes(DatabaseModel *model, OperationList *op_list, Schema *schema, Table *table, double pos_x, double pos_y)
{
    try
    {
        unsigned i, count;
        Table *aux_tab=nullptr;
        ObjectType types[]= { OBJ_COLUMN, OBJ_CONSTRAINT, OBJ_TRIGGER, OBJ_RULE, OBJ_INDEX };

        if(!table)
        {
            table=new Table;

            if(schema)
                table->setSchema(schema);

            /* Sets the 'new_object' flag as true indicating that the alocated table must be treated
            	 as a recently created object */
            this->new_object=true;
        }

        BaseObjectWidget::setAttributes(model, op_list, table, schema, pos_x, pos_y);

        op_list->startOperationChain();
        operation_count=op_list->getCurrentSize();

        /* Listing all objects (column, constraint, trigger, index, rule) on the
        respective table objects */
        for(i=0; i < 5; i++)
        {
            listObjects(types[i]);
            objects_tab_map[types[i]]->setButtonConfiguration(ObjectTableWidget::ALL_BUTTONS ^
                    (ObjectTableWidget::UPDATE_BUTTON));
        }

        //Listing the ancestor tables
        count=table->getAncestorTableCount();
        for(i=0; i < count; i++)
        {
            aux_tab=table->getAncestorTable(i);
            parent_tables->addRow();
            parent_tables->setCellText(aux_tab->getName(), i, 0);
            parent_tables->setCellText(aux_tab->getSchema()->getName(), i, 1);
            parent_tables->setCellText(trUtf8("Parent"), i, 2);
        }

        aux_tab=table->getCopyTable();
        if(aux_tab)
        {
            parent_tables->addRow();
            parent_tables->setCellText(aux_tab->getName(), i, 0);
            parent_tables->setCellText(aux_tab->getSchema()->getName(), i, 1);
            parent_tables->setCellText(trUtf8("Copy"), i, 2);
        }

        parent_tables->clearSelection();
        with_oids_chk->setChecked(table->isWithOIDs());
        unlogged_chk->setChecked(table->isUnlogged());
        gen_alter_cmds_chk->setChecked(table->isGenerateAlterCmds());

        tag_sel->setModel(this->model);
        tag_sel->setSelectedObject(table->getTag());
    }
    catch(Exception &e)
    {
        throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
    }
}
Example #2
0
FunctionWidget::FunctionWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_FUNCTION)
{
    try
    {
        QStringList types;
        QGridLayout *grid=nullptr, *grid1=nullptr;
        QVBoxLayout *vlayout=nullptr;
        QSpacerItem *spacer=nullptr;

        map<QString, vector<QWidget *> > fields_map;
        map<QWidget *, vector<QString> > value_map;
        QFrame *frame=nullptr;

        Ui_FunctionWidget::setupUi(this);

        configureFormLayout(function_grid, OBJ_FUNCTION);
        source_code_txt=new NumberedTextEditor(this);
        dynamic_cast<QGridLayout *>(source_code_frm->layout())->addWidget(source_code_txt, 1, 0, 1, 2);

        source_code_hl=new SyntaxHighlighter(source_code_txt);
        source_code_cp=new CodeCompletionWidget(source_code_txt);

        ret_type=new PgSQLTypeWidget(this);
        vlayout=new QVBoxLayout;
        spacer=new QSpacerItem(5,5,QSizePolicy::Preferred,QSizePolicy::Expanding);
        vlayout->addWidget(ret_type);
        vlayout->addSpacerItem(spacer);

        return_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS ^
                                         ObjectTableWidget::UPDATE_BUTTON, true, this);
        return_tab->setColumnCount(2);
        return_tab->setHeaderLabel(trUtf8("Column"), 0);
        return_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/column.png")),0);
        return_tab->setHeaderLabel(trUtf8("Type"), 1);
        return_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/usertype.png")),1);

        parameters_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS ^
                                             ObjectTableWidget::UPDATE_BUTTON, true, this);
        parameters_tab->setColumnCount(4);
        parameters_tab->setHeaderLabel(trUtf8("Name"),0);
        parameters_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/parameter.png")),0);
        parameters_tab->setHeaderLabel(trUtf8("Type"),1);
        parameters_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/usertype.png")),1);
        parameters_tab->setHeaderLabel(trUtf8("Mode"),2);
        parameters_tab->setHeaderLabel(trUtf8("Default Value"),3);

        grid=new QGridLayout;
        grid->addWidget(parameters_tab,0,0,1,1);
        grid->setContentsMargins(4,4,4,4);
        func_config_twg->widget(1)->setLayout(grid);

        grid=dynamic_cast<QGridLayout *>(func_config_twg->widget(0)->layout());
        grid->addLayout(vlayout, grid->count(), 0, 1, 5);
        grid->addWidget(ret_table_gb, grid->count()-1, 0, 1, 5);

        grid1=new QGridLayout;
        grid1->addWidget(return_tab, 0, 0, 1, 1);
        grid1->setContentsMargins(2,2,2,2);
        ret_table_gb->setLayout(grid1);
        ret_table_gb->setVisible(false);

        fields_map[generateVersionsInterval(AFTER_VERSION, PgSQLVersions::PGSQL_VERSION_92)].push_back(leakproof_chk);
        frame=generateVersionWarningFrame(fields_map, &value_map);
        grid->addWidget(frame, grid->count()+1, 0, 1, 5);
        frame->setParent(func_config_twg->widget(0));

        SecurityType::getTypes(types);
        security_cmb->addItems(types);

        FunctionType::getTypes(types);
        func_type_cmb->addItems(types);

        BehaviorType::getTypes(types);
        behavior_cmb->addItems(types);

        connect(simple_rb, SIGNAL(clicked(bool)), this, SLOT(alternateReturnTypes(void)));
        connect(set_rb, SIGNAL(clicked(bool)), this, SLOT(alternateReturnTypes(void)));
        connect(table_rb, SIGNAL(clicked(bool)), this, SLOT(alternateReturnTypes(void)));
        connect(language_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(selectLanguage(void)));

        connect(parameters_tab, SIGNAL(s_rowAdded(int)), this, SLOT(showParameterForm()));
        connect(parameters_tab, SIGNAL(s_rowEdited(int)), this, SLOT(showParameterForm()));
        connect(return_tab, SIGNAL(s_rowAdded(int)), this, SLOT(showParameterForm()));
        connect(return_tab, SIGNAL(s_rowEdited(int)), this, SLOT(showParameterForm()));

        setRequiredField(language_lbl);
        setRequiredField(ret_method_lbl);
        setRequiredField(symbol_lbl);
        setRequiredField(library_lbl);
        setRequiredField(sourc_code_lbl);
        configureTabOrder();

        setMinimumSize(650, 700);
    }
    catch(Exception &e)
    {
        throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
    }
}
Example #3
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);
	}
}
Example #4
0
void SqlwriteThread::run()
{
    QString databaseseq;
    QSqlDatabase database = QSqlDatabase::addDatabase("QMYSQL",databaseseq.setNum(m_index));
    database.setHostName(m_hostname);
    database.setDatabaseName(m_databasename);
    database.setUserName(m_usrname);
    database.setPassword(m_psword);

    if (!database.open())
    {
        database.close();
        qDebug()<<trUtf8("数据库打不开")<<endl;
        return ;
    }
    else
    {
        qDebug()<<trUtf8("线程内数据已经打开")<<endl;
    }

    QString i2c;
    QFile timelog("timelog"+i2c.setNum(m_index)+".txt");
    if (!timelog.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
    {
        qDebug()<<trUtf8("LOG日志没有打开")<<endl;
        return;
    }
    timelog.close();

    QSqlQuery sqlquery(database);
//    QTime timerecord;
//    timerecord.start();
    qDebug()<<"sqltest thread runing...";
    for(int i=0;i <= m_range/SQLLINE ; ++i)		//i要改成大数,同range
    {
        QString sqlstatement = "";
        int statementnum =( (i+1)*SQLLINE > m_range ) ? m_range - i*SQLLINE: SQLLINE;
        sqlstatement="insert into TestInsert("
                "id,"
                "threadnum,"
                "idinthread,"
                "Data) VALUES";
        for(int j=0; j < statementnum; j++)
        {
            QString inttemp;
            sqlstatement += "(null,";                             //id
            sqlstatement += inttemp.setNum(m_index);                //threadnum
            sqlstatement += ","+inttemp.setNum( i*SQLLINE + j + m_index*m_range );		//idinthread
            sqlstatement += ",'dagnoansdongfnalksngnalksndlfkja;ngaldkfalnlkgnaldnfja')"; //framesize
            if( j == statementnum -1) sqlstatement += ";";
            else sqlstatement += ",";
        }
        if( statementnum != 0 )
        {
            if(!sqlquery.exec(sqlstatement))
            {
                qDebug()<<"block--"<<i<<"\t\n"<<sqlquery.lastError().databaseText();
                qDebug()<<trUtf8("发生语句错误")<<sqlstatement;
                return;
            }
        }
        else
        {
            break;
        }
//        qDebug()<<i<<"--Block insert over!";
    }

//    timelog.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
//    QTextStream logout(&timelog);
//    logout << "Insert "<<m_range<<" Lines to SQL need time : " << timerecord.elapsed() << "(ms)\n";
//    timelog.close();
    database.close();
    qDebug()<<m_index<<"_thread run over!"<<endl;
}
Example #5
0
AbonentDialog::AbonentDialog(qint32 id, quint8 userId, QWidget *parent)
  : QDialog(parent), userId_(userId) 
{
  clientComboBox = new QComboBox;
  clientLabel = new QLabel(trUtf8("Клиент"));
  clientLabel->setBuddy(clientComboBox);

  abonentEdit = new QLineEdit;
  abonentLabel = new QLabel(trUtf8("Абонент"));
  abonentLabel->setBuddy(abonentEdit);

  telEdit = new QLineEdit;
  telLabel = new QLabel(trUtf8("Телефон"));
  telLabel->setBuddy(telEdit);

  tplanComboBox = new QComboBox;
  tplanLabel = new QLabel(trUtf8("ТП"));
  tplanLabel->setBuddy(tplanComboBox);

  abonPaySpinBox = new QDoubleSpinBox;
  abonPaySpinBox->setRange(0, 999999999);
  abonPayLabel = new QLabel(trUtf8("Абон.плата"));
  abonPayLabel->setBuddy(abonPaySpinBox);

  operatorComboBox = new QComboBox;
  operatorLabel = new QLabel(trUtf8("Оператор"));
  operatorLabel->setBuddy(operatorComboBox);

  pBalanceSpinBox = new QDoubleSpinBox;
  pBalanceSpinBox->setRange(0, 999999999);
  pBalanceLabel = new QLabel(trUtf8("П.баланс"));
  pBalanceLabel->setBuddy(pBalanceSpinBox);

  limitSpinBox = new QDoubleSpinBox;
  limitSpinBox->setRange(0, 999999999);
  limitLabel = new QLabel(trUtf8("Лимит"));
  limitLabel->setBuddy(limitSpinBox);

  typeComboBox = new QComboBox;
  typeLabel = new QLabel(trUtf8("ТП"));
  typeLabel->setBuddy(typeComboBox);

  buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
                                   | QDialogButtonBox::Cancel);

  connect(buttonBox, SIGNAL(accepted()), this, SLOT(OkButtonPushed()));
  connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

  QGridLayout *topLayout = new QGridLayout;
  topLayout->addWidget(clientLabel, 0, 0);
  topLayout->addWidget(clientComboBox, 0, 1);
  topLayout->addWidget(abonentLabel, 1, 0);
  topLayout->addWidget(abonentEdit, 1, 1);
  topLayout->addWidget(telLabel, 2, 0);
  topLayout->addWidget(telEdit, 2, 1);
  topLayout->addWidget(tplanLabel, 3, 0);
  topLayout->addWidget(tplanComboBox, 3, 1);
  topLayout->addWidget(abonPayLabel, 4, 0);
  topLayout->addWidget(abonPaySpinBox, 4, 1);
  topLayout->addWidget(pBalanceLabel, 5, 0);
  topLayout->addWidget(pBalanceSpinBox, 5, 1);
  topLayout->addWidget(limitLabel, 6, 0);
  topLayout->addWidget(limitSpinBox, 6, 1);
  topLayout->addWidget(typeLabel, 7, 0);
  topLayout->addWidget(typeComboBox, 7, 1);
  topLayout->addWidget(operatorLabel, 8, 0);
  topLayout->addWidget(operatorComboBox, 8, 1);

  tableModel = new QSqlRelationalTableModel(this);
  tableModel->setTable("tb_abonents");
  tableModel->setRelation(Client, QSqlRelation("tb_clients", "uid", "text"));
  tableModel->setRelation(TPlan, QSqlRelation("tb_tplans", "uid", "text"));
  tableModel->setRelation(Operator, QSqlRelation("tb_operators", "uid", "text"));
  tableModel->setRelation(Type, QSqlRelation("tb_abonentTypes", "uid", "text"));
  tableModel->setFilter(QString("tb_abonents.uid=%1").arg(id));
  tableModel->select();
  tableModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
  
  clientModel = tableModel->relationModel(Client);
  clientModel->sort(clientModel->fieldIndex("text"), Qt::AscendingOrder);
  clientComboBox->setModel(clientModel);
  clientComboBox->setModelColumn(clientModel->fieldIndex("text"));

  tplanModel = tableModel->relationModel(TPlan);
  tplanModel->sort(tplanModel->fieldIndex("text"), Qt::AscendingOrder);
  tplanComboBox->setModel(tplanModel);
  tplanComboBox->setModelColumn(tplanModel->fieldIndex("text"));
  connect(tplanComboBox, SIGNAL(currentIndexChanged(QString)),
          this, SLOT(tplanChanged()), Qt::UniqueConnection);

  for(qint32 i=0; i < tplanModel->rowCount(); ++i) {
    QString text = tplanModel->data(tplanModel->index(i, 1)).toString();
    double costR=tplanModel->data(tplanModel->index(i, 2)).toDouble();
    hashTplans[text] = costR;
  }

  operatorModel = tableModel->relationModel(Operator);
  operatorModel->sort(operatorModel->fieldIndex("text"), Qt::AscendingOrder);
  operatorComboBox->setModel(operatorModel);
  operatorComboBox->setModelColumn(tplanModel->fieldIndex("text"));

  typeModel = tableModel->relationModel(Type);
  typeModel->sort(typeModel->fieldIndex("text"), Qt::AscendingOrder);
  typeComboBox->setModel(typeModel);
  typeComboBox->setModelColumn(typeModel->fieldIndex("text"));
  
  mapper = new QDataWidgetMapper(this);
  mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
  mapper->setModel(tableModel);
  mapper->setItemDelegate(new QSqlRelationalDelegate(this));

  mapper->addMapping(clientComboBox, Client);
  mapper->addMapping(abonentEdit, Abonent);
  mapper->addMapping(telEdit, TelA);
  mapper->addMapping(tplanComboBox, TPlan);
  mapper->addMapping(abonPaySpinBox, AbonPay);
  mapper->addMapping(pBalanceSpinBox, PBalance);
  mapper->addMapping(limitSpinBox, Limit);
  mapper->addMapping(typeComboBox, Type);
  mapper->addMapping(operatorComboBox, Operator);
  
  if(id == -1) {
    tableModel->insertRow(0);
    setWindowTitle(trUtf8("Новый абонент"));
  }
  else
    setWindowTitle(trUtf8("Редактирование абонента"));

  mapper->toFirst();

  QVBoxLayout *mainLayout = new QVBoxLayout;
  mainLayout->addLayout(topLayout);
  mainLayout->addWidget(buttonBox);
  setLayout(mainLayout);

  
}
Example #6
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);
	}
}
/**
 * Methode permettant de creer l'interface d'ajout
 * de produit au documents
 * @return l'interface
 */
QGroupBox* NewDocumentWindow::createAddProductInterface(){

    QGroupBox *groupAddProduct = new QGroupBox(trUtf8("Ajout de produit"), this);
    QFormLayout *layoutFormAddProduct=new QFormLayout;

    productName=new QComboBox(this);
    productName->setToolTip(trUtf8("Nom du produit, description, prix"));
    QList<Product> listProduct= Product::getAllProduct();

    if(listProduct.size()==0){
        this->setDisabled(true);
    }

    for(int i=0;i<listProduct.size();i++)
        productName->addItem(listProduct.at(i).name+", "+listProduct.at(i).description+", "+QVariant(listProduct.at(i).price).toString()+QString(8364));

    layoutFormAddProduct->addRow(trUtf8("Produit: "),productName);


    productQuantity=new QSpinBox(this);
    productQuantity->setMinimum(1);
    productQuantity->setMaximum(99999);
    layoutFormAddProduct->addRow(trUtf8("Quantité: "),productQuantity);

    productReduction=new QDoubleSpinBox(this);
    productQuantity->setMinimum(0);
    productQuantity->setMaximum(99999);
    layoutFormAddProduct->addRow(trUtf8("Remise: "),productReduction);

    QGroupBox *groupTypeReduction = new QGroupBox(this);

    fixedValue=new QRadioButton(trUtf8("Valeur fixe"),this);
    fixedValue->setChecked(true);
    percentage=new QRadioButton(trUtf8("Pourcentage"),this);

    QHBoxLayout *layoutRadioButton = new QHBoxLayout;
    layoutRadioButton->addWidget(fixedValue);
    layoutRadioButton->addWidget(percentage);
    layoutRadioButton->addStretch();

    groupTypeReduction->setLayout(layoutRadioButton);

    layoutFormAddProduct->addRow(trUtf8("Type de reduction"),groupTypeReduction);


    QHBoxLayout *layoutButtonProduct=new QHBoxLayout;

    buttonAddProduct=new QPushButton(trUtf8("Ajouter le produit"),this);
    layoutButtonProduct->addWidget(buttonAddProduct);

    buttonRemoveProduct=new QPushButton(trUtf8("Supprimer le produit sélectionné"),this);
    layoutButtonProduct->addWidget(buttonRemoveProduct);

    layoutButtonProduct->addStretch();
    layoutFormAddProduct->addRow(trUtf8("Actions: "),layoutButtonProduct);

    groupAddProduct->setLayout(layoutFormAddProduct);

    /** ******************************** **/
    /**               Slots              **/
    /** ******************************** **/
    connect(buttonAddProduct, SIGNAL(clicked()), this, SLOT(addProduct()));
    connect(buttonRemoveProduct, SIGNAL(clicked()), this, SLOT(removeProduct()));


    return groupAddProduct;

}
Example #8
0
TypeWidget::TypeWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_TYPE)
{
	try
	{
		QGridLayout *grid=nullptr;
		QSpacerItem *spacer=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(0)->layout());
		spacer=new QSpacerItem(20, 1, QSizePolicy::Minimum, QSizePolicy::Expanding);
		grid->addWidget(like_type,6,0,1,0);
		grid->addWidget(element_type,7,0,1,0);
		grid->addItem(spacer,8,0);

		grid=dynamic_cast<QGridLayout *>(base_attribs_twg->widget(1)->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, 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, true, this);
		attributes_tab->setColumnCount(3);
		attributes_tab->setHeaderLabel(trUtf8("Name"),0);
		attributes_tab->setHeaderIcon(QPixmap(":/icones/icones/uid.png"),0);
		attributes_tab->setHeaderLabel(trUtf8("Type"),1);
		attributes_tab->setHeaderIcon(QPixmap(":/icones/icones/usertype.png"),1);
		attributes_tab->setHeaderLabel(trUtf8("Collation"),2);
		attributes_tab->setHeaderIcon(QPixmap(":/icones/icones/collation.png"),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(1)->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->addWidget(frame, grid->count()+1, 0, 1, 0);
		frame->setParent(base_attribs_twg->widget(1));

		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);
		spacer=new QSpacerItem(20, 1, QSizePolicy::Minimum, QSizePolicy::Expanding);
		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->addWidget(frame, 4, 0, 1, 0);
		grid->addItem(spacer,5,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)));

		parent_form->setMinimumSize(620, 760);

		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);
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Example #9
0
CKongQi::CKongQi(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CKongQi)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint);

    QStringList header;
    header.append(trUtf8("MAC地址"));
    header.append(trUtf8("短地址"));
    ui->tableWidget->setColumnCount(2);
    ui->tableWidget->setColumnWidth(0, 236);
    ui->tableWidget->setColumnWidth(1, 0);
    ui->tableWidget->setHorizontalHeaderLabels(header);
    ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);

    header.clear();
    header.append(trUtf8("节点名称"));
    header.append(trUtf8("短地址"));
    header.append(trUtf8("MAC地址"));
    header.append(trUtf8("节点位置"));
    header.append(trUtf8("功能"));
    ui->tableWidget_2->setColumnCount(5);
    ui->tableWidget_2->setColumnWidth(0, 120);
    ui->tableWidget_2->setColumnWidth(1, 128);
    ui->tableWidget_2->setColumnWidth(2, 128);
    ui->tableWidget_2->setColumnWidth(3, 128);
    ui->tableWidget_2->setColumnWidth(4, 128);
    ui->tableWidget_2->setHorizontalHeaderLabels(header);
    ui->tableWidget_2->setSelectionMode(QAbstractItemView::SingleSelection);
    SelectGuanXianAddr();

    header.clear();
    header.append(trUtf8("主控名称"));
    header.append(trUtf8("主控短地址"));
    header.append(trUtf8("主控MAC地址"));
    header.append(trUtf8("主控位置"));
    header.append(trUtf8("被控名称"));
    header.append(trUtf8("被控短地址"));
    header.append(trUtf8("被控MAC地址"));
    header.append(trUtf8("被控位置"));
    header.append(trUtf8("功能"));
    header.append(trUtf8("实际功能"));
    ui->tableWidget_3->setColumnCount(10);
    ui->tableWidget_3->setColumnWidth(0, 100);
    ui->tableWidget_3->setColumnWidth(1, 100);
    ui->tableWidget_3->setColumnWidth(2, 268);
    ui->tableWidget_3->setColumnWidth(3, 100);
    ui->tableWidget_3->setColumnWidth(4, 110);
    ui->tableWidget_3->setColumnWidth(5, 100);
    ui->tableWidget_3->setColumnWidth(6, 248);
    ui->tableWidget_3->setColumnWidth(7, 148);
    ui->tableWidget_3->setColumnWidth(9, 148);
    ui->tableWidget_3->setColumnWidth(10, 148);
    ui->tableWidget_3->setHorizontalHeaderLabels(header);
    ui->tableWidget_3->setSelectionMode(QAbstractItemView::SingleSelection);
    SelectGuanXianControl();
    readtable();

    ui->comboBox->insertItem(0,QIcon(":/images/1.png"),trUtf8("开"));
    ui->comboBox->insertItem(1,QIcon(":/images/2.png"),trUtf8("关"));
    ui->comboBox->setCurrentIndex(0);

    tablerow1=-1;
    tablerow2=-1;
    tablerow3=-1;
}
Example #10
0
QString Dummy::getPluginTitle(void)
{
	return(trUtf8("Dummy"));
}
Example #11
0
QString Dummy::getPluginDescription(void)
{
	return(trUtf8("A dummy plugin only to test the pgModeler plugin structure."));
}
Example #12
0
void TableObjectView::configureObject(void)
{
	if(this->getSourceObject())
	{
		QTextCharFormat fmt;
		float px;
		QString str_constr, tooltip, atribs_tip;
		TableObject *tab_obj=dynamic_cast<TableObject *>(this->getSourceObject());
		Column *column=dynamic_cast<Column *>(tab_obj);
		ConstraintType constr_type=ConstraintType::null;
		bool sql_disabled=false;

		tooltip=Utf8String::create(tab_obj->getName()) + " (" + tab_obj->getTypeName() + ")";
		sql_disabled=tab_obj->isSQLDisabled();

		if(column)
		{
			if(column->isAddedByRelationship())
				tooltip+=trUtf8("\nRelationship: %1").arg(Utf8String::create(column->getParentRelationship()->getName()));

			str_constr=this->getConstraintString(column);

			if(str_constr.indexOf(TXT_PRIMARY_KEY)>=0)
			{
				fmt=font_config[ParsersAttributes::PK_COLUMN];
				constr_type=ConstraintType::primary_key;
			}
			else if(str_constr.indexOf(TXT_FOREIGN_KEY)>=0)
			{
				fmt=font_config[ParsersAttributes::FK_COLUMN];
				constr_type=ConstraintType::foreign_key;
			}
			else if(str_constr.indexOf(TXT_UNIQUE)>=0)
			{
				fmt=font_config[ParsersAttributes::UQ_COLUMN];
				constr_type=ConstraintType::unique;
			}
			else if(str_constr.indexOf(TXT_NOT_nullptr)>=0)
				fmt=font_config[ParsersAttributes::NN_COLUMN];
			else
				fmt=font_config[ParsersAttributes::COLUMN];

			if(column->isAddedByRelationship())
				fmt=font_config[ParsersAttributes::INH_COLUMN];
			else if(column->isProtected())
				fmt=font_config[ParsersAttributes::PROT_COLUMN];

			if(str_constr.indexOf(TXT_PRIMARY_KEY)>=0)
				atribs_tip+=(~ConstraintType(ConstraintType::primary_key)).toLower() + ", ";

			if(str_constr.indexOf(TXT_FOREIGN_KEY)>=0)
				atribs_tip+=(~ConstraintType(ConstraintType::foreign_key)).toLower() + ", ";

			if(str_constr.indexOf(TXT_UNIQUE)>=0)
				atribs_tip+=(~ConstraintType(ConstraintType::unique)).toLower() + ", ";

			if(str_constr.indexOf(TXT_EXCLUDE)>=0)
				atribs_tip+=(~ConstraintType(ConstraintType::exclude)).toLower() + ", ";

			if(str_constr.indexOf(TXT_NOT_nullptr)>=0)
				atribs_tip+="not null";
		}
		else
		{
			if(!tab_obj->isProtected())
				fmt=font_config[tab_obj->getSchemaName()];
			else
				fmt=font_config[ParsersAttributes::PROT_COLUMN];
		}

		configureDescriptor(constr_type);

		//Set the descriptor position as the first item on the view
		descriptor->setPos(HORIZ_SPACING, 1);
		px=descriptor->pos().x() + descriptor->boundingRect().width() + (2 * HORIZ_SPACING);

		//Configuring the labels as follow: [object name] [type] [constraints]
		//Configuring tha name label
		lables[0]->setText(Utf8String::create(tab_obj->getName()));

		//Strikeout the column name when its SQL is disabled
		QFont font=fmt.font();
		font.setStrikeOut(sql_disabled);
		fmt.setFont(font);

		lables[0]->setFont(fmt.font());
		lables[0]->setBrush(fmt.foreground());
		lables[0]->setPos(px, 0);
		px+=lables[0]->boundingRect().width();

		//Configuring the type label
		fmt=font_config[ParsersAttributes::OBJECT_TYPE];
		if(column)
			lables[1]->setText(Utf8String::create(TYPE_SEPARATOR + (*column->getType())));
		else
			lables[1]->setText(Utf8String::create(TYPE_SEPARATOR + tab_obj->getSchemaName()));

		lables[1]->setFont(fmt.font());
		lables[1]->setBrush(fmt.foreground());
		lables[1]->setPos(px, 0);
		px+=lables[1]->boundingRect().width() + (3 * HORIZ_SPACING);

		//Configuring the constraints label
		fmt=font_config[ParsersAttributes::CONSTRAINTS];
		if(column)
			lables[2]->setText(Utf8String::create(str_constr));
		else
		{
			Rule *rule=dynamic_cast<Rule *>(tab_obj);
			Trigger *trigger=dynamic_cast<Trigger *>(tab_obj);
			Index *index=dynamic_cast<Index *>(tab_obj);

			if(rule)
			{
				str_constr+=(~rule->getExecutionType()).mid(0,1);
				atribs_tip+=(~rule->getExecutionType()).toLower() + ", ";

				str_constr+=CONSTR_SEPARATOR;

				str_constr+=(~rule->getEventType()).mid(3,1);
				atribs_tip+=(~rule->getEventType()).toLower();
				str_constr=str_constr.toLower();
			}
			else if(trigger)
			{
				str_constr+=(~trigger->getFiringType()).mid(0,1);
				str_constr+=CONSTR_SEPARATOR;

				atribs_tip+=(~trigger->getFiringType()).toLower() + ", ";

				for(unsigned i=EventType::on_insert; i <= EventType::on_truncate; i++)
				{
					if(trigger->isExecuteOnEvent(EventType(i)))
					{
						str_constr+=(~EventType(i)).mid(3,1);
						atribs_tip+=(~EventType(i)).toLower() + ", ";
					}
				}
				str_constr=str_constr.toLower();
			}
			else if(index)
			{
				if(index->getIndexAttribute(Index::UNIQUE))
				{
					str_constr+="u";
					atribs_tip += QString("unique") + ", ";
				}

				if(index->getIndexAttribute(Index::CONCURRENT))
				{
					str_constr+="c";
					atribs_tip += QString("concurrent") + ", ";
				}

				if(index->getIndexAttribute(Index::FAST_UPDATE))
				{
					str_constr+="f";
					atribs_tip += "fast updated";
				}
			}

			if(!str_constr.isEmpty())
				lables[2]->setText(Utf8String::create(CONSTR_DELIM_START + " " +
																						 str_constr + " " +
																						 CONSTR_DELIM_END));
		}

		if(!atribs_tip.isEmpty())
		{
			if(atribs_tip.at(atribs_tip.length()-1)==' ')
				atribs_tip.remove(atribs_tip.length()-2, 2);

			atribs_tip=Utf8String::create("\n" + CONSTR_DELIM_START + " " + atribs_tip + " " + CONSTR_DELIM_END);
		}

		lables[2]->setFont(fmt.font());
		lables[2]->setBrush(fmt.foreground());
		lables[2]->setPos(px, 0);

		//Calculating the object bounding rect that is composed by the join of the all object's child dimensions
		descriptor->setPos(HORIZ_SPACING, lables[0]->boundingRect().center().y() - descriptor->boundingRect().center().y());
		bounding_rect.setTopLeft(QPointF(descriptor->boundingRect().left(), lables[0]->boundingRect().top()));

		//Special case: when the constraint label has no text use the type label dimension
		if(lables[2]->boundingRect().width()==0)
			bounding_rect.setBottomRight(QPointF(lables[1]->boundingRect().right(), lables[0]->boundingRect().bottom()));
		else
			bounding_rect.setBottomRight(QPointF(lables[2]->boundingRect().right(), lables[0]->boundingRect().bottom()));

		this->setToolTip(tooltip + atribs_tip);
	}
}
void propertiesDialog::on_okButton_clicked()
{
    if (applyPermissions()) close();  else
        QMessageBox::warning(this,trUtf8("Ошибка"),trUtf8("\nОшибка изменения прав доступа"),QMessageBox::Ok);
}
void SoundLibraryPropertiesDialog::on_saveBtn_clicked()
{

	bool reload = false;

	if ( saveChanges_checkBox->isChecked() ){
		//test if the drumkit is loaded
		if ( Hydrogen::get_instance()->getCurrentDrumkitname() != drumkitinfo->get_name() ){
			QMessageBox::information( this, "Hydrogen", trUtf8 ( "This is not possible, you can only save changes inside instruments to the current loaded sound library"));
			saveChanges_checkBox->setChecked( false );
			return;
		}
		reload = true;
	}

	//load the selected drumkit to save it correct.... later the old drumkit will be reloaded
	if ( drumkitinfo != NULL && ( !saveChanges_checkBox->isChecked() ) ){
		if ( Hydrogen::get_instance()->getCurrentDrumkitname() != drumkitinfo->get_name() ){
			Hydrogen::get_instance()->loadDrumkit( drumkitinfo );
			Hydrogen::get_instance()->getSong()->__is_modified = true;
		}
	}

	//check the drumkit name. if the name is a new one, one qmessagebox with question "are you sure" will displayed.
	if ( nameTxt->text() != oldName  ){
		int res = QMessageBox::information( this, "Hydrogen", tr( "Warning! Changing the drumkit name will result in creating a new drumkit with this name.\nAre you sure?"), tr("&Ok"), tr("&Cancel"), 0, 1 );
		if ( res == 1 ) {
			return;
		}
		else
		{
			reload = true;
		}
	}

	//save the drumkit
	if( !H2Core::Drumkit::save( nameTxt->text(), authorTxt->text(), infoTxt->toHtml(), licenseTxt->text(), H2Core::Hydrogen::get_instance()->getSong()->get_instrument_list(), H2Core::Hydrogen::get_instance()->getSong()->get_components(), true ) ) {
        QMessageBox::information( this, "Hydrogen", trUtf8 ( "Saving of this drumkit failed."));
    }

	//check the name and set the drumkitinfo to current drumkit
	if ( drumkitinfo != NULL && !nameTxt->text().isEmpty() ){
		drumkitinfo->set_name( nameTxt->text() );
		drumkitinfo->set_author( authorTxt->text() );
		drumkitinfo->set_info( infoTxt->toHtml() );
		drumkitinfo->set_license( licenseTxt->text() );
	}


	//check pre loaded drumkit name  and reload the old drumkit
	if ( predrumkit != NULL ){
		if ( predrumkit->get_name() !=  Hydrogen::get_instance()->getCurrentDrumkitname() ){
			Hydrogen::get_instance()->loadDrumkit( predrumkit );
			Hydrogen::get_instance()->getSong()->__is_modified = true;
		}
	}

	//reload if necessary
	if ( reload == true ){
		HydrogenApp::get_instance()->getInstrumentRack()->getSoundLibraryPanel()->test_expandedItems();
		HydrogenApp::get_instance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList();
	}

	accept();

}
Example #15
0
TableWidget::TableWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_TABLE)
{
    QGridLayout *grid=nullptr;
    ObjectTableWidget *tab=nullptr;
    ObjectType types[]= { OBJ_COLUMN, OBJ_CONSTRAINT, OBJ_TRIGGER, OBJ_RULE, OBJ_INDEX };
    map<QString, vector<QWidget *> > fields_map;
    QFrame *frame=nullptr;

    Ui_TableWidget::setupUi(this);

    fields_map[generateVersionsInterval(AFTER_VERSION, PgSQLVersions::PGSQL_VERSION_91)].push_back(unlogged_chk);
    frame=generateVersionWarningFrame(fields_map);
    table_grid->addWidget(frame, table_grid->count()+1, 0, 1, 2);
    frame->setParent(this);

    parent_tables = new ObjectTableWidget(ObjectTableWidget::NO_BUTTONS, true, this);
    parent_tables->setColumnCount(3);
    parent_tables->setHeaderLabel(trUtf8("Name"), 0);
    parent_tables->setHeaderIcon(QPixmap(QString(":/icones/icones/uid.png")),0);
    parent_tables->setHeaderLabel(trUtf8("Schema"), 1);
    parent_tables->setHeaderIcon(QPixmap(QString(":/icones/icones/schema.png")),1);
    parent_tables->setHeaderLabel(trUtf8("Type"), 2);
    parent_tables->setHeaderIcon(QPixmap(QString(":/icones/icones/usertype.png")),2);

    tag_sel=new ObjectSelectorWidget(OBJ_TAG, false, this);
    dynamic_cast<QGridLayout *>(options_gb->layout())->addWidget(tag_sel, 0, 1, 1, 3);

    grid=new QGridLayout;
    grid->addWidget(parent_tables, 0,0,1,1);
    grid->setContentsMargins(4,4,4,4);
    attributes_tbw->widget(5)->setLayout(grid);

    //Configuring the table objects that stores the columns, triggers, constraints, rules and indexes
    for(unsigned i=0; i < 5; i++)
    {
        tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS ^
                                  (ObjectTableWidget::UPDATE_BUTTON), true, this);

        objects_tab_map[types[i]]=tab;

        grid=new QGridLayout;
        grid->addWidget(tab, 0,0,1,1);
        grid->setContentsMargins(4,4,4,4);
        attributes_tbw->widget(i)->setLayout(grid);

        connect(tab, SIGNAL(s_rowsRemoved(void)), this, SLOT(removeObjects(void)));
        connect(tab, SIGNAL(s_rowRemoved(int)), this, SLOT(removeObject(int)));
        connect(tab, SIGNAL(s_rowAdded(int)), this, SLOT(handleObject(void)));
        connect(tab, SIGNAL(s_rowEdited(int)), this, SLOT(handleObject(void)));
        connect(tab, SIGNAL(s_rowsMoved(int,int)), this, SLOT(swapObjects(int,int)));
    }

    objects_tab_map[OBJ_COLUMN]->setColumnCount(4);
    objects_tab_map[OBJ_COLUMN]->setHeaderLabel(trUtf8("Name"), 0);
    objects_tab_map[OBJ_COLUMN]->setHeaderIcon(QPixmap(QString(":/icones/icones/uid.png")),0);
    objects_tab_map[OBJ_COLUMN]->setHeaderLabel(trUtf8("Type"), 1);
    objects_tab_map[OBJ_COLUMN]->setHeaderIcon(QPixmap(QString(":/icones/icones/usertype.png")),1);
    objects_tab_map[OBJ_COLUMN]->setHeaderLabel(trUtf8("Default Value"), 2);
    objects_tab_map[OBJ_COLUMN]->setHeaderLabel(trUtf8("Attribute"), 3);

    objects_tab_map[OBJ_CONSTRAINT]->setColumnCount(4);
    objects_tab_map[OBJ_CONSTRAINT]->setHeaderLabel(trUtf8("Name"), 0);
    objects_tab_map[OBJ_CONSTRAINT]->setHeaderIcon(QPixmap(QString(":/icones/icones/uid.png")),0);
    objects_tab_map[OBJ_CONSTRAINT]->setHeaderLabel(trUtf8("Type"), 1);
    objects_tab_map[OBJ_CONSTRAINT]->setHeaderIcon(QPixmap(QString(":/icones/icones/usertype.png")),1);
    objects_tab_map[OBJ_CONSTRAINT]->setHeaderLabel(trUtf8("ON DELETE"), 2);
    objects_tab_map[OBJ_CONSTRAINT]->setHeaderLabel(trUtf8("ON UPDATE"), 3);

    objects_tab_map[OBJ_TRIGGER]->setColumnCount(4);
    objects_tab_map[OBJ_TRIGGER]->setHeaderLabel(trUtf8("Name"), 0);
    objects_tab_map[OBJ_TRIGGER]->setHeaderIcon(QPixmap(QString(":/icones/icones/uid.png")),0);
    objects_tab_map[OBJ_TRIGGER]->setHeaderLabel(trUtf8("Refer. Table"), 1);
    objects_tab_map[OBJ_TRIGGER]->setHeaderIcon(QPixmap(QString(":/icones/icones/table.png")),1);
    objects_tab_map[OBJ_TRIGGER]->setHeaderLabel(trUtf8("Firing"), 2);
    objects_tab_map[OBJ_TRIGGER]->setHeaderIcon(QPixmap(QString(":/icones/icones/trigger.png")),2);
    objects_tab_map[OBJ_TRIGGER]->setHeaderLabel(trUtf8("Events"), 3);

    objects_tab_map[OBJ_RULE]->setColumnCount(3);
    objects_tab_map[OBJ_RULE]->setHeaderLabel(trUtf8("Name"), 0);
    objects_tab_map[OBJ_RULE]->setHeaderIcon(QPixmap(QString(":/icones/icones/uid.png")),0);
    objects_tab_map[OBJ_RULE]->setHeaderLabel(trUtf8("Execution"), 1);
    objects_tab_map[OBJ_RULE]->setHeaderLabel(trUtf8("Event"), 2);

    objects_tab_map[OBJ_INDEX]->setColumnCount(2);
    objects_tab_map[OBJ_INDEX]->setHeaderLabel(trUtf8("Name"), 0);
    objects_tab_map[OBJ_INDEX]->setHeaderIcon(QPixmap(QString(":/icones/icones/uid.png")),0);
    objects_tab_map[OBJ_INDEX]->setHeaderLabel(trUtf8("Indexing"), 1);

    configureFormLayout(table_grid, OBJ_TABLE);
    configureTabOrder({ tag_sel });

    setMinimumSize(600, 610);
}
Example #16
0
InstrumentRack::InstrumentRack( QWidget *pParent )
 : QWidget( pParent )
 , Object( __class_name )
{
	INFOLOG( "INIT" );

	resize( 290, 450 );
	setMinimumSize( width(), height() );
	setFixedWidth( width() );


// TAB buttons
	QWidget *pTabButtonsPanel = new QWidget( NULL );
	pTabButtonsPanel->setFixedHeight( 24 );
	pTabButtonsPanel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );

	// instrument editor button
	m_pShowInstrumentEditorBtn = new ToggleButton(
			pTabButtonsPanel,
			"/instrumentEditor/instrument_show_on.png",
			"/instrumentEditor/instrument_show_off.png",
			"/instrumentEditor/instrument_show_off.png",
			QSize( 130, 24 )
	);
	m_pShowInstrumentEditorBtn->setToolTip( trUtf8( "Show Instrument editor" ) );
	m_pShowInstrumentEditorBtn->setText( trUtf8( "Instrument" ) );
	connect( m_pShowInstrumentEditorBtn, SIGNAL( clicked( Button* ) ), this, SLOT( on_showInstrumentEditorBtnClicked() ) );

	// show sound library button
	m_pShowSoundLibraryBtn = new ToggleButton(
			pTabButtonsPanel,
			"/instrumentEditor/library_show_on.png",
			"/instrumentEditor/library_show_off.png",
			"/instrumentEditor/library_show_off.png",
			QSize( 150, 24 )
	);
	m_pShowSoundLibraryBtn->setToolTip( trUtf8( "Show sound library" ) );
	m_pShowSoundLibraryBtn->setText( trUtf8( "Sound library" ) );
	connect( m_pShowSoundLibraryBtn, SIGNAL( clicked( Button* ) ), this, SLOT( on_showSoundLibraryBtnClicked() ) );

	QHBoxLayout *pTabHBox = new QHBoxLayout();
	pTabHBox->setSpacing( 0 );
	pTabHBox->setMargin( 0 );
	pTabHBox->addWidget( m_pShowInstrumentEditorBtn );
	pTabHBox->addWidget( m_pShowSoundLibraryBtn );

	pTabButtonsPanel->setLayout( pTabHBox );

//~ TAB buttons


	InstrumentEditorPanel::get_instance()->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );

	m_pSoundLibraryPanel = new SoundLibraryPanel( NULL );

	// LAYOUT
	QGridLayout *pGrid = new QGridLayout();
	pGrid->setSpacing( 0 );
	pGrid->setMargin( 0 );

	pGrid->addWidget( pTabButtonsPanel, 0, 0, 1, 3 );
	pGrid->addWidget( InstrumentEditorPanel::get_instance(), 2, 1 );
	pGrid->addWidget( m_pSoundLibraryPanel, 2, 1 );

	this->setLayout( pGrid );

	on_showInstrumentEditorBtnClicked();	// show the instrument editor as default
}
Example #17
0
/* 
 *  Constructs a KoalaStatus which is a child of 'parent', with the 
 *  name 'name' and widget flags set to 'f'.
 *
 */
KoalaStatus::KoalaStatus( QWidget* parent,  const char* name, WFlags fl )
    : QMainWindow( parent, name, fl )
{
	(void)statusBar();
	if ( !name )
		setName( "KoalaStatus" );
	resize( 600, 480 ); 
	setCaption( trUtf8( "KoalaMUD Status" ) );

	// actions
	Quit = new QAction( this, "Quit" );
	Quit->setText( trUtf8( "Quit" ) );
	StartNetwork = new QAction( this, "StartNetwork" );
	StartNetwork->setText( trUtf8( "StartNetwork" ) );
	PlayerDockAct = new QAction( this, "Players" );
	PlayerDockAct->setToggleAction(true);
	PlayerDockAct->setOn(true);
	PlayerDockAct->setText( trUtf8( "Players" ) );
	ListenDockAct = new QAction( this, "Listens" );
	ListenDockAct->setToggleAction(true);
	ListenDockAct->setOn(true);
	ListenDockAct->setText( trUtf8( "Listens" ) );


	// toolbars


	// menubar
	menubar = new QMenuBar( this, "menubar" );

	System = new QPopupMenu( this ); 
	StartNetwork->addTo( System );
	System->insertSeparator();
	Quit->addTo( System );
	menubar->insertItem( trUtf8( "System" ), System );

	Status = new QPopupMenu( this ); 
	PlayerDockAct->addTo( Status );
	ListenDockAct->addTo( Status );
	menubar->insertItem( trUtf8( "Status" ), Status );

	// Dock Windows
	PlayerStatusDock = new QDockWindow(QDockWindow::InDock, this,
						"PlrStat");
	PlayerStatusList = new QListView(PlayerStatusDock, "PlrStatList");
	PlayerStatusList->addColumn("Player");
	PlayerStatusList->addColumn("Level");
	PlayerStatusList->addColumn("State");
	PlayerCountItem = new QListViewItem(PlayerStatusList, "Total", "0", "");
	PlayerStatusDock->setWidget(PlayerStatusList);
	PlayerStatusDock->setResizeEnabled(true);
	moveDockWindow(PlayerStatusDock, DockLeft);
	setDockEnabled(PlayerStatusDock, DockTop, false);
	setDockEnabled(PlayerStatusDock, DockBottom, false);
	PlayerStatusDock->show();

	ListenStatusDock = new QDockWindow(QDockWindow::InDock, this,
						"ListenStat");
	ListenStatusList = new QListView(ListenStatusDock, "ListenStatList");
	ListenStatusList->addColumn("Listen Port");
	ListenStatusList->addColumn("Listener Status");
	ListenCountItem = new QListViewItem(ListenStatusList, "Total Listeners",
						"0");
	ListenStatusDock->setWidget(ListenStatusList);
	ListenStatusDock->setResizeEnabled(true);
	moveDockWindow(ListenStatusDock, DockLeft);
	setDockEnabled(ListenStatusDock, DockTop, false);
	setDockEnabled(ListenStatusDock, DockBottom, false);
	ListenStatusDock->show();

	// signals and slots connections
	connect( Quit, SIGNAL( activated() ), this, SLOT( close() ) );
	connect(StartNetwork, SIGNAL( activated() ), this, SLOT( portdialog() ) );
	connect(PlayerDockAct, SIGNAL(toggled(bool)), this, SLOT(playerstoggled(bool)));
	connect(ListenDockAct, SIGNAL(toggled(bool)), this, SLOT(listentoggled(bool)));
}
void ModelValidationWidget::updateValidation(ValidationInfo val_info)
{
	QTreeWidgetItem *item=new QTreeWidgetItem, *item1=nullptr, *item2=nullptr;
	QLabel *label=new QLabel, *label1=nullptr, *label2=nullptr;
	vector<BaseObject *> refs;
	BaseTable *table=nullptr;
	TableObject *tab_obj=nullptr;
	QString ref_name;

	if(val_info.getValidationType()==ValidationInfo::BROKEN_REFERENCE)
		label->setText(trUtf8("The object <strong>%1</strong> <em>(%2)</em> [id: %3] is being referenced by <strong>%4</strong> object(s) before its creation.")
									.arg(Utf8String::create(val_info.getObject()->getName(true).remove("\"")))
									.arg(val_info.getObject()->getTypeName())
									.arg(val_info.getObject()->getObjectId())
									.arg(val_info.getReferences().size()));
  else if(val_info.getValidationType()==ValidationInfo::SP_OBJ_BROKEN_REFERENCE)
  {
    QString str_aux;

    if(TableObject::isTableObject(val_info.getObject()->getObjectType()))
    {
      TableObject *tab_obj=dynamic_cast<TableObject *>(val_info.getObject());
      str_aux=QString(" owned by table <strong>%1</strong> ").arg(tab_obj->getParentTable()->getName(true).remove("\""));
    }

    label->setText(trUtf8("The object <strong>%1</strong> <em>(%2)</em> [id: %3]%4 is referencing columns created by <strong>%5</strong> relationship(s) but is created before them.")
                  .arg(Utf8String::create(val_info.getObject()->getName(true).remove("\"")))
                  .arg(val_info.getObject()->getTypeName())
                  .arg(val_info.getObject()->getObjectId())
                  .arg(str_aux)
                  .arg(val_info.getReferences().size()));
  }
	else if(val_info.getValidationType()==ValidationInfo::NO_UNIQUE_NAME)
	{
		tab_obj=dynamic_cast<TableObject *>(val_info.getObject());

		if(tab_obj)
		{
			table=tab_obj->getParentTable();
			ref_name=table->getName(true).remove("\"") + "." + val_info.getObject()->getName(true).remove("\"");
		}
		else
			ref_name=val_info.getObject()->getName(true).remove("\"");

		label->setText(trUtf8("The object <strong>%1</strong> <em>(%2)</em> has a name that conflicts with <strong>%3</strong> object's name(s).")
									 .arg(Utf8String::create(ref_name))
									 .arg(val_info.getObject()->getTypeName())
									 .arg(val_info.getReferences().size()));

	}
	else if(val_info.getValidationType()==ValidationInfo::SQL_VALIDATION_ERR)
		label->setText(trUtf8("SQL validation failed due to error(s) below. <strong>NOTE:</strong><em> These errors does not invalidates the model thus you can save it without any problem.</em>"));
	else
		label->setText(val_info.getErrors().at(0));


	if(val_info.getValidationType()==ValidationInfo::SQL_VALIDATION_ERR ||
		 val_info.getValidationType()==ValidationInfo::VALIDATION_ABORTED)
	{
		QStringList errors=val_info.getErrors();
		QFont fnt;
		item->setIcon(0, QPixmap(QString(":/icones/icones/msgbox_alerta.png")));
		validation_prog_pb->setValue(validation_prog_pb->maximum());		
		reenableValidation();

		if(val_info.getValidationType()==ValidationInfo::SQL_VALIDATION_ERR)
		{
			//Adding all the sql errors into the output pane
			while(!errors.isEmpty())
			{
				item1=new QTreeWidgetItem(item);
				label1=new QLabel;
				label1->setText(errors.back());
				fnt=label1->font();
				fnt.setPointSizeF(8.0f);
				label1->setFont(fnt);
				output_trw->setItemWidget(item1, 0, label1);
				errors.pop_back();
			}
		}
	}
	else
	{
		item->setIcon(0, QPixmap(QString(":/icones/icones/msgbox_erro.png")));

		//Listing the referrer object on output pane
		refs=val_info.getReferences();
		while(!refs.empty())
		{
			item1=new QTreeWidgetItem(item);
			label1=new QLabel;
			item1->setIcon(0, QPixmap(QString(":/icones/icones/") + refs.back()->getSchemaName() + QString(".png")));


			if(val_info.getValidationType()==ValidationInfo::NO_UNIQUE_NAME)
			{
				TableObject *tab_obj=dynamic_cast<TableObject *>(refs.back());
				ref_name=refs.back()->getName(true);

				//If the referrer object is a table object, concatenates the parent table name
				if(tab_obj)
				{
					ref_name=dynamic_cast<TableObject *>(refs.back())->getParentTable()->getName(true) + "." + ref_name;

					if(tab_obj->isAddedByRelationship())
					{
						QPalette pal;
						item2=new QTreeWidgetItem(item1);
						label2=new QLabel;
						pal.setColor(QPalette::Text, QColor(255,0,0));
						label2->setPalette(pal);
						label2->setText(trUtf8("<em>The above object was created by a relationship. Change the name pattern on it's generator relationship. Fix will not be applied!</em>"));
						output_trw->setItemWidget(item2, 0, label2);
						item1->setExpanded(true);
					}
				}

				label1->setText(trUtf8("Conflicting object: <strong>%1</strong> <em>(%2)</em>.")
												.arg(Utf8String::create(ref_name).remove("\""))
												.arg(Utf8String::create(refs.back()->getTypeName())));
			}
			else
			{
        if(val_info.getValidationType()==ValidationInfo::SP_OBJ_BROKEN_REFERENCE)
          label1->setText(trUtf8("Relationship: <strong>%1</strong> [id: %2].")
                          .arg(Utf8String::create(refs.back()->getName(true)))
                          .arg(refs.back()->getObjectId()));
        else
        {
          label1->setText(trUtf8("Referrer object: <strong>%1</strong> <em>(%2)</em> [id: %3].")
                          .arg(Utf8String::create(refs.back()->getName(true)))
                          .arg(Utf8String::create(refs.back()->getTypeName()))
                          .arg(refs.back()->getObjectId()));
        }
			}

			output_trw->setItemWidget(item1, 0, label1);
			refs.pop_back();
		}
	}

	output_trw->addTopLevelItem(item);
	output_trw->setItemWidget(item, 0, label);
	item->setExpanded(false);

	//Stores the validatin on the current tree item
	item->setData(0, Qt::UserRole, QVariant::fromValue<ValidationInfo>(val_info));
	warn_count_lbl->setText(QString("%1").arg(validation_helper.getWarningCount()));
	error_count_lbl->setText(QString("%1").arg(validation_helper.getErrorCount()));
	output_trw->setItemHidden(item, false);
	output_trw->scrollToBottom();
}
Example #19
0
ActsDialog::ActsDialog(qint8 /* typeId */, QWidget *parent)
  : QDialog(parent)
{
  findLabel_ = new QLabel(trUtf8("&Поиск"));
  findEdit_ = new QLineEdit;
  findLabel_->setBuddy(findEdit_);

  QHBoxLayout *topLayout = new QHBoxLayout;
  topLayout->addWidget(findLabel_);
  topLayout->addWidget(findEdit_);

  QSqlQuery query;
  query.exec();
  
  query.prepare("SELECT strftime('%d.%m.%Y',m.date_)"
		" ,m.document"
		" ,p.text"
		" ,COUNT(1)"
		" ,SUM(m.n*d.qty) "
		"FROM tb_moves m "
		" ,tb_places p "
		" ,tb_details d "
		"WHERE 1=1 "
		" AND m.detailId=d.uid"
		// " AND d.typeId=:typeId"
		" AND m.placeId=p.uid"
		" AND m.document NOT LIKE :document "
		"GROUP BY 1,2,3 ORDER BY m.date_ DESC");
  // query.bindValue(":typeId", typeId);
  query.bindValue(":document", trUtf8("л/к%"));
  query.exec();

  tableView_ = new QTableView;
  queryModel_ = new ActsModel;
  
  queryModel_->setQuery(query);

  queryModel_->setHeaderData(Act_Date, Qt::Horizontal, trUtf8("Дата"));
  queryModel_->setHeaderData(Act_Text, Qt::Horizontal, trUtf8("Документ"));
  queryModel_->setHeaderData(Act_Customer, Qt::Horizontal, trUtf8("Заказчик"));
  queryModel_->setHeaderData(Act_Count, Qt::Horizontal, trUtf8("Кол-во"));
  queryModel_->setHeaderData(Act_Sum, Qt::Horizontal, trUtf8("Сумма"));

  proxyModel_ = new QSortFilterProxyModel;
  //proxyModel->setDynamicSortFilter(true);
  proxyModel_->setSourceModel(queryModel_);
  proxyModel_->setFilterKeyColumn(-1);
  //proxyModel->sort(Details_Text, Qt::AscendingOrder);

  connect(findEdit_, SIGNAL(textChanged(QString)),
  	  this, SLOT(filterRegExpChanged()), Qt::UniqueConnection);


  tableView_->setModel(proxyModel_);

  tableView_->setSelectionMode(QAbstractItemView::ExtendedSelection);
  tableView_->setSelectionBehavior(QAbstractItemView::SelectRows);
  
  tableView_->verticalHeader()->hide();
  tableView_->resizeColumnsToContents();
  tableView_->setAlternatingRowColors(true);


  //QAction *viewAction = new QAction(trUtf8("&Просмотр"), this);
  //copyAction->setShortcut(tr("Ctrl+X"));
  //connect(viewAction, SIGNAL(triggered()), this, SLOT(view()));

  QAction *viewAction = new QAction(trUtf8("Просмотр"), this);
  connect(viewAction, SIGNAL(triggered()), this, SLOT(view()));

  tableView_->addAction(viewAction);
  tableView_->setContextMenuPolicy(Qt::ActionsContextMenu);

  /*
  tableView->horizontalHeader()->setStretchLastSection(false);
  tableView->horizontalHeader()->setResizeMode(Storages_AmountBr,QHeaderView::Custom);
  tableView->horizontalHeader()->setResizeMode(Storages_ProductText,QHeaderView::Stretch);
  tableView->horizontalHeader()->setResizeMode(Storages_Amount,QHeaderView::Custom);
  */

  tableView_->resizeColumnsToContents();
  tableView_->setCurrentIndex(tableView_->model()->index(0, 0));

  QVBoxLayout *mainLayout = new QVBoxLayout;
  mainLayout->addLayout(topLayout);
  mainLayout->addWidget(tableView_);
  setLayout(mainLayout);

  setWindowTitle(trUtf8("Акты"));
  setFixedWidth(tableView_->horizontalHeader()->length()+50);
  setFixedHeight(380);
}
/**
 * Methode permettant de creer l'interface de saisie des
 * information de base du document
 * @return l'interface
 */
QGroupBox* NewDocumentWindow::createBasicInfoInterface(){

    QGroupBox *groupBase = new QGroupBox(trUtf8("Informations de base"), this);
    QFormLayout *layoutFormBase=new QFormLayout;

    customerName=new QComboBox(this);
    customerName->setToolTip(trUtf8("Nom du client, ville"));
    QList<Customer> listCustomer= Customer::getAllCustomer();

    if(listCustomer.size()==0){
        this->setDisabled(true);
    }

    for(int i=0;i<listCustomer.size();i++)
        customerName->addItem(listCustomer.at(i).m_name+", "+listCustomer.at(i).m_city);

    layoutFormBase->addRow(trUtf8("Client: "),customerName);


    documentType=new QComboBox(this);
    documentType->addItem(trUtf8("Facture"));
    documentType->addItem(trUtf8("Devis"));
    layoutFormBase->addRow(trUtf8("Type de document: "),documentType);


    reglementMode=new QComboBox(this);
    reglementMode->addItem(trUtf8("Cheque"));
    reglementMode->addItem(trUtf8("Espece"));
    reglementMode->addItem(trUtf8("Virement"));
    layoutFormBase->addRow(trUtf8("Mode de paiement: "),reglementMode);

    documentTva=new QDoubleSpinBox(this);
    documentTva->setMinimum(0.0);
    documentTva->setMaximum(100.0);
    layoutFormBase->addRow(trUtf8("TVA du document: "),documentTva);


    groupBase->setLayout(layoutFormBase);

    /** ******************************** **/
    /**               Slots              **/
    /** ******************************** **/

    connect(documentType, SIGNAL(currentIndexChanged(int)), this, SLOT(turnOnOffDocumentType(int)));

    return groupBase;

}