686 void FmFileBrowseWidget::on_renameAction_triggered() |
686 void FmFileBrowseWidget::on_renameAction_triggered() |
687 { |
687 { |
688 QString filePath = mModel->filePath( mCurrentItem->modelIndex() ); |
688 QString filePath = mModel->filePath( mCurrentItem->modelIndex() ); |
689 QFileInfo fileInfo = mModel->fileInfo( mCurrentItem->modelIndex() ); |
689 QFileInfo fileInfo = mModel->fileInfo( mCurrentItem->modelIndex() ); |
690 int maxFileNameLength = FmUtils::getMaxFileNameLength(); |
690 int maxFileNameLength = FmUtils::getMaxFileNameLength(); |
691 |
691 QString oldSuffix( fileInfo.suffix() ); |
692 QString newName( fileInfo.fileName() ); |
692 QString newName( fileInfo.fileName() ); |
693 while( FmDlgUtils::showTextQuery( hbTrId( "Enter new name for %1" ).arg( newName ), newName, true, |
693 while( FmDlgUtils::showTextQuery( hbTrId( "Enter new name for %1" ).arg( newName ), newName, true, |
694 maxFileNameLength, QString() , true ) ){ |
694 maxFileNameLength, QString() , true ) ){ |
|
695 // remove whitespace from the start and the end. |
|
696 newName = newName.trimmed(); |
695 QString newTargetPath = FmUtils::fillPathWithSplash( |
697 QString newTargetPath = FmUtils::fillPathWithSplash( |
696 fileInfo.absolutePath() ) + newName; |
698 fileInfo.absolutePath() ) + newName; |
697 QFileInfo newFileInfo( newTargetPath ); |
699 QFileInfo newFileInfo( newTargetPath ); |
698 if( !FmUtils::checkFolderFileName( newName ) ) { |
700 if( !FmUtils::checkFolderFileName( newName ) ) { |
699 FmDlgUtils::information( hbTrId( "Invalid file or folder name!" ) ); |
701 FmDlgUtils::information( hbTrId( "Invalid file or folder name!" ) ); |