Changeset 14200


Ignore:
Timestamp:
Sep 8, 2013, 7:59:47 PM (8 years ago)
Author:
jordan
Message:

(trunk, qt) reuse make-dialog's trailing slash fix in the options dialog when setting the download dir

Location:
trunk/qt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/make-dialog.cc

    r14198 r14200  
    4040#include "make-dialog.h"
    4141#include "session.h"
     42#include "utils.h"
    4243
    4344/***
    4445****
    4546***/
    46 
    47 namespace
    48 {
    49   QString removeTrailingSlash (const QString& path)
    50   {
    51     // QFileDialog may return path ending with slash if that path refers to
    52     // directory. QFileInfo::fileName() applied to such path would then return
    53     // an empty string which is not what we want, so we strip the slash here.
    54 
    55     if (!path.endsWith (QDir::separator ()))
    56       return path;
    57 
    58     return path.left (path.length () - 1);
    59   }
    60 }
    6147
    6248void
     
    202188MakeDialog :: onFileSelected( const QString& filename )
    203189{
    204     myFile = removeTrailingSlash (filename);
     190    myFile = Utils::removeTrailingDirSeparator (filename);
    205191    myFileButton->setText( QFileInfo(myFile).fileName() );
    206192    onSourceChanged( );
     
    227213MakeDialog :: onFolderSelected( const QString& filename )
    228214{
    229     myFolder = removeTrailingSlash (filename);
     215    myFolder = Utils::removeTrailingDirSeparator (filename);
    230216    myFolderButton->setText( QFileInfo(myFolder).fileName() );
    231217    onSourceChanged( );
     
    252238MakeDialog :: onDestinationSelected( const QString& filename )
    253239{
    254     myDestination = removeTrailingSlash (filename);
     240    myDestination = Utils::removeTrailingDirSeparator (filename);
    255241    myDestinationButton->setText( QFileInfo(myDestination).fileName() );
    256242}
  • trunk/qt/options.cc

    r14194 r14200  
    515515  if (destinations.size () == 1)
    516516    {
    517       const QString& destination (destinations.first ());
     517      QString destination = Utils::removeTrailingDirSeparator (destinations.first ());
    518518      myFreespaceLabel->setPath (destination);
    519519      myLocalDestination.setPath (destination);
  • trunk/qt/utils.cc

    r14195 r14200  
    207207    return true;
    208208}
     209
     210QString
     211Utils :: removeTrailingDirSeparator (const QString& path)
     212{
     213  return path.endsWith (QDir::separator ())
     214    ? path.left (path.length()-1)
     215    : path;
     216}
  • trunk/qt/utils.h

    r14195 r14200  
    3636        static bool isValidUtf8 ( const char *s );
    3737
     38        static QString removeTrailingDirSeparator (const QString& path);
     39
    3840        // meh
    3941        static void toStderr( const QString& qstr );
Note: See TracChangeset for help on using the changeset viewer.