示例#1
0
void KasGroupItem::paint(QPainter *p)
{
    KasItem::paint(p);

    //
    // Item summary info
    //
    int modCount = 0;
    for(Task::List::iterator it = items.begin(); it != items.end(); ++it)
    {
        if((*it)->isModified())
            modCount++;
    }

    KasResources *res = resources();

    p->setPen(isShowingPopup() ? res->activePenColor() : res->inactivePenColor());

    if(modCount)
    {
        QString modCountStr;
        modCountStr.setNum(modCount);
        p->drawText(extent() - fontMetrics().width(modCountStr) - 3, 15 + fontMetrics().ascent(), modCountStr);

        p->drawPixmap(extent() - 12, 29, res->modifiedIcon());
    }

    int microsPerCol;
    switch(kasbar()->itemSize())
    {
        default:
        case KasBar::Small:
            microsPerCol = 2;
            break;
        case KasBar::Medium:
            microsPerCol = 4;
            break;
        case KasBar::Large:
            microsPerCol = 7;
            break;
        case KasBar::Huge:
            microsPerCol = 9;
            break;
        case KasBar::Enormous:
            microsPerCol = 16;
            break;
    }

    int xpos = 3;
    int ypos = 16;

    for(int i = 0; (i < (int)items.count()) && (i < microsPerCol); i++)
    {
        Task::Ptr t = items.at(i);

        if(t->isIconified())
            p->drawPixmap(xpos, ypos, res->microMinIcon());
        else if(t->isShaded())
            p->drawPixmap(xpos, ypos, res->microShadeIcon());
        else
            p->drawPixmap(xpos, ypos, res->microMaxIcon());

        ypos += 7;
    }

    if(((int)items.count() > microsPerCol) && (kasbar()->itemSize() != KasBar::Small))
    {
        QString countStr;
        countStr.setNum(items.count());
        p->drawText(extent() - fontMetrics().width(countStr) - 3, extent() + fontMetrics().ascent() - 16, countStr);
    }
}
示例#2
0
void KasTaskItem::paint( QPainter *p )
{
    KasItem::paint( p );

    KasResources *res = resources();
    QColor c = task_->isActive() ? res->activePenColor() : res->inactivePenColor();
    p->setPen( c );

    //
    // Overlay the small icon if the icon has changed, we have space,
    // and we are using a KIconLoader icon rather than one from the NET props.
    // This only exists because we are almost always using the icon loader for
    // large icons.
    //
    KasTasker *kas = kasbar();
    bool haveSpace = ( kas->itemSize() != KasBar::Small )
	          && ( kas->itemSize() != KasBar::Medium );

    if ( usedIconLoader && iconHasChanged && haveSpace ) {
	QPixmap pix = icon();
	int x = (extent() - 4 - pix.width()) / 2;
	QPixmap overlay = task_->pixmap();
	p->drawPixmap( x-4+pix.width()-overlay.width(), 18, overlay );
    }

    //
    // Draw window state.
    //
    if( task_->isIconified() )
	paintStateIcon( p, StateIcon );
    else if ( task_->isShaded() )
	paintStateIcon( p, StateShaded );
    else
	paintStateIcon( p, StateNormal );

    //
    // Draw desktop number.
    //

    // Check if we only have one desktop
    bool oneDesktop = (TaskManager::the()->numberOfDesktops() == 1) ? true : false;

    QString deskStr;
    if ( task_->isOnAllDesktops() )
	deskStr = i18n( "All" );
    else
	deskStr.setNum( task_->desktop() );


    if ( kas->itemSize() != KasBar::Small ) {
	// Medium and Large modes
	if ( !oneDesktop )
	    p->drawText( extent()-fontMetrics().width(deskStr)-3, 15+fontMetrics().ascent(), deskStr );

	// Draw document state.
	if ( kas->showModified() )
	    paintModified( p );
    }
    else {
	// Small mode
	if ( !oneDesktop )
	    p->drawText( extent()-fontMetrics().width(deskStr)-2, 13+fontMetrics().ascent(), deskStr );
    }
}