~ivanalert/vkbatchfiledownloader/new-model

« back to all changes in this revision

Viewing changes to src/videoitemdelegate.cpp

  • Committer: Иван Вахромеев
  • Date: 2017-06-14 00:54:36 UTC
  • Revision ID: ivanalert@mail.ru-20170614005436-g6ff0oypp5h7wrrd
Исправлены ошибки, добавлен делегать для видео элементов, который рисует продолжительность видео на миниатюре.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "videoitemdelegate.h"
2
 
 
3
 
#include <QPainter>
4
 
 
5
 
VideoItemDelegate::VideoItemDelegate(QObject *parent)
6
 
    : QStyledItemDelegate(parent)
7
 
{
8
 
 
9
 
}
10
 
 
11
 
void VideoItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
12
 
                          const QModelIndex &index) const
13
 
{
14
 
    QRect infoRect(option.rect.left(), option.rect.top() + option.decorationSize.height() / 2,
15
 
                   option.rect.width(), option.fontMetrics.height());
16
 
    QString text = option.fontMetrics.elidedText(index.data().toString(), Qt::ElideMiddle,
17
 
                                                 option.decorationSize.width());
18
 
 
19
 
    QStyledItemDelegate::paint(painter, option, index);
20
 
    painter->drawText(infoRect, Qt::AlignCenter, text);
21
 
}