@ -539,7 +539,14 @@ bool UBDocumentTreeModel::setData(const QModelIndex &index, const QVariant &valu
if ( ! index . isValid ( ) | | value . toString ( ) . isEmpty ( ) ) {
if ( ! index . isValid ( ) | | value . toString ( ) . isEmpty ( ) ) {
return false ;
return false ;
}
}
setNewName ( index , value . toString ( ) ) ;
QString fullNewName = value . toString ( ) ;
if ( isCatalog ( index ) )
{
fullNewName . replace ( ' / ' , ' - ' ) ;
}
setNewName ( index , fullNewName ) ;
return true ;
return true ;
}
}
return QAbstractItemModel : : setData ( index , value , role ) ;
return QAbstractItemModel : : setData ( index , value , role ) ;
@ -1019,7 +1026,7 @@ QString UBDocumentTreeModel::virtualPathForIndex(const QModelIndex &pIndex) cons
return virtualDirForIndex ( pIndex ) + " / " + curNode - > nodeName ( ) ;
return virtualDirForIndex ( pIndex ) + " / " + curNode - > nodeName ( ) ;
}
}
QStringList UBDocumentTreeModel : : nodeNameList ( const QModelIndex & pIndex ) const
QStringList UBDocumentTreeModel : : nodeNameList ( const QModelIndex & pIndex , bool distinctNodeType ) const
{
{
QStringList result ;
QStringList result ;
@ -1030,12 +1037,21 @@ QStringList UBDocumentTreeModel::nodeNameList(const QModelIndex &pIndex) const
foreach ( UBDocumentTreeNode * curNode , catalog - > children ( ) )
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"
if ( distinctNodeType )
// 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 )
if ( curNode - > nodeType ( ) = = UBDocumentTreeNode : : Catalog )
result < < curNode - > nodeName ( ) ;
{
result < < " folder - " + curNode - > nodeName ( ) ;
}
else
{
result < < curNode - > nodeName ( ) ;
}
}
else
else
result < < " folder - " + curNode - > nodeName ( ) ;
{
result < < curNode - > nodeName ( ) ;
}
}
}
return result ;
return result ;
@ -1166,7 +1182,6 @@ void UBDocumentTreeModel::setNewName(const QModelIndex &index, const QString &ne
QString magicSeparator = " +!##s " ;
QString magicSeparator = " +!##s " ;
if ( isCatalog ( index ) ) {
if ( isCatalog ( index ) ) {
QString fullNewName = newName ;
QString fullNewName = newName ;
fullNewName . replace ( ' / ' , ' - ' ) ;
if ( ! newName . contains ( magicSeparator ) ) {
if ( ! newName . contains ( magicSeparator ) ) {
indexNode - > setNodeName ( fullNewName ) ;
indexNode - > setNodeName ( fullNewName ) ;
QString virtualDir = virtualDirForIndex ( index ) ;
QString virtualDir = virtualDirForIndex ( index ) ;