some fixes on new document mode (actions if nothing selected, disable trash if empty, ...)

preferencesAboutTextFull
Clément Fauconnier 6 years ago
parent d978534980
commit 42fc2882a7
  1. 20
      src/document/UBDocumentController.cpp

@ -1641,7 +1641,10 @@ void UBDocumentController::createNewDocument()
UBPersistenceManager *pManager = UBPersistenceManager::persistenceManager(); UBPersistenceManager *pManager = UBPersistenceManager::persistenceManager();
UBDocumentTreeModel *docModel = pManager->mDocumentTreeStructureModel; UBDocumentTreeModel *docModel = pManager->mDocumentTreeStructureModel;
QModelIndex selectedIndex = firstSelectedTreeIndex(); QModelIndex selectedIndex = firstSelectedTreeIndex();
if (selectedIndex.isValid()) {
if (!selectedIndex.isValid())
selectedIndex = docModel->myDocumentsIndex();
QString groupName = docModel->isCatalog(selectedIndex) QString groupName = docModel->isCatalog(selectedIndex)
? docModel->virtualPathForIndex(selectedIndex) ? docModel->virtualPathForIndex(selectedIndex)
: docModel->virtualDirForIndex(selectedIndex); : docModel->virtualDirForIndex(selectedIndex);
@ -1652,7 +1655,6 @@ void UBDocumentController::createNewDocument()
if (document) if (document)
pManager->mDocumentTreeStructureModel->markDocumentAsNew(document); pManager->mDocumentTreeStructureModel->markDocumentAsNew(document);
} }
}
void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument, const bool onImport, const bool editMode) void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument, const bool onImport, const bool editMode)
{ {
@ -1684,7 +1686,7 @@ void UBDocumentController::createNewDocumentGroup()
UBDocumentTreeModel *docModel = pManager->mDocumentTreeStructureModel; UBDocumentTreeModel *docModel = pManager->mDocumentTreeStructureModel;
QModelIndex selectedIndex = firstSelectedTreeIndex(); QModelIndex selectedIndex = firstSelectedTreeIndex();
if (!selectedIndex.isValid()) { if (!selectedIndex.isValid()) {
return; selectedIndex = docModel->myDocumentsIndex();
} }
QModelIndex parentIndex = docModel->isCatalog(selectedIndex) QModelIndex parentIndex = docModel->isCatalog(selectedIndex)
? selectedIndex ? selectedIndex
@ -2287,6 +2289,7 @@ void UBDocumentController::deleteSelectedItem()
} }
} }
} }
updateActions();
} }
//N/C - NNE - 20140410 //N/C - NNE - 20140410
@ -2444,8 +2447,8 @@ void UBDocumentController::moveToTrash(QModelIndex &index, UBDocumentTreeModel*
void UBDocumentController::emptyFolder(const QModelIndex &index, DeletionType pDeletionType) void UBDocumentController::emptyFolder(const QModelIndex &index, DeletionType pDeletionType)
{ {
// Issue NC - CFA - 20131029 : ajout d'une popup de confirmation pour la suppression definitive // Issue NC - CFA - 20131029 : ajout d'une popup de confirmation pour la suppression definitive
if(pDeletionType == CompleteDelete && !UBApplication::mainWindow->yesNoQuestion(tr("Empty the trash"),tr("You're about to empty the trash.") +"\n\n" + tr("Are you sure ?"))) // if(pDeletionType == CompleteDelete && !UBApplication::mainWindow->yesNoQuestion(tr("Empty the trash"),tr("You're about to empty the trash.") +"\n\n" + tr("Are you sure ?")))
return; // return;
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@ -3225,9 +3228,16 @@ UBDocumentController::deletionTypeForSelection(LastSelectedElementType pTypeSele
} }
} else if (docModel->isConstant(selectedIndex)) { } else if (docModel->isConstant(selectedIndex)) {
if (selectedIndex == docModel->trashIndex()) { if (selectedIndex == docModel->trashIndex()) {
if (docModel->rowCount(selectedIndex) > 0)
return EmptyTrash; return EmptyTrash;
else
return NoDeletion;
} }
if (selectedIndex.isValid())
return EmptyFolder; return EmptyFolder;
else
return NoDeletion;
} else if (pTypeSelection != None) { } else if (pTypeSelection != None) {
if (docModel->inTrash(selectedIndex)) { if (docModel->inTrash(selectedIndex)) {
return CompleteDelete; return CompleteDelete;

Loading…
Cancel
Save