From a748e8a2990d9f7e95c3ce9c6061cfdc084374ae Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Wed, 22 Aug 2012 12:34:07 +0300 Subject: [PATCH 1/3] SANKORE-852 Draw lines and move --- src/board/UBBoardView.cpp | 12 +++++++++++- src/board/UBBoardView.h | 2 ++ src/domain/UBGraphicsStrokesGroup.cpp | 25 +++++++++++++++++++++++++ src/domain/UBGraphicsStrokesGroup.h | 3 +++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 4786c9d0..26ea969d 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -596,7 +596,7 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event) mLastPressedMousePos = mapToScene(event->pos()); - if (movingItem && QGraphicsSvgItem::Type != movingItem->type() + if (movingItem && !hasSelectedParents(movingItem) && QGraphicsSvgItem::Type != movingItem->type() && UBGraphicsDelegateFrame::Type != movingItem->type() && !mMultipleSelectionIsEnabled) { @@ -1405,3 +1405,13 @@ UBBoardView::setToolCursor (int tool) controlViewport->setCursor (UBResources::resources ()->penCursor); } } + + +bool UBBoardView::hasSelectedParents(QGraphicsItem * item) +{ + if (item->isSelected()) + return true; + if (item->parentItem()==NULL) + return false; + return hasSelectedParents(item->parentItem()); +} diff --git a/src/board/UBBoardView.h b/src/board/UBBoardView.h index 34cf7fc7..98907b11 100644 --- a/src/board/UBBoardView.h +++ b/src/board/UBBoardView.h @@ -148,6 +148,8 @@ class UBBoardView : public QGraphicsView bool mIsDragInProgress; bool mMultipleSelectionIsEnabled; + static bool hasSelectedParents(QGraphicsItem * item); + private slots: void settingChanged(QVariant newValue); diff --git a/src/domain/UBGraphicsStrokesGroup.cpp b/src/domain/UBGraphicsStrokesGroup.cpp index 4f1be91f..2f98bed3 100644 --- a/src/domain/UBGraphicsStrokesGroup.cpp +++ b/src/domain/UBGraphicsStrokesGroup.cpp @@ -112,6 +112,31 @@ void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphics QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value) { + if (change == QGraphicsItem::ItemSelectedChange) + { + int a = 13; + } + QVariant newValue = mDelegate->itemChange(change, value); return QGraphicsItemGroup::itemChange(change, newValue); } + + +QPainterPath UBGraphicsStrokesGroup::shape () const +{ + QPainterPath path; + + if (isSelected()) + { + path.addRect(boundingRect()); + } + else + { + foreach(QGraphicsItem* item, childItems()) + { + path.addPath(item->shape()); + } + } + + return path; +} diff --git a/src/domain/UBGraphicsStrokesGroup.h b/src/domain/UBGraphicsStrokesGroup.h index 8339e1c2..b2310773 100644 --- a/src/domain/UBGraphicsStrokesGroup.h +++ b/src/domain/UBGraphicsStrokesGroup.h @@ -25,6 +25,9 @@ public: virtual void setUuid(const QUuid &pUuid); protected: + + virtual QPainterPath shape () const; + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); From 97c2f6f7cebc13a93206bfbe3a4810fe7dc7af49 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Wed, 22 Aug 2012 13:49:30 +0300 Subject: [PATCH 2/3] Removed debug code --- src/domain/UBGraphicsStrokesGroup.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/domain/UBGraphicsStrokesGroup.cpp b/src/domain/UBGraphicsStrokesGroup.cpp index 2f98bed3..a5320924 100644 --- a/src/domain/UBGraphicsStrokesGroup.cpp +++ b/src/domain/UBGraphicsStrokesGroup.cpp @@ -112,11 +112,6 @@ void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphics QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value) { - if (change == QGraphicsItem::ItemSelectedChange) - { - int a = 13; - } - QVariant newValue = mDelegate->itemChange(change, value); return QGraphicsItemGroup::itemChange(change, newValue); } From 474e71a031baabbfeee0109e8ca76420f96754f8 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 22 Aug 2012 15:24:56 +0200 Subject: [PATCH 3/3] fixed issue with licence. Is now stored as combo box index to avoid translations problems --- src/gui/UBTeacherGuideWidget.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 2bec3d15..5322919a 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -879,17 +879,21 @@ void UBTeacherGuidePageZeroWidget::fillComboBoxes() parametersFile.close(); QStringList licences; - licences << tr("Attribution CC BY") << tr("Attribution-NoDerivs CC BY-ND") + licences << tr("Attribution CC BY") + << tr("Attribution-NoDerivs CC BY-ND") << tr("Attribution-ShareAlike CC BY-SA") << tr("Attribution-NonCommercial CC BY-NC") << tr("Attribution-NonCommercial-NoDerivs CC BY-NC-ND") << tr("Attribution-NonCommercial-ShareAlike CC BY-NC-SA") - << tr("Public domain") << tr("Copyright"); + << tr("Public domain") + << tr("Copyright"); mpLicenceBox->addItems(licences); QStringList licenceIconList; licenceIconList << ":images/licenses/ccby.png" - << ":images/licenses/ccbynd.png" << ":images/licenses/ccbysa.png" - << ":images/licenses/ccbync.png" << ":images/licenses/ccbyncnd.png" + << ":images/licenses/ccbynd.png" + << ":images/licenses/ccbysa.png" + << ":images/licenses/ccbync.png" + << ":images/licenses/ccbyncnd.png" << ":images/licenses/ccbyncsa.png"; for (int i = 0; i < licenceIconList.count(); i += 1) mpLicenceBox->setItemData(i, licenceIconList.at(i)); @@ -945,7 +949,7 @@ void UBTeacherGuidePageZeroWidget::loadData() currentIndex = mpSchoolTypeBox->findText(documentProxy->metaData(UBSettings::sessionType).toString()); mpSchoolTypeBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0); - currentIndex = mpLicenceBox->findText(documentProxy->metaData(UBSettings::sessionLicence).toString()); + currentIndex = documentProxy->metaData(UBSettings::sessionLicence).toInt(); mpLicenceBox->setCurrentIndex((currentIndex != -1) ? currentIndex : 0); } @@ -962,7 +966,7 @@ void UBTeacherGuidePageZeroWidget::persistData() documentProxy->setMetaData(UBSettings::sessionGradeLevel, mpSchoolLevelBox->currentText()); documentProxy->setMetaData(UBSettings::sessionSubjects, mpSchoolSubjectsBox->currentText()); documentProxy->setMetaData(UBSettings::sessionType, mpSchoolTypeBox->currentText()); - documentProxy->setMetaData(UBSettings::sessionLicence, mpLicenceBox->currentText()); + documentProxy->setMetaData(UBSettings::sessionLicence, mpLicenceBox->currentIndex()); } } @@ -1087,7 +1091,7 @@ QVector UBTeacherGuidePageZeroWidget::getData() elementNode = new tUBGEElementNode(); elementNode->name = "licence"; - elementNode->attributes.insert("value", mpLicenceBox->currentText()); + elementNode->attributes.insert("value", QString("%1").arg(mpLicenceBox->currentIndex())); result << elementNode; return result; }