shutdown after emptying the trashbin
preferencesAboutTextFull
Anatoly Mihalchenko 12 years ago
parent e441f2c2f8
commit 5816a17f57
  1. 152
      src/document/UBDocumentController.cpp
  2. 3
      src/document/UBDocumentController.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();

Loading…
Cancel
Save