Merge remote-tracking branch 'remotes/origin/anatoly_dev' into develop

preferencesAboutTextFull
Anatoly Mihalchenko 12 years ago
commit 0d1e848f4f
  1. 152
      src/document/UBDocumentController.cpp
  2. 3
      src/document/UBDocumentController.h
  3. 25
      src/domain/UBGraphicsScene.cpp
  4. 12
      src/domain/UBGraphicsScene.h
  5. 4
      src/frameworks/UBCoreGraphicsScene.cpp
  6. 13
      src/frameworks/UBCoreGraphicsScene.h

@ -117,8 +117,11 @@ UBDocumentProxyTreeItem* UBDocumentController::findDocument(UBDocumentProxy* pro
void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument) void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument)
{ {
if (!proxy) if (proxy==NULL)
{
setDocument(NULL);
return; return;
}
QTreeWidgetItemIterator it(mDocumentUI->documentTreeWidget); QTreeWidgetItemIterator it(mDocumentUI->documentTreeWidget);
@ -531,31 +534,8 @@ void UBDocumentController::duplicateSelectedItem()
} }
} }
void UBDocumentController::moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, UBDocumentProxyTreeItem *proxyTi)
void UBDocumentController::deleteSelectedItem()
{
if (mSelectionType == Page)
{
QList<QGraphicsItem*> selectedItems = mDocumentUI->thumbnailWidget->selectedItems();
deletePages(selectedItems);
}
else
{
UBDocumentProxyTreeItem *proxyTi = selectedDocumentProxyTreeItem();
UBDocumentGroupTreeItem* groupTi = selectedDocumentGroupTreeItem();
if (proxyTi && proxyTi->proxy() && proxyTi->parent())
{ {
if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Document"), tr("Are you sure you want to remove the document '%1'?").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString())))
{
if (proxyTi->parent() != mTrashTi)
{
// We have to move document into Trash
// Select another document for processing
// This is for Board, where this document can be selected
int index = proxyTi->parent()->indexOfChild(proxyTi); int index = proxyTi->parent()->indexOfChild(proxyTi);
index --; index --;
@ -619,54 +599,9 @@ void UBDocumentController::deleteSelectedItem()
mTrashTi->addChild(proxyTi); mTrashTi->addChild(proxyTi);
proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable); proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable);
} }
else
{
// We have to physical delete document
// No action with selection required - document from Trash cant be selected in Board
proxyTi->parent()->removeChild(proxyTi);
UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy());
}
}
}
else if (groupTi)
{
if (groupTi == mTrashTi)
{
if(UBApplication::mainWindow->yesNoQuestion(tr("Empty Trash"), tr("Are you sure you want to empty trash?")))
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QList<UBDocumentProxyTreeItem*> toBeDeleted;
for (int i = 0; i < groupTi->childCount(); i++)
{
UBDocumentProxyTreeItem* proxyTi = dynamic_cast<UBDocumentProxyTreeItem*>(groupTi->child(i));
if (proxyTi && proxyTi->proxy())
toBeDeleted << proxyTi;
}
showMessage(tr("Emptying trash"));
for (int i = 0; i < toBeDeleted.count(); i++)
{
UBDocumentProxyTreeItem* proxyTi = toBeDeleted.at(i);
proxyTi->parent()->removeChild(proxyTi);
UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy());
}
showMessage(tr("Emptied trash")); void UBDocumentController::moveFolderToTrash(UBDocumentGroupTreeItem* groupTi)
QApplication::restoreOverrideCursor();
mMainWindow->actionDelete->setEnabled(false);
}
}
else
{
if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Folder"), tr("Are you sure you want to remove the folder '%1' and all its content?").arg(groupTi->groupName())))
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
bool changeCurrentDocument = false; bool changeCurrentDocument = false;
for (int i = 0; i < groupTi->childCount(); i++) for (int i = 0; i < groupTi->childCount(); i++)
{ {
@ -744,9 +679,84 @@ void UBDocumentController::deleteSelectedItem()
} }
} }
reloadThumbnails();
}
void UBDocumentController::deleteSelectedItem()
{
if (mSelectionType == Page)
{
QList<QGraphicsItem*> selectedItems = mDocumentUI->thumbnailWidget->selectedItems();
deletePages(selectedItems);
}
else
{
UBDocumentProxyTreeItem *proxyTi = selectedDocumentProxyTreeItem();
UBDocumentGroupTreeItem* groupTi = selectedDocumentGroupTreeItem();
if (proxyTi && proxyTi->proxy() && proxyTi->parent())
{
if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Document"), tr("Are you sure you want to remove the document '%1'?").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString())))
{
if (proxyTi->parent() != mTrashTi)
{
moveDocumentToTrash(groupTi, proxyTi);
}
else
{
// We have to physically delete document
proxyTi->parent()->removeChild(proxyTi);
UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy());
if (mTrashTi->childCount()==0)
selectDocument(NULL);
else
selectDocument(((UBDocumentProxyTreeItem*)mTrashTi->child(0))->proxy());
reloadThumbnails(); reloadThumbnails();
}
}
}
else if (groupTi)
{
if (groupTi == mTrashTi)
{
if(UBApplication::mainWindow->yesNoQuestion(tr("Empty Trash"), tr("Are you sure you want to empty trash?")))
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QList<UBDocumentProxyTreeItem*> toBeDeleted;
for (int i = 0; i < groupTi->childCount(); i++)
{
UBDocumentProxyTreeItem* proxyTi = dynamic_cast<UBDocumentProxyTreeItem*>(groupTi->child(i));
if (proxyTi && proxyTi->proxy())
toBeDeleted << proxyTi;
}
showMessage(tr("Emptying trash"));
for (int i = 0; i < toBeDeleted.count(); i++)
{
UBDocumentProxyTreeItem* proxyTi = toBeDeleted.at(i);
proxyTi->parent()->removeChild(proxyTi);
UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy());
}
showMessage(tr("Emptied trash"));
QApplication::restoreOverrideCursor();
mMainWindow->actionDelete->setEnabled(false);
}
}
else
{
if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Folder"), tr("Are you sure you want to remove the folder '%1' and all its content?").arg(groupTi->groupName())))
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
moveFolderToTrash(groupTi);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
} }

@ -111,6 +111,9 @@ class UBDocumentController : public UBDocumentContainer
bool mToolsPalettePositionned; bool mToolsPalettePositionned;
UBDocumentGroupTreeItem* mTrashTi; UBDocumentGroupTreeItem* mTrashTi;
void moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, UBDocumentProxyTreeItem *proxyTi);
void moveFolderToTrash(UBDocumentGroupTreeItem* groupTi);
private slots: private slots:
void documentZoomSliderValueChanged (int value); void documentZoomSliderValueChanged (int value);
void loadDocumentProxies(); void loadDocumentProxies();

@ -263,7 +263,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
, mCrossedBackground(false) , mCrossedBackground(false)
, mIsDesktopMode(false) , mIsDesktopMode(false)
, mZoomFactor(1) , mZoomFactor(1)
, mIsModified(true)
, mBackgroundObject(0) , mBackgroundObject(0)
, mPreviousWidth(0) , mPreviousWidth(0)
, mInputDeviceIsPressed(false) , mInputDeviceIsPressed(false)
@ -1116,17 +1115,16 @@ void UBGraphicsScene::clearItems()
{ {
QGraphicsItem* item = itItems.next(); QGraphicsItem* item = itItems.next();
if (!item->parentItem()) bool isGroup = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item) != NULL;
{ bool isPolygon = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item) != NULL;
UBGraphicsPolygonItem* pi = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item); bool isStrokesGroup = qgraphicsitem_cast<UBGraphicsStrokesGroup*>(item) != NULL;
if(!pi && !mTools.contains(item) && !isBackgroundObject(item)) if(!isGroup && !isPolygon && !isStrokesGroup && !mTools.contains(item) && !isBackgroundObject(item))
{ {
removeItem(item); removeItem(item);
removedItems << item; removedItems << item;
} }
} }
}
// 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
update(sceneRect()); update(sceneRect());
@ -1587,7 +1585,6 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q
void UBGraphicsScene::addItem(QGraphicsItem* item) void UBGraphicsScene::addItem(QGraphicsItem* item)
{ {
setModified(true);
UBCoreGraphicsScene::addItem(item); UBCoreGraphicsScene::addItem(item);
UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item)); UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item));
@ -1600,8 +1597,6 @@ void UBGraphicsScene::addItem(QGraphicsItem* item)
void UBGraphicsScene::addItems(const QSet<QGraphicsItem*>& items) void UBGraphicsScene::addItems(const QSet<QGraphicsItem*>& items)
{ {
setModified(true);
foreach(QGraphicsItem* item, items) { foreach(QGraphicsItem* item, items) {
UBCoreGraphicsScene::addItem(item); UBCoreGraphicsScene::addItem(item);
UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item)); UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item));
@ -1614,7 +1609,6 @@ void UBGraphicsScene::addItems(const QSet<QGraphicsItem*>& items)
void UBGraphicsScene::removeItem(QGraphicsItem* item) void UBGraphicsScene::removeItem(QGraphicsItem* item)
{ {
setModified(true);
item->setSelected(false); item->setSelected(false);
UBCoreGraphicsScene::removeItem(item); UBCoreGraphicsScene::removeItem(item);
UBApplication::boardController->freezeW3CWidget(item, true); UBApplication::boardController->freezeW3CWidget(item, true);
@ -1627,8 +1621,6 @@ void UBGraphicsScene::removeItem(QGraphicsItem* item)
void UBGraphicsScene::removeItems(const QSet<QGraphicsItem*>& items) void UBGraphicsScene::removeItems(const QSet<QGraphicsItem*>& items)
{ {
setModified(true);
foreach(QGraphicsItem* item, items) foreach(QGraphicsItem* item, items)
UBCoreGraphicsScene::removeItem(item); UBCoreGraphicsScene::removeItem(item);
@ -1786,7 +1778,6 @@ void UBGraphicsScene::addRuler(QPointF center)
addItem(ruler); addItem(ruler);
ruler->setVisible(true); ruler->setVisible(true);
setModified(true);
} }
void UBGraphicsScene::addProtractor(QPointF center) void UBGraphicsScene::addProtractor(QPointF center)
@ -1804,7 +1795,6 @@ void UBGraphicsScene::addProtractor(QPointF center)
protractor->moveBy(center.x() - itemSceneCenter.x(), center.y() - itemSceneCenter.y()); protractor->moveBy(center.x() - itemSceneCenter.x(), center.y() - itemSceneCenter.y());
protractor->setVisible(true); protractor->setVisible(true);
setModified(true);
} }
void UBGraphicsScene::addTriangle(QPointF center) void UBGraphicsScene::addTriangle(QPointF center)
@ -1822,7 +1812,6 @@ void UBGraphicsScene::addTriangle(QPointF center)
triangle->moveBy(center.x() - itemSceneCenter.x(), center.y() - itemSceneCenter.y()); triangle->moveBy(center.x() - itemSceneCenter.x(), center.y() - itemSceneCenter.y());
triangle->setVisible(true); triangle->setVisible(true);
setModified(true);
} }
void UBGraphicsScene::addMagnifier(UBMagnifierParams params) void UBGraphicsScene::addMagnifier(UBMagnifierParams params)
@ -1881,6 +1870,7 @@ void UBGraphicsScene::moveMagnifier()
{ {
QPoint magnifierPos = QPoint(magniferControlViewWidget->pos().x() + magniferControlViewWidget->size().width() / 2, magniferControlViewWidget->pos().y() + magniferControlViewWidget->size().height() / 2 ); QPoint magnifierPos = QPoint(magniferControlViewWidget->pos().x() + magniferControlViewWidget->size().width() / 2, magniferControlViewWidget->pos().y() + magniferControlViewWidget->size().height() / 2 );
moveMagnifier(magnifierPos, true); moveMagnifier(magnifierPos, true);
setModified(true);
} }
} }
@ -1913,6 +1903,7 @@ void UBGraphicsScene::moveMagnifier(QPoint newPos, bool forceGrab)
void UBGraphicsScene::closeMagnifier() void UBGraphicsScene::closeMagnifier()
{ {
DisposeMagnifierQWidgets(); DisposeMagnifierQWidgets();
setModified(true);
} }
void UBGraphicsScene::zoomInMagnifier() void UBGraphicsScene::zoomInMagnifier()
@ -1930,6 +1921,7 @@ void UBGraphicsScene::zoomOutMagnifier()
{ {
magniferControlViewWidget->setZoom(magniferControlViewWidget->params.zoom - 0.5); magniferControlViewWidget->setZoom(magniferControlViewWidget->params.zoom - 0.5);
magniferDisplayViewWidget->setZoom(magniferDisplayViewWidget->params.zoom - 0.5); magniferDisplayViewWidget->setZoom(magniferDisplayViewWidget->params.zoom - 0.5);
setModified(true);
} }
} }
@ -1941,6 +1933,7 @@ void UBGraphicsScene::resizedMagnifier(qreal newPercent)
magniferControlViewWidget->grabPoint(); magniferControlViewWidget->grabPoint();
magniferDisplayViewWidget->setSize(newPercent); magniferDisplayViewWidget->setSize(newPercent);
magniferDisplayViewWidget->grabPoint(); magniferDisplayViewWidget->grabPoint();
setModified(true);
} }
} }
@ -1956,7 +1949,6 @@ void UBGraphicsScene::addCompass(QPointF center)
compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
compass->setVisible(true); compass->setVisible(true);
setModified(true);
} }
void UBGraphicsScene::addCache() void UBGraphicsScene::addCache()
@ -1986,7 +1978,6 @@ void UBGraphicsScene::addMask(const QPointF &center)
curtain->setRect(rect); curtain->setRect(rect);
curtain->setVisible(true); curtain->setVisible(true);
curtain->setSelected(true); curtain->setSelected(true);
setModified(true);
} }
void UBGraphicsScene::setRenderingQuality(UBItem::RenderingQuality pRenderingQuality) void UBGraphicsScene::setRenderingQuality(UBItem::RenderingQuality pRenderingQuality)

@ -179,16 +179,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
bool isEmpty() const; bool isEmpty() const;
bool isModified() const
{
return mIsModified;
}
void setModified(bool pModified)
{
mIsModified = pModified;
}
void setDocument(UBDocumentProxy* pDocument); void setDocument(UBDocumentProxy* pDocument);
UBDocumentProxy* document() const UBDocumentProxy* document() const
@ -380,8 +370,6 @@ public slots:
bool mIsDesktopMode; bool mIsDesktopMode;
qreal mZoomFactor; qreal mZoomFactor;
bool mIsModified;
QGraphicsItem* mBackgroundObject; QGraphicsItem* mBackgroundObject;
QPointF mPreviousPoint; QPointF mPreviousPoint;

@ -23,6 +23,7 @@
UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent) UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent)
: QGraphicsScene ( parent ) : QGraphicsScene ( parent )
, mIsModified(true)
{ {
//NOOP //NOOP
} }
@ -60,6 +61,8 @@ void UBCoreGraphicsScene::addItem(QGraphicsItem* item)
if (item->scene() != this) if (item->scene() != this)
QGraphicsScene::addItem(item); QGraphicsScene::addItem(item);
setModified(true);
} }
@ -70,6 +73,7 @@ void UBCoreGraphicsScene::removeItem(QGraphicsItem* item, bool forceDelete)
{ {
deleteItem(item); deleteItem(item);
} }
setModified(true);
} }
bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item) bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item)

@ -33,8 +33,21 @@ class UBCoreGraphicsScene : public QGraphicsScene
void removeItemFromDeletion(QGraphicsItem* item); void removeItemFromDeletion(QGraphicsItem* item);
void addItemToDeletion(QGraphicsItem *item); void addItemToDeletion(QGraphicsItem *item);
bool isModified() const
{
return mIsModified;
}
void setModified(bool pModified)
{
mIsModified = pModified;
}
private: private:
QSet<QGraphicsItem*> mItemsToDelete; QSet<QGraphicsItem*> mItemsToDelete;
bool mIsModified;
}; };
#endif /* UBCOREGRAPHICSSCENE_H_ */ #endif /* UBCOREGRAPHICSSCENE_H_ */

Loading…
Cancel
Save