void ZeChatRoom_delegate
::paint(QPainter *painter,
{
// QItemDelegate::paint(painter, option, index);
ZeChatRoom_data * chatData = index.data().value<ZeChatRoom_data *>();
// Display rects
QRect pictureRect
(option.
rect.
x() + 2, option.
rect.
y() + 2,
32,
32);
QRect displayRect
= QRect(option.
rect.
x() + 36, option.
rect.
y() + 2,
option.rect.width() - 38, (option.rect.height() - 4) / 2);
QRect displayRect2
= QRect(option.
rect.
x() + 36, option.
rect.
y() + option.
rect.
height() / 2,
option.rect.width() - 38, (option.rect.height() - 4) / 2);
QColor descriptionColor
= ZeStyle
::get()->getDarkBorderColor
();
if (option.
state & QStyle::State_MouseOver) {
ZePainterController::get()->DrawHighlight(*painter, option.rect);
textColor = ZeStyle::get()->getHighlightTextColor();
descriptionColor = ZeStyle::get()->getHighlightTextColor();
ZePainterController::get()->
DrawBottomLine
(*painter, option.
rect,
QColor(100,
100,
100,
150));
}
else
{
if (index.row() %2 == 0)
{
ZePainterController::get()->
DrawBack
(*painter, option.
rect,
QColor(ZeStyle
::get()->getBorderColor
().
red(),
ZeStyle::get()->getBorderColor().green(),
ZeStyle::get()->getBorderColor().blue(), 50), false);
}
ZePainterController::get()->
DrawBottomLine(*painter, option.rect,
/*QColor(100, 100, 100, 150)*/ QColor(ZeStyle
::get()->getBorderColor
().
red(),
ZeStyle::get()->getBorderColor().green(),
ZeStyle::get()->getBorderColor().blue(), 200));
}
ZePainterController::get()->
DrawPictureRatio(*painter, *chatData->mChatPixmap, pictureRect, 1.0f);
font.setBold(true);
ZePainterController::get()->DrawText(*painter,
displayRect,
chatData
->mRoomName
+ " - " + QString::number(chatData
->mParticipants
),
Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine,
textColor,
&font);
ZePainterController::get()->DrawText(*painter,
displayRect2,
chatData->mDescription,
Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine,
descriptionColor);
}
void ZeChatRoom_delegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
// QItemDelegate::paint(painter, option, index);
ZeChatRoom_data * chatData = index.data().value<ZeChatRoom_data *>();
// Display rects
QRect pictureRect(option.rect.x() + 2, option.rect.y() + 2, 32, 32);
QRect displayRect = QRect(option.rect.x() + 36, option.rect.y() + 2,
option.rect.width() - 38, (option.rect.height() - 4) / 2);
QRect displayRect2 = QRect(option.rect.x() + 36, option.rect.y() + option.rect.height() / 2,
option.rect.width() - 38, (option.rect.height() - 4) / 2);
QColor textColor = Qt::black;
QColor descriptionColor = ZeStyle::get()->getDarkBorderColor();
if (option.state & QStyle::State_MouseOver)
{
ZePainterController::get()->DrawHighlight(*painter, option.rect);
textColor = ZeStyle::get()->getHighlightTextColor();
descriptionColor = ZeStyle::get()->getHighlightTextColor();
ZePainterController::get()->
DrawBottomLine(*painter, option.rect, QColor(100, 100, 100, 150));
}
else
{
if (index.row() %2 == 0)
{
ZePainterController::get()->
DrawBack(*painter, option.rect, QColor(ZeStyle::get()->getBorderColor().red(),
ZeStyle::get()->getBorderColor().green(),
ZeStyle::get()->getBorderColor().blue(), 50), false);
}
ZePainterController::get()->
DrawBottomLine(*painter, option.rect,
/*QColor(100, 100, 100, 150)*/ QColor(ZeStyle::get()->getBorderColor().red(),
ZeStyle::get()->getBorderColor().green(),
ZeStyle::get()->getBorderColor().blue(), 200));
}
ZePainterController::get()->
DrawPictureRatio(*painter, *chatData->mChatPixmap, pictureRect, 1.0f);
QFont font;
font.setBold(true);
ZePainterController::get()->DrawText(*painter,
displayRect,
chatData->mRoomName + " - " + QString::number(chatData->mParticipants),
Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine,
textColor,
&font);
ZePainterController::get()->DrawText(*painter,
displayRect2,
chatData->mDescription,
Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine,
descriptionColor);
}
To copy to clipboard, switch view to plain text mode
Bookmarks