コード例 #1
0
void WorkPlaceWidget::paintDesk(){
    this->core->spotFocus();
    for(int i=0; i<this->core->getEntitieCount(); i++){
       this->drawEntitie(this->core->getEntitieAt(i),(i==this->core->getFocus() && this->core->getFocusObj()),false);
    }
    for(int i=0; i<this->core->getRelationCount(); i++){
        drawRelation(this->core->getRelationAt(i),((i==this->core->getFocus())&&(!this->core->getFocusObj())));
    }
    if(this->core->getState()==0){
        switch(this->core->getEntitieType()){
            case 0:
                this->drawEntitie(this->core->Empty,false,true);
                break;
            case 1:
                this->drawEntitie(this->core->SlowCar,false,true);
                break;
            case 2:
                this->drawEntitie(this->core->MediumCar,false,true);
                break;
            case 3:
                this->drawEntitie(this->core->FastCar,false,true);
                break;
            case 4:
                this->drawEntitie(this->core->SlowVelo,false,true);
                break;
            case 5:
                this->drawEntitie(this->core->MediumVelo,false,true);
                break;
            case 6:
                this->drawEntitie(this->core->FastVelo,false,true);
                break;
            case 7:
                this->drawEntitie(this->core->SchoolBoy,false,true);
                break;
            case 8:
                this->drawEntitie(this->core->Student,false,true);
                break;
            case 9:
                this->drawEntitie(this->core->Teacher,false,true);
                break;
            case 10:
                this->drawEntitie(this->core->Courier,false,true);
                break;
            default:
            this->drawEntitie(this->core->Empty,false,true);
        }
    }
}
コード例 #2
0
void
xQGanttBarViewPort::drawItem(KGanttItem *item, QPainter *p,
                             const QRect &rect)
{
    xQTaskPosition *tpos = _gItemList[item];

    if(!tpos) return;

    if(tpos->_screenX > (rect.x() + rect.width())) return;
    if((tpos->_screenX + tpos->_screenW) < rect.x()) return;
    if(tpos->_screenY > (rect.y() + rect.height())) return;
    if((tpos->_screenY + tpos->_screenHS) < rect.y()) return;

    p->setPen(item->getPen());
    p->setBrush(item->getBrush());

    int style = item->getStyle();

    if(item->getWidth() == 0)
    {

        p->drawLine(tpos->_screenX, tpos->_screenY,
                    tpos->_screenX, tpos->_screenY + tpos->_screenH);

        QPointArray a(4);
        a.setPoint(0, tpos->_screenX, tpos->_screenY + _margin);
        a.setPoint(1, tpos->_screenX - tpos->_screenH / 2 + _margin,
                   tpos->_screenY + tpos->_screenH / 2);
        a.setPoint(2, tpos->_screenX, tpos->_screenY + tpos->_screenH - _margin);
        a.setPoint(3, tpos->_screenX + tpos->_screenH / 2 - _margin,
                   tpos->_screenY + tpos->_screenH / 2);
        p->drawPolygon(a);

    }
    else
    {

        if(style & KGanttItem::DrawFilled)
        {

            p->fillRect(tpos->_screenX, tpos->_screenY + _margin,
                        tpos->_screenW, tpos->_screenHS - 2 * _margin,
                        item->getBrush());

        }

        if(style & KGanttItem::DrawBorder)
        {

            p->setBrush(NoBrush);
            p->drawRect(tpos->_screenX, tpos->_screenY + _margin,
                        tpos->_screenW, tpos->_screenHS - 2 * _margin);

        }

        if(item->isOpen())
        {

            //  draw relations
            for(KGanttRelation *rel = item->getRelations().first();
                    rel != 0;
                    rel = item->getRelations().next())
            {

                drawRelation(p, rel);

            }

            //  draw subitems
            for(KGanttItem *subitem = item->getSubItems().first();
                    subitem != 0;
                    subitem = item->getSubItems().next())
            {

                drawItem(subitem, p, rect);

            }
        }

        p->setPen(item->getPen());
        p->setBrush(item->getBrush());

        if(style & KGanttItem::DrawHandle ||
                ((style & KGanttItem::DrawHandleWSubitems) && item->getSubItems().count() > 0))
        {

            /*
            p->setBrush(QColor("steelblue"));
            p->drawRect(tpos->_screenHandleX, tpos->_screenHandleY,
            tpos->_screenHandleW, tpos->_screenHandleH);
                 */
            if(item->isOpen())
                p->drawPixmap(tpos->_screenHandleX, tpos->_screenHandleY, openedIcon);
            else
                p->drawPixmap(tpos->_screenHandleX, tpos->_screenHandleY, closedIcon);

        }
    }

    if(style & KGanttItem::DrawText)
    {
        p->setPen(item->getTextPen());
        p->drawText(tpos->_textPosX, tpos->_textPosY, item->getText());
    }

    if(item->isSelected())
    {

        p->setPen(QPen(QColor(red), 1));

        p->setBrush(NoBrush);
        p->drawRect(tpos->_screenX - 2, tpos->_screenY,
                    tpos->_screenW + 4, tpos->_screenHS);

        p->fillRect(tpos->_screenX, tpos->_screenY, 6, 6,
                    item->getSelectBrush());

        p->fillRect(tpos->_screenX + tpos->_screenW - 6,
                    tpos->_screenY, 6, 6,
                    item->getSelectBrush());

        p->fillRect(tpos->_screenX + tpos->_screenW - 6,
                    tpos->_screenY + tpos->_screenHS - 6, 6, 6,
                    item->getSelectBrush());

        p->fillRect(tpos->_screenX,
                    tpos->_screenY + tpos->_screenHS - 6, 6, 6,
                    item->getSelectBrush());
    }

}