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


C++ QColorGroup::highlight方法代码示例

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


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

示例1: PaintBars

static void PaintBars(toTreeWidgetItem *item, QPainter *p, const QColorGroup & cg,
                      int width, std::list<double> &val, std::list<double> &maxExt, std::list<double> &curExt)
{
#if 0                           // disabled, wrong override
    if ( val.empty() )
    {
        p->fillRect(0, 0, width, item->height(),
                    QBrush(item->isSelected() ? cg.highlight() : cg.base()));
    }
    else
    {
        int num = 0;
        int lastHeight = 0;

        std::list<double>::iterator j = curExt.begin();
        std::list<double>::iterator k = maxExt.begin();
        for (std::list<double>::iterator i = val.begin();
                i != val.end() && j != curExt.end() && k != maxExt.end();
                i++, j++, k++)
        {
            num++;

            QBrush bg(item->isSelected() ? cg.highlight() : cg.base());
            QBrush fg(num % 2 ? Qt::blue : Qt::red);

            double start = (*i);
            double end = (*j);

            if (BarsAlignLeft)
            {
                end -= start;
                start = 0;
                if (end < 0)
                    end += (*k);
            }

            int height = item->height() * num / val.size();
            int pos = int(start * width / (*k));
            int posEnd = int(end * width / (*k));

            if (start > end)
            {
                p->fillRect(0, lastHeight, posEnd, height, fg);
                p->fillRect(posEnd, lastHeight, pos, height, bg);
                p->fillRect(pos, lastHeight, width, height, fg);
            }
            else
            {
                p->fillRect(0, lastHeight, pos, height, bg);
                p->fillRect(pos, lastHeight, posEnd, height, fg);
                p->fillRect(posEnd, lastHeight, width, height, bg);
            }
            lastHeight = height;
        }
    }
#endif
}
开发者ID:Daniel1892,项目名称:tora,代码行数:57,代码来源:torollback.cpp

示例2: paintCell

void FancyItem::paintCell(QPainter *p, const QColorGroup &cg, int c, int w, int)
{
	int h = height();
	QFontMetrics fm(p->font());
	if(isSelected())
		p->fillRect(0, 0, w, h-1, cg.highlight());
	else
		p->fillRect(0, 0, w, h, cg.base());

	int x = 0;
	const QPixmap *pix = pixmap(c);
	if(pix) {
		p->drawPixmap(4, (h - pix->height()) / 2, *pix);
		x += pix->width();
	}
	else
		x += 16;
	x += 8;
	int y = ((h - fm.height()) / 2) + fm.ascent();
	p->setPen(isSelected() ? cg.highlightedText() : cg.text());
	p->drawText(x, y, text(c));

	p->setPen(QPen(QColor(0xE0, 0xE0, 0xE0), 0, Qt::DotLine));
	p->drawLine(0, h-1, w-1, h-1);
}
开发者ID:Voker57,项目名称:psi,代码行数:25,代码来源:optionsdlg.cpp

示例3: paintCell

void TeQtBigTable::paintCell(QPainter *painter, int row, int col,
                          const QRect &cr, bool selected, const QColorGroup &cg)
{
	QRect rect(0, 0, cr.width(), cr.height());
	if (selected)
	{
		painter->fillRect(rect, cg.highlight());
		painter->setPen(cg.highlightedText());
	}
	else
	{
		painter->fillRect(rect, cg.base());
		painter->setPen(cg.text());
	}

	QTable::paintCell(painter, row, col, cr, selected, cg);

	QVariant v(dataSource_->cell(row, col));
	if (v.type() == QVariant::Pixmap)
	{
		QPixmap p = v.toPixmap();
		painter->drawPixmap(0, 0, p);
	}
	else if (v.type() == QVariant::String || v.type() == QVariant::CString)
	{
		QString qs = v.toString();
		bool ok;
		qs.toDouble(&ok);
		if (ok)
			painter->drawText(0, 0, cr.width()-10, cr.height(), Qt::AlignRight | Qt::SingleLine, v.toString());
		else
			painter->drawText(0, 0, cr.width()-10, cr.height(), Qt::AlignLeft | Qt::SingleLine, v.toString());

	}
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:35,代码来源:TeQtBigTable.cpp

示例4: paintCell

        virtual void paintCell(QPainter *p, const QColorGroup &cg,
                               int column, int width, int alignment)
        {
#if 0                           // disabled - not overriding correct method
            if (column == 2)
            {
                toProfilerUnits *units = dynamic_cast<toProfilerUnits *>(listView());
                if (!units)
                {
                    toTreeWidgetItem::paintCell(p, cg, column, width, alignment);
                    return ;
                }
                double total = allText(column).toDouble();
                QString timstr = FormatTime(total / 1E9);
                double val = total / units->total();

                p->fillRect(0, 0, int(val*width), height(), QBrush(Qt::blue));
                p->fillRect(int(val*width), 0, width, height(),
                            QBrush(isSelected() ? cg.highlight() : cg.base()));

                QPen pen(isSelected() ? cg.highlightedText() : cg.foreground());
                p->setPen(pen);
                p->drawText(0, 0, width, height(), Qt::AlignRight, timstr);
            }
            else
            {
                toTreeWidgetItem::paintCell(p, cg, column, width, alignment);
            }
#endif
        }
开发者ID:netrunner-debian-kde-extras,项目名称:tora,代码行数:30,代码来源:toprofiler.cpp

示例5: paintCell

void ListListViewItem::paintCell(QPainter *p,const QColorGroup &cg,int column,
				 int width,int align)
{
  if(column!=list_track_column) {
    Q3ListViewItem::paintCell(p,cg,column,width,align);
    return;
  }
  QColor fg=cg.text();
  QColor bg=cg.base();
  if(isSelected()) {
    fg=cg.highlightedText();
    bg=cg.highlight();
  }
  QString str=QString().sprintf("%u / %u",list_tracks,list_total_tracks);
  QPixmap *icon=list_whiteball_map;
  if(list_total_tracks>0) {
    if(list_tracks==list_total_tracks) {
      icon=list_greenball_map;
    }
    else {
      icon=list_redball_map;
    }
  }
  QFontMetrics *m=new QFontMetrics(p->font());
  p->setBackgroundColor(bg);
  p->eraseRect(0,0,width,height());
  p->setPen(fg);
  p->drawPixmap(list_parent->itemMargin(),(height()-icon->size().height())/2,
		*icon);
  p->drawText(icon->size().width()+10,3*(height()-m->height())/2,str);
  delete m;
}
开发者ID:WMFO,项目名称:rivendell,代码行数:32,代码来源:list_listviewitem.cpp

示例6: HTMLColors

    HTMLColors()
    {
        map["black"] = "#000000";
        map["green"] = "#008000";
        map["silver"] = "#c0c0c0";
        map["lime"] = "#00ff00";
        map["gray"] = "#808080";
        map["olive"] = "#808000";
        map["white"] = "#ffffff";
        map["yellow"] = "#ffff00";
        map["maroon"] = "#800000";
        map["navy"] = "#000080";
        map["red"] = "#ff0000";
        map["blue"] = "#0000ff";
        map["purple"] = "#800080";
        map["teal"] = "#008080";
        map["fuchsia"] = "#ff00ff";
        map["aqua"] = "#00ffff";
	map["crimson"] = "#dc143c";
	map["indigo"] = "#4b0082";
#ifdef __BEOS__
	printf( "Warning: HTMLColors::HTMLColors() not initiating all colors\n" );
#else	
        // ### react to style changes
        // see http://www.richinstyle.com for details
        QColorGroup cg = kapp->palette().active();
        map["activeborder"] = cg.light(); // bordercolor of an active window
        map["activecaption"] = cg.text(); // caption color of an active window
        map["appworkspace"] = cg.background(); // background color of an MDI interface
        map["highlight"] = cg.highlight();
        map["highlighttext"] = cg.highlightedText();
        cg = kapp->palette().inactive();
        map["background"] = cg.background(); // desktop background color
        map["buttonface"] = cg.button(); // Button background color
        map["buttonhighlight"] =  cg.light();
        map["buttonshadow"] = cg.shadow();
        map["buttontext"] = cg.buttonText();
        map["captiontext"] = cg.text();
        map["infobackground"] = QToolTip::palette().inactive().background();
        map["menu"] = cg.background();
        map["menutext"] = cg.foreground();
        map["scrollbar"] = cg.background();
        map["threeddarkshadow"] = cg.dark();
        map["threedface"] = cg.button();
        map["threedhighlight"] = cg.light();
        map["threedlightshadow"] = cg.midlight();
        map["window"] = cg.background();
        map["windowframe"] = cg.background();
        map["text"] = cg.text();
        cg = kapp->palette().disabled();
        map["inactiveborder"] = cg.background();
        map["inactivecaption"] = cg.background();
        map["inactivecaptiontext"] = cg.text();
        map["graytext"] = cg.text();
#endif	
    };
开发者ID:BackupTheBerlios,项目名称:nirvana-svn,代码行数:56,代码来源:helper.cpp

示例7: paintItem

void IconViewItemExt::paintItem(QPainter* p,const QColorGroup& cg)
{
  if(isSelected())
  {
    p->setBrush(cg.highlight());
    p->drawRect(textRect(false));
    p->setPen(QPen(cg.highlightedText()));
    p->setBackgroundColor(cg.highlight());
    p->setBackgroundMode(Qt::OpaqueMode);
    p->drawText(textRect(false),Qt::AlignHCenter|Qt::WordBreak,text());
    p->setPen(QPen(cg.dark(),4));
    p->drawRect(pixmapRect(false));
    p->drawPixmap(pixmapRect(false).x(),pixmapRect(false).y(),*pixmap());
  }
  else
  {
    QIconViewItem::paintItem ( p,cg);
  }
}
开发者ID:arunjalota,项目名称:paperman,代码行数:19,代码来源:iconviewitemext.cpp

示例8: listView

//////////////////////////////////////////////////////////////////////////////////////////
/// CLASS QueueItem
//////////////////////////////////////////////////////////////////////////////////////////
void
QueueItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
{
    KListViewItem::paintCell( p, cg, column, width, align );

    QString str = QString::number( ( static_cast<KListView *>( listView() ) )->itemIndex( this ) + 1 );

    //draw the symbol's outline
    uint fw = p->fontMetrics().width( str ) + 2;
    const uint w  = 16; //keep this even
    const uint h  = height() - 2;

    p->setBrush( cg.highlight() );
    p->setPen( cg.highlight().dark() ); //TODO blend with background color
    p->drawEllipse( width - fw - w/2, 1, w, h );
    p->drawRect( width - fw, 1, fw, h );
    p->setPen( cg.highlight() );
    p->drawLine( width - fw, 2, width - fw, h - 1 );

    fw += 2; //add some more padding
    p->setPen( cg.highlightedText() );
    p->drawText( width - fw, 2, fw, h-1, Qt::AlignCenter, str );
}
开发者ID:tmarques,项目名称:waheela,代码行数:26,代码来源:queuemanager.cpp

示例9: palette

/*! \brief Returns a palette with colored scrollbars
 *
 *  This method creates a palette with skin specific scrollbar colors.
 *  Parent should be a widget that holds a "default" active palette, which will
 *  be used as base for the resulting palette.
 *  The returned QPalette is a copy of the parent palette but with modified
 *  scrollbar colors: QColorGroup::Highlight, QColorGroup::Button,
 *  QColorGroup::Foreground, QColorGroup::Background and QColorGroup::ButtonText.
 */
QPalette CSkin::palette(QWidget *parent)
{
  QPalette pal;
  QColorGroup cg;
  cg = parent->QWidget::palette().active(); // copy active palette from parent
  // ButtonText +  arrow of scrollbar
  if (colors.btnTxt)
  {
    cg.setColor(QColorGroup::ButtonText, QColor(colors.btnTxt));
    cg.setColor(QColorGroup::Foreground, cg.buttonText());
  }
  // Scrollbar
  if (colors.scrollbar)
  {
    cg.setColor(QColorGroup::Highlight, QColor(colors.scrollbar));
    cg.setColor(QColorGroup::Button, cg.highlight());
    cg.setColor(QColorGroup::Background, cg.highlight());
  }
  pal.setActive(cg);
  pal.setInactive(cg);
  pal.setDisabled(cg);
  return pal;
}
开发者ID:nic0lae,项目名称:freebsddistro,代码行数:32,代码来源:skin.cpp

示例10: paintCell

void DriverItem::paintCell(QPainter *p, const QColorGroup &cg, int, int width, int)
{
    // background
    p->fillRect(0, 0, width, height(), cg.base());

    // highlight rectangle
    if(isSelected())
        p->fillRect(0, 0, /*2+p->fontMetrics().width(text(0))+(pixmap(0) ? pixmap(0)->width()+2 : 0)*/ width, height(),
                    (m_conflict ? red : cg.highlight()));

    // draw pixmap
    int w(0);
    if(pixmap(0) && !pixmap(0)->isNull())
    {
        int h((height() - pixmap(0)->height()) / 2);
        p->drawPixmap(w, h, *pixmap(0));
        w += (pixmap(0)->width() + 2);
    }

    // draw Text
    if(!m_item || !m_item->isOption() || isSelected())
    {
        p->setPen((isSelected() ? cg.highlightedText() : (m_conflict ? red : cg.text())));
        p->drawText(w, 0, width - w, height(), Qt::AlignLeft | Qt::AlignVCenter, text(0));
    }
    else
    {
        int w1(0);
        QString s(m_item->get("text") + ": <");
        w1 = p->fontMetrics().width(s);
        p->setPen(cg.text());
        p->drawText(w, 0, w1, height(), Qt::AlignLeft | Qt::AlignVCenter, s);
        w += w1;
        p->setPen((m_conflict ? red : darkGreen));
        s = m_item->prettyText();
        w1 = p->fontMetrics().width(s);
        p->drawText(w, 0, w1, height(), Qt::AlignLeft | Qt::AlignVCenter, s);
        w += w1;
        p->setPen(cg.text());
        s = QString::fromLatin1(">");
        w1 = p->fontMetrics().width(s);
        p->drawText(w, 0, w1, height(), Qt::AlignLeft | Qt::AlignVCenter, s);
    }
}
开发者ID:serghei,项目名称:kde3-kdelibs,代码行数:44,代码来源:driveritem.cpp

示例11: drawControl

/*! \reimp */
void QCompactStyle::drawControl( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r,
		  const QColorGroup &g, SFlags flags, const QStyleOption& opt )
{
    switch ( element ) {
    case CE_PopupMenuItem:
	{
	    if (! widget || opt.isDefault())
		break;

	    const QPopupMenu *popupmenu = (const QPopupMenu *) widget;
	    QMenuItem *mi = opt.menuItem();
	    if ( !mi )
		break;

	    int tab = opt.tabWidth();
	    int maxpmw = opt.maxIconWidth();
	    bool dis = !(flags & Style_Enabled);
	    bool checkable = popupmenu->isCheckable();
	    bool act = flags & Style_Active;
	    int x, y, w, h;
	    r.rect( &x, &y, &w, &h );

	    QColorGroup itemg = g;

	    if ( checkable )
		maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks

	    int checkcol	  =     maxpmw;

	    if ( mi && mi->isSeparator() ) {			// draw separator
		p->setPen( g.dark() );
		p->drawLine( x, y, x+w, y );
		p->setPen( g.light() );
		p->drawLine( x, y+1, x+w, y+1 );
		return;
	    }

	    QBrush fill = act? g.brush( QColorGroup::Highlight ) :
				    g.brush( QColorGroup::Button );
	    p->fillRect( x, y, w, h, fill);

	    if ( !mi )
		return;

	    if ( mi->isChecked() ) {
		if ( act && !dis ) {
		    qDrawShadePanel( p, x, y, checkcol, h,
				     g, TRUE, 1, &g.brush( QColorGroup::Button ) );
		} else {
		    qDrawShadePanel( p, x, y, checkcol, h,
				     g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
		}
	    } else if ( !act ) {
		p->fillRect(x, y, checkcol , h,
			    g.brush( QColorGroup::Button ));
	    }

	    if ( mi->iconSet() ) {		// draw iconset
		QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
		if (act && !dis )
		    mode = QIconSet::Active;
		QPixmap pixmap;
		if ( checkable && mi->isChecked() )
		    pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode, QIconSet::On );
		else
		    pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
		int pixw = pixmap.width();
		int pixh = pixmap.height();
		if ( act && !dis ) {
		    if ( !mi->isChecked() )
			qDrawShadePanel( p, x, y, checkcol, h, g, FALSE,  1, &g.brush( QColorGroup::Button ) );
		}
		QRect cr( x, y, checkcol, h );
		QRect pmr( 0, 0, pixw, pixh );
		pmr.moveCenter( cr.center() );
		p->setPen( itemg.text() );
		p->drawPixmap( pmr.topLeft(), pixmap );

		QBrush fill = act? g.brush( QColorGroup::Highlight ) :
				      g.brush( QColorGroup::Button );
		p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill);
	    } else  if ( checkable ) {	// just "checking"...
		int mw = checkcol + motifItemFrame;
		int mh = h - 2*motifItemFrame;
		if ( mi->isChecked() ) {

		    SFlags cflags = Style_Default;
		    if (! dis)
			cflags |= Style_Enabled;
		    if (act)
			cflags |= Style_On;

		    drawPrimitive( PE_CheckMark, p, QRect(x + motifItemFrame + 2, y + motifItemFrame,
				    mw, mh), itemg, cflags, opt );
		}
	    }

	    p->setPen( act ? g.highlightedText() : g.buttonText() );

//.........这里部分代码省略.........
开发者ID:AliYousuf,项目名称:univ-aca-mips,代码行数:101,代码来源:qcompactstyle.cpp

示例12: paintCell

void DataViewTable::paintCell(QPainter* painter, int row, int col,
                              const QRect& cr, bool selected, const QColorGroup& cg) {
  if (selector_ == NULL || row < 0 || col < 0)
    return;

  QRect rect(0, 0, cr.width(), cr.height());
  if (selected) {
    painter->fillRect(rect, cg.highlight());
    painter->setPen(cg.highlightedText());
  } else {
    if (row % 2) {
      painter->fillRect(rect, cg.base());
    } else {
      painter->fillRect(rect, cg.background().light(135));
    }
    painter->setPen(cg.text());
  }

  const SelectList &flist = selector_->pickList();

  // Check for row out of bounds.
  int max_row_id = flist.size() - 1;
  if (row > max_row_id)
    return;

  // determine if table has optional col for the feature id
  bool show_id = Preferences::getConfig().dataViewShowFID;

  if (show_id && col == 0) {
    painter->drawText(rect, Qt::AlignRight, QString::number(flist[row]));
    return;
  }

  if (!selector_->HasAttrib()) {
    // we don't have anny attribs, bail now
    return;
  }

  // we don't have to worry about fails attribute fetches since we are anly
  // asking for records that are already in our select list and they cannot
  // get into the select list w/o a valid record.
  gstRecordHandle rec;
  try {
    rec = theSourceManager->GetAttributeOrThrow(
        UniqueFeatureId(selector_->getSourceID(), selector_->layer(),
                        flist[row]));
  } catch (...) {
    // silently ignore. see comment before 'try'
    return;
  }

  int num_fields = static_cast<int>(rec->NumFields());
  // Check for column out of bounds.
  int max_column_id = show_id ? num_fields : num_fields - 1;
  if (col > max_column_id)
    return;

  gstValue* val = rec->Field(show_id ? col - 1 : col);
  int tf = val->IsNumber() ? Qt::AlignRight : Qt::AlignLeft;
  int rowHeight = this->rowHeight(row);
  int colWidth  = this->columnWidth(col);
  QRect bounding_rect = fontMetrics().boundingRect(val->ValueAsUnicode());

  // fontMetrics should account for the font descenders, but it
  // seems to be broken.
  // I accounted for the descenders by adding a margin of 4 around the cell
  // contents to account for errors in the fontMetrics
  // height estimation for font descenders, e.g., the tail of
  // the "y" or "p") . This seems to work for even large fonts and
  // is readable for smaller fonts.
  int added_cell_margin = 4;
  int cellWidth = bounding_rect.width() + added_cell_margin * 2;
  int cellHeight = bounding_rect.height() + added_cell_margin * 2;
  if (cellHeight > rowHeight) {
    setRowHeight(row, cellHeight);
  }
  if (cellWidth > colWidth) {
    setColumnWidth(col, cellWidth);
  }

  // When drawing, we're going to force the horizontal margin here.
  QRect text_rect(added_cell_margin, 0, cr.width() - added_cell_margin, cr.height());

  painter->drawText(text_rect, tf, val->ValueAsUnicode());
}
开发者ID:zhanghaoit445,项目名称:earthenterprise,代码行数:85,代码来源:DataViewTable.cpp

示例13: drawComplexControl


//.........这里部分代码省略.........
		p->setPen( cg.mid() );
		p->drawPoint( xx + ww - 4, yy + hh - 4 );

		// and the arrows
		p->setPen( cg.foreground() );
		QPointArray a ;
		a.setPoints(  7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2  );
		a.translate( xx + ww / 2, yy + hh / 2 - 3 );
		p->drawLineSegments( a, 0, 3 );		// draw arrow
		p->drawPoint( a[6] );
		a.setPoints( 7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2 );
		a.translate( xx + ww / 2, yy + hh / 2 + 2 );
		p->drawLineSegments( a, 0, 3 );		// draw arrow
		p->drawPoint( a[6] );

	    }
#ifndef QT_NO_COMBOBOX
	    if ( sub & SC_ComboBoxEditField ) {
		const QComboBox *cmb;
		cmb = (const QComboBox*)widget;
		// sadly this is pretty much the windows code, except
		// for the first fillRect call...
		QRect re =
		    QStyle::visualRect( querySubControlMetrics( CC_ComboBox,
								widget,
								SC_ComboBoxEditField ),
					widget );
		if ( cmb->hasFocus() && !cmb->editable() )
		    p->fillRect( re.x() + 1, re.y() + 1,
				 re.width() - 2, re.height() - 2,
				 cg.brush( QColorGroup::Highlight ) );

		if ( cmb->hasFocus() ) {
		    p->setPen( cg.highlightedText() );
		    p->setBackgroundColor( cg.highlight() );
		} else {
		    p->setPen( cg.text() );
		    p->setBackgroundColor( cg.background() );
		}

		if ( cmb->hasFocus() && !cmb->editable() ) {
		    QRect re =
			QStyle::visualRect( subRect( SR_ComboBoxFocusRect,
						     cmb ),
					    widget );
		    drawPrimitive( PE_FocusRect, p, re, cg,
				   Style_FocusAtBorder,
				   QStyleOption(cg.highlight()));
		}
		if ( cmb->editable() ) {
		    // need this for the moment...
		    // was the code in comboButton rect
		    QRect ir( x + 3, y + 3,
			      w - 6 - 16, h - 6 );
		    if ( QApplication::reverseLayout() )
			ir.moveBy( 16, 0 );
		    // end comboButtonRect...
		    ir.setRect( ir.left() - 1, ir.top() - 1, ir.width() + 2,
				ir.height() + 2 );
		    qDrawShadePanel( p, ir, cg, TRUE, 2, 0 );
		}
	    }
#endif
	    break;
	}
    case CC_Slider:
开发者ID:AliYousuf,项目名称:univ-aca-mips,代码行数:67,代码来源:qplatinumstyle.cpp

示例14: paintCell

void PlaylistItem::paintCell( QPainter *painter, const QColorGroup &cg, int column, int width, int align )
{
    //TODO add spacing on either side of items
    //p->translate( 2, 0 ); width -= 3;

    // Don't try to draw if width or height is 0, as this crashes Qt
    if( !painter || !listView() || width <= 0 || height() == 0 )
        return;

    static const QImage currentTrackLeft  = locate( "data", "amarok/images/currenttrack_bar_left.png" );
    static const QImage currentTrackMid   = locate( "data", "amarok/images/currenttrack_bar_mid.png" );
    static const QImage currentTrackRight = locate( "data", "amarok/images/currenttrack_bar_right.png" );

    if( column == Mood  &&  !moodbar().dataExists() )
      moodbar().load();  // Only has an effect the first time
    // The moodbar column can have text in it, like "Calculating".
    // moodbarType is 0 if column != Mood, 1 if we're displaying
    // a moodbar, and 2 if we're displaying text
    const int moodbarType =
        column != Mood ? 0 : moodbar().state() == Moodbar::Loaded ? 1 : 2;

    const QString colText = text( column );
    const bool isCurrent = this == listView()->currentTrack();

    QPixmap buf( width, height() );
    QPainter p( &buf, true );

    if( isCurrent )
    {
        static paintCacheItem paintCache[NUM_COLUMNS];

        // Convert intensity to string, so we can use it as a key
        const QString colorKey = QString::number( glowIntensity );

        const bool cacheValid =
            paintCache[column].width == width &&
            paintCache[column].height == height() &&
            paintCache[column].text == colText &&
            paintCache[column].font == painter->font() &&
            paintCache[column].color == glowBase &&
            paintCache[column].selected == isSelected() &&
            !s_pixmapChanged;

            // If any parameter changed, we must regenerate all pixmaps
            if ( !cacheValid )
            {
                for( int i = 0; i < NUM_COLUMNS; ++i)
                    paintCache[i].map.clear();
                s_pixmapChanged = false;
            }

            // Determine if we need to repaint the pixmap, or paint from cache
            if ( paintCache[column].map.find( colorKey ) == paintCache[column].map.end() )
            {
                // Update painting cache
                paintCache[column].width = width;
                paintCache[column].height = height();
                paintCache[column].text = colText;
                paintCache[column].font = painter->font();
                paintCache[column].color = glowBase;
                paintCache[column].selected = isSelected();

                QColor bg;
                if( isSelected() )
                    bg = listView()->colorGroup().highlight();
                else
                    bg = isAlternate() ? listView()->alternateBackground() :
                                        listView()->viewport()->backgroundColor();

                buf.fill( bg );

                // Draw column divider line
                p.setPen( listView()->viewport()->colorGroup().mid() );
                p.drawLine( width - 1, 0, width - 1, height() - 1 );

                // Here we draw the background bar graphics for the current track:
                //
                // Illustration of design, L = Left, M = Middle, R = Right:
                // <LMMMMMMMMMMMMMMMR>

                int leftOffset  = 0;
                int rightOffset = 0;
                int margin      = listView()->itemMargin();

                const float  colorize  = 0.8;
                const double intensity = 1.0 - glowIntensity * 0.021;

                // Left part
                if( column == listView()->m_firstColumn ) {
                    QImage tmpImage = currentTrackLeft.smoothScale( 1, height(), QImage::ScaleMax );
                    KIconEffect::colorize( tmpImage, glowBase, colorize );
                    imageTransparency( tmpImage, intensity );
                    p.drawImage( 0, 0, tmpImage, 0, 0, tmpImage.width() - 1 ); //HACK
                    leftOffset = tmpImage.width() - 1; //HACK Subtracting 1, to work around the black line bug
                    margin += 6;
                }

                // Right part
                else
                if( column == Playlist::instance()->mapToLogicalColumn( Playlist::instance()->numVisibleColumns() - 1 ) )
//.........这里部分代码省略.........
开发者ID:gms8994,项目名称:amarok-1.4,代码行数:101,代码来源:playlistitem.cpp

示例15: highlightColorGroup

QColorGroup PropertyPanel::highlightColorGroup( QColorGroup cg )
{
	cg.setColor( QColorGroup::Foreground, cg.highlightedText() );
	cg.setColor( QColorGroup::Background, cg.highlight() );
	return cg;
}
开发者ID:serghei,项目名称:kde3-kdemultimedia,代码行数:6,代码来源:propertypanel.cpp


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