Changeset 12697


Ignore:
Timestamp:
Aug 20, 2011, 5:19:27 AM (10 years ago)
Author:
jordan
Message:

(trunk qt) #4428 "Conversion to QString in "New torrent" dialog assumes the input string is ASCII" -- fix many ascii-to-QString assumptions in the code.

Location:
trunk/qt
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/about.cc

    r11626 r12697  
    3838
    3939    l = new QLabel;
    40     l->setPixmap( QPixmap( ":/icons/transmission-48.png" ) );
     40    l->setPixmap( QPixmap( QString::fromAscii( ":/icons/transmission-48.png" ) ) );
    4141    l->setAlignment( Qt::AlignCenter );
    4242    v->addWidget( l );
     
    4545    f.setWeight( QFont::Bold );
    4646    f.setPointSize( int( f.pointSize( ) * 1.2 ) );
    47     l = new QLabel( "<big>Transmission " LONG_VERSION_STRING "</big>" );
     47    l = new QLabel( tr( "<big>Transmission %1</big>" ).arg( QString::fromAscii( LONG_VERSION_STRING ) ) );
    4848    l->setAlignment( Qt::AlignCenter );
    4949    l->setFont( f );
     
    5252
    5353    l = new QLabel( tr( "A fast and easy BitTorrent client" ) );
    54     l->setStyleSheet( "text-align: center" );
     54    l->setStyleSheet( QString::fromAscii( "text-align: center" ) );
    5555    l->setAlignment( Qt::AlignCenter );
    5656    v->addWidget( l );
     
    6060    v->addWidget( l );
    6161
    62     l = new QLabel( "<a href=\"http://www.transmissionbt.com/\">http://www.transmissionbt.com/</a>" );
     62    l = new QLabel( QString::fromAscii( "<a href=\"http://www.transmissionbt.com/\">http://www.transmissionbt.com/</a>" ) );
    6363    l->setOpenExternalLinks( true );
    6464    l->setAlignment( Qt::AlignCenter );
     
    8888{
    8989    QMessageBox::about( this, tr( "Credits" ),
    90         "Jordan Lee (Backend; Daemon; GTK+; Qt)\n"
    91         "Michell Livingston (Backend; OS X)\n"
    92         "Kevin Glowacz (Web client)" );
     90        QString::fromAscii( "Jordan Lee (Backend; Daemon; GTK+; Qt)\n"
     91                            "Michell Livingston (Backend; OS X)\n"
     92                            "Kevin Glowacz (Web client)" ) );
    9393}
    9494
  • trunk/qt/add-data.cc

    r12212 r12697  
    2828        type = MAGNET;
    2929    }
    30     else if ( Utils::isURL( key ) )
     30    else if ( Utils::isUriWithSupportedScheme( key ) )
    3131    {
    3232        url = key;
     
    4545    else if( Utils::isHexHashcode( key ) )
    4646    {
    47         magnet = QString("magnet:?xt=urn:btih:") + key;
     47        magnet = QString::fromAscii("magnet:?xt=urn:btih:") + key;
    4848        type = MAGNET;
    4949    }
     
    9797            tr_ctorSetMetainfo( ctor, (const uint8_t*)metainfo.constData(), metainfo.size() );
    9898            if( tr_torrentParse( ctor, &inf ) == TR_PARSE_OK  ) {
    99                 ret = inf.name;
     99                ret = QString::fromUtf8( inf.name ); // metainfo is required to be UTF-8
    100100                tr_metainfoFree( &inf );
    101101            }
  • trunk/qt/app.cc

    r12601 r12697  
    4646namespace
    4747{
    48     const char * DBUS_SERVICE     ( "com.transmissionbt.Transmission"  );
    49     const char * DBUS_OBJECT_PATH ( "/com/transmissionbt/Transmission" );
    50     const char * DBUS_INTERFACE   ( "com.transmissionbt.Transmission"  );
    51 
    52     const char * MY_CONFIG_NAME( "transmission" );
     48    const QString DBUS_SERVICE     = QString::fromAscii( "com.transmissionbt.Transmission"  );
     49    const QString DBUS_OBJECT_PATH = QString::fromAscii( "/com/transmissionbt/Transmission" );
     50    const QString DBUS_INTERFACE   = QString::fromAscii( "com.transmissionbt.Transmission"  );
     51
    5352    const char * MY_READABLE_NAME( "transmission-qt" );
    54 
    5553
    5654    const tr_option opts[] =
     
    9290    myLastFullUpdateTime( 0 )
    9391{
     92    const QString MY_CONFIG_NAME = QString::fromAscii( "transmission" );
     93
    9494    setApplicationName( MY_CONFIG_NAME );
    9595
     
    110110    // set the default icon
    111111    QIcon icon;
    112     icon.addPixmap( QPixmap( ":/icons/transmission-16.png" ) );
    113     icon.addPixmap( QPixmap( ":/icons/transmission-22.png" ) );
    114     icon.addPixmap( QPixmap( ":/icons/transmission-24.png" ) );
    115     icon.addPixmap( QPixmap( ":/icons/transmission-32.png" ) );
    116     icon.addPixmap( QPixmap( ":/icons/transmission-48.png" ) );
     112    QList<int> sizes;
     113    sizes << 16 << 22 << 24 << 32 << 48;
     114    foreach( int size, sizes )
     115        icon.addPixmap( QPixmap( QString::fromAscii(":/icons/transmission-%1.png" ).arg(size) ) );
    117116    setWindowIcon( icon );
    118117
     
    143142    // set the fallback config dir
    144143    if( configDir == 0 )
    145         configDir = tr_getDefaultConfigDir( MY_CONFIG_NAME );
     144        configDir = tr_getDefaultConfigDir( "transmission" );
    146145
    147146    // ensure our config directory exists
     
    250249    QDBusConnection bus = QDBusConnection::sessionBus();
    251250    if( !bus.registerService( DBUS_SERVICE ) )
    252         std::cerr << "couldn't register " << DBUS_SERVICE << std::endl;
     251        std::cerr << "couldn't register " << qPrintable(DBUS_SERVICE) << std::endl;
    253252    if( !bus.registerObject( DBUS_OBJECT_PATH, this ) )
    254         std::cerr << "couldn't register " << DBUS_OBJECT_PATH << std::endl;
     253        std::cerr << "couldn't register " << qPrintable(DBUS_OBJECT_PATH) << std::endl;
    255254}
    256255
     
    444443MyApp :: notify( const QString& title, const QString& body ) const
    445444{
    446     const QString dbusServiceName = "org.freedesktop.Notifications";
    447     const QString dbusInterfaceName = "org.freedesktop.Notifications";
    448     const QString dbusPath = "/org/freedesktop/Notifications";
    449 
    450     QDBusMessage m = QDBusMessage::createMethodCall(dbusServiceName, dbusPath, dbusInterfaceName, "Notify");
     445    const QString dbusServiceName   = QString::fromAscii( "org.freedesktop.Notifications" );
     446    const QString dbusInterfaceName = QString::fromAscii( "org.freedesktop.Notifications" );
     447    const QString dbusPath          = QString::fromAscii( "/org/freedesktop/Notifications" );
     448
     449    QDBusMessage m = QDBusMessage::createMethodCall(dbusServiceName, dbusPath, dbusInterfaceName, QString::fromAscii("Notify"));
    451450    QList<QVariant> args;
    452     args.append( "Transmission" ); // app_name
    453     args.append( 0U );             // replaces_id
    454     args.append( "transmission" ); // icon
    455     args.append( title );          // summary
    456     args.append( body );           // body
    457     args.append( QStringList( ) ); // actions - unused for plain passive popups
    458     args.append( QVariantMap( ) ); // hints - unused atm
    459     args.append( int32_t(-1) );    // use the default timeout period
     451    args.append( QString::fromAscii( "Transmission" ) ); // app_name
     452    args.append( 0U );                                   // replaces_id
     453    args.append( QString::fromAscii( "transmission" ) ); // icon
     454    args.append( title );                                // summary
     455    args.append( body );                                 // body
     456    args.append( QStringList( ) );                       // actions - unused for plain passive popups
     457    args.append( QVariantMap( ) );                       // hints - unused atm
     458    args.append( int32_t(-1) );                          // use the default timeout period
    460459    m.setArguments( args );
    461460    QDBusMessage replyMsg = QDBusConnection::sessionBus().call(m);
     
    490489                                                               DBUS_OBJECT_PATH,
    491490                                                               DBUS_INTERFACE,
    492                                                                "AddMetainfo" );
     491                                                               QString::fromAscii("AddMetainfo") );
    493492        QList<QVariant> arguments;
    494493        AddData a( addme[i] );
  • trunk/qt/file-tree.cc

    r11522 r12697  
    421421    FileTreeItem * i( rootItem );
    422422
    423     foreach( QString token, filename.split( "/" ) )
     423    foreach( QString token, filename.split( QChar::fromAscii('/') ) )
    424424    {
    425425        FileTreeItem * child( i->child( token ) );
  • trunk/qt/make-dialog.cc

    r11824 r12697  
    5757    switch( myNewButtonBox->standardButton( button ) )
    5858    {
    59         case QDialogButtonBox::Open:
    60 std::cerr << "calling mySession.addTorrent( " << qPrintable(myTarget) << ", " << qPrintable(QFileInfo(myBuilder->top).dir().path()) << ')' << std::endl;
    61             mySession.addNewlyCreatedTorrent( myTarget, QFileInfo(myBuilder->top).dir().path() );
     59        case QDialogButtonBox::Open: {
     60            const QString top = QString::fromLocal8Bit( myBuilder->top );
     61std::cerr << "calling mySession.addTorrent( " << qPrintable(myTarget) << ", " << qPrintable(QFileInfo(top).dir().path()) << ')' << std::endl;
     62            mySession.addNewlyCreatedTorrent( myTarget, QFileInfo(top).dir().path() );
    6263            break;
     64        }
    6365        case QDialogButtonBox::Abort:
    6466            myBuilder->abortFlag = true;
     
    8082
    8183    // progress label
    82     const QString base( QFileInfo(b->top).baseName() );
     84    const QString top = QString::fromLocal8Bit( myBuilder->top );
     85    const QString base( QFileInfo(top).baseName() );
    8386    QString str;
    8487    if( !b->isDone )
     
    8790        str = tr( "Created \"%1\"!" ).arg( base );
    8891    else if( b->result == TR_MAKEMETA_URL )
    89         str = tr( "Error: invalid announce URL \"%1\"" ).arg( b->errfile );
     92        str = tr( "Error: invalid announce URL \"%1\"" ).arg( QString::fromLocal8Bit( b->errfile ) );
    9093    else if( b->result == TR_MAKEMETA_CANCELLED )
    9194        str = tr( "Cancelled" );
    9295    else if( b->result == TR_MAKEMETA_IO_READ )
    93         str = tr( "Error reading \"%1\": %2" ).arg( b->errfile ).arg( strerror(b->my_errno) );
     96        str = tr( "Error reading \"%1\": %2" ).arg( QString::fromLocal8Bit(b->errfile) ).arg( QString::fromLocal8Bit(strerror(b->my_errno)) );
    9497    else if( b->result == TR_MAKEMETA_IO_WRITE )
    95         str = tr( "Error writing \"%1\": %2" ).arg( b->errfile ).arg( strerror(b->my_errno) );
     98        str = tr( "Error writing \"%1\": %2" ).arg( QString::fromLocal8Bit(b->errfile) ).arg( QString::fromLocal8Bit(strerror(b->my_errno)) );
    9699    myNewLabel->setText( str );
    97100
     
    112115    int tier = 0;
    113116    QList<tr_tracker_info> trackers;
    114     foreach( QString line, myTrackerEdit->toPlainText().split("\n") ) {
     117    foreach( QString line, myTrackerEdit->toPlainText().split(QChar::fromAscii('\n')) ) {
    115118        line = line.trimmed( );
    116119        if( line.isEmpty( ) )
     
    145148
    146149    // the file to create
    147     myTarget = QDir( myDestination ).filePath( QFileInfo(myBuilder->top).baseName() + ".torrent" );
     150    const QString path = QString::fromLocal8Bit( myBuilder->top );
     151    const QString torrentName = QFileInfo(path).baseName() + QString::fromAscii(".torrent");
     152    myTarget = QDir( myDestination ).filePath( torrentName );
    148153    std::cerr << qPrintable(myTarget) << std::endl;
    149154
     
    151156    QString comment;
    152157    if( myCommentCheck->isChecked() )
    153         comment = myCommentEdit->text().toUtf8().constData();
     158        comment = myCommentEdit->text();
    154159
    155160    // start making the torrent
     
    334339        QPushButton * b = new QPushButton;
    335340        b->setIcon( folderPixmap );
    336         b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
     341        b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
    337342        myDestination = QDir::homePath();
    338343        b->setText( myDestination );
     
    348353        myFolderButton->setIcon( folderPixmap );
    349354        myFolderButton->setText( tr( "(None)" ) );
    350         myFolderButton->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
     355        myFolderButton->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
    351356        connect( myFolderButton, SIGNAL(clicked(bool)),
    352357                 this, SLOT(onFolderClicked(void)) );
     
    363368        myFileButton->setText( tr( "(None)" ) );
    364369        myFileButton->setIcon( filePixmap );
    365         myFileButton->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
     370        myFileButton->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
    366371        connect( myFileButton, SIGNAL(clicked(bool)),
    367372                 this, SLOT(onFileClicked(void)) );
     
    376381
    377382        hig->addWideControl( myTrackerEdit = new ShortPlainTextEdit );
    378         const int height = fontMetrics().size( 0, "\n\n\n\n" ).height( );
     383        const int height = fontMetrics().size( 0, QString::fromAscii("\n\n\n\n") ).height( );
    379384        myTrackerEdit->setMinimumHeight( height );
    380385        hig->addTallRow( tr( "&Trackers:" ), myTrackerEdit );
  • trunk/qt/options.cc

    r11720 r12697  
    9898
    9999    QPushButton * p;
    100     int width = fontMetrics.size( 0, "This is a pretty long torrent filename indeed.torrent" ).width( );
     100    int width = fontMetrics.size( 0, QString::fromAscii( "This is a pretty long torrent filename indeed.torrent" ) ).width( );
    101101    QLabel * l = new QLabel( tr( "&Torrent file:" ) );
    102102    layout->addWidget( l, row, 0, Qt::AlignLeft );
     
    104104    p->setIcon( filePixmap );
    105105    p->setMinimumWidth( width );
    106     p->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
     106    p->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
    107107    p->installEventFilter( this );
    108108
  • trunk/qt/prefs-dialog.cc

    r12661 r12697  
    135135    const int minutes( myPrefs.getInt( key ) );
    136136    QTimeEdit * e = new QTimeEdit( );
    137     e->setDisplayFormat( "hh:mm" );
     137    e->setDisplayFormat( QString::fromAscii( "hh:mm" ) );
    138138    e->setProperty( PREF_KEY, key );
    139139    e->setTime( QTime().addSecs( minutes * 60 ) );
     
    233233    h->setSpacing( HIG :: PAD );
    234234    QLabel * label = new QLabel;
    235     label->setPixmap( QPixmap( ":/icons/alt-limit-off.png" ) );
     235    label->setPixmap( QPixmap( QString::fromAscii( ":/icons/alt-limit-off.png" ) ) );
    236236    label->setAlignment( Qt::AlignLeft|Qt::AlignVCenter );
    237237    h->addWidget( label );
    238238    label = new QLabel( tr( "Temporary Speed Limits" ) );
    239     label->setStyleSheet( "font: bold" );
     239    label->setStyleSheet( QString::fromAscii( "font: bold" ) );
    240240    label->setAlignment( Qt::AlignLeft|Qt::AlignVCenter );
    241241    h->addWidget( label );
     
    347347
    348348    hig->addRow( tr( "&Port for incoming connections:" ), s );
    349     hig->addRow( "", h, 0 );
     349    hig->addRow( QString(), h, 0 );
    350350    hig->addWideControl( checkBoxNew( tr( "Pick a &random port every time Transmission is started" ), Prefs :: PEER_PORT_RANDOM_ON_START ) );
    351351    hig->addWideControl( checkBoxNew( tr( "Use UPnP or NAT-PMP port &forwarding from my router" ), Prefs::PORT_FORWARDING ) );
     
    397397{
    398398    myBlocklistDialog = new QMessageBox( QMessageBox::Information,
    399                                          "",
     399                                         QString(),
    400400                                         tr( "<b>Update Blocklist</b><p>Getting new blocklist..." ),
    401401                                         QMessageBox::Close,
     
    427427    hig->addRow( l, e );
    428428
    429     l = myBlocklistLabel = new QLabel( "" );
     429    l = myBlocklistLabel = new QLabel( );
    430430    myBlockWidgets << l;
    431431    w = new QPushButton( tr( "&Update" ) );
     
    540540        QPushButton * b = myWatchButton = new QPushButton;
    541541        b->setIcon( folderPixmap );
    542         b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
     542        b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
    543543        connect( b, SIGNAL(clicked(bool)), this, SLOT(onWatchClicked(void)) );
    544544        hig->addRow( l, b );
     
    578578        QPushButton * b = myDestinationButton = new QPushButton;
    579579        b->setIcon( folderPixmap );
    580         b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
     580        b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
    581581        connect( b, SIGNAL(clicked(bool)), this, SLOT(onDestinationClicked(void)) );
    582582        hig->addRow( tr( "Save to &Location:" ), b );
     
    596596        b = myIncompleteButton = new QPushButton;
    597597        b->setIcon( folderPixmap );
    598         b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
     598        b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
    599599        connect( b, SIGNAL(clicked(bool)), this, SLOT(onIncompleteClicked(void)) );
    600600        hig->addRow( myIncompleteCheckbox, b );
     
    604604        b = myTorrentDoneScriptButton = new QPushButton;
    605605        b->setIcon( filePixmap );
    606         b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
     606        b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) );
    607607        connect( b, SIGNAL(clicked(bool)), this, SLOT(onScriptClicked(void)) );
    608608        hig->addRow( myTorrentDoneScriptCheckbox, b );
  • trunk/qt/relocate.cc

    r11092 r12697  
    8585                myPath = QDir::homePath( );
    8686            else
    87                 myPath = QString( "/" );
     87                myPath = QDir::rootPath( );
    8888        }
    8989    }
  • trunk/qt/torrent-delegate.cc

    r12651 r12697  
    247247
    248248        default:
    249             str = "Error";
     249            str = tr( "Error" );
    250250            break;
    251251    }
  • trunk/qt/torrent.cc

    r12650 r12697  
    565565        while(( child = tr_bencListChild( trackers, i++ ))) {
    566566            if( tr_bencDictFindStr( child, "announce", &str )) {
    567                 dynamic_cast<MyApp*>(QApplication::instance())->favicons.add( QUrl(str) );
     567                dynamic_cast<MyApp*>(QApplication::instance())->favicons.add( QUrl(QString::fromUtf8(str)) );
    568568                list.append( QString::fromUtf8( str ) );
    569569            }
     
    606606                trackerStat.lastAnnouncePeerCount = i;
    607607            if( tr_bencDictFindStr( child, "lastAnnounceResult", &str ) )
    608                 trackerStat.lastAnnounceResult = str;
     608                trackerStat.lastAnnounceResult = QString::fromUtf8(str);
    609609            if( tr_bencDictFindInt( child, "lastAnnounceStartTime", &i ) )
    610610                trackerStat.lastAnnounceStartTime = i;
  • trunk/qt/utils.cc

    r11137 r12697  
    6868        fallback = QApplication::style()->standardIcon( QStyle :: SP_FileIcon );
    6969
    70         fileIcons[DISK]= QIcon::fromTheme( "media-optical", fallback );
    71         suffixes[DISK] << "iso";
     70        suffixes[DISK] << QString::fromAscii("iso");
     71        fileIcons[DISK]= QIcon::fromTheme( QString::fromAscii("media-optical"), fallback );
    7272
    73         fileIcons[DOCUMENT] = QIcon::fromTheme( "text-x-generic", fallback );
    74         suffixes[DOCUMENT] << "abw" << "csv" << "doc" << "dvi" << "htm" << "html" << "ini" << "log"
    75                            << "odp" << "ods" << "odt" << "pdf" << "ppt" << "ps" << "rtf" << "tex"
    76                            << "txt" << "xml";
     73        const char * doc_types[] = {
     74            "abw", "csv", "doc", "dvi", "htm", "html", "ini", "log", "odp",
     75            "ods", "odt", "pdf", "ppt", "ps",  "rtf", "tex", "txt", "xml" };
     76        for( int i=0, n=sizeof(doc_types)/sizeof(doc_types[0]); i<n; ++i )
     77            suffixes[DOCUMENT] << QString::fromAscii(doc_types[i] );
     78        fileIcons[DOCUMENT] = QIcon::fromTheme( QString::fromAscii("text-x-generic"), fallback );
    7779
    78         fileIcons[PICTURE]  = QIcon::fromTheme( "image-x-generic", fallback );
    79         suffixes[PICTURE] << "bmp" << "gif" << "jpg" << "jpeg" << "pcx" << "png" << "psd" << "raw"
    80                           << "tga" << "tiff";
     80        const char * pic_types[] = {
     81            "bmp", "gif", "jpg", "jpeg", "pcx", "png", "psd", "ras", "tga", "tiff" };
     82        for( int i=0, n=sizeof(pic_types)/sizeof(pic_types[0]); i<n; ++i )
     83            suffixes[PICTURE] << QString::fromAscii(pic_types[i]);
     84        fileIcons[PICTURE]  = QIcon::fromTheme( QString::fromAscii("image-x-generic"), fallback );
    8185
    82         fileIcons[VIDEO] = QIcon::fromTheme( "video-x-generic", fallback );
    83         suffixes[VIDEO] << "3gp" << "asf" << "avi" << "mov" << "mpeg" << "mpg" << "mp4" << "mkv"
    84                         << "mov" << "ogm" << "ogv" << "qt" << "rm" << "wmv";
     86        const char * vid_types[] = {
     87            "3gp", "asf", "avi", "mov", "mpeg", "mpg", "mp4" "mkv", "mov",
     88            "ogm", "ogv", "qt", "rm", "wmv" };
     89        for( int i=0, n=sizeof(vid_types)/sizeof(vid_types[0]); i<n; ++i )
     90            suffixes[VIDEO] << QString::fromAscii(vid_types[i]);
     91        fileIcons[VIDEO] = QIcon::fromTheme( QString::fromAscii("video-x-generic"), fallback );
    8592
    86         fileIcons[ARCHIVE]  = QIcon::fromTheme( "package-x-generic", fallback );
    87         suffixes[ARCHIVE] << "7z" << "ace" << "bz2" << "cbz" << "gz" << "gzip" << "lzma" << "rar"
    88                           << "sft" << "tar" << "zip";
     93        const char * arc_types[] = {
     94            "7z", "ace", "bz2", "cbz", "gz", "gzip", "lzma", "rar", "sft", "tar", "zip" };
     95        for( int i=0, n=sizeof(arc_types)/sizeof(arc_types[0]); i<n; ++i )
     96            suffixes[VIDEO] << QString::fromAscii(arc_types[i]);
     97        fileIcons[ARCHIVE]  = QIcon::fromTheme( QString::fromAscii("package-x-generic"), fallback );
    8998
    90         fileIcons[AUDIO] = QIcon::fromTheme( "audio-x-generic", fallback );
    91         suffixes[AUDIO] << "aac" << "ac3" << "aiff" << "ape" << "au" << "flac" << "m3u" << "m4a"
    92                         << "mid" << "midi" << "mp2" << "mp3" << "mpc" << "nsf" << "oga" << "ogg"
    93                         << "ra" << "ram" << "shn" << "voc" << "wav" << "wma";
     99        const char * aud_types[] = {
     100            "aac", "ac3", "aiff", "ape", "au", "flac", "m3u", "m4a", "mid", "midi", "mp2",
     101            "mp3", "mpc", "nsf", "oga", "ogg", "ra", "ram", "shn", "voc", "wav", "wma" };
     102        for( int i=0, n=sizeof(aud_types)/sizeof(aud_types[0]); i<n; ++i )
     103            suffixes[AUDIO] << QString::fromAscii(aud_types[i]);
     104        fileIcons[AUDIO] = QIcon::fromTheme( QString::fromAscii("audio-x-generic"), fallback );
    94105
    95         fileIcons[APP] = QIcon::fromTheme( "application-x-executable", fallback );
    96         suffixes[APP] << "bat" << "cmd" << "com" << "exe";
     106        const char * exe_types[] = { "bat", "cmd", "com", "exe" };
     107        for( int i=0, n=sizeof(exe_types)/sizeof(exe_types[0]); i<n; ++i )
     108            suffixes[APP] << QString::fromAscii(exe_types[i]);
     109        fileIcons[APP] = QIcon::fromTheme( QString::fromAscii("application-x-executable"), fallback );
    97110    }
    98111
  • trunk/qt/utils.h

    r11623 r12697  
    4141        ///
    4242
    43         static bool isMagnetLink( const QString& s ) { return s.startsWith( "magnet:?" ); }
     43        static bool isMagnetLink( const QString& s ) { return s.startsWith( QString::fromAscii( "magnet:?" ) ); }
    4444
    4545        static bool isHexHashcode( const QString& s )
     
    5050        }
    5151
    52         static bool isURL( const QString& s ) { return s.startsWith( "http://" )
    53                                                     || s.startsWith( "https://" )
    54                                                     || s.startsWith( "ftp://" ); }
     52        static bool isUriWithSupportedScheme( const QString& s )
     53        {
     54            static const QString ftp = QString::fromAscii( "ftp://" );
     55            static const QString http = QString::fromAscii( "http://" );
     56            static const QString https = QString::fromAscii( "https://" );
     57            return s.startsWith(http) || s.startsWith(https) || s.startsWith(ftp);
     58        }
    5559
    5660};
  • trunk/qt/watchdir.cc

    r11092 r12697  
    5353    if( err )
    5454        ret = ERROR;
    55     else if( myModel.hasTorrent( inf.hashString ) )
     55    else if( myModel.hasTorrent( QString::fromAscii( inf.hashString ) ) )
    5656        ret = DUPLICATE;
    5757    else
     
    107107    // try to add any new files which end in .torrent
    108108    const QSet<QString> newFiles( files - myWatchDirFiles );
     109    const QString torrentSuffix = QString::fromAscii( ".torrent" );
    109110    foreach( QString name, newFiles ) {
    110         if( name.endsWith( ".torrent", Qt::CaseInsensitive ) ) {
     111        if( name.endsWith( torrentSuffix, Qt::CaseInsensitive ) ) {
    111112            const QString filename = dir.absoluteFilePath( name );
    112113            switch( metainfoTest( filename ) ) {
Note: See TracChangeset for help on using the changeset viewer.