|
|
@ -26,9 +26,10 @@ UBDocumentThumbnailWidget::UBDocumentThumbnailWidget(QWidget* parent) |
|
|
|
: UBThumbnailWidget(parent) |
|
|
|
: UBThumbnailWidget(parent) |
|
|
|
, mDropCaretRectItem(0) |
|
|
|
, mDropCaretRectItem(0) |
|
|
|
, mClosestDropItem(0) |
|
|
|
, mClosestDropItem(0) |
|
|
|
, mDragEnabled(true) |
|
|
|
, mDragEnabled(true), mScrollMagnitude(0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// NOOP
|
|
|
|
mScrollTimer = new QTimer(this); |
|
|
|
|
|
|
|
connect(mScrollTimer, SIGNAL(timeout()), this, SLOT(autoScroll())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -96,13 +97,43 @@ void UBDocumentThumbnailWidget::dragEnterEvent(QDragEnterEvent *event) |
|
|
|
void UBDocumentThumbnailWidget::dragLeaveEvent(QDragLeaveEvent *event) |
|
|
|
void UBDocumentThumbnailWidget::dragLeaveEvent(QDragLeaveEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_UNUSED(event); |
|
|
|
Q_UNUSED(event); |
|
|
|
|
|
|
|
if (mScrollTimer->isActive()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mScrollMagnitude = 0; |
|
|
|
|
|
|
|
mScrollTimer->stop(); |
|
|
|
|
|
|
|
} |
|
|
|
deleteDropCaret(); |
|
|
|
deleteDropCaret(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentThumbnailWidget::autoScroll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this->verticalScrollBar()->setValue(this->verticalScrollBar()->value() + mScrollMagnitude); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event) |
|
|
|
void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QList<UBSceneThumbnailPixmap*> pixmapItems; |
|
|
|
QRect boundingFrame = frameRect(); |
|
|
|
foreach (QGraphicsItem *item, scene()->items(mapToScene(frameRect()))) |
|
|
|
//setting up automatic scrolling
|
|
|
|
|
|
|
|
const int SCROLL_DISTANCE = 16; |
|
|
|
|
|
|
|
int bottomDist = boundingFrame.bottom() - event->pos().y(), topDist = boundingFrame.top() - event->pos().y(); |
|
|
|
|
|
|
|
if(qAbs(bottomDist) <= SCROLL_DISTANCE) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mScrollMagnitude = (SCROLL_DISTANCE - bottomDist)*4; |
|
|
|
|
|
|
|
if(verticalScrollBar()->isVisible() && !mScrollTimer->isActive()) mScrollTimer->start(100); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if(qAbs(topDist) <= SCROLL_DISTANCE) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mScrollMagnitude = (- SCROLL_DISTANCE - topDist)*4; |
|
|
|
|
|
|
|
if(verticalScrollBar()->isVisible() && !mScrollTimer->isActive()) mScrollTimer->start(100); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mScrollMagnitude = 0; |
|
|
|
|
|
|
|
mScrollTimer->stop(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<UBSceneThumbnailPixmap*> pixmapItems; |
|
|
|
|
|
|
|
foreach (QGraphicsItem *item, scene()->items(mapToScene(boundingFrame))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBSceneThumbnailPixmap* sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(item); |
|
|
|
UBSceneThumbnailPixmap* sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(item); |
|
|
|
if (sceneItem) |
|
|
|
if (sceneItem) |
|
|
@ -161,9 +192,15 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event) |
|
|
|
event->acceptProposedAction(); |
|
|
|
event->acceptProposedAction(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event) |
|
|
|
void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
deleteDropCaret(); |
|
|
|
if (mScrollTimer->isActive()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mScrollMagnitude = 0; |
|
|
|
|
|
|
|
mScrollTimer->stop(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
deleteDropCaret(); |
|
|
|
|
|
|
|
|
|
|
|
if (mClosestDropItem) |
|
|
|
if (mClosestDropItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|