- Timestamp:
- 08/23/11 20:43:56 (11 years ago)
- Branches:
- master, qt5
- Children:
- ec813bb
- Parents:
- 5dbcd35
- Location:
- src/mvc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mvc/delegate.cpp
r5dbcd35 rbe12b9f 52 52 void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 53 53 { 54 if (!mViewPtr)54 if (!mViewPtr) 55 55 return; 56 56 57 57 painter->save(); 58 QColor bkgrColor = option.palette.color(QPalette::Background);59 //QColor bkgrColor = QColor(0xAA,0xAA,0xAA);60 QColor conflictColor = Qt::yellow;61 58 62 59 QColor textColor = option.palette.color(QPalette::Text); 63 QPen borderPen(textColor); 60 64 61 if(hasParent(index)) 65 62 { … … 70 67 int aux = option.rect.height() - SPACER - mControls[FavouriteControlOn]->image()->height(); 71 68 Event *event = static_cast<Event*>(index.internalPointer()); 69 72 70 // font SMALL 73 71 QFont fontSmall = option.font; … … 78 76 QFont fontSmallB = fontSmall; 79 77 fontSmallB.setBold(true); 80 QFontMetrics fmSmallB(fontSmallB);81 78 82 79 // font BIG … … 85 82 fontBig.setPixelSize(aux*0.33); 86 83 QFontMetrics fmBig(fontBig); 84 87 85 // font BIG bold 88 86 QFont fontBigB = fontBig; … … 90 88 QFontMetrics fmBigB(fontBigB); 91 89 92 //int spacer = (fmSmall.boundingRect("999").width() < SPACER) ? SPACER : fmSmall.boundingRect("999").width(); 93 94 //Time conflicts are colored differently 95 if(event->hasTimeConflict()) 96 bkgrColor = conflictColor; 97 98 QLinearGradient itemGradient(option.rect.topLeft(), option.rect.bottomLeft()); 99 itemGradient.setColorAt(0.0, bkgrColor); 100 itemGradient.setColorAt(1.0, bkgrColor); 101 102 if(isLast(index)) 103 { 104 QPainterPath endPath; 105 endPath.moveTo(option.rect.topLeft()); 106 endPath.lineTo(option.rect.bottomLeft()-QPoint(0, RADIUS)); 107 endPath.arcTo(option.rect.left(), option.rect.bottom()-2*RADIUS, 2*RADIUS, 2*RADIUS, 180, 90); 108 endPath.lineTo(option.rect.bottomRight()-QPoint(RADIUS, 0)); 109 endPath.arcTo(option.rect.right()-2*RADIUS, option.rect.bottom()-2*RADIUS, 2*RADIUS, 2*RADIUS, 270, 90); 110 endPath.lineTo(option.rect.topRight()); 111 112 //painter->setBrush( bkgrColor ); 113 painter->setBrush(itemGradient); 114 painter->setPen(Qt::NoPen); 115 painter->drawPath(endPath); 116 painter->setPen(borderPen); 117 118 painter->setFont(option.font); 119 } 120 else // middle elements 121 { 122 //painter->setBrush( bkgrColor ); 123 painter->setBrush(itemGradient); 90 // background (in case of time conflicts) 91 if(event->hasTimeConflict()) { 92 painter->setBrush(Qt::yellow); 124 93 painter->setPen(Qt::NoPen); 125 94 painter->drawRect(option.rect); 126 127 painter->setPen(borderPen); 128 /* 129 // vertical lines 130 painter->drawLine(option.rect.topLeft(), option.rect.bottomLeft()); 131 painter->drawLine(option.rect.topRight(), option.rect.bottomRight()); 132 */ 133 // horizontal lines 134 painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight()); 135 136 painter->setFont(option.font); 95 } 96 97 // background (without time conflicts) 98 else { 99 QStyleOption styleOption; 100 styleOption.rect = option.rect; 101 qApp->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &styleOption, painter, mViewPtr); 137 102 } 138 103 … … 158 123 // ("position of text" is lower-left angle of the first letter, 159 124 // so the first line is actually at the same height as the image) 125 painter->setPen(QPen(event->hasTimeConflict() ? Qt::black : textColor)); 160 126 QPointF titlePointF(option.rect.x() + SPACER, 161 127 option.rect.y() + SPACER + mControls[FavouriteControlOn]->image()->height()); … … 163 129 painter->setFont(fontBig); 164 130 painter->drawText(titlePointF,start.toString("hh:mm") + "-" + start.addSecs(event->duration()).toString("hh:mm") + ", " + event->roomName()); 131 165 132 // title 166 133 titlePointF.setY(titlePointF.y()+fmBig.height()-fmBig.descent()); … … 182 149 } 183 150 painter->drawText(titlePointF,title); 151 184 152 // persons 185 153 titlePointF.setY(titlePointF.y()+fmSmall.height()-fmSmall.descent()); … … 187 155 QString presenterPrefix = event->persons().count() < 2 ? "Presenter" : "Presenters"; 188 156 painter->drawText(titlePointF,presenterPrefix + ": " + event->persons().join(" and ")); 157 189 158 // track 190 159 titlePointF.setY(titlePointF.y()+fmSmall.height()-fmSmall.descent()); 191 160 painter->drawText(titlePointF,"Track: " + Track::retrieveTrackName(event->trackId())); 192 161 } 162 193 163 else // doesn't have parent - time-groups' elements (top items) 194 164 { 165 int numFav = numberOfFavourities(index); 166 167 QStyleOptionButton styleOptionButton; 168 styleOptionButton.rect = option.rect; 169 if (isExpanded(index)) styleOptionButton.state = QStyle::State_Sunken; 170 // styleOptionButton.text = qVariantValue<QString>(index.data()); 171 qApp->style()->drawPrimitive(QStyle::PE_PanelButtonCommand, &styleOptionButton, painter, mViewPtr); 172 // qApp->style()->drawControl(QStyle::CE_PushButtonLabel, &styleOptionButton, painter, mViewPtr); 173 // qApp->style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &styleOptionButton, painter, mViewPtr); 174 195 175 QFont fontSmall = option.font; 196 176 fontSmall.setBold(true); … … 205 185 int spacer = (fmSmall.boundingRect("999").width() < SPACER) ? SPACER : fmSmall.boundingRect("999").width(); 206 186 207 QLinearGradient titleGradient(option.rect.topLeft(), option.rect.topRight());208 bkgrColor = option.palette.color(QPalette::Highlight);209 textColor = option.palette.color(QPalette::HighlightedText);210 titleGradient.setColorAt(0.0, bkgrColor);211 titleGradient.setColorAt(1.0, bkgrColor);212 213 QPainterPath titlePath;214 if(isExpanded(index))215 {216 titlePath.moveTo(option.rect.bottomLeft());217 titlePath.lineTo(option.rect.topLeft()+QPoint(0, RADIUS));218 titlePath.arcTo(option.rect.left(), option.rect.top(), 2*RADIUS, 2*RADIUS, 180, -90);219 titlePath.lineTo(option.rect.topRight()-QPoint(RADIUS, 0));220 titlePath.arcTo(option.rect.right()-2*RADIUS, option.rect.top(), 2*RADIUS, 2*RADIUS, 90, -90);221 titlePath.lineTo(option.rect.bottomRight());222 titlePath.closeSubpath();223 }224 else225 {226 titlePath.lineTo(option.rect.topLeft()+QPoint(0, RADIUS));227 titlePath.arcTo(option.rect.left(), option.rect.top(), 2*RADIUS, 2*RADIUS, 180, -90);228 titlePath.lineTo(option.rect.topRight()-QPoint(RADIUS, 0));229 titlePath.arcTo(option.rect.right()-2*RADIUS, option.rect.top(), 2*RADIUS, 2*RADIUS, 90, -90);230 titlePath.lineTo(option.rect.bottomRight()-QPoint(0, RADIUS));231 titlePath.arcTo(option.rect.right()-2*RADIUS, option.rect.bottom()-2*RADIUS, 2*RADIUS, 2*RADIUS, 0, -90);232 titlePath.lineTo(option.rect.bottomLeft()+QPoint(RADIUS, 0));233 titlePath.arcTo(option.rect.left(), option.rect.bottom()-2*RADIUS, 2*RADIUS, 2*RADIUS, 270, -90);234 titlePath.closeSubpath();235 }236 237 painter->setBrush(titleGradient);238 painter->setPen(borderPen);239 painter->drawPath(titlePath);240 241 187 // draw icons 242 borderPen.setColor(textColor); 243 painter->setPen(borderPen); 188 painter->setPen(QPen(textColor)); 244 189 painter->setFont(fontSmall); 245 QImage *image = mControls[ FavouriteControlOn]->image();190 QImage *image = mControls[numFav ? FavouriteControlOn : FavouriteControlOff]->image(); 246 191 QPoint drawPoint = 247 192 option.rect.topRight() … … 251 196 painter->drawImage(drawPoint,*image); 252 197 painter->drawText(drawPoint+QPoint(image->width()+2, image->height() - 2), 253 QString::number(num berOfFavourities(index)));198 QString::number(numFav)); 254 199 #ifdef MAEMO 255 200 drawPoint.setX(drawPoint.x() - spacer - image->width()); … … 268 213 option.rect.y()+option.rect.height()-fmBig.descent()); 269 214 painter->setFont(fontBig); 270 271 215 painter->drawText(titlePointF,qVariantValue<QString>(index.data())); 272 216 } -
src/mvc/delegate.h
r5dbcd35 rbe12b9f 21 21 #define DELEGATE_H 22 22 23 #include <QItemDelegate> 24 #include <QTreeView> 25 #include <QPointer> 23 #include <QtGui> 26 24 27 25 class Delegate : public QItemDelegate
Note: See TracChangeset
for help on using the changeset viewer.