From daca7121df4ea273f3d9f69a9318564d81bda5b1 Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Wed, 4 Apr 2012 18:14:00 +0300 Subject: [PATCH 1/4] Fix to cffadaptor - added forgotten "delete" in destructor. --- plugins/cffadaptor/src/UBCFFAdaptor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/cffadaptor/src/UBCFFAdaptor.cpp b/plugins/cffadaptor/src/UBCFFAdaptor.cpp index 6de92d92..af8b4f1b 100644 --- a/plugins/cffadaptor/src/UBCFFAdaptor.cpp +++ b/plugins/cffadaptor/src/UBCFFAdaptor.cpp @@ -1876,6 +1876,8 @@ UBCFFAdaptor::UBToCFFConverter::~UBToCFFConverter() delete mDataModel; if (mIWBContentWriter) delete mIWBContentWriter; + if (mDocumentToWrite) + delete mDocumentToWrite; } bool UBCFFAdaptor::UBToCFFConverter::isValid() const { From 1613ca0a196daae4be883f26c326dfe29f1dd704 Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Wed, 11 Apr 2012 10:26:36 +0300 Subject: [PATCH 2/4] CffAdaptor builds separately for debug and for release. Sankore is adapted to use cffadaptor builds separately. --- Sankore_3.1.pro | 7 ++---- plugins/cffadaptor/UBCFFAdaptor.pro | 37 +++++++++++++++++++---------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro index a630e889..9fff2773 100644 --- a/Sankore_3.1.pro +++ b/Sankore_3.1.pro @@ -109,8 +109,9 @@ MOC_DIR = $$BUILD_DIR/moc RCC_DIR = $$BUILD_DIR/rcc UI_DIR = $$BUILD_DIR/ui +LIBS += "-Lplugins/cffadaptor/$$BUILD_DIR/lib" "-lCFF_Adaptor" + win32 { - LIBS += "-Lplugins/cffadaptor/lib/win32" "-lCFF_Adaptor" RC_FILE = resources/win/sankore.rc CONFIG += qaxcontainer exists(console):CONFIG += console @@ -131,7 +132,6 @@ win32 { } macx { - LIBS += "-Lplugins/cffadaptor/lib/macx" "-lCFF_Adaptor" LIBS += -framework Foundation LIBS += -lcrypto LIBS += -framework AppKit @@ -329,7 +329,6 @@ macx { } linux-g++ { - LIBS += "-Lplugins/cffadaptor/lib/linux" "-lCFF_Adaptor" LIBS += -lcrypto QMAKE_CFLAGS += -fopenmp QMAKE_CXXFLAGS += -fopenmp @@ -345,7 +344,6 @@ linux-g++ { } linux-g++-32 { - LIBS += "-Lplugins/cffadaptor/lib/linux" "-lCFF_Adaptor" LIBS += -lcrypto QMAKE_CFLAGS += -fopenmp QMAKE_CXXFLAGS += -fopenmp @@ -361,7 +359,6 @@ linux-g++-32 { } linux-g++-64 { - LIBS += "-Lplugins/cffadaptor/lib/linux" "-lCFF_Adaptor" LIBS += -lcrypto QMAKE_CFLAGS += -fopenmp QMAKE_CXXFLAGS += -fopenmp diff --git a/plugins/cffadaptor/UBCFFAdaptor.pro b/plugins/cffadaptor/UBCFFAdaptor.pro index 36ef90fe..079de115 100644 --- a/plugins/cffadaptor/UBCFFAdaptor.pro +++ b/plugins/cffadaptor/UBCFFAdaptor.pro @@ -4,6 +4,9 @@ # #------------------------------------------------- +TARGET = CFF_Adaptor +TEMPLATE = lib + win32: SUB_DIR = win32 macx: SUB_DIR = macx linux-g++: SUB_DIR = linux @@ -13,11 +16,21 @@ linux-g++-64: SUB_DIR = linux THIRD_PARTY_PATH = ../../../Sankore-ThirdParty QUAZIP_DIR = "$$PWD/../../../Sankore-ThirdParty/quazip/quazip-0.3" -INCLUDEPATH += src +BUILD_DIR = $$PWD/build/$$SUB_DIR +CONFIG(debug, debug|release):BUILD_DIR = $$BUILD_DIR/debug +CONFIG(release, debug|release) { + BUILD_DIR = $$BUILD_DIR/release + CONFIG += warn_off +} -DEPENDPATH += $$THIRD_PARTY_PATH/quazip/ -INCLUDEPATH += $$THIRD_PARTY_PATH/quazip/ -include($$THIRD_PARTY_PATH/quazip/quazip.pri) +win32{ + CONFIG += dll +} + +OBJECTS_DIR = $$BUILD_DIR/objects +MOC_DIR = $$BUILD_DIR/moc +DESTDIR = $$BUILD_DIR/lib +RCC_DIR = $$BUILD_DIR/rcc LIBS += "-L$$THIRD_PARTY_PATH/quazip/lib/$$SUB_DIR" "-lquazip" @@ -25,15 +38,17 @@ QT += xml xmlpatterns core QT += gui QT += svg -TARGET = CFF_Adaptor -TEMPLATE = lib -win32{ - CONFIG += dll -} DEFINES += UBCFFADAPTOR_LIBRARY DEFINES += NO_THIRD_PARTY_WARNINGS +INCLUDEPATH += src + +DEPENDPATH += $$THIRD_PARTY_PATH/quazip/ +INCLUDEPATH += $$THIRD_PARTY_PATH/quazip/ +include($$THIRD_PARTY_PATH/quazip/quazip.pri) + + SOURCES += \ src/UBCFFAdaptor.cpp @@ -43,9 +58,5 @@ HEADERS +=\ src/UBCFFAdaptor_global.h \ src/UBCFFConstants.h -OBJECTS_DIR = $$PWD/objects -MOC_DIR = $$PWD/moc -DESTDIR = $$PWD/lib/$$SUB_DIR - RESOURCES += \ resources/resources.qrc From 0d339d4cdf8d933bbdb31d0eda31bb2a918752bb Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Fri, 13 Apr 2012 13:25:55 +0300 Subject: [PATCH 3/4] Selection items hotfix. --- src/gui/UBThumbnailWidget.cpp | 82 ++++++++++++++++++++++++++--------- src/gui/UBThumbnailWidget.h | 4 +- 2 files changed, 64 insertions(+), 22 deletions(-) diff --git a/src/gui/UBThumbnailWidget.cpp b/src/gui/UBThumbnailWidget.cpp index cd0ebec3..96f448d9 100644 --- a/src/gui/UBThumbnailWidget.cpp +++ b/src/gui/UBThumbnailWidget.cpp @@ -33,6 +33,7 @@ UBThumbnailWidget::UBThumbnailWidget(QWidget* parent) , mLastSelectedThumbnail(0) , mSelectionSpan(0) , mLassoRectItem(0) + , mPrevLassoRect(QRect()) { // By default, the drag is possible bCanDrag = true; @@ -217,6 +218,7 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event) QStyleOption option; option.initFrom(&rubberBand); + mPrevLassoRect = QRect(); mLassoRectItem = new QGraphicsRectItem(0, scene()); #ifdef Q_WS_MAC @@ -248,6 +250,8 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event) } mSelectedThumbnailItems.clear(); + mPreviouslyIncrementalSelectedItemsX.clear(); + mPreviouslyIncrementalSelectedItemsY.clear(); QGraphicsView::mousePressEvent(event); } else if (Qt::ShiftModifier & event->modifiers()) @@ -305,6 +309,8 @@ void UBThumbnailWidget::mouseMoveEvent(QMouseEvent *event) QRectF lassoRect( qMin(mMousePressScenePos.x(), currentScenePos.x()), qMin(mMousePressScenePos.y(), currentScenePos.y()), qAbs(mMousePressScenePos.x() - currentScenePos.x()), qAbs(mMousePressScenePos.y() - currentScenePos.y())); + if (QPoint() == prevMoveMousePos) + prevMoveMousePos = currentScenePos; QRectF incrementXSelection( qMin(prevMoveMousePos.x(), currentScenePos.x()), qMin(mMousePressScenePos.y(), currentScenePos.y()), qAbs(prevMoveMousePos.x() - currentScenePos.x())+incrementLassoMinWidth, qAbs(mMousePressScenePos.y() - currentScenePos.y())); @@ -315,50 +321,83 @@ void UBThumbnailWidget::mouseMoveEvent(QMouseEvent *event) prevMoveMousePos = currentScenePos; mLassoRectItem->setRect(lassoRect); + QSet lassoSelectedThumbnailItems; - QSet incSelectedItems = scene()->items(incrementXSelection, Qt::IntersectsItemBoundingRect).toSet() - + scene()->items(incrementYSelection, Qt::IntersectsItemBoundingRect).toSet(); + QSet toUnset; + QSet toSet; - mPreviouslyIncrementalSelectedItems = incSelectedItems; - QSet lassoSelectedItems; - QSet lassoSelectedThumbnailItems; - foreach (QGraphicsItem *lassoSelectedItem, incSelectedItems) + // for horizontal moving + QSet incSelectedItemsX = scene()->items(incrementXSelection, Qt::IntersectsItemBoundingRect).toSet(); + foreach (QGraphicsItem *lassoSelectedItem, incSelectedItemsX) + { + if (lassoSelectedItem) + { + UBSceneThumbnailPixmap *thumbnailItem = dynamic_cast(lassoSelectedItem); + if (thumbnailItem) + lassoSelectedThumbnailItems += lassoSelectedItem; + } + } + + if(lassoRect.width() < mPrevLassoRect.width()) + { + if (!lassoSelectedThumbnailItems.contains(mPreviouslyIncrementalSelectedItemsX)) + toUnset += mPreviouslyIncrementalSelectedItemsX - lassoSelectedThumbnailItems; + + } + mPreviouslyIncrementalSelectedItemsX = lassoSelectedThumbnailItems; + + toSet += lassoSelectedThumbnailItems + mPreviouslyIncrementalSelectedItemsX; + + + lassoSelectedThumbnailItems.clear(); + + // for vertical moving + + QSet incSelectedItemsY = scene()->items(incrementYSelection, Qt::IntersectsItemBoundingRect).toSet(); + foreach (QGraphicsItem *lassoSelectedItem, incSelectedItemsY) { if (lassoSelectedItem) { UBSceneThumbnailPixmap *thumbnailItem = dynamic_cast(lassoSelectedItem); if (thumbnailItem) - { - lassoSelectedItem->setSelected(true); lassoSelectedThumbnailItems += lassoSelectedItem; - } } } - QSet toUnset; - toUnset = mSelectedThumbnailItems - lassoSelectedThumbnailItems; - foreach(QGraphicsItem* item, toUnset) + if(lassoRect.height() < mPrevLassoRect.height()) { - item->setSelected(false); + if (!lassoSelectedThumbnailItems.contains(mPreviouslyIncrementalSelectedItemsY)) + toUnset += mPreviouslyIncrementalSelectedItemsY - lassoSelectedThumbnailItems; + } + mPreviouslyIncrementalSelectedItemsY = lassoSelectedThumbnailItems; - - mSelectedThumbnailItems += lassoSelectedItems; - // foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedThumbnailItems) + + toSet += lassoSelectedThumbnailItems + mPreviouslyIncrementalSelectedItemsY; + + + toSet -= toUnset; + + foreach (QGraphicsItem *item, toSet) { - + item->setSelected(true); + } + + foreach (QGraphicsItem *item, toUnset) + { + item->setSelected(false); } + + mSelectedThumbnailItems += lassoSelectedThumbnailItems; + mPrevLassoRect = lassoRect; + if (Qt::ControlModifier & event->modifiers()) { for (int i = 0; i < mSelectedThumbnailItems.count()-1; i++) { mSelectedThumbnailItems.values().at(i)->setSelected(true); } - // foreach (QGraphicsItem *selectedItem, mSelectedThumbnailItems) - { - // selectedItem->setSelected(true); - } } } else @@ -404,6 +443,7 @@ void UBThumbnailWidget::mouseMoveEvent(QMouseEvent *event) void UBThumbnailWidget::mouseReleaseEvent(QMouseEvent *event) { int elapsedTimeSincePress = mClickTime.elapsed(); + prevMoveMousePos = QPoint(); deleteLasso(); QGraphicsView::mouseReleaseEvent(event); diff --git a/src/gui/UBThumbnailWidget.h b/src/gui/UBThumbnailWidget.h index 2ad70c37..0429e370 100644 --- a/src/gui/UBThumbnailWidget.h +++ b/src/gui/UBThumbnailWidget.h @@ -113,9 +113,11 @@ class UBThumbnailWidget : public QGraphicsView UBThumbnail *mLastSelectedThumbnail; int mSelectionSpan; + QRectF mPrevLassoRect; QGraphicsRectItem *mLassoRectItem; QSet mSelectedThumbnailItems; - QSet mPreviouslyIncrementalSelectedItems; + QSet mPreviouslyIncrementalSelectedItemsX; + QSet mPreviouslyIncrementalSelectedItemsY; QTime mClickTime; }; From 7f8d9c10f1791b61d26d9b48ec2eac446e218c39 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Fri, 13 Apr 2012 19:05:16 +0300 Subject: [PATCH 4/4] =?UTF-8?q?Sankor=C3=A9SANKORE-499=20Document=20explor?= =?UTF-8?q?er(navigator):=20pages=20of=20a=20document=20can=20not=20be=20m?= =?UTF-8?q?oved=20using=20D'n'D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/board/UBBoardController.h | 2 ++ src/core/UBApplicationController.cpp | 11 +++++++-- src/gui/UBDocumentNavigator.cpp | 1 + src/gui/UBDocumentNavigator.h | 1 + src/gui/UBDocumentTreeWidget.cpp | 36 ++++++++++++++++++++++++++++ src/gui/UBDocumentTreeWidget.h | 4 ++++ 6 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/board/UBBoardController.h b/src/board/UBBoardController.h index 4ea56d7a..d5d6bee1 100644 --- a/src/board/UBBoardController.h +++ b/src/board/UBBoardController.h @@ -152,6 +152,7 @@ class UBBoardController : public QObject void displayMetaData(QMap 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 metadata); + void scrollToSelectedPage(); protected: void setupViews(); diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index 89af16fa..ac2e12af 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -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; diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index efb3e04a..c2dd5df2 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -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())); } /** diff --git a/src/gui/UBDocumentNavigator.h b/src/gui/UBDocumentNavigator.h index 5f322355..e643fbf6 100644 --- a/src/gui/UBDocumentNavigator.h +++ b/src/gui/UBDocumentNavigator.h @@ -46,6 +46,7 @@ signals: public slots: void onMovedToIndex(int index); + void onScrollToSelectedPage() { centerOn(mCrntItem); } protected: virtual void resizeEvent(QResizeEvent *event); diff --git a/src/gui/UBDocumentTreeWidget.cpp b/src/gui/UBDocumentTreeWidget.cpp index b344855c..e693e865 100644 --- a/src/gui/UBDocumentTreeWidget.cpp +++ b/src/gui/UBDocumentTreeWidget.cpp @@ -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); +} \ No newline at end of file diff --git a/src/gui/UBDocumentTreeWidget.h b/src/gui/UBDocumentTreeWidget.h index f76d1696..d4fe72f6 100644 --- a/src/gui/UBDocumentTreeWidget.h +++ b/src/gui/UBDocumentTreeWidget.h @@ -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; };