From 322bd7c8dbd467872359febf7fb363a3a674bd4f Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 14 May 2012 16:06:01 +0200 Subject: [PATCH 1/7] fixed copy issue on windows --- release.win7.vc9.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release.win7.vc9.bat b/release.win7.vc9.bat index dbf91aa2..226d3247 100644 --- a/release.win7.vc9.bat +++ b/release.win7.vc9.bat @@ -62,7 +62,8 @@ nmake release-install copy %BASE_QT_TRANSLATIONS_DIRECTORY%\qt_*.qm build\win32\release\product\i18n\ -copy resources\customizations build\win32\release\product\ +mkdir build\win32\release\product\customizations +xcopy resources\customizations\* build\win32\release\product\customizations del build\win32\release\product\i18n\qt_help* From f943726b20dd2a20a26151c1c216525a1f8c8b95 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 May 2012 16:25:53 +0200 Subject: [PATCH 2/7] fixed release windows issue --- release.win7.vc9.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.win7.vc9.bat b/release.win7.vc9.bat index 226d3247..c11d938d 100644 --- a/release.win7.vc9.bat +++ b/release.win7.vc9.bat @@ -63,7 +63,7 @@ nmake release-install copy %BASE_QT_TRANSLATIONS_DIRECTORY%\qt_*.qm build\win32\release\product\i18n\ mkdir build\win32\release\product\customizations -xcopy resources\customizations\* build\win32\release\product\customizations +xcopy /s resources\customizations\* build\win32\release\product\customizations del build\win32\release\product\i18n\qt_help* From b253ed5774fed7a3ae18e26638c62a5bb7294888 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 May 2012 17:55:19 +0200 Subject: [PATCH 3/7] fixed some path issue on windows --- src/core/UBPersistenceManager.cpp | 9 +++++++-- src/domain/UBW3CWidget.cpp | 7 +++++-- src/gui/UBTeacherGuideWidget.cpp | 8 +++++++- src/gui/UBTeacherGuideWidgetsTools.cpp | 6 +++++- src/gui/UBThumbnailWidget.cpp | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 91b1f478..29e0ef71 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -848,7 +848,12 @@ QString UBPersistenceManager::teacherGuideAbsoluteObjectPath(UBDocumentProxy* pD QString UBPersistenceManager::addObjectToTeacherGuideDirectory(UBDocumentProxy* pDocumentProxy, QString pPath) { - QFileInfo fi(pPath.replace("file://","")); + QString path = pPath; + //windows + path.replace("file:///",""); + //others + path.replace("file://",""); + QFileInfo fi(path); QString uuid = QUuid::createUuid(); if (!fi.exists() || !pDocumentProxy) @@ -862,7 +867,7 @@ QString UBPersistenceManager::addObjectToTeacherGuideDirectory(UBDocumentProxy* QDir dir; dir.mkdir(pDocumentProxy->persistencePath() + "/" + UBPersistenceManager::teacherGuideDirectory); - QFile source(pPath); + QFile source(path); source.copy(destPath); } diff --git a/src/domain/UBW3CWidget.cpp b/src/domain/UBW3CWidget.cpp index 9b423322..60c7bc52 100644 --- a/src/domain/UBW3CWidget.cpp +++ b/src/domain/UBW3CWidget.cpp @@ -247,7 +247,9 @@ QString UBW3CWidget::createNPAPIWrapperInDir(const QString& pUrl, const QDir& pD { QString url = pUrl; // if the file name start with file:// it has be removed because QFileInfo doesn't support this form - url = url.replace("file://",""); + // + url = url.replace("file:///",""); + url = url.replace("file://",""); QString name = pName; QFileInfo fi(url); @@ -304,7 +306,8 @@ QString UBW3CWidget::createNPAPIWrapperInDir(const QString& pUrl, const QDir& pD if (fi.exists()){ QString target = widgetLibraryPath + "/" + fi.fileName(); QString source = pUrl; - source.replace("file://",""); + source.replace("file:///",""); + source.replace("file://",""); QFile::copy(source, target); } diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 9b6cd010..9121ce0a 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -533,7 +533,13 @@ void UBTeacherGuidePresentationWidget::showData(QVector data) newWidgetItem->setText(0,element->attributes.value("title")); newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_MEDIA); newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); - newWidgetItem->setData(0, TG_USER_ROLE_MIME_TYPE, UBApplication::boardController->activeDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")); + QString mimeTypeString; +#ifdef Q_WS_WIN + mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->activeDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString(); +#else + mimeTypeString = UBApplication::boardController->activeDocument()->persistencePath()+ "/" + element->attributes.value("relativePath"); +#endif + newWidgetItem->setData(0, TG_USER_ROLE_MIME_TYPE, mimeTypeString); newWidgetItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable); mpRootWidgetItem->addChild(newWidgetItem); diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index bbda8fd1..c7ba3aa1 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -372,7 +372,7 @@ tUBGEElementNode* UBTGMediaWidget::saveData() tUBGEElementNode* result = new tUBGEElementNode(); QString relativePath = mMediaPath; relativePath = relativePath.replace(UBApplication::boardController->activeDocument()->persistencePath()+"/",""); - result->name = "media"; + result->name = "media"; result->attributes.insert("title",mpTitle->text()); result->attributes.insert("relativePath",relativePath); result->attributes.insert("mediaType",mMediaType); @@ -499,7 +499,11 @@ void UBTGMediaWidget::mousePressEvent(QMouseEvent *event) QDrag *drag = new QDrag(this); QMimeData *mimeData = new QMimeData(); QList urlList; +#ifdef Q_WS_WIN + urlList << QUrl::fromLocalFile(mMediaPath); +#else urlList << QUrl(mMediaPath); +#endif mimeData->setUrls(urlList); drag->setMimeData(mimeData); diff --git a/src/gui/UBThumbnailWidget.cpp b/src/gui/UBThumbnailWidget.cpp index 371e8abb..4f22cc42 100644 --- a/src/gui/UBThumbnailWidget.cpp +++ b/src/gui/UBThumbnailWidget.cpp @@ -842,7 +842,7 @@ void UBSceneThumbnailNavigPixmap::updateButtonsState() } } } - if(UBSettings::settings()->teacherGuidePageZeroActivated and sceneIndex()<=1) + if(UBSettings::settings()->teacherGuidePageZeroActivated && sceneIndex()<=1) bCanMoveUp = false; if(bCanDelete || bCanMoveUp || bCanMoveDown) From d5b3182d33aef9a6e171605596db4a9eff52cab4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 May 2012 18:36:47 +0200 Subject: [PATCH 4/7] fixed windows flash path --- src/gui/UBTeacherGuideWidgetsTools.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index c7ba3aa1..cba4e8bc 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -230,11 +230,14 @@ void UBTGAdaptableText::bottomMargin(int newValue) * class UBTGDraggableWeb * ***************************************************************************/ UBDraggableWeb::UBDraggableWeb(QString& relativePath, QWidget* parent): QWebView(parent) - , mRelativePath(relativePath) , mDragStartPosition(QPoint(-1,-1)) , mDragStarted(false) { + if(!relativePath.startsWith("file://")) + mRelativePath = QUrl::fromLocalFile(relativePath).toString(); + else + mRelativePath = relativePath; //NOOP } From 1a43936d45dd241d40a9a52d4ac799fcfe56bef7 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Tue, 15 May 2012 09:09:18 +0200 Subject: [PATCH 5/7] Updated the eraser on the lines as objects --- src/board/UBDrawingController.cpp | 4 +- src/domain/UBGraphicsScene.cpp | 116 +++++++++--------------------- 2 files changed, 36 insertions(+), 84 deletions(-) diff --git a/src/board/UBDrawingController.cpp b/src/board/UBDrawingController.cpp index a9e4b813..e03ef408 100644 --- a/src/board/UBDrawingController.cpp +++ b/src/board/UBDrawingController.cpp @@ -45,7 +45,7 @@ UBDrawingController::UBDrawingController(QObject * parent) , mActiveRuler(NULL) , mStylusTool((UBStylusTool::Enum)-1) , mLatestDrawingTool((UBStylusTool::Enum)-1) - , mDrawingMode(/*DRAWING_MODE*/eDrawingMode_Vector) + , mDrawingMode(DRAWING_MODE) { connect(UBSettings::settings(), SIGNAL(colorContextChanged()), this, SIGNAL(colorPaletteChanged())); @@ -114,7 +114,7 @@ void UBDrawingController::setStylusTool(int tool) UBApplication::mainWindow->actionPen->setChecked(true); else if (mStylusTool == UBStylusTool::Eraser){ UBApplication::mainWindow->actionEraser->setChecked(true); - //mDrawingMode = eDrawingMode_Artistic; + mDrawingMode = eDrawingMode_Artistic; } else if (mStylusTool == UBStylusTool::Marker) UBApplication::mainWindow->actionMarker->setChecked(true); diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 5ebab1fd..6ff18a96 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -314,6 +314,7 @@ void UBGraphicsScene::selectionChangedProcessing() + QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f')); } } + void UBGraphicsScene::enableGroupingButton() { QAction *groupAction = UBApplication::mainWindow->actionGroupItems; @@ -324,6 +325,7 @@ void UBGraphicsScene::enableGroupingButton() groupAction->setEnabled(false); } } + void UBGraphicsScene::processGroupItems() { qDebug() << "processing grouping items"; @@ -345,9 +347,6 @@ void UBGraphicsScene::processGroupItems() qDebug() << groupItem->boundingRect(); } -// MARK: - -// MARK: Mouse/Tablet events handling - bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pressure) { //mMesure1Ms = 0; @@ -434,7 +433,6 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre return accepted; } - bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pressure) { bool accepted = false; @@ -518,7 +516,6 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres return accepted; } - bool UBGraphicsScene::inputDeviceRelease() { /* @@ -617,8 +614,6 @@ bool UBGraphicsScene::inputDeviceRelease() return accepted; } -// MARK: - - void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool isFirstDraw) { qreal eraserWidth = UBSettings::settings()->currentEraserWidth(); @@ -694,7 +689,6 @@ void UBGraphicsScene::moveTo(const QPointF &pPoint) mDrawWithCompass = false; } - void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, bool bLineStyle) { if (mPreviousWidth == -1.0) @@ -746,11 +740,8 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, } } - void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) { -// QList itemList; - const QLineF line(mPreviousPoint, pEndPoint); const QPolygonF eraserPolygon = UBGeometryUtils::lineToPolygon(line, pWidth); @@ -787,7 +778,6 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) } } } - }else{ QSet toBeAddedItems; QSet toBeRemovedItems; @@ -797,23 +787,19 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) if (mShouldUseOMP) { -// #pragma omp parallel for + #pragma omp parallel for for (int i = 0; i < collidItemsSize; i++) { UBGraphicsPolygonItem *collidingPolygonItem = qgraphicsitem_cast(collidItems.at(i)); if (NULL != collidingPolygonItem) { - collidingPolygonItem->setColor(QColor(Qt::green)); - UBGraphicsStrokesGroup* pGroup = collidingPolygonItem->strokesGroup(); if(eraserInnerRect.contains(collidingPolygonItem->boundingRect())) { -// #pragma omp critical - qDebug() << "case 1"; + #pragma omp critical // Put the entire polygon into the remove list - collidingPolygonItem->setColor(QColor(Qt::blue)); toBeRemovedItems << collidingPolygonItem; } else @@ -825,43 +811,55 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) collidingPath.addPolygon(collidingPolygon); // Then we substract the eraser path to the polygon and we simplify it - QPainterPath croppedPath = collidingPath.subtracted(eraserPath); + /**/ + QTransform polyTransform = collidingPolygonItem->sceneTransform(); + QPointF mTrPrevPoint; + QPointF mTrEndPoint; + + // TODO: Handle the scale & rotation transform here + mTrPrevPoint.setX(mPreviousPoint.x() - polyTransform.dx()); + mTrPrevPoint.setY(mPreviousPoint.y() - polyTransform.dy()); + mTrEndPoint.setX(pEndPoint.x() - polyTransform.dx()); + mTrEndPoint.setY(pEndPoint.y() - polyTransform.dy()); + const QLineF trLine(mTrPrevPoint, mTrEndPoint); + const QPolygonF trEraserPolygon = UBGeometryUtils::lineToPolygon(trLine, pWidth); + + QPainterPath trEraser; + trEraser.addPolygon(trEraserPolygon); + QPainterPath croppedPath = collidingPath.subtracted(trEraser); + /**/ + + // Original + //QPainterPath croppedPath = collidingPath.subtracted(eraserPath); QPainterPath croppedPathSimplified = croppedPath.simplified(); /*if (croppedPath == collidingPath) { // NOOP - qDebug() << "case 2"; toBeRemovedItems << collidingPolygonItem; } else */if (croppedPathSimplified.isEmpty()) { -// #pragma omp critical - qDebug() << "case 3"; + #pragma omp critical // Put the entire polygon into the remove list if the eraser removes all its visible content - collidingPolygonItem->setColor(QColor(Qt::blue)); toBeRemovedItems << collidingPolygonItem; } else { - //qDebug() << "case 4"; // Then we convert the remaining path to a list of polygons that will be converted in // UBGraphicsPolygonItems and added to the scene foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons()) { UBGraphicsPolygonItem* croppedPolygonItem = collidingPolygonItem->deepCopy(pol); - croppedPolygonItem->setColor(QColor(Qt::black)); -// #pragma omp critical + #pragma omp critical if(NULL != pGroup){ croppedPolygonItem->setStrokesGroup(pGroup); -// croppedPolygonItem->setTransform(pGroup->sceneTransform().inverted()); } // Add this new polygon to the 'added' list toBeAddedItems << croppedPolygonItem; } -// #pragma omp critical + #pragma omp critical // Remove the original polygonitem because it has been replaced by many smaller polygons - collidingPolygonItem->setColor(QColor(Qt::blue)); toBeRemovedItems << collidingPolygonItem; } } @@ -934,30 +932,14 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) mRemovedItems += toBeRemovedItems; } -// bool hack = false; -// UBGraphicsStrokesGroup* pG = new UBGraphicsStrokesGroup(); if(eDrawingMode_Vector == DRAWING_MODE){ foreach(QGraphicsItem* item, toBeAddedItems){ UBGraphicsPolygonItem* poly = dynamic_cast(item); if(NULL != poly && NULL != poly->strokesGroup()){ -// if(!hack){ -// itemList = poly->strokesGroup()->childItems(); -// removeItem(poly->strokesGroup()); - -// foreach(QGraphicsItem* it, itemList){ -// pG->addToGroup(it); -// } -// hack = true; -// } - qreal dx = -poly->strokesGroup()->sceneTransform().inverted().dx(); - qreal dy = -poly->strokesGroup()->sceneTransform().inverted().dy(); - - //poly->setTransform(QTransform().translate(20, 0)); - poly->setTransform(QTransform().translate(dx, dy)); - poly->strokesGroup()/*pG*/->addToGroup(poly); + poly->setTransform(poly->strokesGroup()->transform()); + poly->strokesGroup()->addToGroup(poly); } } - //addItem(pG); }else{ addItems(toBeAddedItems); mAddedItems += toBeAddedItems; @@ -967,7 +949,6 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) mPreviousPoint = pEndPoint; } - void UBGraphicsScene::drawArcTo(const QPointF& pCenterPoint, qreal pSpanAngle) { mDrawWithCompass = true; @@ -1079,7 +1060,6 @@ void UBGraphicsScene::recolorAllItems() } } - UBGraphicsPolygonItem* UBGraphicsScene::lineToPolygonItem(const QLineF &pLine, const qreal &pWidth) { UBGraphicsPolygonItem *polygonItem = new UBGraphicsPolygonItem(pLine, pWidth); @@ -1089,7 +1069,6 @@ UBGraphicsPolygonItem* UBGraphicsScene::lineToPolygonItem(const QLineF &pLine, c return polygonItem; } - void UBGraphicsScene::initPolygonItem(UBGraphicsPolygonItem* polygonItem) { QColor colorOnDarkBG; @@ -1121,7 +1100,6 @@ void UBGraphicsScene::initPolygonItem(UBGraphicsPolygonItem* polygonItem) polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); } - UBGraphicsPolygonItem* UBGraphicsScene::arcToPolygonItem(const QLineF& pStartRadius, qreal pSpanAngle, qreal pWidth) { QPolygonF polygon = UBGeometryUtils::arcToPolygon(pStartRadius, pSpanAngle, pWidth); @@ -1129,7 +1107,6 @@ UBGraphicsPolygonItem* UBGraphicsScene::arcToPolygonItem(const QLineF& pStartRad return polygonToPolygonItem(polygon); } - UBGraphicsPolygonItem* UBGraphicsScene::polygonToPolygonItem(const QPolygonF pPolygon) { UBGraphicsPolygonItem *polygonItem = new UBGraphicsPolygonItem(pPolygon); @@ -1139,14 +1116,12 @@ UBGraphicsPolygonItem* UBGraphicsScene::polygonToPolygonItem(const QPolygonF pPo return polygonItem; } - void UBGraphicsScene::hideEraser() { if (mEraser) mEraser->hide(); } - void UBGraphicsScene::leaveEvent(QEvent * event) { Q_UNUSED(event); @@ -1221,13 +1196,11 @@ UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const return copy; } - UBItem* UBGraphicsScene::deepCopy() const { return sceneDeepCopy(); } - void UBGraphicsScene::clearItemsAndAnnotations() { deselectAllItems(); @@ -1259,7 +1232,6 @@ void UBGraphicsScene::clearItemsAndAnnotations() setDocumentUpdated(); } - void UBGraphicsScene::clearItems() { deselectAllItems(); @@ -1297,7 +1269,6 @@ void UBGraphicsScene::clearItems() setDocumentUpdated(); } - void UBGraphicsScene::clearAnnotations() { QSet emptyList; @@ -1328,7 +1299,6 @@ void UBGraphicsScene::clearAnnotations() setDocumentUpdated(); } - UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, const QPointF& pPos, qreal pScaleFactor, bool pUseAnimation) { UBGraphicsPixmapItem* pixmapItem = new UBGraphicsPixmapItem(); @@ -1368,7 +1338,6 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, const Q return pixmapItem; } - void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem) { if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented @@ -1377,7 +1346,6 @@ void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem) } } - UBGraphicsVideoItem* UBGraphicsScene::addVideo(const QUrl& pVideoFileUrl, bool shouldPlayAsap, const QPointF& pPos) { UBGraphicsVideoItem* videoItem = new UBGraphicsVideoItem(pVideoFileUrl); @@ -1440,7 +1408,6 @@ UBGraphicsAudioItem* UBGraphicsScene::addAudio(const QUrl& pAudioFileUrl, bool s return audioItem; } - UBGraphicsWidgetItem* UBGraphicsScene::addWidget(const QUrl& pWidgetUrl, const QPointF& pPos) { int widgetType = UBAbstractWidget::widgetType(pWidgetUrl); @@ -1460,7 +1427,6 @@ UBGraphicsWidgetItem* UBGraphicsScene::addWidget(const QUrl& pWidgetUrl, const Q } } - UBGraphicsAppleWidgetItem* UBGraphicsScene::addAppleWidget(const QUrl& pWidgetUrl, const QPointF& pPos) { UBGraphicsAppleWidgetItem *appleWidget = new UBGraphicsAppleWidgetItem(pWidgetUrl); @@ -1470,7 +1436,6 @@ UBGraphicsAppleWidgetItem* UBGraphicsScene::addAppleWidget(const QUrl& pWidgetUr return appleWidget; } - UBGraphicsW3CWidgetItem* UBGraphicsScene::addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos, int widgetType) { UBGraphicsW3CWidgetItem *w3CWidget = new UBGraphicsW3CWidgetItem(pWidgetUrl, 0, widgetType); @@ -1511,7 +1476,6 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co } } - UBGraphicsW3CWidgetItem* UBGraphicsScene::addOEmbed(const QUrl& pContentUrl, const QPointF& pPos) { QStringList widgetPaths = UBPersistenceManager::persistenceManager()->allWidgets(UBSettings::settings()->applicationApplicationsLibraryDirectory()); @@ -1564,7 +1528,6 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint return svgItem; } - UBGraphicsTextItem* UBGraphicsScene::addText(const QString& pString, const QPointF& pTopLeft) { return addTextWithFont(pString, pTopLeft, UBSettings::settings()->fontPixelSize() @@ -1572,7 +1535,6 @@ UBGraphicsTextItem* UBGraphicsScene::addText(const QString& pString, const QPoin , UBSettings::settings()->isItalicFont()); } - UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, const QPointF& pTopLeft , int pointSize, const QString& fontFamily, bool bold, bool italic) { @@ -1629,6 +1591,7 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con return textItem; } + UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const QPointF& pTopLeft) { UBGraphicsTextItem *textItem = new UBGraphicsTextItem(); @@ -1692,7 +1655,6 @@ void UBGraphicsScene::removeItem(QGraphicsItem* item) mFastAccessItems.removeAll(item); } - void UBGraphicsScene::removeItems(const QSet& items) { setModified(true); @@ -1706,7 +1668,6 @@ void UBGraphicsScene::removeItems(const QSet& items) mFastAccessItems.removeAll(item); } - void UBGraphicsScene::deselectAllItems() { foreach(QGraphicsItem *gi, selectedItems ()) @@ -1752,7 +1713,6 @@ QGraphicsItem* UBGraphicsScene::setAsBackgroundObject(QGraphicsItem* item, bool return item; } - QRectF UBGraphicsScene::normalizedSceneRect(qreal ratio) { @@ -1792,7 +1752,6 @@ QRectF UBGraphicsScene::normalizedSceneRect(qreal ratio) return normalizedRect; } - void UBGraphicsScene::setDocument(UBDocumentProxy* pDocument) { if (pDocument != mDocument) @@ -1807,7 +1766,6 @@ void UBGraphicsScene::setDocument(UBDocumentProxy* pDocument) } } - QGraphicsItem* UBGraphicsScene::scaleToFitDocumentSize(QGraphicsItem* item, bool center, int margin, bool expand) { int maxWidth = mNominalSize.width() - (margin * 2); @@ -1831,7 +1789,6 @@ QGraphicsItem* UBGraphicsScene::scaleToFitDocumentSize(QGraphicsItem* item, bool return item; } - void UBGraphicsScene::addRuler(QPointF center) { UBGraphicsRuler* ruler = new UBGraphicsRuler(); // mem : owned and destroyed by the scene @@ -1847,7 +1804,6 @@ void UBGraphicsScene::addRuler(QPointF center) setModified(true); } - void UBGraphicsScene::addProtractor(QPointF center) { // Protractor @@ -2039,7 +1995,6 @@ void UBGraphicsScene::addMask(const QPointF ¢er) setModified(true); } - void UBGraphicsScene::setRenderingQuality(UBItem::RenderingQuality pRenderingQuality) { QListIterator itItems(mFastAccessItems); @@ -2057,7 +2012,6 @@ void UBGraphicsScene::setRenderingQuality(UBItem::RenderingQuality pRenderingQua } } - QList UBGraphicsScene::relativeDependencies() const { QList relativePathes; @@ -2077,7 +2031,6 @@ QList UBGraphicsScene::relativeDependencies() const return relativePathes; } - QSize UBGraphicsScene::nominalSize() { if (mDocument && !mNominalSize.isValid()) @@ -2088,7 +2041,6 @@ QSize UBGraphicsScene::nominalSize() return mNominalSize; } - void UBGraphicsScene::setNominalSize(const QSize& pSize) { if (nominalSize() != pSize) @@ -2102,7 +2054,6 @@ void UBGraphicsScene::setNominalSize(const QSize& pSize) } } - void UBGraphicsScene::setNominalSize(int pWidth, int pHeight) { setNominalSize(QSize(pWidth, pHeight)); @@ -2112,10 +2063,12 @@ void UBGraphicsScene::setSelectedZLevel(QGraphicsItem * item) { item->setZValue(mZLayerController->generateZLevel(itemLayerType::SelectedItem)); } + void UBGraphicsScene::setOwnZlevel(QGraphicsItem *item) { item->setZValue(item->data(UBGraphicsItemData::ItemOwnZValue).toReal()); } + void UBGraphicsScene::groupItems(QList &itemList) { foreach (QGraphicsItem *item, itemList) { @@ -2124,7 +2077,6 @@ void UBGraphicsScene::groupItems(QList &itemList) } } - qreal UBGraphicsScene::changeZLevelTo(QGraphicsItem *item, UBZLayerController::moveDestination dest) { return mZLayerController->changeZLevelTo(item, dest); @@ -2142,7 +2094,6 @@ QGraphicsItem* UBGraphicsScene::rootItem(QGraphicsItem* item) const return root; } - void UBGraphicsScene::drawItems (QPainter * painter, int numItems, QGraphicsItem * items[], const QStyleOptionGraphicsItem options[], QWidget * widget) { @@ -2317,13 +2268,13 @@ void UBGraphicsScene::keyReleaseEvent(QKeyEvent * keyEvent) QGraphicsScene::keyReleaseEvent(keyEvent); } - void UBGraphicsScene::setDocumentUpdated() { if (document()) document()->setMetaData(UBSettings::documentUpdatedAt , UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); } + void UBGraphicsScene::createEraiser() { mEraser = new QGraphicsEllipseItem(); // mem : owned and destroyed by the scene @@ -2337,6 +2288,7 @@ void UBGraphicsScene::createEraiser() addItem(mEraser); } + void UBGraphicsScene::createPointer() { mPointer = new QGraphicsEllipseItem(); // mem : owned and destroyed by the scene From 6ec28ed726a56bff566580fcb74edb34f9e7faf8 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Tue, 15 May 2012 13:27:55 +0200 Subject: [PATCH 6/7] Strokes as objects support all the transform for the eraser now --- src/domain/UBGraphicsScene.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 431a215c..a01aad4e 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -859,15 +859,10 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) // Then we substract the eraser path to the polygon and we simplify it /**/ - QTransform polyTransform = collidingPolygonItem->sceneTransform(); - QPointF mTrPrevPoint; - QPointF mTrEndPoint; - - // TODO: Handle the scale & rotation transform here - mTrPrevPoint.setX(mPreviousPoint.x() - polyTransform.dx()); - mTrPrevPoint.setY(mPreviousPoint.y() - polyTransform.dy()); - mTrEndPoint.setX(pEndPoint.x() - polyTransform.dx()); - mTrEndPoint.setY(pEndPoint.y() - polyTransform.dy()); + QTransform polyTransform = collidingPolygonItem->sceneTransform().inverted(); + QPointF mTrPrevPoint = polyTransform.map(mPreviousPoint); + QPointF mTrEndPoint = polyTransform.map(pEndPoint); + const QLineF trLine(mTrPrevPoint, mTrEndPoint); const QPolygonF trEraserPolygon = UBGeometryUtils::lineToPolygon(trLine, pWidth); From 70db49550f2f8ce014297539dcc84aabdcbe9139 Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Thu, 17 May 2012 13:13:48 +0300 Subject: [PATCH 7/7] Fix to Sankore 636. Now copyes of video and audio items stops in the sate tomes when stops original items. Generating of missing thumbnails no more crashes Sankore. Improved performance of navigating between pages. --- src/adaptors/UBSvgSubsetAdaptor.cpp | 4 +- src/adaptors/UBThumbnailAdaptor.cpp | 110 ++++++++++------------------ src/adaptors/UBThumbnailAdaptor.h | 1 + src/domain/UBGraphicsAudioItem.cpp | 2 + src/domain/UBGraphicsVideoItem.cpp | 2 + 5 files changed, 45 insertions(+), 74 deletions(-) diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index baf2fb87..286d148d 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -1961,7 +1961,7 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::audioItemToLinkedAudio(UBGraphicsAud mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "position", QString("%1").arg(pos)); } - QString audioFileHref = audioItem->mediaFileUrl().toString(); + QString audioFileHref = audioItem->mediaFileUrl().toLocalFile(); mXmlWriter.writeAttribute(nsXLink, "href", audioFileHref); mXmlWriter.writeEndElement(); } @@ -1986,7 +1986,7 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::videoItemToLinkedVideo(UBGraphicsVid mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "position", QString("%1").arg(pos)); } - QString videoFileHref = videoItem->mediaFileUrl().toString(); + QString videoFileHref = videoItem->mediaFileUrl().toLocalFile(); mXmlWriter.writeAttribute(nsXLink, "href", videoFileHref); mXmlWriter.writeEndElement(); } diff --git a/src/adaptors/UBThumbnailAdaptor.cpp b/src/adaptors/UBThumbnailAdaptor.cpp index 69de0876..2432f89c 100644 --- a/src/adaptors/UBThumbnailAdaptor.cpp +++ b/src/adaptors/UBThumbnailAdaptor.cpp @@ -33,29 +33,23 @@ #include "core/memcheck.h" -QList UBThumbnailAdaptor::load(UBDocumentProxy* proxy) +void UBThumbnailAdaptor::generateMissingThumbnails(UBDocumentProxy* proxy) { - QList thumbnails; - - if (!proxy || proxy->persistencePath().isEmpty()) - return thumbnails; - - //compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails - int existingPageCount = proxy->pageCount(); - QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", existingPageCount); - QFile thumbFile(thumbFileName); - - if (!thumbFile.exists()) + for (int iPageNo = 0; iPageNo < existingPageCount; ++iPageNo) { - bool displayMessage = (existingPageCount > 5); + QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", iPageNo); - int thumbCount = 0; + QFile thumbFile(thumbFileName); - for(int i = 0 ; i < existingPageCount; i++) + if (!thumbFile.exists()) { - UBGraphicsScene* scene = UBSvgSubsetAdaptor::loadScene(proxy, i); + bool displayMessage = (existingPageCount > 5); + + int thumbCount = 0; + + UBGraphicsScene* scene = UBSvgSubsetAdaptor::loadScene(proxy, iPageNo); if (scene) { @@ -64,24 +58,25 @@ QList UBThumbnailAdaptor::load(UBDocumentProxy* proxy) if (displayMessage && thumbCount == 1) UBApplication::showMessage(tr("Generating preview thumbnails ...")); - persistScene(proxy->persistencePath(), scene, i); + persistScene(proxy->persistencePath(), scene, iPageNo); } - else{ - if(i==0){ - // we are working a document without zero page but on a system that enable it - // we have to create an empty zero scene - scene = new UBGraphicsScene(proxy); - UBSvgSubsetAdaptor::persistScene(proxy,scene,0); - persistScene(proxy->persistencePath(),scene,i); - thumbCount++; - } - } - } - if (displayMessage && thumbCount > 0) - UBApplication::showMessage(tr("%1 thumbnails generated ...").arg(thumbCount)); + if (displayMessage && thumbCount > 0) + UBApplication::showMessage(tr("%1 thumbnails generated ...").arg(thumbCount)); + } } +} + +QList UBThumbnailAdaptor::load(UBDocumentProxy* proxy) +{ + QList thumbnails; + + if (!proxy || proxy->persistencePath().isEmpty()) + return thumbnails; + + //compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails + generateMissingThumbnails(proxy); //end compatibility with older format @@ -113,56 +108,27 @@ QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index) { int existingPageCount = proxy->pageCount(); - if (!proxy || proxy->persistencePath().size() == 0 || index < 0 || index >= existingPageCount) + if (!proxy || proxy->persistencePath().size() == 0 || index < 0 || index > existingPageCount) return QPixmap(); //compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails - - QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", existingPageCount); - - QFile thumbFile(thumbFileName); - - if (!thumbFile.exists()) - { - bool displayMessage = (existingPageCount > 5); - - int thumbCount = 0; - - for(int i = 0 ; i < existingPageCount; i++) - { - UBGraphicsScene* scene = UBSvgSubsetAdaptor::loadScene(proxy, i); - - if (scene) - { - thumbCount++; - - if (displayMessage && thumbCount == 1) - UBApplication::showMessage(tr("Generating preview thumbnails ...")); - - persistScene(proxy->persistencePath(), scene, i); - } - } - - if (displayMessage && thumbCount > 0) - UBApplication::showMessage(tr("%1 thumbnails generated ...").arg(thumbCount)); - - } + generateMissingThumbnails(proxy); //end compatibility with older format - QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index); + QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index); - QFile file(fileName); - if (file.exists()) - { - QPixmap pix; - //Warning. Works only with modified Qt + QFile file(fileName); + if (file.exists()) + { + QPixmap pix; + //Warning. Works only with modified Qt #ifdef Q_WS_X11 - pix.load(fileName, 0, Qt::AutoColor); + pix.load(fileName, 0, Qt::AutoColor); #else - pix.load(fileName, 0, Qt::AutoColor, false); + pix.load(fileName, 0, Qt::AutoColor, false); #endif - return pix; - } - return QPixmap(); + return pix; + } + return QPixmap(); } void UBThumbnailAdaptor::persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified) diff --git a/src/adaptors/UBThumbnailAdaptor.h b/src/adaptors/UBThumbnailAdaptor.h index 68352102..75011f2d 100644 --- a/src/adaptors/UBThumbnailAdaptor.h +++ b/src/adaptors/UBThumbnailAdaptor.h @@ -29,6 +29,7 @@ private: UBThumbnailAdaptor() {} public: static void persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false); + static void generateMissingThumbnails(UBDocumentProxy* proxy); static QList load(UBDocumentProxy* proxy); static QPixmap load(UBDocumentProxy* proxy, int index); diff --git a/src/domain/UBGraphicsAudioItem.cpp b/src/domain/UBGraphicsAudioItem.cpp index f2d1ab45..b43271bf 100644 --- a/src/domain/UBGraphicsAudioItem.cpp +++ b/src/domain/UBGraphicsAudioItem.cpp @@ -96,6 +96,8 @@ UBItem* UBGraphicsAudioItem::deepCopy() const UBGraphicsAudioItem *copy = new UBGraphicsAudioItem(audioUrl, parentItem()); + connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), copy, SLOT(activeSceneChanged())); + copy->setPos(this->pos()); copy->setTransform(this->transform()); copy->setFlag(QGraphicsItem::ItemIsMovable, true); diff --git a/src/domain/UBGraphicsVideoItem.cpp b/src/domain/UBGraphicsVideoItem.cpp index 7ef73f8d..40461a7f 100644 --- a/src/domain/UBGraphicsVideoItem.cpp +++ b/src/domain/UBGraphicsVideoItem.cpp @@ -69,6 +69,8 @@ UBItem* UBGraphicsVideoItem::deepCopy() const UBGraphicsVideoItem *copy = new UBGraphicsVideoItem(videoUrl, parentItem()); + connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), copy, SLOT(activeSceneChanged())); + copy->setPos(this->pos()); copy->setTransform(this->transform()); copy->setFlag(QGraphicsItem::ItemIsMovable, true);