SankoréSANKORE-499

Document explorer(navigator): pages of a document can not be moved using D'n'D
preferencesAboutTextFull
Anatoly Mihalchenko 13 years ago
parent 0d339d4cdf
commit 7f8d9c10f1
  1. 2
      src/board/UBBoardController.h
  2. 11
      src/core/UBApplicationController.cpp
  3. 1
      src/gui/UBDocumentNavigator.cpp
  4. 1
      src/gui/UBDocumentNavigator.h
  5. 36
      src/gui/UBDocumentTreeWidget.cpp
  6. 4
      src/gui/UBDocumentTreeWidget.h

@ -152,6 +152,7 @@ class UBBoardController : public QObject
void displayMetaData(QMap<QString, QString> metadatas);
void ClearUndoStack();
void emitScrollSignal() { emit scrollToSelectedPage(); }
public slots:
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0);
@ -230,6 +231,7 @@ class UBBoardController : public QObject
void setDocOnPageNavigator(UBDocumentProxy* doc);
void documentReorganized(int index);
void displayMetadata(QMap<QString, QString> metadata);
void scrollToSelectedPage();
protected:
void setupViews();

@ -337,8 +337,15 @@ void UBApplicationController::showBoard()
mMainWindow->tutorialToolBar->hide();
mMainWindow->boardToolBar->show();
if (mMainMode == Document && UBApplication::documentController->getSelectedItemIndex() != -1)
UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->getCurrentDocument(), UBApplication::documentController->getSelectedItemIndex());
if (mMainMode == Document)
{
int selectedSceneIndex = UBApplication::documentController->getSelectedItemIndex();
if (selectedSceneIndex != -1)
{
UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->getCurrentDocument(), selectedSceneIndex);
UBApplication::boardController->emitScrollSignal();
}
}
mMainMode = Board;

@ -58,6 +58,7 @@ UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGra
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(addNewPage()));
connect(mScene, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
connect(UBApplication::boardController, SIGNAL(documentReorganized(int)), this, SLOT(onMovedToIndex(int)));
connect(UBApplication::boardController, SIGNAL(scrollToSelectedPage()), this, SLOT(onScrollToSelectedPage()));
}
/**

@ -46,6 +46,7 @@ signals:
public slots:
void onMovedToIndex(int index);
void onScrollToSelectedPage() { centerOn(mCrntItem); }
protected:
virtual void resizeEvent(QResizeEvent *event);

@ -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);
}

@ -43,10 +43,14 @@ class UBDocumentTreeWidget : public QTreeWidget
void itemChangedValidation(QTreeWidgetItem * item, int column);
void autoScroll();
private:
UBDocumentProxyTreeItem *mSelectedProxyTi;
QTreeWidgetItem *mDropTargetProxyTi;
QBrush mBackground;
QTimer* mScrollTimer;
int mScrollMagnitude;
};

Loading…
Cancel
Save