new document and new folder editable at creation + expand path if needed

preferencesAboutTextFull
Clément Fauconnier 6 years ago
parent 3a4843f421
commit 41c50a2c0a
  1. 2
      src/core/UBPersistenceManager.cpp
  2. 20
      src/document/UBDocumentController.cpp
  3. 6
      src/document/UBDocumentController.h

@ -532,7 +532,7 @@ void UBPersistenceManager::deleteDocument(UBDocumentProxy* pDocumentProxy)
emit documentWillBeDeleted(pDocumentProxy); emit documentWillBeDeleted(pDocumentProxy);
Q_ASSERT(QFileInfo(pDocumentProxy->persistencePath()).exists()); if (QFileInfo(pDocumentProxy->persistencePath()).exists())
UBFileSystemUtils::deleteDir(pDocumentProxy->persistencePath()); UBFileSystemUtils::deleteDir(pDocumentProxy->persistencePath());
mSceneCache.removeAllScenes(pDocumentProxy); mSceneCache.removeAllScenes(pDocumentProxy);

@ -1109,14 +1109,14 @@ void UBDocumentTreeModel::addNewDocument(UBDocumentProxy *pProxyData, const QMod
mNewDocuments << pProxyData; mNewDocuments << pProxyData;
} }
void UBDocumentTreeModel::addCatalog(const QString &pName, const QModelIndex &pParent) QModelIndex UBDocumentTreeModel::addCatalog(const QString &pName, const QModelIndex &pParent)
{ {
if (pName.isEmpty() || !pParent.isValid()) { if (pName.isEmpty() || !pParent.isValid()) {
return; return QModelIndex();
} }
UBDocumentTreeNode *catalogNode = new UBDocumentTreeNode(UBDocumentTreeNode::Catalog, pName); UBDocumentTreeNode *catalogNode = new UBDocumentTreeNode(UBDocumentTreeNode::Catalog, pName);
addNode(catalogNode, pParent); return addNode(catalogNode, pParent);
} }
void UBDocumentTreeModel::setNewName(const QModelIndex &index, const QString &newName) void UBDocumentTreeModel::setNewName(const QModelIndex &index, const QString &newName)
@ -1272,7 +1272,7 @@ UBDocumentTreeView::UBDocumentTreeView(QWidget *parent) : QTreeView(parent)
setRootIsDecorated(true); setRootIsDecorated(true);
} }
void UBDocumentTreeView::setSelectedAndExpanded(const QModelIndex &pIndex, bool pExpand) void UBDocumentTreeView::setSelectedAndExpanded(const QModelIndex &pIndex, bool pExpand, bool pEdit)
{ {
if (!pIndex.isValid()) { if (!pIndex.isValid()) {
return; return;
@ -1299,6 +1299,9 @@ void UBDocumentTreeView::setSelectedAndExpanded(const QModelIndex &pIndex, bool
} }
scrollTo(proxy->mapFromSource(pIndex), QAbstractItemView::PositionAtCenter); scrollTo(proxy->mapFromSource(pIndex), QAbstractItemView::PositionAtCenter);
if (pEdit)
edit(proxy->mapFromSource(pIndex));
} }
void UBDocumentTreeView::onModelIndexChanged(const QModelIndex &pNewIndex, const QModelIndex &pOldIndex) void UBDocumentTreeView::onModelIndexChanged(const QModelIndex &pNewIndex, const QModelIndex &pOldIndex)
@ -1660,14 +1663,14 @@ void UBDocumentController::createNewDocument()
: docModel->virtualDirForIndex(selectedIndex); : docModel->virtualDirForIndex(selectedIndex);
UBDocumentProxy *document = pManager->createDocument(groupName); UBDocumentProxy *document = pManager->createDocument(groupName);
selectDocument(document); selectDocument(document, true, false, true);
if (document) if (document)
pManager->mDocumentTreeStructureModel->markDocumentAsNew(document); pManager->mDocumentTreeStructureModel->markDocumentAsNew(document);
} }
} }
void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument, const bool onImport) void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument, const bool onImport, const bool editMode)
{ {
if (proxy==NULL) if (proxy==NULL)
{ {
@ -1678,7 +1681,7 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr
if (setAsCurrentDocument) { if (setAsCurrentDocument) {
UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel->setCurrentDocument(proxy); UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel->setCurrentDocument(proxy);
QModelIndex indexCurrentDoc = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel->indexForProxy(proxy); QModelIndex indexCurrentDoc = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel->indexForProxy(proxy);
mDocumentUI->documentTreeView->setSelectedAndExpanded(indexCurrentDoc, true); mDocumentUI->documentTreeView->setSelectedAndExpanded(indexCurrentDoc, true, editMode);
if (proxy != mBoardController->selectedDocument()) // only if wanted Document is different from document actually on Board, // ALTI/AOU - 20140217 if (proxy != mBoardController->selectedDocument()) // only if wanted Document is different from document actually on Board, // ALTI/AOU - 20140217
{ {
@ -1705,7 +1708,8 @@ void UBDocumentController::createNewDocumentGroup()
QString newFolderName = docModel->adjustNameForParentIndex(tr("New Folder"), parentIndex); QString newFolderName = docModel->adjustNameForParentIndex(tr("New Folder"), parentIndex);
docModel->addCatalog(newFolderName, parentIndex); QModelIndex newIndex = docModel->addCatalog(newFolderName, parentIndex);
mDocumentUI->documentTreeView->setSelectedAndExpanded(newIndex, true, true);
} }

@ -208,7 +208,7 @@ public:
UBDocumentProxy *proxyData(const QModelIndex &index) const {return nodeFromIndex(index)->proxyData();} UBDocumentProxy *proxyData(const QModelIndex &index) const {return nodeFromIndex(index)->proxyData();}
void addDocument(UBDocumentProxy *pProxyData, const QModelIndex &pParent = QModelIndex()); void addDocument(UBDocumentProxy *pProxyData, const QModelIndex &pParent = QModelIndex());
void addNewDocument(UBDocumentProxy *pProxyData, const QModelIndex &pParent = QModelIndex()); void addNewDocument(UBDocumentProxy *pProxyData, const QModelIndex &pParent = QModelIndex());
void addCatalog(const QString &pName, const QModelIndex &pParent); QModelIndex addCatalog(const QString &pName, const QModelIndex &pParent);
QList<UBDocumentProxy*> newDocuments() {return mNewDocuments;} QList<UBDocumentProxy*> newDocuments() {return mNewDocuments;}
void markDocumentAsNew(UBDocumentProxy *pDoc) {if (indexForProxy(pDoc).isValid()) mNewDocuments << pDoc;} void markDocumentAsNew(UBDocumentProxy *pDoc) {if (indexForProxy(pDoc).isValid()) mNewDocuments << pDoc;}
void setNewName(const QModelIndex &index, const QString &newName); void setNewName(const QModelIndex &index, const QString &newName);
@ -286,7 +286,7 @@ public:
QModelIndexList mapIndexesToSource(const QModelIndexList &indexes); QModelIndexList mapIndexesToSource(const QModelIndexList &indexes);
public slots: public slots:
void setSelectedAndExpanded(const QModelIndex &pIndex, bool pExpand = true); void setSelectedAndExpanded(const QModelIndex &pIndex, bool pExpand = true, bool pEdit = false);
void onModelIndexChanged(const QModelIndex &pNewIndex, const QModelIndex &pOldIndex); void onModelIndexChanged(const QModelIndex &pNewIndex, const QModelIndex &pOldIndex);
void hSliderRangeChanged(int min, int max); void hSliderRangeChanged(int min, int max);
@ -429,7 +429,7 @@ class UBDocumentController : public UBDocumentContainer
void duplicateSelectedItem(); void duplicateSelectedItem();
void importFile(); void importFile();
void moveSceneToIndex(UBDocumentProxy* proxy, int source, int target); void moveSceneToIndex(UBDocumentProxy* proxy, int source, int target);
void selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument = true, const bool onImport = false); void selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument = true, const bool onImport = false, const bool editMode = false);
void show(); void show();
void hide(); void hide();
void showMessage(const QString& message, bool showSpinningWheel = false); void showMessage(const QString& message, bool showSpinningWheel = false);

Loading…
Cancel
Save