QPainterPath MockWidgetCheater::shape() const
{   
    QPainterPath path;
    QRectF currentRect(rect());
    currentRect.setHeight(currentRect.height() + 10);
    path.addRect(currentRect);    
    return path;
}
    //____________________________________________________________
    void MenuBarDataV2::updateAnimatedRect( void )
    {

        // check rect validity
        if( !( currentRect().isValid() && previousRect().isValid() ) )
        {
            _animatedRect = QRect();
            return;
        }

        // compute rect located 'between' previous and current
        _animatedRect.setLeft( previousRect().left() + progress()*(currentRect().left() - previousRect().left()) );
        _animatedRect.setRight( previousRect().right() + progress()*(currentRect().right() - previousRect().right()) );
        _animatedRect.setTop( previousRect().top() + progress()*(currentRect().top() - previousRect().top()) );
        _animatedRect.setBottom( previousRect().bottom() + progress()*(currentRect().bottom() - previousRect().bottom()) );

        // trigger update
        setDirty();

        return;

    }
void OpenGLSceneViewCore::mouseUp(NSPoint point, bool alt, bool cmd, bool ctrl, bool shift, int clickCount)
{
    _isPainting = false;
    
	_currentPoint = point;
	
	if (_isManipulating)
	{
        _delegate->manipulationEnded();
        _isManipulating = false;
	}

	if (_isSelecting)
	{
		_isSelecting = false;

		if (_manipulated != NULL)
		{
			OpenGLSelectionMode selectionMode = OpenGLSelectionMode::Add;
	        
			if (cmd)
				selectionMode = OpenGLSelectionMode::Invert;
			else if (shift)
				selectionMode = OpenGLSelectionMode::Add;
			else
				_manipulated->changeSelection(false);
			
			NSRect rect = currentRect();
			if (clickCount <= 1 && rect.size.width > 5.0f && rect.size.height > 5.0f)
			{
				select(rect, _manipulated, selectionMode, ctrl || _alwaysSelectThrough);
			}
			else
			{
				if (clickCount == 2)
				{
					if (selectionMode == OpenGLSelectionMode::Invert)
						selectionMode = OpenGLSelectionMode::InvertExpand;
					else
						selectionMode = OpenGLSelectionMode::Expand;
				}
	            
				select(_currentPoint, _manipulated, selectionMode);
			}
			
			_delegate->selectionChanged();
		}

        _delegate->setNeedsDisplay();
	}
}
示例#4
0
void TrackDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    /* Painting background */

    QStyle *style = option.widget->style();
    style->drawControl(QStyle::CE_ItemViewItem, &option, painter, option.widget);

    /* Painting time */

    QString time = index.data(PlaylistModel::DurationRole).toString();
    int timeWidth = option.fontMetrics.width(time);

    QRect timeRect(option.rect.right() - m_margin - option.rect.height() - m_margin - timeWidth,
                    option.rect.top(),
                    timeWidth,
                    option.rect.height());
    painter->drawText(timeRect, Qt::AlignCenter, time);

    /* Painting favorite */

    QRect favoriteRect(option.rect.right() - option.rect.height(),
                        option.rect.top(),
                        option.rect.height(),
                        option.rect.height());
    m_star.paint(painter, favoriteRect, Qt::AlignCenter, TrackDelegate::iconMode(index), QIcon::On);

    /* Painting current icon */

    QRect currentRect(option.rect.left() + m_margin,
                   option.rect.top() + m_margin,
                   16,
                   16);

    if (index.data(PlaylistModel::CurrentRole).toBool()) {
        painter->drawPixmap(currentRect, m_current);
    }

    /* Painting track details */

    QRect textRect(option.rect.left() + 2 * m_margin + currentRect.width(),
                    option.rect.top() + m_margin,
                    option.rect.width() - 5 * m_margin - currentRect.width() - favoriteRect.width() - timeRect.width(),
                    option.rect.height());
    QString mainText = index.data(Qt::DisplayRole).toString();
    QString elidedText = option.fontMetrics.elidedText(mainText, Qt::ElideRight, textRect.width());

    painter->drawText(textRect, elidedText);

//    if (index.row() % 4 == 0) {
//        painter->save();
//        painter->setOpacity(0.9);
//        painter->setPen(Qt::white);
//        painter->setBrush(QBrush(Qt::white));
//        painter->drawRect(option.rect);
//        painter->setOpacity(1.0);
//        painter->setBrush(QBrush(Qt::red));
//        painter->setPen(QPen(Qt::red));
//        painter->drawText(textRect, Qt::AlignHCenter, "Error: File not available");
//        painter->restore();
//    }
}