From 82453e51369e966f8d9a9aa8495c98d83cdf73fa Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 16 Jul 2013 11:26:31 +0200 Subject: [PATCH 1/6] frame button and transparency strokes fixed issue 50 --- src/domain/UBGraphicsItemDelegate.cpp | 10 +++++++++- src/domain/UBGraphicsProxyWidget.cpp | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index 817aa4ba..91fc6252 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -120,14 +120,17 @@ void DelegateButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void DelegateButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + painter->save(); + painter->setCompositionMode(QPainter::CompositionMode_SourceOver); QGraphicsSvgItem::paint(painter, option, widget); + painter->restore(); if (mIsPressed && mShowProgressIndicator) { QPen pen; pen.setBrush(Qt::white); pen.setWidth(3); painter->save(); - + painter->setCompositionMode(QPainter::CompositionMode_SourceOver); painter->setPen(pen); int spanAngle = qMin(mPressProgres, UBSettings::longClickInterval) * 360 / UBSettings::longClickInterval; @@ -848,6 +851,11 @@ void UBGraphicsToolBarItem::paint(QPainter *painter, const QStyleOptionGraphicsI setBrush(QBrush(UBSettings::paletteColor)); +// QPainter newPainter; + +// newPaiter->setBrush(QBrush(Qt::red)); + + painter->fillPath(path, brush()); } diff --git a/src/domain/UBGraphicsProxyWidget.cpp b/src/domain/UBGraphicsProxyWidget.cpp index 046541df..24f3b6c7 100644 --- a/src/domain/UBGraphicsProxyWidget.cpp +++ b/src/domain/UBGraphicsProxyWidget.cpp @@ -49,8 +49,11 @@ UBGraphicsProxyWidget::~UBGraphicsProxyWidget() void UBGraphicsProxyWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + painter->save(); + painter->setCompositionMode(QPainter::CompositionMode_SourceOver); QGraphicsProxyWidget::paint(painter,option,widget); Delegate()->postpaint(painter, option, widget); + painter->restore(); } QVariant UBGraphicsProxyWidget::itemChange(GraphicsItemChange change, const QVariant &value) From 338a6978207fcd9aa3fdd20f5319d28b49e908e9 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 16 Jul 2013 15:14:17 +0200 Subject: [PATCH 2/6] copy/paste work correctly. Issue 4 --- src/board/UBBoardController.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index cdd10639..0d3da7e9 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -2220,11 +2220,7 @@ void UBBoardController::copy() UBItem* ubItem = dynamic_cast(gi); if (ubItem && !mActiveScene->tools().contains(gi)) - { - UBItem *itemCopy = ubItem->deepCopy(); - if (itemCopy) - selected << itemCopy; - } + selected << ubItem; } if (selected.size() > 0) From a11a952212c776b28ca33ab5200ea33c05f3721f Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 16 Jul 2013 15:14:40 +0200 Subject: [PATCH 3/6] unused comments removed --- src/domain/UBGraphicsGroupContainerItem.cpp | 18 +++--------------- src/domain/UBGraphicsItemDelegate.cpp | 5 ----- src/domain/UBSelectionFrame.cpp | 18 ------------------ 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/src/domain/UBGraphicsGroupContainerItem.cpp b/src/domain/UBGraphicsGroupContainerItem.cpp index 69686aff..35e46a0e 100644 --- a/src/domain/UBGraphicsGroupContainerItem.cpp +++ b/src/domain/UBGraphicsGroupContainerItem.cpp @@ -139,7 +139,7 @@ void UBGraphicsGroupContainerItem::removeFromGroup(QGraphicsItem *item) UBCoreGraphicsScene *groupScene = corescene(); if (groupScene) - { + { groupScene->addItemToDeletion(item); } @@ -164,7 +164,7 @@ void UBGraphicsGroupContainerItem::deselectCurrentItem() { dynamic_cast(mCurrentItem)->Delegate()->getToolBarItem()->hide(); } - break; + break; } mCurrentItem->setSelected(false); @@ -183,16 +183,6 @@ void UBGraphicsGroupContainerItem::paint(QPainter *painter, const QStyleOptionGr Q_UNUSED(painter); Q_UNUSED(option); -// we would not use paint smth for the moment -// if (option->state & QStyle::State_Selected) { -// painter->setBrush(Qt::NoBrush); -// QPen tmpPen; -// qreal tmpPenWidth = 1.0; -// tmpPen.setWidth(tmpPenWidth); -// tmpPen.setColor(Qt::lightGray); -// painter->setPen(tmpPen); -// painter->drawRect(itemsBoundingRect.adjusted(tmpPenWidth / 2, tmpPenWidth / 2, -tmpPenWidth / 2, -tmpPenWidth / 2)); -// } Delegate()->postpaint(painter, option, widget); } @@ -211,8 +201,6 @@ UBGraphicsGroupContainerItem *UBGraphicsGroupContainerItem::deepCopy() const copyItemParameters(copy); -// copy->resize(this->size()); - return copy; } @@ -353,7 +341,7 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item) UBGraphicsScene *Scene = dynamic_cast(item->scene()); if (Scene) - { + { Scene->addItem(item); } diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index 91fc6252..0e015cc2 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -851,11 +851,6 @@ void UBGraphicsToolBarItem::paint(QPainter *painter, const QStyleOptionGraphicsI setBrush(QBrush(UBSettings::paletteColor)); -// QPainter newPainter; - -// newPaiter->setBrush(QBrush(Qt::red)); - - painter->fillPath(path, brush()); } diff --git a/src/domain/UBSelectionFrame.cpp b/src/domain/UBSelectionFrame.cpp index 6de5d187..c253b197 100644 --- a/src/domain/UBSelectionFrame.cpp +++ b/src/domain/UBSelectionFrame.cpp @@ -133,12 +133,6 @@ void UBSelectionFrame::mousePressEvent(QGraphicsSceneMouseEvent *event) } else { mOperationMode = om_moving; } - -// foreach (UBGraphicsItemDelegate *curDelegate, mEnclosedtems) { -// qDebug() << "TransformBefore" << curDelegate->delegated()->transform(); -// } - -// QGraphicsRectItem::mousePressEvent(event); } void UBSelectionFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) @@ -191,9 +185,6 @@ void UBSelectionFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) item->update(); item->setTransform(ownTransform, false); -// int resultAngle = (int)mRotationAngle % 360; -// setCursorFromAngle(QString::number(resultAngle)); - qDebug() << "curAngle" << mRotationAngle; } break; @@ -219,11 +210,6 @@ void UBSelectionFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent */*event*/) } mOperationMode = om_idle; - -// foreach (UBGraphicsItemDelegate *curDelegate, mEnclosedtems) { -// qDebug() << "TransformBefore" << curDelegate->delegated()->transform(); -// } -// QGraphicsRectItem::mouseReleaseEvent(event); } void UBSelectionFrame::onZoomChanged(qreal pZoom) @@ -232,11 +218,7 @@ void UBSelectionFrame::onZoomChanged(qreal pZoom) qDebug() << "Board current zoom" << UBApplication::boardController->currentZoom(); qDebug() << "UBApplication::boardController->systemScaleFactor()" << UBApplication::boardController->systemScaleFactor(); mAntiscaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * pZoom); -// updateScale(); -// QTransform tr; -// tr.scale(mAntiscaleRatio, mAntiscaleRatio); -// this->setTransform(tr); } void UBSelectionFrame::remove() From 3d162dcc58448e324b1221cf39adea2950749320 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 16 Jul 2013 16:19:03 +0200 Subject: [PATCH 4/6] removed unused code --- src/domain/UBGraphicsScene.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 5491d1b3..e72d2b64 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -319,8 +319,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta mShouldUseOMP = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5; #endif -// setItemIndexMethod(QGraphicsScene::BspTreeIndex); - setUuid(QUuid::createUuid()); setDocument(parent); createEraiser(); @@ -1070,9 +1068,6 @@ void UBGraphicsScene::notifyZChanged(QGraphicsItem *item, qreal zValue) void UBGraphicsScene::updateSelectionFrame() { qDebug() << "selected item count" << selectedItems().count(); -// if (!mMultipleSelectionProcess) { -// return; -// } if (!mSelectionFrame) { mSelectionFrame = new UBSelectionFrame(); From 4e7f1bb646bfba4c91340f9b79109f457f76a2e3 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 16 Jul 2013 16:19:43 +0200 Subject: [PATCH 5/6] set the deleted items to NULL --- src/core/UBMimeData.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/UBMimeData.cpp b/src/core/UBMimeData.cpp index 42a835fc..c5c5dab5 100644 --- a/src/core/UBMimeData.cpp +++ b/src/core/UBMimeData.cpp @@ -61,6 +61,8 @@ UBMimeDataGraphicsItem::UBMimeDataGraphicsItem(QList pItems) UBMimeDataGraphicsItem::~UBMimeDataGraphicsItem() { - foreach(UBItem* item, mItems) - delete item; + foreach(UBItem* item, mItems){ + delete item; + item = 0; + } } From 3b0bb2f0914dbe82b03061bb58f3155eba33dd62 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 16 Jul 2013 17:01:52 +0200 Subject: [PATCH 6/6] copy/paste issue fixed. Issues: 4, 41, 53 --- src/board/UBBoardController.cpp | 13 +++++-------- src/board/UBBoardController.h | 4 ++-- src/core/UBMimeData.cpp | 5 +---- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 0d3da7e9..ac5e2398 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -543,7 +543,7 @@ void UBBoardController::duplicateScene() duplicateScene(mActiveSceneIndex); } -UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item, bool bAsync) +UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item) { if (!item) return NULL; @@ -602,11 +602,8 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item, bool bAsync) if (mitem) { sourceUrl = mitem->mediaFileUrl(); - if (bAsync) - { - downloadURL(sourceUrl, srcFile, itemPos, QSize(itemSize.width(), itemSize.height()), false, false); - return NULL; // async operation - } + downloadURL(sourceUrl, srcFile, itemPos, QSize(itemSize.width(), itemSize.height()), false, false); + return NULL; // async operation } }break; @@ -643,8 +640,8 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item, bool bAsync) mActiveScene->setURStackEnable(false); foreach(QGraphicsItem* pIt, children){ UBItem* pItem = dynamic_cast(pIt); - if(pItem){ // we diong sync duplication of all childs. - QGraphicsItem * itemToGroup = dynamic_cast(duplicateItem(pItem, false)); + if(pItem){ + QGraphicsItem * itemToGroup = dynamic_cast(duplicateItem(pItem)); if (itemToGroup) duplicatedItems.append(itemToGroup); } diff --git a/src/board/UBBoardController.h b/src/board/UBBoardController.h index ce4fb7d2..8ab9b27e 100644 --- a/src/board/UBBoardController.h +++ b/src/board/UBBoardController.h @@ -149,7 +149,7 @@ class UBBoardController : public UBDocumentContainer void setBoxing(QRect displayRect); void setToolbarTexts(); static QUrl expandWidgetToTempDir(const QByteArray& pZipedData, const QString& pExtension = QString("wgt")); - + void setPageSize(QSize newSize); UBBoardPaletteManager *paletteManager() { @@ -168,7 +168,7 @@ class UBBoardController : public UBDocumentContainer void moveSceneToIndex(int source, int target); void duplicateScene(int index); - UBGraphicsItem *duplicateItem(UBItem *item, bool bAsync = true); + UBGraphicsItem *duplicateItem(UBItem *item); void deleteScene(int index); bool cacheIsVisible() {return mCacheWidgetIsEnabled;} diff --git a/src/core/UBMimeData.cpp b/src/core/UBMimeData.cpp index c5c5dab5..b62ffa84 100644 --- a/src/core/UBMimeData.cpp +++ b/src/core/UBMimeData.cpp @@ -61,8 +61,5 @@ UBMimeDataGraphicsItem::UBMimeDataGraphicsItem(QList pItems) UBMimeDataGraphicsItem::~UBMimeDataGraphicsItem() { - foreach(UBItem* item, mItems){ - delete item; - item = 0; - } +// Explanation: selected items are owned by the scene and handled by this class }