Better drawing when big selection rect is drawn.

svn path=/trunk/KDE/kdebase/apps/; revision=681460
This commit is contained in:
Rafael Fernández López 2007-06-29 01:19:56 +00:00
parent 7992063d83
commit 0829b5fc8a
2 changed files with 45 additions and 13 deletions

View file

@ -637,19 +637,6 @@ void KListView::paintEvent(QPaintEvent *event)
itemDelegate(index)->paint(&painter, option, index);
}
// Redraw categories
QStyleOptionViewItem otherOption;
foreach (const QString &category, d->categories)
{
otherOption = option;
otherOption.rect = d->categoryVisualRect(category);
if (otherOption.rect.intersects(area))
{
d->drawNewCategory(category, otherOption, &painter);
}
}
if (d->mouseButtonPressed && !d->isDragging)
{
QPoint start, end, initialPressPosition;
@ -681,6 +668,19 @@ void KListView::paintEvent(QPaintEvent *event)
painter.restore();
}
// Redraw categories
QStyleOptionViewItem otherOption;
foreach (const QString &category, d->categories)
{
otherOption = option;
otherOption.rect = d->categoryVisualRect(category);
if (otherOption.rect.intersects(area))
{
d->drawNewCategory(category, otherOption, &painter);
}
}
if (d->isDragging && !d->dragLeftViewport)
{
painter.setOpacity(0.5);
@ -801,6 +801,37 @@ void KListView::mouseMoveEvent(QMouseEvent *event)
viewport()->update(d->categoryVisualRect(category));
}
QRect rect;
if (d->mouseButtonPressed && !d->isDragging)
{
QPoint start, end, initialPressPosition;
initialPressPosition = d->initialPressPosition;
initialPressPosition.setY(initialPressPosition.y() - verticalOffset());
initialPressPosition.setX(initialPressPosition.x() - horizontalOffset());
if (d->initialPressPosition.x() > d->mousePosition.x() ||
d->initialPressPosition.y() > d->mousePosition.y())
{
start = d->mousePosition;
end = initialPressPosition;
}
else
{
start = initialPressPosition;
end = d->mousePosition;
}
viewport()->update(d->lastSelectionRect);
rect = QRect(start, end).intersected(viewport()->rect().adjusted(-16, -16, 16, 16));
viewport()->update(rect);
d->lastSelectionRect = rect;
}
}
void KListView::mousePressEvent(QMouseEvent *event)

View file

@ -143,6 +143,7 @@ public:
QStringList categories;
QModelIndexList intersectedIndexes;
QRect lastDraggedItemsRect;
QRect lastSelectionRect;
// Attributes for speed reasons
KSortFilterProxyModel *proxyModel;