本文整理汇总了C++中QListView::itemMargin方法的典型用法代码示例。如果您正苦于以下问题:C++ QListView::itemMargin方法的具体用法?C++ QListView::itemMargin怎么用?C++ QListView::itemMargin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListView
的用法示例。
在下文中一共展示了QListView::itemMargin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintCell
void RosterBoxItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align)
{
if(!v_rt){
QListViewItem::paintCell(p, cg, column, width, align);
return;
}
p->save();
QListView* lv = listView();
if ( isSelected() != v_selected || lv->isActiveWindow() != v_active)
setup();
int r = lv->itemMargin();
const QBrush *paper;
// setup (colors, sizes, ...)
if ( isSelected() ) {
paper = &cg.brush( QColorGroup::Highlight );
}
else{
const QColorGroup::ColorRole crole = QPalette::backgroundRoleFromMode( lv->viewport()->backgroundMode() );
paper = &cg.brush( crole );
}
const QPixmap * px = pixmap( column );
QRect pxrect;
int pxw = 0;
int pxh = 0;
if(px) {
pxw = px->width();
pxh = px->height();
pxrect = QRect(r, (height() - pxh)/2, pxw, pxh);
r += pxw + lv->itemMargin();
}
if(px)
pxrect.moveTop( (height() - pxh)/2 );
// start drawing
QRect rtrect(r, (height() - v_rt->height())/2, v_widthUsed, v_rt->height());
v_rt->draw(p, rtrect.left(), rtrect.top(), rtrect, cg, paper);
QRegion clip(0, 0, width, height());
clip -= rtrect;
p->setClipRegion(clip, QPainter::CoordPainter);
p->fillRect( 0, 0, width, height(), *paper );
if(px)
p->drawPixmap(pxrect, *px);
p->restore();
}
示例2: setup
void HeaderItem::setup()
{
widthChanged();
const int ph = KMHeaders::pixNew->height();
QListView *v = listView();
int h = QMAX( v->fontMetrics().height(), ph ) + 2*v->itemMargin();
h = QMAX( h, QApplication::globalStrut().height());
if ( h % 2 > 0 )
h++;
setHeight( h );
}
示例3: paintCell
void ConfigurationItem::paintCell(QPainter *p, const QColorGroup &cg, int column,
int width, int align)
{
if ( (column == 0) || (column == 1) || (column == 2) )
{
if ( !p )
return;
QListView *lv = listView();
if ( !lv )
return;
const BackgroundMode bgmode = lv->viewport()->backgroundMode();
const QColorGroup::ColorRole crole = QPalette::backgroundRoleFromMode( bgmode );
p->fillRect(0, 0, width, height(), cg.brush(crole));
QFontMetrics fm(lv->fontMetrics());
int boxsize = lv->style().pixelMetric(QStyle::PM_CheckListButtonSize, lv);
int marg = lv->itemMargin();
int styleflags = QStyle::Style_Default;
if (((column == 0) && m_contents) || ((column == 1) && m_index) || ((column == 2) && m_fullTextSearch))
styleflags |= QStyle::Style_On;
else
styleflags |= QStyle::Style_Off;
if ((column == 0) || ((column == 1) && m_indexPossible) || ((column == 2) && m_fullTextSearchPossible))
styleflags |= QStyle::Style_Enabled;
int x = 0;
int y = 0;
x += 3;
if (align & AlignVCenter)
y = ((height() - boxsize) / 2) + marg;
else
y = (fm.height() + 2 + marg - boxsize) / 2;
QStyleOption opt(this);
lv->style().drawPrimitive(QStyle::PE_CheckListIndicator, p,
QRect(x, y, boxsize, fm.height() + 2 + marg), cg, styleflags, opt);
return;
}
QListViewItem::paintCell(p, cg, column, width, align);
}
示例4: paintCell
void QMultiCheckListItem::paintCell(QPainter *p,const QColorGroup & cg, int col, int width, int align)
{
if ( !p )
return;
QListView *lv = listView();
if ( !lv )
return;
QListViewItem::paintCell(p,cg,col,width,align );
int marg = lv->itemMargin();
// int width = BoxSize + marg*2;
// use a provate color group and set the text/highlighted text colors
QColorGroup mcg = cg;
if (checkBoxColumns.testBit(col)) {
// Bold/Italic/use default checkboxes
// code allmost identical to QCheckListItem
Q_ASSERT( lv ); //###
// I use the text color of defaultStyles[0], normalcol in parent listview
// mcg.setColor( QColorGroup::Text, ((StyleListView*)lv)->normalcol );
int x = 0;
if ( align == AlignCenter ) {
QFontMetrics fm( lv->font() );
x = (width - BoxSize - fm.width(text(0)))/2;
}
int y = (height() - BoxSize) / 2;
if ( !isEnabled() || disableStates.testBit(col))
p->setPen( QPen( lv->palette().color( QPalette::Disabled, QColorGroup::Text ), 2 ) );
else
p->setPen( QPen( mcg.text(), 2 ) );
if ( isSelected() && lv->header()->mapToSection( 0 ) != 0 ) {
p->fillRect( 0, 0, x + marg + BoxSize + 4, height(),
mcg.brush( QColorGroup::Highlight ) );
if ( isEnabled() )
p->setPen( QPen( mcg.highlightedText(), 2 ) ); // FIXME! - use defaultstyles[0].selecol. luckily not used :)
}
p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 );
x++;
y++;
if ( checkStates.testBit(col) ) {
QPointArray a( 7*2 );
int i, xx, yy;
xx = x+1+marg;
yy = y+5;
for ( i=0; i<3; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy++;
}
yy -= 2;
for ( i=3; i<7; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy--;
}
p->drawLineSegments( a );
}
}
}
示例5: paintCell
void ChannelListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
{
QPixmap back( width, height() );
QPainter paint( &back );
//KListViewItem::paintCell( &paint, cg, column, width, align );
// PASTED FROM KLISTVIEWITEM:
// set the alternate cell background colour if necessary
QColorGroup _cg = cg;
if (isAlternate())
if (listView()->viewport()->backgroundMode()==Qt::FixedColor)
_cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground());
else
_cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground());
// PASTED FROM QLISTVIEWITEM
{
QPainter *p = &paint;
QListView *lv = listView();
if ( !lv )
return;
QFontMetrics fm( p->fontMetrics() );
// any text we render is done by the Components, not by this class, so make sure we've nothing to write
QString t;
// removed text truncating code from Qt - we do that differently, further on
int marg = lv->itemMargin();
int r = marg;
// const QPixmap * icon = pixmap( column );
const BackgroundMode bgmode = lv->viewport()->backgroundMode();
const QColorGroup::ColorRole crole = QPalette::backgroundRoleFromMode( bgmode );
if ( _cg.brush( crole ) != lv->colorGroup().brush( crole ) )
p->fillRect( 0, 0, width, height(), _cg.brush( crole ) );
else
{
// all copied from QListView::paintEmptyArea
//lv->paintEmptyArea( p, QRect( 0, 0, width, height() ) );
QStyleOption opt( lv->sortColumn(), 0 ); // ### hack; in 3.1, add a property in QListView and QHeader
QStyle::SFlags how = QStyle::Style_Default;
if ( lv->isEnabled() )
how |= QStyle::Style_Enabled;
lv->style().drawComplexControl( QStyle::CC_ListView,
p, lv, QRect( 0, 0, width, height() ), lv->colorGroup(),
how, QStyle::SC_ListView, QStyle::SC_None,
opt );
}
if ( isSelected() &&
(column == 0 || lv->allColumnsShowFocus()) ) {
p->fillRect( r - marg, 0, width - r + marg, height(),
_cg.brush( QColorGroup::Highlight ) );
// removed text pen setting code from Qt
}
// removed icon drawing code from Qt
// draw the tree gubbins
if ( multiLinesEnabled() && column == 0 && isOpen() && childCount() ) {
int textheight = fm.size( align, t ).height() + 2 * lv->itemMargin();
textheight = QMAX( textheight, QApplication::globalStrut().height() );
if ( textheight % 2 > 0 )
textheight++;
if ( textheight < height() ) {
int w = lv->treeStepSize() / 2;
lv->style().drawComplexControl( QStyle::CC_ListView, p, lv,
QRect( 0, textheight, w + 1, height() - textheight + 1 ), _cg,
lv->isEnabled() ? QStyle::Style_Enabled : QStyle::Style_Default,
QStyle::SC_ListViewExpand,
(uint)QStyle::SC_All, QStyleOption( this ) );
}
}
}
// END OF PASTE
//do you see a better way to tell the TextComponent we are selected ? - Olivier 2004-09-02
if ( isSelected() )
_cg.setColor(QColorGroup::Text , _cg.highlightedText() );
QSimpleRichText myrichtext( text(column), paint.font() );
myrichtext.draw( &paint, 0, 0, paint.window(), _cg );
paint.end();
p->drawPixmap( 0, 0, back );
}