Changeset 5d7c9e5 for src/mvc


Ignore:
Timestamp:
01/20/10 10:59:03 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
807cbdb
Parents:
4996c21
Message:

some drawing modifications

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/delegate.cpp

    r4996c21 r5d7c9e5  
    66
    77const int RADIUS = 10;
    8 const int SPACER = 15;
     8const int SPACER = 23;
     9
     10const double scaleFactor1 = 0.4;
     11const double scaleFactor2 = 0.8;
    912
    1013Delegate::Delegate(QTreeView *aParent)
     
    2932    if(!mViewPtr)
    3033        return;
     34
     35    QFont fontSmall = option.font;
     36    fontSmall.setBold(true);
     37    fontSmall.setPixelSize(option.rect.height()*scaleFactor1);
     38    QFontMetrics fmSmall(fontSmall);
     39
     40    QFont fontBig = option.font;
     41    fontBig.setBold(true);
     42    fontBig.setPixelSize(option.rect.height()*scaleFactor2);
     43    QFontMetrics fmBig(fontBig);
     44
     45    int spacer = (fmSmall.boundingRect("999").width() < SPACER) ? SPACER : fmSmall.boundingRect("999").width();
    3146
    3247    painter->save();
     
    96111        // map
    97112        painter->drawImage(mControls[MapControl]->drawPoint(option.rect),*mControls[MapControl]->image());
     113
     114        // draw texts
     115        QPointF titlePointF;
     116        titlePointF = QPoint(option.rect.x()+SPACER,option.rect.y()+option.rect.height()-10);
     117        QString text = qVariantValue<QString>(index.data()) + ": " + static_cast<Event*>(index.internalPointer())->title();
     118        painter->drawText(titlePointF,text);
    98119    }
    99120    else // doesn't have parent - time-groups' elements (top items)
     
    133154        painter->drawPath(titlePath);
    134155
    135         QFont font = option.font;
    136         font.setBold(true);
    137         painter->setFont(font);
    138 
    139156        // draw icons
     157        painter->setFont(fontSmall);
    140158        QPoint drawPoint =
    141159            option.rect.topRight()
    142160            - QPoint(
    143                     SPACER + mControls[FavouriteControlOn]->image()->width(),
     161                    spacer + mControls[FavouriteControlOn]->image()->width(),
    144162                    - option.rect.height()/2 + mControls[FavouriteControlOn]->image()->height()/2);
    145163        painter->drawImage(drawPoint,*mControls[FavouriteControlOn]->image());
    146164        painter->drawText(drawPoint+QPoint(mControls[FavouriteControlOn]->image()->width()+2, option.rect.height()/2),
    147165                QString::number(numberOfFavourities(index)));
    148         drawPoint.setX(drawPoint.x() - SPACER - mControls[FavouriteControlOn]->image()->width());
     166        drawPoint.setX(drawPoint.x() - spacer - mControls[FavouriteControlOn]->image()->width());
    149167        painter->drawImage(drawPoint,*mControls[AlarmControlOn]->image());
    150168        painter->drawText(drawPoint+QPoint(mControls[FavouriteControlOn]->image()->width()+2, option.rect.height()/2),
    151169                QString::number(numberOfAlarms(index)));
    152170        // draw texts
    153         drawPoint.setX(drawPoint.x() - SPACER -mControls[AlarmControlOn]->image()->width() - 35);
     171        QString numEvents = QString::number(index.model()->rowCount(index)).append("/");
     172        drawPoint.setX(drawPoint.x() - spacer - fmSmall.boundingRect(numEvents).width());
    154173        drawPoint.setY(drawPoint.y() + option.rect.height()/2);
    155         painter->drawText(drawPoint,QString("Events: ") + QString::number(index.model()->rowCount(index)));
     174        painter->drawText(drawPoint,numEvents);
     175
     176        QPointF titlePointF = QPoint(
     177                option.rect.x()+SPACER,
     178                option.rect.y()+option.rect.height()-fmBig.descent());
     179        painter->setFont(fontBig);
     180
     181        painter->drawText(titlePointF,qVariantValue<QString>(index.data()));
    156182    }
    157183
     
    159185    //if (option.state & QStyle::State_Selected)
    160186        //painter->fillRect(option.rect, option.palette.highlight());
    161 
    162     // draw title
    163     QPointF titlePointF(option.rect.x()+SPACER,option.rect.y()+option.rect.height()-10);
    164     QString text;
    165     if(index.parent().isValid()) // event
    166         text = qVariantValue<QString>(index.data()) + ": " + static_cast<Event*>(index.internalPointer())->title();
    167     else // group
    168         text = qVariantValue<QString>(index.data());
    169     painter->drawText(titlePointF,text);
    170187
    171188    painter->restore();
Note: See TracChangeset for help on using the changeset viewer.