diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 0c78f096..a160127a 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -227,7 +227,7 @@ QDialog::DialogCode UBPersistenceManager::processInteractiveReplacementDialog(UB return QDialog::Rejected; } - QStringList docList = mDocumentTreeStructureModel->nodeNameList(parentIndex); + QStringList docList = mDocumentTreeStructureModel->nodeNameList(parentIndex, true); QString docName = pProxy->metaData(UBSettings::documentName).toString(); if (docList.contains(docName)) { diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index 12171d2c..970d08bf 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -539,7 +539,14 @@ bool UBDocumentTreeModel::setData(const QModelIndex &index, const QVariant &valu if (!index.isValid() || value.toString().isEmpty()) { return false; } - setNewName(index, value.toString()); + + QString fullNewName = value.toString(); + if (isCatalog(index)) + { + fullNewName.replace('/', '-'); + } + + setNewName(index, fullNewName); return true; } return QAbstractItemModel::setData(index, value, role); @@ -1019,7 +1026,7 @@ QString UBDocumentTreeModel::virtualPathForIndex(const QModelIndex &pIndex) cons return virtualDirForIndex(pIndex) + "/" + curNode->nodeName(); } -QStringList UBDocumentTreeModel::nodeNameList(const QModelIndex &pIndex) const +QStringList UBDocumentTreeModel::nodeNameList(const QModelIndex &pIndex, bool distinctNodeType) const { QStringList result; @@ -1030,12 +1037,21 @@ QStringList UBDocumentTreeModel::nodeNameList(const QModelIndex &pIndex) const foreach (UBDocumentTreeNode *curNode, catalog->children()) { - /* this function is only used (at this time) to compare filenames eachother, so it has to distinguish a folder named "A" from a file named "A" - // notice that it is a really poor way to search for file indexes, and that the code where it is called should be entirely reworked, when the time permits it. */ - if (curNode->nodeType() != UBDocumentTreeNode::Catalog) - result << curNode->nodeName(); + if (distinctNodeType) + { + if (curNode->nodeType() == UBDocumentTreeNode::Catalog) + { + result << "folder - " + curNode->nodeName(); + } + else + { + result << curNode->nodeName(); + } + } else - result << "folder - " + curNode->nodeName(); + { + result << curNode->nodeName(); + } } return result; @@ -1166,7 +1182,6 @@ void UBDocumentTreeModel::setNewName(const QModelIndex &index, const QString &ne QString magicSeparator = "+!##s"; if (isCatalog(index)) { QString fullNewName = newName; - fullNewName.replace('/', '-'); if (!newName.contains(magicSeparator)) { indexNode->setNodeName(fullNewName); QString virtualDir = virtualDirForIndex(index); diff --git a/src/document/UBDocumentController.h b/src/document/UBDocumentController.h index 88ed74b2..a67908be 100644 --- a/src/document/UBDocumentController.h +++ b/src/document/UBDocumentController.h @@ -209,7 +209,7 @@ public: UBDocumentProxy *proxyForIndex(const QModelIndex &pIndex) const; QString virtualDirForIndex(const QModelIndex &pIndex) const; QString virtualPathForIndex(const QModelIndex &pIndex) const; - QStringList nodeNameList(const QModelIndex &pIndex) const; + QStringList nodeNameList(const QModelIndex &pIndex, bool distinctNodeType = false) const; bool newNodeAllowed(const QModelIndex &pSelectedIndex) const; QModelIndex goTo(const QString &dir); bool inTrash(const QModelIndex &index) const;