Ejemplo n.º 1
0
void TrackView::paintTracks(QStylePainter &painter, const QRegion &region)
{
	const QRect &rect = region.boundingRect();
	int startTrack = qBound(0, getTrackFromPhysicalX(qMax(rect.left(), leftMarginWidth)), getTrackCount());
	int endTrack = qBound(0, getTrackFromPhysicalX(rect.right()) + 1, getTrackCount());

	painter.setClipRect(QRectF(QPointF(leftMarginWidth - 0.5f, topMarginHeight - 0.5f),
	                           QPointF(rect.right() + 1.0f, rect.bottom() + 1.0f)));
	painter.fillRect(rect, palette().dark());

	for (int track = startTrack; track < endTrack; ++track)
		paintTrack(painter, region, track);
}
Ejemplo n.º 2
0
void TrackViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QObject *obj = static_cast<QObject*>(index.internalPointer());
    Track *track = qobject_cast<Track*>(obj);
    if (track)
    {
        paintTrack(painter, option, index, track);
        return;
    }

    if (index.column() == 0)
    {
        Disk *disk = qobject_cast<Disk*>(obj);
        if (disk)
        {
            paintDisk(painter, option, index, disk);
        }
    }
}
Ejemplo n.º 3
0
void TrackViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QStyleOptionViewItem opt = option;
    opt.state &= ~QStyle::State_Selected;

    QObject *obj = static_cast<QObject*>(index.internalPointer());
    Track *track = qobject_cast<Track*>(obj);
    if (track)
    {
        QColor bgColor = (index.row() % 2) ? mTrackView->palette().base().color() : mTrackView->palette().alternateBase().color();
        painter->fillRect(opt.rect, bgColor);

        paintTrack(painter, opt, index, track);
        return;
    }

    if (index.column() == 0)
    {
        Disk *disk = qobject_cast<Disk*>(obj);
        if (disk)
        {
            QColor bgColor = mTrackView->palette().base().color();
            painter->fillRect(opt.rect, bgColor);

            if (mTrackView-> selectionModel()->isSelected(index))
            {
                QRect rect = opt.rect;
                if (index.row() > 0)
                    rect.setTop(rect.top() + TOP_PADDING);
                drawSelectionMark(painter, rect);
            }

            paintDisk(painter, opt, index, disk);
        }
    }
}
Ejemplo n.º 4
0
void PlaylistItemDelegate::paint(
        QPainter* painter,
        const QStyleOptionViewItem& option,
        const QModelIndex& index) const {
    paintTrack(painter, option, index);
}