void KWQtSqlEasyFilter::slotValueChanged ( int row, int col ) { switch (row) { case 0: if ( !m_table->item(row,col)->text().isEmpty() ) { if (col==m_table->numCols()-1) { m_table->insertColumns(col+1,1); createColumn(col+1); } m_table->item(1,col)->setEnabled(true); m_table->item(2,col)->setEnabled(true); bool enableSearch=(static_cast<QCheckTableItem*>(m_table->item(2,col))->isChecked()); m_table->item(3,col)->setEnabled(enableSearch); m_table->item(4,col)->setEnabled(enableSearch); m_table->item(5,col)->setEnabled(enableSearch); } else { for (int i=1;i<6;i++) m_table->item(i,col)->setEnabled(false); } break; case 2: bool enSearch=static_cast<QCheckTableItem*>(m_table->item(row,col))->isChecked(); m_table->item(3,col)->setEnabled(enSearch); m_table->item(4,col)->setEnabled(enSearch); m_table->item(5,col)->setEnabled(enSearch); break; } }
void EditSheet::initDisplay() { ui->lineEdit->setText(sheet->getName()); for(int i=0;i<sheet->getNbColumns();i++) { ui->vboxLayout->addLayout(createColumn(sheet->getColumn(i))); emit newPos(ui->vboxLayout->count()); } ui->tableWidget->setRowCount(1); }
void EditSheet::addColumn() { column c; c.name = Tr("CompleteName"); c.width = 50; c.stream = Stream_General; c.key = "CompleteName"; ui->vboxLayout->addLayout(createColumn(c)); emit newPos(ui->vboxLayout->count()); refreshDisplay(); }
// encipher the plaintext, fragment by fragment char* encipherText(char* text, Matrix* keyMatrix) { int i, j; Matrix* tempMatrix = NULL; Matrix* cipherColumn = NULL; char *output = calloc(10000, sizeof(char)); for(i = 0; i < 10000; i += keyMatrix->rows) { if(text[i] != 0) { tempMatrix = createColumn(&text[i], keyMatrix->rows); for(j = 0; j < keyMatrix->rows; ++j) { output[i + j] = (hillProduct(keyMatrix, tempMatrix)->grid)[j][0]; } } } return output; }
WTableColumn* WTable::insertColumn(int column, WTableColumn *tableColumn) { for (unsigned i = 0; i < rows_.size(); ++i) rows_[i]->insertColumn(column); if ((unsigned)column <= columns_.size()) { if(!tableColumn){ tableColumn = createColumn(column); tableColumn->table_ = this; } columns_.insert(columns_.begin() + column, tableColumn); } flags_.set(BIT_GRID_CHANGED); repaint(RepaintSizeAffected); return tableColumn; }
KWQtSqlEasyFilter::KWQtSqlEasyFilter( QWidget *parent) :KDialogBase( Swallow, i18n( "Mail Merge - Editor" ), Ok | Cancel, Ok, parent, "", true) { m_fieldList << "" <<"one" << "two" << "three" << "four"; m_sortingList << ""<<i18n("ascending")<<i18n("descending"); m_operationList <<"="<<i18n("contains")<< "<" << ">"; m_table=new QTable(6,3,this); setMainWidget(m_table); m_table->verticalHeader()->setLabel(0,i18n("Field")); m_table->verticalHeader()->setLabel(1,i18n("Sorting Order")); m_table->verticalHeader()->setLabel(2,i18n("Include")); m_table->verticalHeader()->setLabel(3,i18n("Operator")); m_table->verticalHeader()->setLabel(4,i18n("Condition")); m_table->verticalHeader()->setLabel(5,i18n("Value")); m_table->setSelectionMode(QTable::NoSelection); m_table->setColumnMovingEnabled(true); m_table->setSorting(false); for (int i=0; i<3; i++) { createColumn(i); } int h=m_table->rowHeight(0); for (int i=0;i<6;i++) h+=m_table->rowHeight(i); h+=m_table->horizontalHeader()->sizeHint().height(); m_table->setMinimumHeight(h); int w=0; for (int i=0;i<3;i++) w+=m_table->columnWidth(i); w+=m_table->verticalHeader()->headerWidth(); m_table->setMinimumWidth(w); connect(m_table,SIGNAL(valueChanged ( int, int)),this,SLOT(slotValueChanged ( int, int))); }
void FunctionArrayIntersect::executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count) { const auto & return_type = block.getByPosition(result).type; auto return_type_array = checkAndGetDataType<DataTypeArray>(return_type.get()); if (!return_type) throw Exception{"Return type for function " + getName() + " must be array.", ErrorCodes::LOGICAL_ERROR}; const auto & nested_return_type = return_type_array->getNestedType(); if (typeid_cast<const DataTypeNothing *>(nested_return_type.get())) { block.getByPosition(result).column = return_type->createColumnConstWithDefaultValue(input_rows_count); return; } auto num_args = arguments.size(); DataTypes data_types; data_types.reserve(num_args); for (size_t i = 0; i < num_args; ++i) data_types.push_back(block.getByPosition(arguments[i]).type); auto return_type_with_nulls = getMostSubtype(data_types, true, true); Columns columns = castColumns(block, arguments, return_type, return_type_with_nulls); UnpackedArrays arrays = prepareArrays(columns); ColumnPtr result_column; auto not_nullable_nested_return_type = removeNullable(nested_return_type); TypeListNumbers::forEach(NumberExecutor(arrays, not_nullable_nested_return_type, result_column)); using DateMap = ClearableHashMap<DataTypeDate::FieldType, size_t, DefaultHash<DataTypeDate::FieldType>, HashTableGrower<INITIAL_SIZE_DEGREE>, HashTableAllocatorWithStackMemory<(1ULL << INITIAL_SIZE_DEGREE) * sizeof(DataTypeDate::FieldType)>>; using DateTimeMap = ClearableHashMap<DataTypeDateTime::FieldType, size_t, DefaultHash<DataTypeDateTime::FieldType>, HashTableGrower<INITIAL_SIZE_DEGREE>, HashTableAllocatorWithStackMemory<(1ULL << INITIAL_SIZE_DEGREE) * sizeof(DataTypeDateTime::FieldType)>>; using StringMap = ClearableHashMap<StringRef, size_t, StringRefHash, HashTableGrower<INITIAL_SIZE_DEGREE>, HashTableAllocatorWithStackMemory<(1ULL << INITIAL_SIZE_DEGREE) * sizeof(StringRef)>>; if (!result_column) { auto column = not_nullable_nested_return_type->createColumn(); WhichDataType which(not_nullable_nested_return_type); if (which.isDate()) result_column = execute<DateMap, ColumnVector<DataTypeDate::FieldType>, true>(arrays, std::move(column)); else if (which.isDateTime()) result_column = execute<DateTimeMap, ColumnVector<DataTypeDateTime::FieldType>, true>(arrays, std::move(column)); else if (which.isString()) result_column = execute<StringMap, ColumnString, false>(arrays, std::move(column)); else if (which.isFixedString()) result_column = execute<StringMap, ColumnFixedString, false>(arrays, std::move(column)); else { column = static_cast<const DataTypeArray &>(*return_type_with_nulls).getNestedType()->createColumn(); result_column = castRemoveNullable(execute<StringMap, IColumn, false>(arrays, std::move(column)), return_type); } } block.getByPosition(result).column = std::move(result_column); }
void Sheet::load(const SheetData& data) { m_rows.clear(); m_columns.clear(); /* 1. add rows */ foreach(const LodgerData & lodg, data.lodgers) { insertRow(lodg.id); } /* 2. add input columns */ //StringColumn* pNamesCol = new StringColumn(*this, ColId(), "nume"); //insertColumn(pNamesCol); //special column: name always comes first foreach(const ColumnData & col, data.columns) { if (col.type.startsWith("input.")) { createColumn(col, data); } } /* 3. fill inputs: names... */ int l = 0; //rows foreach(const LodgerData & lodg, data.lodgers) { //pNamesCol->cellAt(l)->setData(lodg.name); //inputs: for(int c = 0, n = m_columns.size(); c<n; ++c) { StringColumn* pInputTextColumn = dynamic_cast<StringColumn*>(m_columns[c]); if (pInputTextColumn) { const QString & val = lodg.inputText[pInputTextColumn->getTitle()]; pInputTextColumn->cellAt(l)->setData(val); continue; } InputColumn* pInputCol = dynamic_cast<InputColumn*>(m_columns[c]); if (pInputCol) { const numeric_t & val = lodg.inputValues[pInputCol->getTitle()]; pInputCol->cellAt(l)->setData(val); } } ++l; } /* 4. add output columns */ foreach(const ColumnData & col, data.columns) { if (col.type.startsWith("output.")) { createColumn(col, data); } } insertColumn(new TotalColumn(*this, ColId(), "TOTAL")); //special column: total always comes last /* 5. customize inputs */ //see InputColumn::setCustomInputValue }
std::vector<DictionaryAttribute> DictionaryStructure::getAttributes( const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, const bool hierarchy_allowed, const bool allow_null_values) { Poco::Util::AbstractConfiguration::Keys keys; config.keys(config_prefix, keys); auto has_hierarchy = false; std::vector<DictionaryAttribute> attributes; for (const auto & key : keys) { if (0 != strncmp(key.data(), "attribute", strlen("attribute"))) continue; const auto prefix = config_prefix + '.' + key + '.'; const auto name = config.getString(prefix + "name"); const auto type_string = config.getString(prefix + "type"); const auto type = DataTypeFactory::instance().get(type_string); const auto underlying_type = getAttributeUnderlyingType(type_string); const auto expression = config.getString(prefix + "expression", ""); if (!expression.empty()) has_expressions = true; Field null_value; if (allow_null_values) { const auto null_value_string = config.getString(prefix + "null_value"); try { ReadBufferFromString null_value_buffer{null_value_string}; ColumnPtr column_with_null_value = type->createColumn(); type->deserializeTextEscaped(*column_with_null_value, null_value_buffer); null_value = (*column_with_null_value)[0]; } catch (const std::exception & e) { throw Exception{ std::string{"Error parsing null_value: "} + e.what(), ErrorCodes::BAD_ARGUMENTS}; } } const auto hierarchical = config.getBool(prefix + "hierarchical", false); const auto injective = config.getBool(prefix + "injective", false); if (name.empty()) throw Exception{ "Properties 'name' and 'type' of an attribute cannot be empty", ErrorCodes::BAD_ARGUMENTS}; if (has_hierarchy && !hierarchy_allowed) throw Exception{ "Hierarchy not allowed in '" + prefix, ErrorCodes::BAD_ARGUMENTS}; if (has_hierarchy && hierarchical) throw Exception{ "Only one hierarchical attribute supported", ErrorCodes::BAD_ARGUMENTS}; has_hierarchy = has_hierarchy || hierarchical; attributes.emplace_back(DictionaryAttribute{ name, underlying_type, type, expression, null_value, hierarchical, injective }); } return attributes; }
ColumnPtr IDataType::createColumnConst(size_t size, const Field & field) const { auto column = createColumn(); column->insert(field); return ColumnConst::create(std::move(column), size); }