|
|
@ -243,7 +243,7 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event) |
|
|
|
|
|
|
|
|
|
|
|
if (Qt::ControlModifier & event->modifiers() || Qt::ShiftModifier & event->modifiers()) |
|
|
|
if (Qt::ControlModifier & event->modifiers() || Qt::ShiftModifier & event->modifiers()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mSelectedThumbnailItems = selectedItems(); |
|
|
|
// mSelectedThumbnailItems = selectedItems().toSet();
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -261,7 +261,7 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event) |
|
|
|
int index2 = mGraphicItems.indexOf(underlyingItem); |
|
|
|
int index2 = mGraphicItems.indexOf(underlyingItem); |
|
|
|
if (-1 == index2) |
|
|
|
if (-1 == index2) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mSelectedThumbnailItems = selectedItems(); |
|
|
|
mSelectedThumbnailItems = selectedItems().toSet(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
mSelectionSpan = index2 - index1; |
|
|
|
mSelectionSpan = index2 - index1; |
|
|
@ -300,40 +300,64 @@ void UBThumbnailWidget::mouseMoveEvent(QMouseEvent *event) |
|
|
|
if (mLassoRectItem) |
|
|
|
if (mLassoRectItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bSelectionInProgress = true; |
|
|
|
bSelectionInProgress = true; |
|
|
|
|
|
|
|
int incrementLassoMinWidth = 2; |
|
|
|
QPointF currentScenePos = mapToScene(event->pos()); |
|
|
|
QPointF currentScenePos = mapToScene(event->pos()); |
|
|
|
QRectF lassoRect( |
|
|
|
QRectF lassoRect( |
|
|
|
qMin(mMousePressScenePos.x(), currentScenePos.x()), qMin(mMousePressScenePos.y(), currentScenePos.y()), |
|
|
|
qMin(mMousePressScenePos.x(), currentScenePos.x()), qMin(mMousePressScenePos.y(), currentScenePos.y()), |
|
|
|
qAbs(mMousePressScenePos.x() - currentScenePos.x()), qAbs(mMousePressScenePos.y() - currentScenePos.y())); |
|
|
|
qAbs(mMousePressScenePos.x() - currentScenePos.x()), qAbs(mMousePressScenePos.y() - currentScenePos.y())); |
|
|
|
|
|
|
|
QRectF incrementXSelection( |
|
|
|
|
|
|
|
qMin(prevMoveMousePos.x(), currentScenePos.x()), qMin(mMousePressScenePos.y(), currentScenePos.y()), |
|
|
|
|
|
|
|
qAbs(prevMoveMousePos.x() - currentScenePos.x())+incrementLassoMinWidth, qAbs(mMousePressScenePos.y() - currentScenePos.y())); |
|
|
|
|
|
|
|
QRectF incrementYSelection( |
|
|
|
|
|
|
|
qMin(mMousePressScenePos.x(), currentScenePos.x()), qMin(prevMoveMousePos.y(), currentScenePos.y()), |
|
|
|
|
|
|
|
qAbs(mMousePressScenePos.x() - currentScenePos.x()), qAbs(prevMoveMousePos.y() - currentScenePos.y())+incrementLassoMinWidth); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prevMoveMousePos = currentScenePos; |
|
|
|
mLassoRectItem->setRect(lassoRect); |
|
|
|
mLassoRectItem->setRect(lassoRect); |
|
|
|
|
|
|
|
|
|
|
|
QList<QGraphicsItem*> lassoSelectedItems = scene()->items(lassoRect, Qt::IntersectsItemBoundingRect); |
|
|
|
|
|
|
|
QList<QGraphicsItem*> lassoSelectedThumbnailItems; |
|
|
|
|
|
|
|
foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedItems) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UBThumbnail *thumbnailItem = dynamic_cast<UBThumbnail*>(lassoSelectedItem); |
|
|
|
|
|
|
|
if (thumbnailItem) |
|
|
|
|
|
|
|
lassoSelectedThumbnailItems.append(lassoSelectedItems); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unselectAll(); |
|
|
|
QSet<QGraphicsItem*> incSelectedItems = scene()->items(incrementXSelection, Qt::IntersectsItemBoundingRect).toSet() |
|
|
|
foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedThumbnailItems) |
|
|
|
+ scene()->items(incrementYSelection, Qt::IntersectsItemBoundingRect).toSet();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mPreviouslyIncrementalSelectedItems = incSelectedItems; |
|
|
|
|
|
|
|
QSet<QGraphicsItem*> lassoSelectedItems; |
|
|
|
|
|
|
|
QSet<QGraphicsItem*> lassoSelectedThumbnailItems; |
|
|
|
|
|
|
|
foreach (QGraphicsItem *lassoSelectedItem, incSelectedItems) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (Qt::ControlModifier & event->modifiers()) |
|
|
|
if (lassoSelectedItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!mSelectedThumbnailItems.contains(lassoSelectedItem)) |
|
|
|
UBSceneThumbnailPixmap *thumbnailItem = dynamic_cast<UBSceneThumbnailPixmap*>(lassoSelectedItem); |
|
|
|
selectItemAt(mGraphicItems.indexOf(lassoSelectedItem), true); |
|
|
|
|
|
|
|
} |
|
|
|
if (thumbnailItem) |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
lassoSelectedItem->setSelected(true); |
|
|
|
selectItemAt(mGraphicItems.indexOf(lassoSelectedItem), true); |
|
|
|
lassoSelectedThumbnailItems += lassoSelectedItem; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QSet<QGraphicsItem*> toUnset; |
|
|
|
|
|
|
|
toUnset = mSelectedThumbnailItems - lassoSelectedThumbnailItems; |
|
|
|
|
|
|
|
foreach(QGraphicsItem* item, toUnset) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
item->setSelected(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mSelectedThumbnailItems += lassoSelectedItems; |
|
|
|
|
|
|
|
// foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedThumbnailItems)
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
if (Qt::ControlModifier & event->modifiers()) |
|
|
|
if (Qt::ControlModifier & event->modifiers()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (QGraphicsItem *selectedItem, mSelectedThumbnailItems) |
|
|
|
for (int i = 0; i < mSelectedThumbnailItems.count()-1; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mSelectedThumbnailItems.values().at(i)->setSelected(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// foreach (QGraphicsItem *selectedItem, mSelectedThumbnailItems)
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!lassoSelectedThumbnailItems.contains(selectedItem)) |
|
|
|
// selectedItem->setSelected(true);
|
|
|
|
selectItemAt(mGraphicItems.indexOf(selectedItem), true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -609,14 +633,6 @@ void UBThumbnailWidget::selectAll() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBThumbnailWidget::unselectAll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (QGraphicsItem* item, mGraphicItems) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
item->setSelected(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int UBThumbnailWidget::rowCount() const |
|
|
|
int UBThumbnailWidget::rowCount() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBThumbnail *lastThumbnail = dynamic_cast<UBThumbnail*>(mGraphicItems.last()); |
|
|
|
UBThumbnail *lastThumbnail = dynamic_cast<UBThumbnail*>(mGraphicItems.last()); |
|
|
|