void K3bListViewItem::setForegroundColor( int col, const QColor& c ) { ColumnInfo* info = getColumnInfo( col ); info->foregroundColorSet = true; info->foregroundColor = c; repaint(); }
void K3bListViewItem::setMarginHorizontal( int col, int margin ) { ColumnInfo* info = getColumnInfo( col ); info->margin = margin; repaint(); }
std::string TupleSchema::debug() const { std::ostringstream buffer; buffer << "Schema has " << columnCount() << " columns, " << hiddenColumnCount() << " hidden columns, " << "length = " << tupleLength() << ", " << "uninlinedObjectColumns " << m_uninlinedObjectColumnCount << std::endl; for (uint16_t i = 0; i < columnCount(); i++) { const TupleSchema::ColumnInfo *columnInfo = getColumnInfo(i); buffer << " column " << i << ": " << columnInfo->debug() << std::endl; } for (uint16_t i = 0; i < hiddenColumnCount(); i++) { const TupleSchema::ColumnInfo *columnInfo = getHiddenColumnInfo(i); buffer << " hidden column " << i << ": " << columnInfo->debug() << std::endl; } buffer << " terminator column info: " << getColumnInfoPrivate(totalColumnCount())->debug() << std::endl; std::string ret(buffer.str()); return ret; }
void K3bListViewItem::setTotalSteps( int col, int steps ) { ColumnInfo* info = getColumnInfo( col ); info->totalProgressSteps = steps; repaint(); }
void K3bListViewItem::setEditor( int column, int editor, const QStringList& cs ) { ColumnInfo* colInfo = getColumnInfo(column); colInfo->editorType = editor; if( !cs.isEmpty() ) colInfo->comboItems = cs; }
// GWW: escrow column void TupleSchema::setColumnMetaData(uint16_t index, ValueType type, const int32_t length, bool allowNull, bool escrowColumn, uint16_t &uninlinedObjectColumnIndex) { assert(length <= 1048576); uint32_t offset = 0; // set the type ColumnInfo *columnInfo = getColumnInfo(index); columnInfo->type = static_cast<char>(type); columnInfo->allowNull = (char)(allowNull ? 1 : 0); // GWW columnInfo->escrowCol = escrowColumn; columnInfo->length = length; if ((type == VALUE_TYPE_VARCHAR) || (type == VALUE_TYPE_VARBINARY)) { if (length < UNINLINEABLE_OBJECT_LENGTH && m_allowInlinedObjects) { /* * Inline the string if it is less then UNINLINEABLE_OBJECT_LENGTH bytes. */ columnInfo->inlined = true; // One byte to store the size offset = static_cast<uint32_t>(length + SHORT_OBJECT_LENGTHLENGTH); } else { /* * Set the length to the size of a String pointer since it won't be inlined. */ offset = static_cast<uint32_t>(NValue::getTupleStorageSize(type)); columnInfo->inlined = false; setUninlinedObjectColumnInfoIndex(uninlinedObjectColumnIndex++, index); } } else { // All values are inlined if they aren't strings. columnInfo->inlined = true; // don't trust the planner since it can be avoided offset = static_cast<uint32_t>(NValue::getTupleStorageSize(type)); } // make the column offsets right for all columns past this one int oldsize = columnLengthPrivate(index); ColumnInfo *nextColumnInfo = NULL; for (int i = index + 1; i <= m_columnCount; i++) { nextColumnInfo = getColumnInfo(i); nextColumnInfo->offset = static_cast<uint32_t>(nextColumnInfo->offset + offset - oldsize); } assert(index == 0 ? columnInfo->offset == 0 : true); }
void K3bListViewItem::setProgress( int col, int p ) { ColumnInfo* info = getColumnInfo( col ); if( !info->showProgress ) setDisplayProgressBar( col, true ); if( info->progressValue != p ) { info->progressValue = p; repaint(); } }
void K3bListViewItem::paintProgressBar( QPainter* p, const QColorGroup& cgh, int col, int width ) { ColumnInfo* info = getColumnInfo( col ); QStyle::SFlags flags = QStyle::Style_Default; if( listView()->isEnabled() ) flags |= QStyle::Style_Enabled; if( listView()->hasFocus() ) flags |= QStyle::Style_HasFocus; // FIXME: the QPainter is translated so 0, m_vMargin is the upper left of our paint rect QRect r( 0, m_vMargin, width, height()-2*m_vMargin ); // create the double buffer pixmap static QPixmap *doubleBuffer = 0; if( !doubleBuffer ) doubleBuffer = new QPixmap; doubleBuffer->resize( width, height() ); QPainter dbPainter( doubleBuffer ); // clear the background (we cannot use paintEmptyArea since it's protected in QListView) if( K3bListView* lv = dynamic_cast<K3bListView*>(listView()) ) lv->paintEmptyArea( &dbPainter, r ); else dbPainter.fillRect( 0, 0, width, height(), cgh.brush( QPalette::backgroundRoleFromMode(listView()->viewport()->backgroundMode()) ) ); // we want a little additional margin r.setLeft( r.left()+1 ); r.setWidth( r.width()-2 ); r.setTop( r.top()+1 ); r.setHeight( r.height()-2 ); // this might be a stupid hack but most styles do not reimplement drawPrimitive PE_ProgressBarChunk // so this way the user is happy.... static QProgressBar* s_dummyProgressBar = 0; if( !s_dummyProgressBar ) { s_dummyProgressBar = new QProgressBar(); } s_dummyProgressBar->setTotalSteps( info->totalProgressSteps ); s_dummyProgressBar->setProgress( info->progressValue ); // some styles use the widget's geometry s_dummyProgressBar->setGeometry( r ); listView()->style().drawControl(QStyle::CE_ProgressBarContents, &dbPainter, s_dummyProgressBar, r, cgh, flags ); listView()->style().drawControl(QStyle::CE_ProgressBarLabel, &dbPainter, s_dummyProgressBar, r, cgh, flags ); // now we really paint the progress in the listview p->drawPixmap( 0, 0, *doubleBuffer ); }
std::string TupleSchema::debug() const { std::ostringstream buffer; buffer << "Schema has " << columnCount() << " columns, length = " << tupleLength() << ", uninlinedObjectColumns " << m_uninlinedObjectColumnCount << std::endl; for (uint16_t i = 0; i < columnCount(); i++) { const TupleSchema::ColumnInfo *columnInfo = getColumnInfo(i); buffer << " column " << i << ": type = " << getTypeName(columnInfo->getVoltType()); buffer << ", length = " << columnInfo->length << ", nullable = "; buffer << (columnInfo->allowNull ? "true" : "false") << ", isInlined = " << columnInfo->inlined << std::endl; } std::string ret(buffer.str()); return ret; }
void K3bListViewItem::paintCell( QPainter* p, const QColorGroup& cg, int col, int width, int align ) { ColumnInfo* info = getColumnInfo( col ); p->save(); QFont oldFont( p->font() ); QFont newFont = info->fontSet ? info->font : oldFont; p->setFont( newFont ); QColorGroup cgh(cg); if( info->foregroundColorSet ) cgh.setColor( QColorGroup::Text, info->foregroundColor ); if( info->backgroundColorSet ) cgh.setColor( QColorGroup::Base, info->backgroundColor ); // in case this is the selected row has a margin we need to repaint the selection bar if( isSelected() && (col == 0 || listView()->allColumnsShowFocus()) && info->margin > 0 ) { p->fillRect( 0, 0, info->margin, height(), cgh.brush( QColorGroup::Highlight ) ); p->fillRect( width-info->margin, 0, info->margin, height(), cgh.brush( QColorGroup::Highlight ) ); } else { // in case we use the KListView alternate color stuff p->fillRect( 0, 0, info->margin, height(), cgh.brush( QColorGroup::Base ) ); p->fillRect( width-info->margin, 0, info->margin, height(), cgh.brush( QColorGroup::Base ) ); } // FIXME: the margin (we can only translate horizontally since height() is used for painting) p->translate( info->margin, 0 ); if( info->showProgress ) { paintProgressBar( p, cgh, col, width-2*info->margin ); } else { paintK3bCell( p, cgh, col, width-2*info->margin, align ); } p->restore(); }
bool TupleSchema::equals(const TupleSchema *other) const { if (other->m_columnCount != m_columnCount || other->m_uninlinedObjectColumnCount != m_uninlinedObjectColumnCount || other->m_allowInlinedObjects != m_allowInlinedObjects) { return false; } for (int ii = 0; ii < m_columnCount; ii++) { const ColumnInfo *columnInfo = getColumnInfo(ii); const ColumnInfo *ocolumnInfo = other->getColumnInfo(ii); if (columnInfo->allowNull != ocolumnInfo->allowNull || columnInfo->offset != ocolumnInfo->offset || columnInfo->type != ocolumnInfo->type) { return false; } } return true; }
bool TupleSchema::equals(const TupleSchema *other) const { // First check for structural equality. if ( ! isCompatibleForCopy(other)) { return false; } // Finally, rule out behavior differences. for (int ii = 0; ii < m_columnCount; ii++) { const ColumnInfo *columnInfo = getColumnInfo(ii); const ColumnInfo *ocolumnInfo = other->getColumnInfo(ii); if (columnInfo->allowNull != ocolumnInfo->allowNull) { return false; } // The declared column length for an out-of-line object is a behavior difference // that has no effect on tuple format. if (( ! columnInfo->inlined) && (columnInfo->length != ocolumnInfo->length)) { return false; } } return true; }
bool TupleSchema::isCompatibleForCopy(const TupleSchema *other) const { if (this == other) { return true; } if (other->m_columnCount != m_columnCount || other->m_uninlinedObjectColumnCount != m_uninlinedObjectColumnCount || other->tupleLength() != tupleLength()) { return false; } for (int ii = 0; ii < m_columnCount; ii++) { const ColumnInfo *columnInfo = getColumnInfo(ii); const ColumnInfo *ocolumnInfo = other->getColumnInfo(ii); if (columnInfo->offset != ocolumnInfo->offset || columnInfo->type != ocolumnInfo->type || columnInfo->inlined != ocolumnInfo->inlined) { return false; } } return true; }
int K3bListViewItem::width( const QFontMetrics& fm, const QListView* lv, int c ) const { return KListViewItem::width( fm, lv, c ) + getColumnInfo(c)->margin*2; }
void K3bListViewItem::setValidator( int column, QValidator* v ) { getColumnInfo(column)->validator = v; }
QValidator* K3bListViewItem::validator( int col ) const { return getColumnInfo(col)->validator; }
void K3bListViewItem::setButton( int column, bool on ) { ColumnInfo* colInfo = getColumnInfo(column); colInfo->button = on; }
int K3bListViewItem::editorType( int col ) const { ColumnInfo* info = getColumnInfo( col ); return info->editorType; }
void TupleSchema::setColumnMetaData(uint16_t index, ValueType type, const int32_t length, bool allowNull, uint16_t &uninlinedObjectColumnIndex, bool inBytes) { assert(length <= COLUMN_MAX_VALUE_LENGTH); uint32_t offset = 0; // set the type ColumnInfo *columnInfo = getColumnInfo(index); columnInfo->type = static_cast<char>(type); columnInfo->allowNull = (char)(allowNull ? 1 : 0); columnInfo->length = length; columnInfo->inBytes = inBytes; if ((type == VALUE_TYPE_VARCHAR && inBytes) || type == VALUE_TYPE_VARBINARY) { if (length == 0) { throwFatalLogicErrorStreamed("Zero length for object type " << valueToString((ValueType)type)); } if (length < UNINLINEABLE_OBJECT_LENGTH) { /* * Inline the string if it is less then UNINLINEABLE_OBJECT_LENGTH bytes. */ columnInfo->inlined = true; // One byte to store the size offset = static_cast<uint32_t>(length + SHORT_OBJECT_LENGTHLENGTH); } else { /* * Set the length to the size of a String pointer since it won't be inlined. */ offset = static_cast<uint32_t>(NValue::getTupleStorageSize(type)); columnInfo->inlined = false; setUninlinedObjectColumnInfoIndex(uninlinedObjectColumnIndex++, index); } } else if (type == VALUE_TYPE_VARCHAR) { if (length == 0) { throwFatalLogicErrorStreamed("Zero length for object type " << valueToString((ValueType)type)); } if (length < UNINLINEABLE_CHARACTER_LENGTH) { /* * Inline the string if it is less then UNINLINEABLE_CHARACTER_LENGTH characters. */ columnInfo->inlined = true; // One byte to store the size offset = static_cast<uint32_t>(length * 4 + SHORT_OBJECT_LENGTHLENGTH); } else { /* * Set the length to the size of a String pointer since it won't be inlined. */ offset = static_cast<uint32_t>(NValue::getTupleStorageSize(type)); columnInfo->inlined = false; setUninlinedObjectColumnInfoIndex(uninlinedObjectColumnIndex++, index); } } else { // All values are inlined if they aren't strings. columnInfo->inlined = true; // don't trust the planner since it can be avoided offset = static_cast<uint32_t>(NValue::getTupleStorageSize(type)); } // make the column offsets right for all columns past this one int oldsize = columnLengthPrivate(index); ColumnInfo *nextColumnInfo = NULL; for (int i = index + 1; i <= m_columnCount; i++) { nextColumnInfo = getColumnInfo(i); nextColumnInfo->offset = static_cast<uint32_t>(nextColumnInfo->offset + offset - oldsize); } assert(index == 0 ? columnInfo->offset == 0 : true); }
bool K3bListViewItem::needButton( int col ) const { ColumnInfo* info = getColumnInfo( col ); return info->button; }
int K3bListViewItem::marginHorizontal( int col ) const { return getColumnInfo( col )->margin; }
const QStringList& K3bListViewItem::comboStrings( int col ) const { ColumnInfo* info = getColumnInfo( col ); return info->comboItems; }
void K3bListViewItem::setFont( int col, const QFont& f ) { ColumnInfo* info = getColumnInfo( col ); info->fontSet = true; info->font = f; }
void K3bListViewItem::setDisplayProgressBar( int col, bool displ ) { ColumnInfo* info = getColumnInfo( col ); info->showProgress = displ; }