SANKORE-1069

Show Desktop: "Erase all" button isn't work
preferencesAboutTextFull
Anatoly Mihalchenko 12 years ago
parent 3a2dd1685a
commit 869164ca28
  1. 3
      src/adaptors/UBCFFSubsetAdaptor.cpp
  2. 19
      src/adaptors/UBSvgSubsetAdaptor.cpp
  3. 18
      src/board/UBDrawingController.cpp
  4. 10
      src/board/UBDrawingController.h
  5. 7
      src/core/UBApplicationController.cpp
  6. 4
      src/core/UBPersistenceManager.cpp
  7. 2
      src/core/UBPersistenceManager.h
  8. 4
      src/core/UBSceneCache.cpp
  9. 2
      src/core/UBSceneCache.h
  10. 6
      src/desktop/UBDesktopAnnotationController.cpp
  11. 37
      src/domain/UBGraphicsScene.cpp
  12. 8
      src/domain/UBGraphicsScene.h
  13. 19
      src/frameworks/UBCoreGraphicsScene.cpp

@ -1146,8 +1146,7 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::repositionSvgItem(QGraphicsItem *ite
bool UBCFFSubsetAdaptor::UBCFFSubsetReader::createNewScene()
{
mCurrentScene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(mProxy, mProxy->pageCount());
mCurrentScene->setURStackEnable(false);
mCurrentScene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(mProxy, mProxy->pageCount(), false);
mCurrentScene->setSceneRect(mViewBox);
if ((mCurrentScene->sceneRect().topLeft().x() >= 0) || (mCurrentScene->sceneRect().topLeft().y() >= 0)) {
mShiftVector = -mViewBox.center();

@ -380,7 +380,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
UBGraphicsStroke* annotationGroup = 0;
UBGraphicsStrokesGroup* strokesGroup = 0;
UBDrawingController* dc = UBDrawingController::drawingController();
while (!mXmlReader.atEnd())
{
@ -395,8 +394,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{
if (!mScene)
{
mScene = new UBGraphicsScene(mProxy);
mScene->setURStackEnable(false);
mScene = new UBGraphicsScene(mProxy, false);
}
// introduced in UB 4.2
@ -514,10 +512,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
else
annotationGroup = new UBGraphicsStroke();
if(eDrawingMode_Vector == dc->drawingMode()){
strokesGroup = new UBGraphicsStrokesGroup();
graphicsItemFromSvg(strokesGroup);
}
QStringRef ubZValue = mXmlReader.attributes().value(mNamespaceUri, "z-value");
@ -561,15 +558,12 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
polygonItem->setStroke(annotationGroup);
}
if(eDrawingMode_Vector == dc->drawingMode()){
if(strokesGroup){
polygonItem->setTransform(strokesGroup->transform());
strokesGroup->addToGroup(polygonItem);
polygonItem->setStrokesGroup(strokesGroup);
}
}else{
mScene->addItem(polygonItem);
}
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
@ -588,15 +582,12 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
polygonItem->setStroke(annotationGroup);
}
if(eDrawingMode_Vector == dc->drawingMode()){
if(strokesGroup){
polygonItem->setTransform(strokesGroup->transform());
strokesGroup->addToGroup(polygonItem);
polygonItem->setStrokesGroup(strokesGroup);
}
}else{
mScene->addItem(polygonItem);
}
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
polygonItem->show();
@ -1014,7 +1005,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
delete annotationGroup;
}
mScene->setURStackEnable(true);
mScene->enableUndoRedoStack();
return mScene;
}

@ -47,7 +47,6 @@ UBDrawingController::UBDrawingController(QObject * parent)
, mActiveRuler(NULL)
, mStylusTool((UBStylusTool::Enum)-1)
, mLatestDrawingTool((UBStylusTool::Enum)-1)
, mDrawingMode(DRAWING_MODE)
, mIsDesktopMode(false)
{
connect(UBSettings::settings(), SIGNAL(colorContextChanged()), this, SIGNAL(colorPaletteChanged()));
@ -110,16 +109,10 @@ void UBDrawingController::setStylusTool(int tool)
mStylusTool = (UBStylusTool::Enum)tool;
if(eDrawingMode_Vector == DRAWING_MODE && !mIsDesktopMode){
mDrawingMode = eDrawingMode_Vector;
}
if (mStylusTool == UBStylusTool::Pen)
UBApplication::mainWindow->actionPen->setChecked(true);
else if (mStylusTool == UBStylusTool::Eraser){
else if (mStylusTool == UBStylusTool::Eraser)
UBApplication::mainWindow->actionEraser->setChecked(true);
mDrawingMode = eDrawingMode_Artistic;
}
else if (mStylusTool == UBStylusTool::Marker)
UBApplication::mainWindow->actionMarker->setChecked(true);
else if (mStylusTool == UBStylusTool::Selector)
@ -407,12 +400,3 @@ void UBDrawingController::captureToolSelected(bool checked)
setStylusTool(UBStylusTool::Capture);
}
void UBDrawingController::setDrawingMode(eDrawingMode mode)
{
mDrawingMode = mode;
}
eDrawingMode UBDrawingController::drawingMode()
{
return mDrawingMode;
}

@ -22,13 +22,6 @@
class UBAbstractDrawRuler;
typedef enum{
eDrawingMode_Artistic,
eDrawingMode_Vector
}eDrawingMode;
#define DRAWING_MODE eDrawingMode_Vector
class UBDrawingController : public QObject
{
Q_OBJECT;
@ -56,8 +49,6 @@ class UBDrawingController : public QObject
void setPenColor(bool onDarkBackground, const QColor& color, int pIndex);
void setMarkerColor(bool onDarkBackground, const QColor& color, int pIndex);
void setMarkerAlpha(qreal alpha);
void setDrawingMode(eDrawingMode mode);
eDrawingMode drawingMode();
UBAbstractDrawRuler* mActiveRuler;
@ -86,7 +77,6 @@ class UBDrawingController : public QObject
private:
UBStylusTool::Enum mStylusTool;
UBStylusTool::Enum mLatestDrawingTool;
eDrawingMode mDrawingMode;
bool mIsDesktopMode;
static UBDrawingController* sDrawingController;

@ -464,7 +464,6 @@ void UBApplicationController::showDesktop(bool dontSwitchFrontProcess)
}
UBDrawingController::drawingController()->setInDestopMode(true);
UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Artistic);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
@ -598,12 +597,6 @@ void UBApplicationController::checkUpdateRequest()
void UBApplicationController::hideDesktop()
{
if(UBStylusTool::Eraser != UBDrawingController::drawingController()->stylusTool()){
UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Vector);
}
if (mMainMode == Board)
{
showBoard();

@ -493,7 +493,7 @@ void UBPersistenceManager::duplicateDocumentScene(UBDocumentProxy* proxy, int in
}
UBGraphicsScene* UBPersistenceManager::createDocumentSceneAt(UBDocumentProxy* proxy, int index)
UBGraphicsScene* UBPersistenceManager::createDocumentSceneAt(UBDocumentProxy* proxy, int index, bool useUndoRedoStack)
{
int count = sceneCount(proxy);
@ -502,7 +502,7 @@ UBGraphicsScene* UBPersistenceManager::createDocumentSceneAt(UBDocumentProxy* pr
mSceneCache.shiftUpScenes(proxy, index, count -1);
UBGraphicsScene *newScene = mSceneCache.createScene(proxy, index);
UBGraphicsScene *newScene = mSceneCache.createScene(proxy, index, useUndoRedoStack);
newScene->setBackground(UBSettings::settings()->isDarkBackground(),
UBSettings::settings()->UBSettings::isCrossedBackground());

@ -62,7 +62,7 @@ class UBPersistenceManager : public QObject
virtual void persistDocumentScene(UBDocumentProxy* pDocumentProxy,
UBGraphicsScene* pScene, const int pSceneIndex);
virtual UBGraphicsScene* createDocumentSceneAt(UBDocumentProxy* pDocumentProxy, int index);
virtual UBGraphicsScene* createDocumentSceneAt(UBDocumentProxy* pDocumentProxy, int index, bool useUndoRedoStack = true);
virtual void insertDocumentSceneAt(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* scene, int index);

@ -38,9 +38,9 @@ UBSceneCache::~UBSceneCache()
}
UBGraphicsScene* UBSceneCache::createScene(UBDocumentProxy* proxy, int pageIndex)
UBGraphicsScene* UBSceneCache::createScene(UBDocumentProxy* proxy, int pageIndex, bool useUndoRedoStack)
{
UBGraphicsScene* newScene = new UBGraphicsScene(proxy);
UBGraphicsScene* newScene = new UBGraphicsScene(proxy, useUndoRedoStack);
insert(proxy, pageIndex, newScene);
return newScene;

@ -64,7 +64,7 @@ class UBSceneCache : public QHash<UBSceneCacheID, UBGraphicsScene*>
UBSceneCache();
virtual ~UBSceneCache();
UBGraphicsScene* createScene(UBDocumentProxy* proxy, int pageIndex);
UBGraphicsScene* createScene(UBDocumentProxy* proxy, int pageIndex, bool useUndoRedoStack);
void insert (UBDocumentProxy* proxy, int pageIndex, UBGraphicsScene* scene );

@ -81,7 +81,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent, UB
QString backgroundStyle = "QWidget {background-color: rgba(127, 127, 127, 0)}";
mTransparentDrawingView->setStyleSheet(backgroundStyle);
mTransparentDrawingScene = new UBGraphicsScene(0);
mTransparentDrawingScene = new UBGraphicsScene(0, false);
mTransparentDrawingView->setScene(mTransparentDrawingScene);
mTransparentDrawingScene->setDrawingMode(true);
@ -372,10 +372,6 @@ void UBDesktopAnnotationController::goToUniboard()
UBPlatformUtils::setDesktopMode(false);
UBDrawingController::drawingController()->setInDestopMode(false);
if(UBStylusTool::Eraser != UBDrawingController::drawingController()->stylusTool()){
UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Vector);
}
emit restoreUniboard();
}

@ -254,7 +254,7 @@ void UBZLayerController::setLayerType(QGraphicsItem *pItem, itemLayerType::Enum
pItem->setData(UBGraphicsItemData::itemLayerType, QVariant(pNewType));
}
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoStack)
: UBCoreGraphicsScene(parent)
, mEraser(0)
, mPointer(0)
@ -271,7 +271,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
, mCurrentStroke(0)
, mShouldUseOMP(true)
, mItemCount(0)
, enableUndoRedoStack(true)
, mUndoRedoStackEnabled(enableUndoRedoStack)
, magniferControlViewWidget(0)
, magniferDisplayViewWidget(0)
, mZLayerController(new UBZLayerController(this))
@ -558,7 +558,7 @@ bool UBGraphicsScene::inputDeviceRelease()
if (dc->isDrawingTool() || mDrawWithCompass)
{
if(mArcPolygonItem){
if(eDrawingMode_Vector == dc->drawingMode()){
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
// Add the arc
@ -580,10 +580,9 @@ bool UBGraphicsScene::inputDeviceRelease()
mAddedItems << pStrokes;
addItem(pStrokes);
mDrawWithCompass = false;
}
}else if (mCurrentStroke)
{
if(eDrawingMode_Vector == UBDrawingController::drawingController()->drawingMode()){
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
// Remove the strokes that were just drawn here and replace them by a stroke item
@ -600,7 +599,6 @@ bool UBGraphicsScene::inputDeviceRelease()
mAddedItems.clear();
mAddedItems << pStrokes;
addItem(pStrokes);
}
if (mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
@ -612,7 +610,7 @@ bool UBGraphicsScene::inputDeviceRelease()
if (mRemovedItems.size() > 0 || mAddedItems.size() > 0)
{
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* udcmd = new UBGraphicsItemUndoCommand(this, mRemovedItems, mAddedItems); //deleted by the undoStack
if(UBApplication::undoStack)
@ -751,10 +749,7 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
if (!mCurrentStroke)
mCurrentStroke = new UBGraphicsStroke();
if (mCurrentStroke)
{
polygonItem->setStroke(mCurrentStroke);
}
mPreviousPolygonItems.append(polygonItem);
@ -1002,7 +997,7 @@ void UBGraphicsScene::leaveEvent(QEvent * event)
UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const
{
UBGraphicsScene* copy = new UBGraphicsScene(this->document());
UBGraphicsScene* copy = new UBGraphicsScene(this->document(), this->mUndoRedoStackEnabled);
copy->setBackground(this->isDarkBackground(), this->isCrossedBackground());
copy->setSceneRect(this->sceneRect());
@ -1138,7 +1133,7 @@ void UBGraphicsScene::clearContent(clearCase pCase)
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
update(sceneRect());
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, QSet<QGraphicsItem*>(), groupsMap);
UBApplication::undoStack->push(uc);
@ -1165,7 +1160,7 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, QGraphi
addItem(pixmapItem);
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, replaceFor, pixmapItem);
UBApplication::undoStack->push(uc);
}
@ -1192,7 +1187,7 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, QGraphi
void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem)
{
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsTextItemUndoCommand* uc = new UBGraphicsTextItemUndoCommand(textItem);
UBApplication::undoStack->push(uc);
}
@ -1213,7 +1208,7 @@ UBGraphicsMediaItem* UBGraphicsScene::addMedia(const QUrl& pMediaFileUrl, bool s
mediaItem->show();
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, mediaItem);
UBApplication::undoStack->push(uc);
}
@ -1296,7 +1291,7 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
// graphicsWidget->widgetWebView()->loadMainHtml();
graphicsWidget->setSelected(true);
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget);
UBApplication::undoStack->push(uc);
}
@ -1362,7 +1357,7 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *
groupItem->setVisible(true);
groupItem->setFocus();
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemGroupUndoCommand* uc = new UBGraphicsItemGroupUndoCommand(this, groupItem);
UBApplication::undoStack->push(uc);
}
@ -1391,7 +1386,7 @@ void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem)
groupItem->setUuid(QUuid::createUuid());
}
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, groupItem);
UBApplication::undoStack->push(uc);
}
@ -1421,7 +1416,7 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint
addItem(svgItem);
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, svgItem);
UBApplication::undoStack->push(uc);
}
@ -1511,7 +1506,7 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con
textItem->show();
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem);
UBApplication::undoStack->push(uc);
}
@ -1535,7 +1530,7 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q
addItem(textItem);
textItem->show();
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem);
UBApplication::undoStack->push(uc);
}

@ -109,10 +109,10 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
};
// tmp stub for divide addings scene objects from undo mechanism implementation
void setURStackEnable(bool set = true) {enableUndoRedoStack = set;}
bool isURStackIsEnabled(){ return enableUndoRedoStack;}
bool isURStackIsEnabled(){ return mUndoRedoStackEnabled;}
void enableUndoRedoStack(){mUndoRedoStackEnabled = true;}
UBGraphicsScene(UBDocumentProxy *parent);
UBGraphicsScene(UBDocumentProxy *parent, bool enableUndoRedoStack = true);
virtual ~UBGraphicsScene();
virtual UBItem* deepCopy() const;
@ -405,7 +405,7 @@ public slots:
bool mHasCache;
// tmp stub for divide addings scene objects from undo mechanism implementation
bool enableUndoRedoStack;
bool mUndoRedoStackEnabled;
UBMagnifier *magniferControlViewWidget;
UBMagnifier *magniferDisplayViewWidget;

@ -32,24 +32,18 @@ UBCoreGraphicsScene::~UBCoreGraphicsScene()
{
//we must delete removed items that are no more in any scene
//at groups deleting some items can be added to mItemsToDelete, so we need to use iterators.
if (mItemsToDelete.count())
foreach(QGraphicsItem* item, mItemsToDelete)
{
QSet<QGraphicsItem *>::iterator it = mItemsToDelete.begin();
QGraphicsItem* item = *it;
do
if (item)
{
item = *it;
if (item && (item->scene() == NULL || item->scene() == this))
if (item->scene() == NULL || item->scene() == this)
{
mItemsToDelete.remove(*it);
delete item;
}
it = mItemsToDelete.begin();
}while(mItemsToDelete.count());
}
}
mItemsToDelete.clear();
}
void UBCoreGraphicsScene::addItem(QGraphicsItem* item)
{
@ -84,12 +78,11 @@ bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item)
if(mItemsToDelete.contains(item))
{
UBGraphicsItem *item_casted = dynamic_cast<UBGraphicsItem *>(item);
if (0 != item_casted)
if (item_casted != NULL)
item_casted->clearSource();
mItemsToDelete.remove(item);
delete item;
item = 0;
return true;
}
else

Loading…
Cancel
Save