当前位置: 首页>>代码示例>>C++>>正文


C++ Catalog::getObjectsAttributes方法代码示例

本文整理汇总了C++中Catalog::getObjectsAttributes方法的典型用法代码示例。如果您正苦于以下问题:C++ Catalog::getObjectsAttributes方法的具体用法?C++ Catalog::getObjectsAttributes怎么用?C++ Catalog::getObjectsAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Catalog的用法示例。


在下文中一共展示了Catalog::getObjectsAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: retrievePKColumns

void DataManipulationForm::retrievePKColumns(const QString &schema, const QString &table)
{
  Catalog catalog;
  Connection conn=Connection(tmpl_conn_params);

	try
	{
		vector<attribs_map> pks;
		ObjectType obj_type=static_cast<ObjectType>(table_cmb->currentData().toUInt());

		if(obj_type==OBJ_VIEW)
		{
			warning_frm->setVisible(true);
			warning_lbl->setText(trUtf8("Views can't have their data handled through this grid, this way, all operations are disabled."));
		}
		else
		{
      catalog.setConnection(conn);
			//Retrieving the constraints from catalog using a custom filter to select only primary keys (contype=p)
      pks=catalog.getObjectsAttributes(OBJ_CONSTRAINT, schema, table, {}, {{ParsersAttributes::CUSTOM_FILTER, QString("contype='p'")}});
      catalog.closeConnection();

      warning_frm->setVisible(pks.empty());

			if(pks.empty())
				warning_lbl->setText(trUtf8("The selected table doesn't owns a primary key! Updates and deletes will be performed by considering all columns as primary key. <strong>WARNING:</strong> those operations can affect more than one row."));
		}

		hint_frm->setVisible(obj_type==OBJ_TABLE);
		add_tb->setEnabled(obj_type==OBJ_TABLE);
		pk_col_ids.clear();

		if(!pks.empty())
		{
			QStringList col_str_ids=Catalog::parseArrayValues(pks[0][ParsersAttributes::COLUMNS]);

			for(QString id : col_str_ids)
				pk_col_ids.push_back(id.toInt() - 1);
		}

		//For tables, even if there is no pk the user can manipulate data
		if(obj_type==OBJ_TABLE)
			results_tbw->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::AnyKeyPressed);
		else
			results_tbw->setEditTriggers(QAbstractItemView::NoEditTriggers);
	}
	catch(Exception &e)
	{
    catalog.closeConnection();
		throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
开发者ID:InnovaMex,项目名称:pgmodeler,代码行数:52,代码来源:datamanipulationform.cpp

示例2: listColumns

void DataManipulationForm::listColumns(void)
{
  Catalog catalog;
  Connection conn=Connection(tmpl_conn_params);

  try
  {
    resetAdvancedControls();
    col_names.clear();
    code_compl_wgt->clearCustomItems();

    if(table_cmb->currentIndex() > 0)
    {
      vector<attribs_map> cols;

      catalog.setConnection(conn);
      cols=catalog.getObjectsAttributes(OBJ_COLUMN, schema_cmb->currentText(), table_cmb->currentText());

      for(auto &col : cols)
      {
        col_names.push_back(col[ParsersAttributes::NAME]);
        code_compl_wgt->insertCustomItem(col[ParsersAttributes::NAME], {},
                                         QPixmap(QString(":/icones/icones/column.png")));
      }

      ord_column_cmb->addItems(col_names);
    }

    add_ord_col_tb->setEnabled(ord_column_cmb->count() > 0);
    filter_tb->setEnabled(ord_column_cmb->count() > 0);
  }
  catch(Exception &e)
  {
    catalog.closeConnection();
    throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__,&e);
  }

}
开发者ID:InnovaMex,项目名称:pgmodeler,代码行数:38,代码来源:datamanipulationform.cpp

示例3: fillResultsTable

void SQLExecutionWidget::fillResultsTable(Catalog &catalog, ResultSet &res, QTableWidget *results_tbw, bool store_data)
{
	if(!results_tbw)
		throw Exception(ERR_OPR_NOT_ALOC_OBJECT ,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	try
	{
		int col=0, row=0, col_cnt=res.getColumnCount();
		QTableWidgetItem *item=nullptr;
		vector<unsigned> type_ids;
		vector<attribs_map> types;
		map<unsigned, QString> type_names;
		unsigned orig_filter=catalog.getFilter();

		results_tbw->setRowCount(0);
		results_tbw->setColumnCount(col_cnt);
		results_tbw->verticalHeader()->setVisible(true);
		results_tbw->blockSignals(true);

		//Configuring the grid columns with the names of retrived table columns
		for(col=0; col < col_cnt; col++)
		{
			type_ids.push_back(res.getColumnTypeId(col));
			results_tbw->setHorizontalHeaderItem(col, new QTableWidgetItem(res.getColumnName(col)));
		}

		//Retrieving the data type names for each column
		catalog.setFilter(Catalog::LIST_ALL_OBJS);
		std::unique(type_ids.begin(), type_ids.end());
    types=catalog.getObjectsAttributes(OBJ_TYPE, QString(), QString(), type_ids);

    for(auto &tp : types)
			type_names[tp[ParsersAttributes::OID].toUInt()]=tp[ParsersAttributes::NAME];

		catalog.setFilter(orig_filter);

		//Assinging the type names as tooltip on header items
		for(col=0; col < col_cnt; col++)
		{
			item=results_tbw->horizontalHeaderItem(col);
			item->setToolTip(type_names[res.getColumnTypeId(col)]);
			item->setData(Qt::UserRole, type_names[res.getColumnTypeId(col)]);
		}

		if(res.accessTuple(ResultSet::FIRST_TUPLE))
		{
			results_tbw->setRowCount(res.getTupleCount());

			do
			{
				//Fills the current row with the values of current tuple
				for(col=0; col < col_cnt; col++)
				{
					item=new QTableWidgetItem;

					if(res.isColumnBinaryFormat(col))
					{
						//Binary columns can't be edited by user
						item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
						item->setText(trUtf8("[binary data]"));
					}
					else
					{
						item->setText(res.getColumnValue(col));

						if(store_data)
							item->setData(Qt::UserRole, item->text());
					}

					results_tbw->setItem(row, col, item);
				}

				//Configure the vertical header to show the current tuple id
				results_tbw->setVerticalHeaderItem(row, new QTableWidgetItem(QString::number(row + 1)));
				row++;
			}
			while(res.accessTuple(ResultSet::NEXT_TUPLE));
		}

		results_tbw->blockSignals(false);
		results_tbw->resizeColumnsToContents();
		results_tbw->resizeRowsToContents();
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
开发者ID:InnovaMex,项目名称:pgmodeler,代码行数:88,代码来源:sqlexecutionwidget.cpp


注:本文中的Catalog::getObjectsAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。