|
|
@ -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; |
|
|
|
QSet<QGraphicsItem*> incSelectedItems = scene()->items(incrementXSelection, Qt::IntersectsItemBoundingRect).toSet() |
|
|
|
foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedItems) |
|
|
|
+ scene()->items(incrementYSelection, Qt::IntersectsItemBoundingRect).toSet();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mPreviouslyIncrementalSelectedItems = incSelectedItems; |
|
|
|
|
|
|
|
QSet<QGraphicsItem*> lassoSelectedItems; |
|
|
|
|
|
|
|
QSet<QGraphicsItem*> lassoSelectedThumbnailItems; |
|
|
|
|
|
|
|
foreach (QGraphicsItem *lassoSelectedItem, incSelectedItems) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (lassoSelectedItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBThumbnail *thumbnailItem = dynamic_cast<UBThumbnail*>(lassoSelectedItem); |
|
|
|
UBSceneThumbnailPixmap *thumbnailItem = dynamic_cast<UBSceneThumbnailPixmap*>(lassoSelectedItem); |
|
|
|
|
|
|
|
|
|
|
|
if (thumbnailItem) |
|
|
|
if (thumbnailItem) |
|
|
|
lassoSelectedThumbnailItems.append(lassoSelectedItems); |
|
|
|
{ |
|
|
|
|
|
|
|
lassoSelectedItem->setSelected(true); |
|
|
|
|
|
|
|
lassoSelectedThumbnailItems += lassoSelectedItem; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unselectAll(); |
|
|
|
QSet<QGraphicsItem*> toUnset; |
|
|
|
foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedThumbnailItems) |
|
|
|
toUnset = mSelectedThumbnailItems - lassoSelectedThumbnailItems; |
|
|
|
{ |
|
|
|
foreach(QGraphicsItem* item, toUnset) |
|
|
|
if (Qt::ControlModifier & event->modifiers()) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!mSelectedThumbnailItems.contains(lassoSelectedItem)) |
|
|
|
item->setSelected(false); |
|
|
|
selectItemAt(mGraphicItems.indexOf(lassoSelectedItem), true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mSelectedThumbnailItems += lassoSelectedItems; |
|
|
|
|
|
|
|
// foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedThumbnailItems)
|
|
|
|
{ |
|
|
|
{ |
|
|
|
selectItemAt(mGraphicItems.indexOf(lassoSelectedItem), true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (Qt::ControlModifier & event->modifiers()) |
|
|
|
if (Qt::ControlModifier & event->modifiers()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (QGraphicsItem *selectedItem, mSelectedThumbnailItems) |
|
|
|
for (int i = 0; i < mSelectedThumbnailItems.count()-1; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!lassoSelectedThumbnailItems.contains(selectedItem)) |
|
|
|
mSelectedThumbnailItems.values().at(i)->setSelected(true); |
|
|
|
selectItemAt(mGraphicItems.indexOf(selectedItem), true); |
|
|
|
} |
|
|
|
|
|
|
|
// foreach (QGraphicsItem *selectedItem, mSelectedThumbnailItems)
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// selectedItem->setSelected(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()); |
|
|
|