Merge branch 'develop' into shiba-dev

preferencesAboutTextFull
shibakaneki 12 years ago
commit 69fec641b2
  1. 2
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 4
      src/board/UBBoardController.cpp
  3. 14
      src/board/UBFeaturesController.cpp
  4. 3
      src/core/UBPersistenceManager.cpp
  5. 189
      src/domain/UBGraphicsDelegateFrame.cpp
  6. 3
      src/domain/UBGraphicsDelegateFrame.h
  7. 6
      src/domain/UBGraphicsGroupContainerItem.cpp
  8. 2
      src/domain/UBGraphicsGroupContainerItem.h
  9. 1
      src/domain/UBGraphicsItemDelegate.cpp
  10. 4
      src/domain/UBGraphicsItemGroupUndoCommand.cpp
  11. 62
      src/domain/UBGraphicsItemUndoCommand.cpp
  12. 6
      src/domain/UBGraphicsItemUndoCommand.h
  13. 18
      src/domain/UBGraphicsScene.cpp
  14. 2
      src/domain/UBGraphicsScene.h
  15. 2
      src/domain/UBGraphicsStrokesGroup.cpp
  16. 6
      src/domain/UBGraphicsTextItem.cpp
  17. 11
      src/domain/UBItem.cpp
  18. 4
      src/domain/UBItem.h
  19. 2
      src/gui/UBTeacherGuideWidget.cpp

@ -1084,7 +1084,7 @@ QGraphicsItem *UBSvgSubsetAdaptor::UBSvgSubsetReader::readElementFromGroup()
{ {
QGraphicsItem *result = 0; QGraphicsItem *result = 0;
result = mScene->itemByUuid(QUuid(mXmlReader.attributes().value(aId).toString())); result = mScene->itemForUuid(QUuid(mXmlReader.attributes().value(aId).toString()));
mXmlReader.skipCurrentElement(); mXmlReader.skipCurrentElement();
mXmlReader.readNext(); mXmlReader.readNext();

@ -1132,7 +1132,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
QString destFile; QString destFile;
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(), bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(),
"", sourceUrl.toString(),
UBPersistenceManager::videoDirectory, UBPersistenceManager::videoDirectory,
uuid, uuid,
destFile, destFile,
@ -1175,7 +1175,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
QString destFile; QString destFile;
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(), bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(),
"", sourceUrl.toString(),
UBPersistenceManager::audioDirectory, UBPersistenceManager::audioDirectory,
uuid, uuid,
destFile, destFile,

@ -144,7 +144,7 @@ void UBFeaturesComputingThread::compute(const QList<QPair<QUrl, UBFeature> > &pS
void UBFeaturesComputingThread::run() void UBFeaturesComputingThread::run()
{ {
forever { forever {
qDebug() << "Custom thread started execution"; // qDebug() << "Custom thread started execution";
mMutex.lock(); mMutex.lock();
QList<QPair<QUrl, UBFeature> > searchData = mScanningData; QList<QPair<QUrl, UBFeature> > searchData = mScanningData;
@ -158,17 +158,17 @@ void UBFeaturesComputingThread::run()
break; break;
} }
QTime curTime = QTime::currentTime(); // QTime curTime = QTime::currentTime();
int fsCnt = featuresCountAll(searchData); int fsCnt = featuresCountAll(searchData);
int msecsto = curTime.msecsTo(QTime::currentTime()); // int msecsto = curTime.msecsTo(QTime::currentTime());
qDebug() << "time on evaluation" << msecsto; // qDebug() << "time on evaluation" << msecsto;
emit maxFilesCountEvaluated(fsCnt); emit maxFilesCountEvaluated(fsCnt);
emit scanStarted(); emit scanStarted();
curTime = QTime::currentTime(); // curTime = QTime::currentTime();
scanAll(searchData, favoriteSet); scanAll(searchData, favoriteSet);
qDebug() << "Time on finishing" << curTime.msecsTo(QTime::currentTime()); // qDebug() << "Time on finishing" << curTime.msecsTo(QTime::currentTime());
emit scanFinished(); emit scanFinished();
mMutex.lock(); mMutex.lock();
@ -183,7 +183,7 @@ void UBFeaturesComputingThread::run()
UBFeaturesComputingThread::~UBFeaturesComputingThread() UBFeaturesComputingThread::~UBFeaturesComputingThread()
{ {
qDebug() << "thread destructor catched"; // qDebug() << "thread destructor catched";
mMutex.lock(); mMutex.lock();
abort = true; abort = true;

@ -913,6 +913,7 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy,
QString& destinationPath, QString& destinationPath,
QByteArray* data) QByteArray* data)
{ {
Q_ASSERT(path.length());
QFileInfo fi(path); QFileInfo fi(path);
if (!pDocumentProxy || objectUuid.isNull()) if (!pDocumentProxy || objectUuid.isNull())
@ -920,6 +921,8 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy,
if (data == NULL && !fi.exists()) if (data == NULL && !fi.exists())
return false; return false;
qDebug() << fi.suffix();
QString fileName = subdir + "/" + objectUuid.toString() + "." + fi.suffix(); QString fileName = subdir + "/" + objectUuid.toString() + "." + fi.suffix();
destinationPath = pDocumentProxy->persistencePath() + "/" + fileName; destinationPath = pDocumentProxy->persistencePath() + "/" + fileName;

@ -286,18 +286,111 @@ bool UBGraphicsDelegateFrame::canResizeBottomRight(qreal width, qreal height, qr
return res; return res;
} }
QPointF UBGraphicsDelegateFrame::getFixedPointFromPos()
{
QPointF fixedPoint;
if (!moving() && !rotating())
{
if (resizingTop())
{
if (mMirrorX && mMirrorY)
{
if ((0 < mAngle) && (mAngle < 90))
fixedPoint = delegated()->sceneBoundingRect().topLeft();
else
fixedPoint = delegated()->sceneBoundingRect().topRight();
}
else
{
if ((0 < mAngle) && (mAngle <= 90))
fixedPoint = delegated()->sceneBoundingRect().bottomRight();
else
fixedPoint = delegated()->sceneBoundingRect().bottomLeft();
}
}
else if (resizingLeft())
{
if (mMirrorX && mMirrorY)
{
if ((0 < mAngle) && (mAngle < 90))
fixedPoint = delegated()->sceneBoundingRect().bottomLeft();
else
fixedPoint = delegated()->sceneBoundingRect().topLeft();
}
else
{
if ((0 < mAngle) && (mAngle <= 90))
fixedPoint = delegated()->sceneBoundingRect().topRight();
else
fixedPoint = delegated()->sceneBoundingRect().bottomRight();
}
}
}
return fixedPoint;
}
QSizeF UBGraphicsDelegateFrame::getResizeVector(qreal moveX, qreal moveY)
{
qreal dPosX = 0;
qreal dPosY = 0;
if (resizingTop())
{
if (mMirrorX && mMirrorY)
dPosY = moveY;
else
dPosY = -moveY;
}
else if (resizingLeft())
{
if (mMirrorX && mMirrorY)
dPosX = moveX;
else
dPosX = -moveX;
}
else if (resizingRight())
dPosX = (mMirrorX) ? -moveX : moveX;
else if (resizingBottom())
dPosY = mMirrorY ? -moveY : moveY;
return QSizeF(dPosX, dPosY);
}
void UBGraphicsDelegateFrame::resizeDelegate(qreal moveX, qreal moveY)
{
QPointF fixedPoint = getFixedPointFromPos();
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(delegated());
if (resizableItem)
{
QSizeF originalSize = delegated()->boundingRect().size();
resizableItem->resize(originalSize + getResizeVector(moveX, moveY));
if (resizingTop() || resizingLeft() || ((mMirrorX || mMirrorY) && resizingBottomRight()))
{
delegated()->setPos(delegated()->pos()-getFixedPointFromPos()+fixedPoint);
}
}
}
void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (None == mCurrentTool) if (None == mCurrentTool)
return; return;
QLineF move(mStartingPoint, event->scenePos()); QLineF move;
if(rotating() || moving() || mOperationMode == Scaling)
move = QLineF(mStartingPoint, event->scenePos());
else
move = QLineF(event->lastScenePos(), event->scenePos());
qreal moveX = move.length() * cos((move.angle() - mAngle) * PI / 180); qreal moveX = move.length() * cos((move.angle() - mAngle) * PI / 180);
qreal moveY = -move.length() * sin((move.angle() - mAngle) * PI / 180); qreal moveY = -move.length() * sin((move.angle() - mAngle) * PI / 180);
qreal width = delegated()->boundingRect().width() * mTotalScaleX; qreal width = delegated()->boundingRect().width() * mTotalScaleX;
qreal height = delegated()->boundingRect().height() * mTotalScaleY; qreal height = delegated()->boundingRect().height() * mTotalScaleY;
if(mOperationMode == Scaling) if(!rotating())
{ {
mTranslateX = moveX; mTranslateX = moveX;
// Perform the resize // Perform the resize
@ -398,43 +491,6 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
} }
} }
} }
else if (mOperationMode == Resizing || mOperationMode == ResizingHorizontally)
{
mTranslateX = moveX;
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(delegated());
if (resizableItem)
{
QLineF mousePosDelta(delegated()->mapFromScene(event->lastScenePos())
, delegated()->mapFromScene(event->scenePos()));
QSizeF incVector(0, 0);
if (resizingBottomRight())
{
incVector = QSizeF(mousePosDelta.dx(), mousePosDelta.dy());
}
else if (resizingRight())
{
incVector = QSizeF(mousePosDelta.dx(), 0);
}
else if (resizingBottom())
{
incVector = QSizeF(0, mousePosDelta.dy());
}
else if (resizingLeft())
{
incVector = QSizeF(- mousePosDelta.dx(), 0);
}
else if (resizingTop())
{
incVector = QSizeF(0, - mousePosDelta.dy());
}
QSizeF newSize = resizableItem->size() + incVector;
resizableItem->resize(newSize);
}
}
if (rotating()) if (rotating())
{ {
@ -483,49 +539,56 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
// we just detects coordinates of corner before and after scaling and then moves object at diff between them. // we just detects coordinates of corner before and after scaling and then moves object at diff between them.
if (resizingBottomRight() && mMirrorX) if (resizingBottomRight() && mMirrorX)
{
mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomRight()).x() - tr.map(delegated()->boundingRect().bottomRight()).x(); mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomRight()).x() - tr.map(delegated()->boundingRect().bottomRight()).x();
else
mTranslateX += mInitialTransform.map(delegated()->boundingRect().topLeft()).x() - tr.map(delegated()->boundingRect().topLeft()).x();
if (resizingBottomRight() && mMirrorY)
mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomRight()).y() - tr.map(delegated()->boundingRect().bottomRight()).y(); mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomRight()).y() - tr.map(delegated()->boundingRect().bottomRight()).y();
}
else else
{
mTranslateX += mInitialTransform.map(delegated()->boundingRect().topLeft()).x() - tr.map(delegated()->boundingRect().topLeft()).x();
mTranslateY += mInitialTransform.map(delegated()->boundingRect().topLeft()).y() - tr.map(delegated()->boundingRect().topLeft()).y(); mTranslateY += mInitialTransform.map(delegated()->boundingRect().topLeft()).y() - tr.map(delegated()->boundingRect().topLeft()).y();
}
// Update the transform
tr = buildTransform();
} }
else if (resizingTop() || resizingLeft()) else if (resizingTop() || resizingLeft())
{
if (mOperationMode == Scaling)
{ {
QPointF bottomRight = tr.map(delegated()->boundingRect().bottomRight()); QPointF bottomRight = tr.map(delegated()->boundingRect().bottomRight());
QPointF fixedPoint = mInitialTransform.map(delegated()->boundingRect().bottomRight()); QPointF fixedPoint = mInitialTransform.map(delegated()->boundingRect().bottomRight());
mTranslateX += fixedPoint.x() - bottomRight.x(); mTranslateX += fixedPoint.x() - bottomRight.x();
mTranslateY += fixedPoint.y() - bottomRight.y(); mTranslateY += fixedPoint.y() - bottomRight.y();
} }
else
{
QLineF vector; if (mOperationMode == Scaling || moving() || rotating())
if (resizingLeft())
{ {
QPointF topRight1 = mInitialTransform.map(QPointF(delegated()->boundingRect().width() - moveX, 0)); tr = buildTransform();
QPointF topRight2 = mInitialTransform.map(QPointF(delegated()->boundingRect().width(), 0)); delegated()->setTransform(tr);
vector.setPoints(topRight1, topRight2);
} }
else else if (mOperationMode == Resizing)
{ {
QPointF bottomLeft1 = mInitialTransform.map(QPointF(0, delegated()->boundingRect().height() - moveY)); if (!moving() && !rotating())
QPointF bottomLeft2 = mInitialTransform.map(QPointF(0, delegated()->boundingRect().height())); {
vector.setPoints(bottomLeft1, bottomLeft2); if (resizingBottomRight())
{
if (mMirrorX && mMirrorY)
mCurrentTool = ResizeTop;
else
mCurrentTool = ResizeBottom;
resizeDelegate(moveX, moveY);
if (mMirrorX && mMirrorY)
mCurrentTool = ResizeLeft;
else
mCurrentTool = ResizeRight;
resizeDelegate(moveX, moveY);
mCurrentTool = ResizeBottomRight;
} }
mTranslateX = vector.dx(); else
mTranslateY = vector.dy(); resizeDelegate(moveX, moveY);
} }
tr = buildTransform();
} }
delegated()->setTransform(tr);
event->accept(); event->accept();
} }

@ -37,6 +37,9 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
QPainterPath shape() const; QPainterPath shape() const;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
QPointF getFixedPointFromPos();
QSizeF getResizeVector(qreal moveX, qreal moveY);
void resizeDelegate(qreal moveX, qreal moveY);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

@ -123,6 +123,8 @@ void UBGraphicsGroupContainerItem::removeFromGroup(QGraphicsItem *item)
pRemoveFromGroup(item); pRemoveFromGroup(item);
item->setFlags(ItemIsSelectable | ItemIsFocusable);
} }
void UBGraphicsGroupContainerItem::deselectCurrentItem() void UBGraphicsGroupContainerItem::deselectCurrentItem()
@ -211,7 +213,7 @@ void UBGraphicsGroupContainerItem::setUuid(const QUuid &pUuid)
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene
} }
void UBGraphicsGroupContainerItem::destroy() { void UBGraphicsGroupContainerItem::destroy(bool canUndo) {
foreach (QGraphicsItem *item, childItems()) { foreach (QGraphicsItem *item, childItems()) {
pRemoveFromGroup(item); pRemoveFromGroup(item);
@ -219,7 +221,7 @@ void UBGraphicsGroupContainerItem::destroy() {
item->setFlag(QGraphicsItem::ItemIsFocusable, true); item->setFlag(QGraphicsItem::ItemIsFocusable, true);
} }
remove(); remove(canUndo);
} }
void UBGraphicsGroupContainerItem::clearSource() void UBGraphicsGroupContainerItem::clearSource()

@ -34,7 +34,7 @@ public:
} }
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
void destroy(); void destroy(bool canUndo = true);
virtual void clearSource(); virtual void clearSource();

@ -166,6 +166,7 @@ void UBGraphicsItemDelegate::init()
UBGraphicsItemDelegate::~UBGraphicsItemDelegate() UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
{ {
if (UBApplication::boardController)
disconnect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged())); disconnect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged()));
// do not release mMimeData. // do not release mMimeData.
// the mMimeData is owned by QDrag since the setMimeData call as specified in the documentation // the mMimeData is owned by QDrag since the setMimeData call as specified in the documentation

@ -22,7 +22,7 @@ UBGraphicsItemGroupUndoCommand::~UBGraphicsItemGroupUndoCommand()
void UBGraphicsItemGroupUndoCommand::undo() void UBGraphicsItemGroupUndoCommand::undo()
{ {
mGroup->destroy(); mGroup->destroy(false);
foreach(QGraphicsItem *item, mItems) { foreach(QGraphicsItem *item, mItems) {
item->setSelected(true); item->setSelected(true);
} }
@ -41,7 +41,7 @@ void UBGraphicsItemGroupUndoCommand::redo()
QList<QGraphicsItem*> childItems = item->childItems(); QList<QGraphicsItem*> childItems = item->childItems();
UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(item); UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
if (currentGroup) { if (currentGroup) {
currentGroup->destroy(); currentGroup->destroy(false);
} }
foreach (QGraphicsItem *chItem, childItems) { foreach (QGraphicsItem *chItem, childItems) {
mGroup->addToGroup(chItem); mGroup->addToGroup(chItem);

@ -27,10 +27,11 @@
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems,
const QSet<QGraphicsItem*>& pAddedItems) const QSet<QGraphicsItem*>& pAddedItems, const GroupDataTable &groupsMap)
: mScene(pScene) : mScene(pScene)
, mRemovedItems(pRemovedItems - pAddedItems) , mRemovedItems(pRemovedItems - pAddedItems)
, mAddedItems(pAddedItems - pRemovedItems) , mAddedItems(pAddedItems - pRemovedItems)
, mExcludedFromGroup(groupsMap)
{ {
mFirstRedo = true; mFirstRedo = true;
@ -110,6 +111,36 @@ void UBGraphicsItemUndoCommand::undo()
} }
} }
QMapIterator<UBGraphicsGroupContainerItem*, QUuid> curMapElement(mExcludedFromGroup);
UBGraphicsGroupContainerItem *nextGroup = 0;
UBGraphicsGroupContainerItem *previousGroupItem;
bool groupChanged = false;
while (curMapElement.hasNext()) {
curMapElement.next();
groupChanged = previousGroupItem != curMapElement.key();
//trying to find the group on the scene;
if (!nextGroup || groupChanged) {
UBGraphicsGroupContainerItem *groupCandidate = curMapElement.key();
if (groupCandidate) {
nextGroup = groupCandidate;
if(!mScene->items().contains(nextGroup)) {
mScene->addItem(nextGroup);
}
nextGroup->setVisible(true);
}
}
QGraphicsItem *groupedItem = mScene->itemForUuid(curMapElement.value());
if (groupedItem) {
nextGroup->addToGroup(groupedItem);
}
previousGroupItem = curMapElement.key();
UBGraphicsItem::Delegate(nextGroup)->update();
}
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint // force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
mScene->update(mScene->sceneRect()); mScene->update(mScene->sceneRect());
@ -125,6 +156,35 @@ void UBGraphicsItemUndoCommand::redo()
return; return;
} }
QMapIterator<UBGraphicsGroupContainerItem*, QUuid> curMapElement(mExcludedFromGroup);
UBGraphicsGroupContainerItem *nextGroup = 0;
UBGraphicsGroupContainerItem *previousGroupItem;
bool groupChanged = false;
while (curMapElement.hasNext()) {
curMapElement.next();
groupChanged = previousGroupItem != curMapElement.key();
//trying to find the group on the scene;
if (!nextGroup || groupChanged) {
UBGraphicsGroupContainerItem *groupCandidate = curMapElement.key();
if (groupCandidate) {
nextGroup = groupCandidate;
}
}
QGraphicsItem *groupedItem = mScene->itemForUuid(curMapElement.value());
if (groupedItem) {
if (nextGroup->childItems().count() == 1) {
nextGroup->destroy(false);
break;
}
nextGroup->removeFromGroup(groupedItem);
}
previousGroupItem = curMapElement.key();
UBGraphicsItem::Delegate(nextGroup)->update();
}
QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems); QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems);
while (itRemoved.hasNext()) while (itRemoved.hasNext())
{ {

@ -18,6 +18,7 @@
#include <QtGui> #include <QtGui>
#include "UBAbstractUndoCommand.h" #include "UBAbstractUndoCommand.h"
#include "UBGraphicsGroupContainerItem.h"
class UBGraphicsScene; class UBGraphicsScene;
@ -26,8 +27,10 @@ class UBGraphicsScene;
class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand
{ {
public: public:
typedef QMultiMap<UBGraphicsGroupContainerItem*, QUuid> GroupDataTable;
UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems,
const QSet<QGraphicsItem*>& pAddedItems); const QSet<QGraphicsItem*>& pAddedItems, const GroupDataTable &groupsMap = GroupDataTable());
UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem, UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem,
QGraphicsItem* pAddedItem); QGraphicsItem* pAddedItem);
@ -47,6 +50,7 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand
UBGraphicsScene* mScene; UBGraphicsScene* mScene;
QSet<QGraphicsItem*> mRemovedItems; QSet<QGraphicsItem*> mRemovedItems;
QSet<QGraphicsItem*> mAddedItems; QSet<QGraphicsItem*> mAddedItems;
GroupDataTable mExcludedFromGroup;
bool mFirstRedo; bool mFirstRedo;
}; };

@ -1067,6 +1067,7 @@ UBItem* UBGraphicsScene::deepCopy() const
void UBGraphicsScene::clearContent(clearCase pCase) void UBGraphicsScene::clearContent(clearCase pCase)
{ {
QSet<QGraphicsItem*> removedItems; QSet<QGraphicsItem*> removedItems;
UBGraphicsItemUndoCommand::GroupDataTable groupsMap;
switch (pCase) { switch (pCase) {
case clearBackground : case clearBackground :
@ -1106,8 +1107,14 @@ void UBGraphicsScene::clearContent(clearCase pCase)
if(shouldDelete) { if(shouldDelete) {
if (itemGroup) { if (itemGroup) {
itemGroup->removeFromGroup(item); itemGroup->removeFromGroup(item);
groupsMap.insert(itemGroup, UBGraphicsItem::getOwnUuid(item));
if (itemGroup->childItems().count() == 1) { if (itemGroup->childItems().count() == 1) {
itemGroup->destroy(); groupsMap.insert(itemGroup, UBGraphicsItem::getOwnUuid(itemGroup->childItems().first()));
QGraphicsItem *lastItem = itemGroup->childItems().first();
bool isSelected = itemGroup->isSelected();
itemGroup->destroy(false);
lastItem->setSelected(isSelected);
} }
itemGroup->Delegate()->update(); itemGroup->Delegate()->update();
} }
@ -1123,7 +1130,8 @@ void UBGraphicsScene::clearContent(clearCase pCase)
update(sceneRect()); update(sceneRect());
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, QSet<QGraphicsItem*>());
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, QSet<QGraphicsItem*>(), groupsMap);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
@ -1442,6 +1450,7 @@ UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, c
textItem->setObjectName(objectName); textItem->setObjectName(objectName);
QSizeF size = textItem->size(); QSizeF size = textItem->size();
textItem->setPos(QPointF(-size.width()/2.0,-size.height()/2.0)); textItem->setPos(QPointF(-size.width()/2.0,-size.height()/2.0));
textItem->setData(UBGraphicsItemData::ItemEditable,QVariant(false));
} }
textItem->setPlainText(pString); textItem->setPlainText(pString);
@ -1571,8 +1580,9 @@ void UBGraphicsScene::removeItem(QGraphicsItem* item)
void UBGraphicsScene::removeItems(const QSet<QGraphicsItem*>& items) void UBGraphicsScene::removeItems(const QSet<QGraphicsItem*>& items)
{ {
foreach(QGraphicsItem* item, items) foreach(QGraphicsItem* item, items) {
UBCoreGraphicsScene::removeItem(item); UBCoreGraphicsScene::removeItem(item);
}
mItemCount -= items.size(); mItemCount -= items.size();
@ -1665,7 +1675,7 @@ QRectF UBGraphicsScene::normalizedSceneRect(qreal ratio)
return normalizedRect; return normalizedRect;
} }
QGraphicsItem *UBGraphicsScene::itemByUuid(QUuid uuid) QGraphicsItem *UBGraphicsScene::itemForUuid(QUuid uuid)
{ {
QGraphicsItem *result = 0; QGraphicsItem *result = 0;

@ -174,7 +174,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
QRectF normalizedSceneRect(qreal ratio = -1.0); QRectF normalizedSceneRect(qreal ratio = -1.0);
QGraphicsItem *itemByUuid(QUuid uuid); QGraphicsItem *itemForUuid(QUuid uuid);
void moveTo(const QPointF& pPoint); void moveTo(const QPointF& pPoint);
void drawLineTo(const QPointF& pEndPoint, const qreal& pWidth, bool bLineStyle); void drawLineTo(const QPointF& pEndPoint, const qreal& pWidth, bool bLineStyle);

@ -5,7 +5,7 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent) UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent)
:UBGraphicsItem(), QGraphicsItemGroup(parent) :QGraphicsItemGroup(parent), UBGraphicsItem()
{ {
setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false)); setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false));
Delegate()->init(); Delegate()->init();

@ -30,9 +30,9 @@
QColor UBGraphicsTextItem::lastUsedTextColor; QColor UBGraphicsTextItem::lastUsedTextColor;
UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) :
: UBGraphicsItem() QGraphicsTextItem(parent)
, QGraphicsTextItem(parent) , UBGraphicsItem()
, mMultiClickState(0) , mMultiClickState(0)
, mLastMousePressTime(QTime::currentTime()) , mLastMousePressTime(QTime::currentTime())
{ {

@ -66,12 +66,17 @@ bool UBGraphicsItem::isRotatable(QGraphicsItem *item)
return item->data(UBGraphicsItemData::ItemRotatable).toBool(); return item->data(UBGraphicsItemData::ItemRotatable).toBool();
} }
void UBGraphicsItem::remove() QUuid UBGraphicsItem::getOwnUuid(QGraphicsItem *item)
{ {
if (Delegate()) QString idCandidate = item->data(UBGraphicsItemData::ItemUuid).toString();
Delegate()->remove(this); return idCandidate == QUuid().toString() ? QUuid() : QUuid(idCandidate);
} }
void UBGraphicsItem::remove(bool canUndo)
{
if (Delegate())
Delegate()->remove(canUndo);
}
UBGraphicsItemDelegate *UBGraphicsItem::Delegate(QGraphicsItem *pItem) UBGraphicsItemDelegate *UBGraphicsItem::Delegate(QGraphicsItem *pItem)
{ {

@ -104,11 +104,11 @@ public:
static void assignZValue(QGraphicsItem*, qreal value); static void assignZValue(QGraphicsItem*, qreal value);
static bool isRotatable(QGraphicsItem *item); static bool isRotatable(QGraphicsItem *item);
static bool isFlippable(QGraphicsItem *item); static bool isFlippable(QGraphicsItem *item);
static QUuid getOwnUuid(QGraphicsItem *item);
static UBGraphicsItemDelegate *Delegate(QGraphicsItem *pItem); static UBGraphicsItemDelegate *Delegate(QGraphicsItem *pItem);
void remove(bool canUndo = true);
void remove();
virtual void clearSource(){} virtual void clearSource(){}

@ -163,6 +163,7 @@ UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget()
void UBTeacherGuideEditionWidget::onSliderMoved(int size) void UBTeacherGuideEditionWidget::onSliderMoved(int size)
{ {
Q_UNUSED(size); Q_UNUSED(size);
if(mpAddAMediaItem)
mpAddAMediaItem->setExpanded(true); mpAddAMediaItem->setExpanded(true);
} }
#endif #endif
@ -491,6 +492,7 @@ UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget()
void UBTeacherGuidePresentationWidget::onSliderMoved(int size) void UBTeacherGuidePresentationWidget::onSliderMoved(int size)
{ {
Q_UNUSED(size); Q_UNUSED(size);
if(mpMediaSwitchItem)
mpMediaSwitchItem->setExpanded(true); mpMediaSwitchItem->setExpanded(true);
} }
#endif #endif

Loading…
Cancel
Save