Fixed deletion removed groups.

Code was cleaned.
Corrections in removing strokes.
preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent 4b7939b6c3
commit 8b19847c11
  1. 2
      src/board/UBBoardController.cpp
  2. 4
      src/domain/UBGraphicsGroupContainerItem.cpp
  3. 4
      src/domain/UBGraphicsPolygonItem.cpp
  4. 17
      src/domain/UBGraphicsScene.cpp

@ -1495,7 +1495,7 @@ void UBBoardController::ClearUndoStack()
while (itRemoved.hasNext()) while (itRemoved.hasNext())
{ {
QGraphicsItem* item = itRemoved.next(); QGraphicsItem* item = itRemoved.next();
if( !uniqueItems.contains(item) && (item->parentItem() && UBGraphicsGroupContainerItem::Type != item->parentItem()->type())) if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()))
uniqueItems.insert(item); uniqueItems.insert(item);
} }
} }

@ -219,10 +219,6 @@ void UBGraphicsGroupContainerItem::destroy() {
UBCoreGraphicsScene *groupScene = corescene(); UBCoreGraphicsScene *groupScene = corescene();
if (groupScene) {
// groupScene->addItemToDeletion(this);
}
foreach (QGraphicsItem *item, childItems()) { foreach (QGraphicsItem *item, childItems()) {
pRemoveFromGroup(item); pRemoveFromGroup(item);
item->setFlag(QGraphicsItem::ItemIsSelectable, true); item->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -67,8 +67,8 @@ void UBGraphicsPolygonItem::clearStroke()
if (mStroke!=NULL) if (mStroke!=NULL)
{ {
mStroke->remove(this); mStroke->remove(this);
//if (mStroke->polygons().empty()) if (mStroke->polygons().empty())
// delete mStroke; delete mStroke;
mStroke = NULL; mStroke = NULL;
} }
} }

@ -305,7 +305,10 @@ UBGraphicsScene::~UBGraphicsScene()
{ {
if (mCurrentStroke) if (mCurrentStroke)
if (mCurrentStroke->polygons().empty()) if (mCurrentStroke->polygons().empty())
{
delete mCurrentStroke; delete mCurrentStroke;
mCurrentStroke = NULL;
}
if (mZLayerController) if (mZLayerController)
delete mZLayerController; delete mZLayerController;
@ -433,6 +436,11 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
} }
} }
if (mCurrentStroke && mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
mCurrentStroke = NULL;
}
return accepted; return accepted;
} }
@ -474,6 +482,10 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
UBCoreGraphicsScene::removeItemFromDeletion(mpLastPolygon); UBCoreGraphicsScene::removeItemFromDeletion(mpLastPolygon);
mAddedItems.remove(mpLastPolygon); mAddedItems.remove(mpLastPolygon);
mCurrentStroke->remove(mpLastPolygon); mCurrentStroke->remove(mpLastPolygon);
if (mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
mCurrentStroke = NULL;
}
removeItem(mpLastPolygon); removeItem(mpLastPolygon);
mPreviousPolygonItems.removeAll(mpLastPolygon); mPreviousPolygonItems.removeAll(mpLastPolygon);
} }
@ -2285,6 +2297,11 @@ void UBGraphicsScene::setToolCursor(int tool)
{ {
deselectAllItems(); deselectAllItems();
} }
if (mCurrentStroke && mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
}
mCurrentStroke = NULL;
} }
void UBGraphicsScene::initStroke(){ void UBGraphicsScene::initStroke(){

Loading…
Cancel
Save