|
|
|
@ -39,11 +39,14 @@ UBDocumentTreeWidget::UBDocumentTreeWidget(QWidget * parent) |
|
|
|
|
setDragDropMode(QAbstractItemView::InternalMove); |
|
|
|
|
setAutoScroll(true); |
|
|
|
|
|
|
|
|
|
mScrollTimer = new QTimer(this); |
|
|
|
|
connect(UBDocumentManager::documentManager(), SIGNAL(documentUpdated(UBDocumentProxy*)) |
|
|
|
|
, this, SLOT(documentUpdated(UBDocumentProxy*))); |
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(itemChanged(QTreeWidgetItem *, int)) |
|
|
|
|
, this, SLOT(itemChangedValidation(QTreeWidgetItem *, int))); |
|
|
|
|
connect(mScrollTimer, SIGNAL(timeout()) |
|
|
|
|
, this, SLOT(autoScroll())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -104,6 +107,12 @@ void UBDocumentTreeWidget::dragLeaveEvent(QDragLeaveEvent *event) |
|
|
|
|
{ |
|
|
|
|
Q_UNUSED(event); |
|
|
|
|
|
|
|
|
|
if (mScrollTimer->isActive()) |
|
|
|
|
{ |
|
|
|
|
mScrollMagnitude = 0; |
|
|
|
|
mScrollTimer->stop(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mDropTargetProxyTi) |
|
|
|
|
{ |
|
|
|
|
mDropTargetProxyTi->setBackground(0, mBackground); |
|
|
|
@ -114,6 +123,27 @@ void UBDocumentTreeWidget::dragLeaveEvent(QDragLeaveEvent *event) |
|
|
|
|
|
|
|
|
|
void UBDocumentTreeWidget::dragMoveEvent(QDragMoveEvent *event) |
|
|
|
|
{ |
|
|
|
|
QRect boundingFrame = frameRect(); |
|
|
|
|
//setting up automatic scrolling
|
|
|
|
|
const int SCROLL_DISTANCE = 4; |
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QTreeWidgetItem* underlyingItem = this->itemAt(event->pos()); |
|
|
|
|
|
|
|
|
|
if (event->mimeData()->hasFormat(UBApplication::mimeTypeUniboardPage)) |
|
|
|
@ -417,3 +447,9 @@ bool UBDocumentGroupTreeItem::isDefaultFolder() const |
|
|
|
|
{ |
|
|
|
|
return (0 == (flags() & Qt::ItemIsEditable)) && (groupName() == UBSettings::defaultDocumentGroupName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentTreeWidget::autoScroll() |
|
|
|
|
{ |
|
|
|
|
this->verticalScrollBar()->setValue(this->verticalScrollBar()->value() + mScrollMagnitude); |
|
|
|
|
} |