src/writely/WriterUI.cpp
/**
 * Only return the name of available file
 * @param    path  path for generating file
 * @param    originalPath   A generated name match originalPath is acceptable, regardless the existence of the file with that name
 */
Only return the name of available file
@param    path  path for generating file
@param    originalPath   A generated name match originalPath is acceptable, regardless the existence of the file with that name
Only return the name of available file @param path path for generating file @param originalPath A generated name match originalPath is acceptable regardless the existence of the file with that name
QString WriterUI::availableUntitledFilePath( const QString& path, const QString& originalPath ) {
    int counter = 0;
    while (true) {
        QString fileName = untitledFilePath(path, counter);
        if (fileName == originalPath) {
            QFileInfo info(originalPath);
            return info.baseName();
        }
        QFile file(fileName);
        if (!file.exists())
            break;
        counter ++;
    }
    QString fullFilePath = untitledFilePath("", counter);
    QFileInfo info(fullFilePath);
    return info.baseName();
}
QString WriterUI :: availableUntitledFilePath ( const QString & path , const QString & originalPath ) { int counter = 0 ; while ( true ) { QString fileName = untitledFilePath ( path , counter ) ; if ( fileName == originalPath ) { QFileInfo info ( originalPath ) ; return info . baseName ( ) ; } QFile file ( fileName ) ; if ( ! file . exists ( ) ) break ; counter ++ ; } QString fullFilePath = untitledFilePath ( " " , counter ) ; QFileInfo info ( fullFilePath ) ; return info . baseName ( ) ; }
Only return the name of available file
 @param    path  path for generating file
 @param    originalPath   A generated name match originalPath is acceptable, regardless the existence of the file with that name
Only return the name of available file @param path path for generating file @param originalPath A generated name match originalPath is acceptable regardless the existence of the file with that name