Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Claudio Valerio 13 years ago
commit 20d6e93e14
  1. 70
      src/gui/UBThumbnailWidget.cpp
  2. 6
      src/gui/UBThumbnailWidget.h

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

@ -93,7 +93,6 @@ class UBThumbnailWidget : public QGraphicsView
private:
void selectAll();
void unselectAll();
void selectItems(int startIndex, int count);
int rowCount() const;
int columnCount() const;
@ -106,6 +105,8 @@ class UBThumbnailWidget : public QGraphicsView
QString mMimeType;
QPointF prevMoveMousePos;
qreal mThumbnailWidth;
qreal mThumbnailHeight;
qreal mSpacing;
@ -113,7 +114,8 @@ class UBThumbnailWidget : public QGraphicsView
UBThumbnail *mLastSelectedThumbnail;
int mSelectionSpan;
QGraphicsRectItem *mLassoRectItem;
QList<QGraphicsItem*> mSelectedThumbnailItems;
QSet<QGraphicsItem*> mSelectedThumbnailItems;
QSet<QGraphicsItem*> mPreviouslyIncrementalSelectedItems;
QTime mClickTime;
};

Loading…
Cancel
Save