From: Jordan Lee Date: Sat, 20 Aug 2011 05:19:27 +0000 (+0000) Subject: (trunk qt) #4428 "Conversion to QString in "New torrent" dialog assumes the input... X-Git-Tag: 2.40b1~208 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b53b62773217e16969111efe12fb02a27a925c7;p=transmission (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. --- diff --git a/qt/about.cc b/qt/about.cc index 85aa9e3b5..5b21617cc 100644 --- a/qt/about.cc +++ b/qt/about.cc @@ -37,21 +37,21 @@ AboutDialog :: AboutDialog( QWidget * parent ): QVBoxLayout * v = new QVBoxLayout( this ); l = new QLabel; - l->setPixmap( QPixmap( ":/icons/transmission-48.png" ) ); + l->setPixmap( QPixmap( QString::fromAscii( ":/icons/transmission-48.png" ) ) ); l->setAlignment( Qt::AlignCenter ); v->addWidget( l ); QFont f( font( ) ); f.setWeight( QFont::Bold ); f.setPointSize( int( f.pointSize( ) * 1.2 ) ); - l = new QLabel( "Transmission " LONG_VERSION_STRING "" ); + l = new QLabel( tr( "Transmission %1" ).arg( QString::fromAscii( LONG_VERSION_STRING ) ) ); l->setAlignment( Qt::AlignCenter ); l->setFont( f ); l->setMargin( 8 ); v->addWidget( l ); l = new QLabel( tr( "A fast and easy BitTorrent client" ) ); - l->setStyleSheet( "text-align: center" ); + l->setStyleSheet( QString::fromAscii( "text-align: center" ) ); l->setAlignment( Qt::AlignCenter ); v->addWidget( l ); @@ -59,7 +59,7 @@ AboutDialog :: AboutDialog( QWidget * parent ): l->setAlignment( Qt::AlignCenter ); v->addWidget( l ); - l = new QLabel( "http://www.transmissionbt.com/" ); + l = new QLabel( QString::fromAscii( "http://www.transmissionbt.com/" ) ); l->setOpenExternalLinks( true ); l->setAlignment( Qt::AlignCenter ); v->addWidget( l ); @@ -87,8 +87,8 @@ void AboutDialog :: showCredits( ) { QMessageBox::about( this, tr( "Credits" ), - "Jordan Lee (Backend; Daemon; GTK+; Qt)\n" - "Michell Livingston (Backend; OS X)\n" - "Kevin Glowacz (Web client)" ); + QString::fromAscii( "Jordan Lee (Backend; Daemon; GTK+; Qt)\n" + "Michell Livingston (Backend; OS X)\n" + "Kevin Glowacz (Web client)" ) ); } diff --git a/qt/add-data.cc b/qt/add-data.cc index 84230b8e5..570408172 100644 --- a/qt/add-data.cc +++ b/qt/add-data.cc @@ -27,7 +27,7 @@ AddData :: set( const QString& key ) magnet = key; type = MAGNET; } - else if ( Utils::isURL( key ) ) + else if ( Utils::isUriWithSupportedScheme( key ) ) { url = key; type = URL; @@ -44,7 +44,7 @@ AddData :: set( const QString& key ) } else if( Utils::isHexHashcode( key ) ) { - magnet = QString("magnet:?xt=urn:btih:") + key; + magnet = QString::fromAscii("magnet:?xt=urn:btih:") + key; type = MAGNET; } else @@ -96,7 +96,7 @@ AddData :: readableName( ) const tr_ctor * ctor = tr_ctorNew( NULL ); tr_ctorSetMetainfo( ctor, (const uint8_t*)metainfo.constData(), metainfo.size() ); if( tr_torrentParse( ctor, &inf ) == TR_PARSE_OK ) { - ret = inf.name; + ret = QString::fromUtf8( inf.name ); // metainfo is required to be UTF-8 tr_metainfoFree( &inf ); } tr_ctorFree( ctor ); diff --git a/qt/app.cc b/qt/app.cc index 9d2ff70bd..979ce8a38 100644 --- a/qt/app.cc +++ b/qt/app.cc @@ -45,14 +45,12 @@ namespace { - const char * DBUS_SERVICE ( "com.transmissionbt.Transmission" ); - const char * DBUS_OBJECT_PATH ( "/com/transmissionbt/Transmission" ); - const char * DBUS_INTERFACE ( "com.transmissionbt.Transmission" ); + const QString DBUS_SERVICE = QString::fromAscii( "com.transmissionbt.Transmission" ); + const QString DBUS_OBJECT_PATH = QString::fromAscii( "/com/transmissionbt/Transmission" ); + const QString DBUS_INTERFACE = QString::fromAscii( "com.transmissionbt.Transmission" ); - const char * MY_CONFIG_NAME( "transmission" ); const char * MY_READABLE_NAME( "transmission-qt" ); - const tr_option opts[] = { { 'g', "config-dir", "Where to look for configuration files", "g", 1, "" }, @@ -91,6 +89,8 @@ MyApp :: MyApp( int& argc, char ** argv ): QApplication( argc, argv ), myLastFullUpdateTime( 0 ) { + const QString MY_CONFIG_NAME = QString::fromAscii( "transmission" ); + setApplicationName( MY_CONFIG_NAME ); // install the qt translator @@ -109,11 +109,10 @@ MyApp :: MyApp( int& argc, char ** argv ): // set the default icon QIcon icon; - icon.addPixmap( QPixmap( ":/icons/transmission-16.png" ) ); - icon.addPixmap( QPixmap( ":/icons/transmission-22.png" ) ); - icon.addPixmap( QPixmap( ":/icons/transmission-24.png" ) ); - icon.addPixmap( QPixmap( ":/icons/transmission-32.png" ) ); - icon.addPixmap( QPixmap( ":/icons/transmission-48.png" ) ); + QList sizes; + sizes << 16 << 22 << 24 << 32 << 48; + foreach( int size, sizes ) + icon.addPixmap( QPixmap( QString::fromAscii(":/icons/transmission-%1.png" ).arg(size) ) ); setWindowIcon( icon ); // parse the command-line arguments @@ -142,7 +141,7 @@ MyApp :: MyApp( int& argc, char ** argv ): // set the fallback config dir if( configDir == 0 ) - configDir = tr_getDefaultConfigDir( MY_CONFIG_NAME ); + configDir = tr_getDefaultConfigDir( "transmission" ); // ensure our config directory exists QDir dir( configDir ); @@ -249,9 +248,9 @@ MyApp :: MyApp( int& argc, char ** argv ): new TrDBusAdaptor( this ); QDBusConnection bus = QDBusConnection::sessionBus(); if( !bus.registerService( DBUS_SERVICE ) ) - std::cerr << "couldn't register " << DBUS_SERVICE << std::endl; + std::cerr << "couldn't register " << qPrintable(DBUS_SERVICE) << std::endl; if( !bus.registerObject( DBUS_OBJECT_PATH, this ) ) - std::cerr << "couldn't register " << DBUS_OBJECT_PATH << std::endl; + std::cerr << "couldn't register " << qPrintable(DBUS_OBJECT_PATH) << std::endl; } /* these functions are for popping up desktop notifications */ @@ -443,20 +442,20 @@ MyApp :: raise( ) bool MyApp :: notify( const QString& title, const QString& body ) const { - const QString dbusServiceName = "org.freedesktop.Notifications"; - const QString dbusInterfaceName = "org.freedesktop.Notifications"; - const QString dbusPath = "/org/freedesktop/Notifications"; + const QString dbusServiceName = QString::fromAscii( "org.freedesktop.Notifications" ); + const QString dbusInterfaceName = QString::fromAscii( "org.freedesktop.Notifications" ); + const QString dbusPath = QString::fromAscii( "/org/freedesktop/Notifications" ); - QDBusMessage m = QDBusMessage::createMethodCall(dbusServiceName, dbusPath, dbusInterfaceName, "Notify"); + QDBusMessage m = QDBusMessage::createMethodCall(dbusServiceName, dbusPath, dbusInterfaceName, QString::fromAscii("Notify")); QList args; - args.append( "Transmission" ); // app_name - args.append( 0U ); // replaces_id - args.append( "transmission" ); // icon - args.append( title ); // summary - args.append( body ); // body - args.append( QStringList( ) ); // actions - unused for plain passive popups - args.append( QVariantMap( ) ); // hints - unused atm - args.append( int32_t(-1) ); // use the default timeout period + args.append( QString::fromAscii( "Transmission" ) ); // app_name + args.append( 0U ); // replaces_id + args.append( QString::fromAscii( "transmission" ) ); // icon + args.append( title ); // summary + args.append( body ); // body + args.append( QStringList( ) ); // actions - unused for plain passive popups + args.append( QVariantMap( ) ); // hints - unused atm + args.append( int32_t(-1) ); // use the default timeout period m.setArguments( args ); QDBusMessage replyMsg = QDBusConnection::sessionBus().call(m); //std::cerr << qPrintable(replyMsg.errorName()) << std::endl; @@ -489,7 +488,7 @@ main( int argc, char * argv[] ) QDBusMessage request = QDBusMessage::createMethodCall( DBUS_SERVICE, DBUS_OBJECT_PATH, DBUS_INTERFACE, - "AddMetainfo" ); + QString::fromAscii("AddMetainfo") ); QList arguments; AddData a( addme[i] ); switch( a.type ) { diff --git a/qt/file-tree.cc b/qt/file-tree.cc index a252e7092..c0f580933 100644 --- a/qt/file-tree.cc +++ b/qt/file-tree.cc @@ -420,7 +420,7 @@ FileTreeModel :: addFile( int index, { FileTreeItem * i( rootItem ); - foreach( QString token, filename.split( "/" ) ) + foreach( QString token, filename.split( QChar::fromAscii('/') ) ) { FileTreeItem * child( i->child( token ) ); if( !child ) diff --git a/qt/make-dialog.cc b/qt/make-dialog.cc index 407642a3f..f718c8a69 100644 --- a/qt/make-dialog.cc +++ b/qt/make-dialog.cc @@ -56,10 +56,12 @@ MakeDialog :: onNewButtonBoxClicked( QAbstractButton * button ) { switch( myNewButtonBox->standardButton( button ) ) { - case QDialogButtonBox::Open: -std::cerr << "calling mySession.addTorrent( " << qPrintable(myTarget) << ", " << qPrintable(QFileInfo(myBuilder->top).dir().path()) << ')' << std::endl; - mySession.addNewlyCreatedTorrent( myTarget, QFileInfo(myBuilder->top).dir().path() ); + case QDialogButtonBox::Open: { + const QString top = QString::fromLocal8Bit( myBuilder->top ); +std::cerr << "calling mySession.addTorrent( " << qPrintable(myTarget) << ", " << qPrintable(QFileInfo(top).dir().path()) << ')' << std::endl; + mySession.addNewlyCreatedTorrent( myTarget, QFileInfo(top).dir().path() ); break; + } case QDialogButtonBox::Abort: myBuilder->abortFlag = true; break; @@ -79,20 +81,21 @@ MakeDialog :: onProgress( ) myNewProgress->setValue( (int) ((100.0 * b->pieceIndex) / denom ) ); // progress label - const QString base( QFileInfo(b->top).baseName() ); + const QString top = QString::fromLocal8Bit( myBuilder->top ); + const QString base( QFileInfo(top).baseName() ); QString str; if( !b->isDone ) str = tr( "Creating \"%1\"" ).arg( base ); else if( b->result == TR_MAKEMETA_OK ) str = tr( "Created \"%1\"!" ).arg( base ); else if( b->result == TR_MAKEMETA_URL ) - str = tr( "Error: invalid announce URL \"%1\"" ).arg( b->errfile ); + str = tr( "Error: invalid announce URL \"%1\"" ).arg( QString::fromLocal8Bit( b->errfile ) ); else if( b->result == TR_MAKEMETA_CANCELLED ) str = tr( "Cancelled" ); else if( b->result == TR_MAKEMETA_IO_READ ) - str = tr( "Error reading \"%1\": %2" ).arg( b->errfile ).arg( strerror(b->my_errno) ); + str = tr( "Error reading \"%1\": %2" ).arg( QString::fromLocal8Bit(b->errfile) ).arg( QString::fromLocal8Bit(strerror(b->my_errno)) ); else if( b->result == TR_MAKEMETA_IO_WRITE ) - str = tr( "Error writing \"%1\": %2" ).arg( b->errfile ).arg( strerror(b->my_errno) ); + str = tr( "Error writing \"%1\": %2" ).arg( QString::fromLocal8Bit(b->errfile) ).arg( QString::fromLocal8Bit(strerror(b->my_errno)) ); myNewLabel->setText( str ); // buttons @@ -111,7 +114,7 @@ MakeDialog :: makeTorrent( ) // get the tiers int tier = 0; QList trackers; - foreach( QString line, myTrackerEdit->toPlainText().split("\n") ) { + foreach( QString line, myTrackerEdit->toPlainText().split(QChar::fromAscii('\n')) ) { line = line.trimmed( ); if( line.isEmpty( ) ) ++tier; @@ -144,13 +147,15 @@ MakeDialog :: makeTorrent( ) myTimer.start( 100 ); // the file to create - myTarget = QDir( myDestination ).filePath( QFileInfo(myBuilder->top).baseName() + ".torrent" ); + const QString path = QString::fromLocal8Bit( myBuilder->top ); + const QString torrentName = QFileInfo(path).baseName() + QString::fromAscii(".torrent"); + myTarget = QDir( myDestination ).filePath( torrentName ); std::cerr << qPrintable(myTarget) << std::endl; // comment QString comment; if( myCommentCheck->isChecked() ) - comment = myCommentEdit->text().toUtf8().constData(); + comment = myCommentEdit->text(); // start making the torrent tr_makeMetaInfo( myBuilder, @@ -333,7 +338,7 @@ MakeDialog :: MakeDialog( Session & session, QWidget * parent ): const QPixmap folderPixmap = folderIcon.pixmap( iconSize ); QPushButton * b = new QPushButton; b->setIcon( folderPixmap ); - b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" ); + b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); myDestination = QDir::homePath(); b->setText( myDestination ); connect( b, SIGNAL(clicked(bool)), @@ -347,7 +352,7 @@ MakeDialog :: MakeDialog( Session & session, QWidget * parent ): myFolderButton = new QPushButton; myFolderButton->setIcon( folderPixmap ); myFolderButton->setText( tr( "(None)" ) ); - myFolderButton->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" ); + myFolderButton->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); connect( myFolderButton, SIGNAL(clicked(bool)), this, SLOT(onFolderClicked(void)) ); hig->addRow( myFolderRadio, myFolderButton ); @@ -362,7 +367,7 @@ MakeDialog :: MakeDialog( Session & session, QWidget * parent ): myFileButton = new QPushButton; myFileButton->setText( tr( "(None)" ) ); myFileButton->setIcon( filePixmap ); - myFileButton->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" ); + myFileButton->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); connect( myFileButton, SIGNAL(clicked(bool)), this, SLOT(onFileClicked(void)) ); hig->addRow( myFileRadio, myFileButton ); @@ -375,7 +380,7 @@ MakeDialog :: MakeDialog( Session & session, QWidget * parent ): hig->addSectionTitle( tr( "Properties" ) ); hig->addWideControl( myTrackerEdit = new ShortPlainTextEdit ); - const int height = fontMetrics().size( 0, "\n\n\n\n" ).height( ); + const int height = fontMetrics().size( 0, QString::fromAscii("\n\n\n\n") ).height( ); myTrackerEdit->setMinimumHeight( height ); hig->addTallRow( tr( "&Trackers:" ), myTrackerEdit ); QLabel * l = new QLabel( tr( "To add a backup URL, add it on the line after the primary URL.\nTo add another primary URL, add it after a blank line." ) ); diff --git a/qt/options.cc b/qt/options.cc index 8c83db996..b66a863c4 100644 --- a/qt/options.cc +++ b/qt/options.cc @@ -97,13 +97,13 @@ Options :: Options( Session& session, const Prefs& prefs, const AddData& addme, const QPixmap filePixmap = fileIcon.pixmap( iconSize ); QPushButton * p; - int width = fontMetrics.size( 0, "This is a pretty long torrent filename indeed.torrent" ).width( ); + int width = fontMetrics.size( 0, QString::fromAscii( "This is a pretty long torrent filename indeed.torrent" ) ).width( ); QLabel * l = new QLabel( tr( "&Torrent file:" ) ); layout->addWidget( l, row, 0, Qt::AlignLeft ); p = myFileButton = new QPushButton; p->setIcon( filePixmap ); p->setMinimumWidth( width ); - p->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" ); + p->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); p->installEventFilter( this ); layout->addWidget( p, row, 1 ); diff --git a/qt/prefs-dialog.cc b/qt/prefs-dialog.cc index 71b2e8e99..8c0828a25 100644 --- a/qt/prefs-dialog.cc +++ b/qt/prefs-dialog.cc @@ -134,7 +134,7 @@ PrefsDialog :: timeEditNew( int key ) { const int minutes( myPrefs.getInt( key ) ); QTimeEdit * e = new QTimeEdit( ); - e->setDisplayFormat( "hh:mm" ); + e->setDisplayFormat( QString::fromAscii( "hh:mm" ) ); e->setProperty( PREF_KEY, key ); e->setTime( QTime().addSecs( minutes * 60 ) ); myWidgets.insert( key, e ); @@ -232,11 +232,11 @@ PrefsDialog :: createSpeedTab( ) QHBoxLayout * h = new QHBoxLayout; h->setSpacing( HIG :: PAD ); QLabel * label = new QLabel; - label->setPixmap( QPixmap( ":/icons/alt-limit-off.png" ) ); + label->setPixmap( QPixmap( QString::fromAscii( ":/icons/alt-limit-off.png" ) ) ); label->setAlignment( Qt::AlignLeft|Qt::AlignVCenter ); h->addWidget( label ); label = new QLabel( tr( "Temporary Speed Limits" ) ); - label->setStyleSheet( "font: bold" ); + label->setStyleSheet( QString::fromAscii( "font: bold" ) ); label->setAlignment( Qt::AlignLeft|Qt::AlignVCenter ); h->addWidget( label ); hig->addSectionTitle( h ); @@ -346,7 +346,7 @@ PrefsDialog :: createNetworkTab( ) connect( &mySession, SIGNAL(portTested(bool)), this, SLOT(onPortTested(bool))); hig->addRow( tr( "&Port for incoming connections:" ), s ); - hig->addRow( "", h, 0 ); + hig->addRow( QString(), h, 0 ); hig->addWideControl( checkBoxNew( tr( "Pick a &random port every time Transmission is started" ), Prefs :: PEER_PORT_RANDOM_ON_START ) ); hig->addWideControl( checkBoxNew( tr( "Use UPnP or NAT-PMP port &forwarding from my router" ), Prefs::PORT_FORWARDING ) ); @@ -396,7 +396,7 @@ void PrefsDialog :: onUpdateBlocklistClicked( ) { myBlocklistDialog = new QMessageBox( QMessageBox::Information, - "", + QString(), tr( "Update Blocklist

Getting new blocklist..." ), QMessageBox::Close, this ); @@ -426,7 +426,7 @@ PrefsDialog :: createPrivacyTab( ) myBlockWidgets << e; hig->addRow( l, e ); - l = myBlocklistLabel = new QLabel( "" ); + l = myBlocklistLabel = new QLabel( ); myBlockWidgets << l; w = new QPushButton( tr( "&Update" ) ); connect( w, SIGNAL(clicked(bool)), this, SLOT(onUpdateBlocklistClicked())); @@ -539,7 +539,7 @@ PrefsDialog :: createTorrentsTab( ) l = checkBoxNew( tr( "Automatically &add torrents from:" ), Prefs::DIR_WATCH_ENABLED ); QPushButton * b = myWatchButton = new QPushButton; b->setIcon( folderPixmap ); - b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" ); + b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); connect( b, SIGNAL(clicked(bool)), this, SLOT(onWatchClicked(void)) ); hig->addRow( l, b ); enableBuddyWhenChecked( qobject_cast(l), b ); @@ -577,7 +577,7 @@ PrefsDialog :: createDownloadTab( ) QPushButton * b = myDestinationButton = new QPushButton; b->setIcon( folderPixmap ); - b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" ); + b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); connect( b, SIGNAL(clicked(bool)), this, SLOT(onDestinationClicked(void)) ); hig->addRow( tr( "Save to &Location:" ), b ); @@ -595,7 +595,7 @@ PrefsDialog :: createDownloadTab( ) l = myIncompleteCheckbox = checkBoxNew( tr( "Keep &incomplete files in:" ), Prefs::INCOMPLETE_DIR_ENABLED ); b = myIncompleteButton = new QPushButton; b->setIcon( folderPixmap ); - b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" ); + b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); connect( b, SIGNAL(clicked(bool)), this, SLOT(onIncompleteClicked(void)) ); hig->addRow( myIncompleteCheckbox, b ); enableBuddyWhenChecked( qobject_cast(l), b ); @@ -603,7 +603,7 @@ PrefsDialog :: createDownloadTab( ) l = myTorrentDoneScriptCheckbox = checkBoxNew( tr( "Call scrip&t when torrent is completed:" ), Prefs::SCRIPT_TORRENT_DONE_ENABLED ); b = myTorrentDoneScriptButton = new QPushButton; b->setIcon( filePixmap ); - b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" ); + b->setStyleSheet( QString::fromAscii( "text-align: left; padding-left: 5; padding-right: 5" ) ); connect( b, SIGNAL(clicked(bool)), this, SLOT(onScriptClicked(void)) ); hig->addRow( myTorrentDoneScriptCheckbox, b ); enableBuddyWhenChecked( qobject_cast(l), b ); diff --git a/qt/relocate.cc b/qt/relocate.cc index 50879773e..16e460e3b 100644 --- a/qt/relocate.cc +++ b/qt/relocate.cc @@ -84,7 +84,7 @@ RelocateDialog :: RelocateDialog( Session& session, TorrentModel& model, const Q if( mySession.isServer() ) myPath = QDir::homePath( ); else - myPath = QString( "/" ); + myPath = QDir::rootPath( ); } } diff --git a/qt/torrent-delegate.cc b/qt/torrent-delegate.cc index 99ea94f8e..541520a3d 100644 --- a/qt/torrent-delegate.cc +++ b/qt/torrent-delegate.cc @@ -246,7 +246,7 @@ TorrentDelegate :: statusString( const Torrent& tor ) const break; default: - str = "Error"; + str = tr( "Error" ); break; } diff --git a/qt/torrent.cc b/qt/torrent.cc index 540d6d407..cad2b9458 100644 --- a/qt/torrent.cc +++ b/qt/torrent.cc @@ -564,7 +564,7 @@ Torrent :: update( tr_benc * d ) tr_benc * child; while(( child = tr_bencListChild( trackers, i++ ))) { if( tr_bencDictFindStr( child, "announce", &str )) { - dynamic_cast(QApplication::instance())->favicons.add( QUrl(str) ); + dynamic_cast(QApplication::instance())->favicons.add( QUrl(QString::fromUtf8(str)) ); list.append( QString::fromUtf8( str ) ); } } @@ -605,7 +605,7 @@ Torrent :: update( tr_benc * d ) if( tr_bencDictFindInt( child, "lastAnnouncePeerCount", &i ) ) trackerStat.lastAnnouncePeerCount = i; if( tr_bencDictFindStr( child, "lastAnnounceResult", &str ) ) - trackerStat.lastAnnounceResult = str; + trackerStat.lastAnnounceResult = QString::fromUtf8(str); if( tr_bencDictFindInt( child, "lastAnnounceStartTime", &i ) ) trackerStat.lastAnnounceStartTime = i; if( tr_bencDictFindBool( child, "lastAnnounceSucceeded", &b ) ) diff --git a/qt/utils.cc b/qt/utils.cc index 976e7385d..0b3a5d968 100644 --- a/qt/utils.cc +++ b/qt/utils.cc @@ -67,33 +67,46 @@ Utils :: guessMimeIcon( const QString& filename ) { fallback = QApplication::style()->standardIcon( QStyle :: SP_FileIcon ); - fileIcons[DISK]= QIcon::fromTheme( "media-optical", fallback ); - suffixes[DISK] << "iso"; - - fileIcons[DOCUMENT] = QIcon::fromTheme( "text-x-generic", fallback ); - suffixes[DOCUMENT] << "abw" << "csv" << "doc" << "dvi" << "htm" << "html" << "ini" << "log" - << "odp" << "ods" << "odt" << "pdf" << "ppt" << "ps" << "rtf" << "tex" - << "txt" << "xml"; - - fileIcons[PICTURE] = QIcon::fromTheme( "image-x-generic", fallback ); - suffixes[PICTURE] << "bmp" << "gif" << "jpg" << "jpeg" << "pcx" << "png" << "psd" << "raw" - << "tga" << "tiff"; - - fileIcons[VIDEO] = QIcon::fromTheme( "video-x-generic", fallback ); - suffixes[VIDEO] << "3gp" << "asf" << "avi" << "mov" << "mpeg" << "mpg" << "mp4" << "mkv" - << "mov" << "ogm" << "ogv" << "qt" << "rm" << "wmv"; - - fileIcons[ARCHIVE] = QIcon::fromTheme( "package-x-generic", fallback ); - suffixes[ARCHIVE] << "7z" << "ace" << "bz2" << "cbz" << "gz" << "gzip" << "lzma" << "rar" - << "sft" << "tar" << "zip"; - - fileIcons[AUDIO] = QIcon::fromTheme( "audio-x-generic", fallback ); - suffixes[AUDIO] << "aac" << "ac3" << "aiff" << "ape" << "au" << "flac" << "m3u" << "m4a" - << "mid" << "midi" << "mp2" << "mp3" << "mpc" << "nsf" << "oga" << "ogg" - << "ra" << "ram" << "shn" << "voc" << "wav" << "wma"; - - fileIcons[APP] = QIcon::fromTheme( "application-x-executable", fallback ); - suffixes[APP] << "bat" << "cmd" << "com" << "exe"; + suffixes[DISK] << QString::fromAscii("iso"); + fileIcons[DISK]= QIcon::fromTheme( QString::fromAscii("media-optical"), fallback ); + + const char * doc_types[] = { + "abw", "csv", "doc", "dvi", "htm", "html", "ini", "log", "odp", + "ods", "odt", "pdf", "ppt", "ps", "rtf", "tex", "txt", "xml" }; + for( int i=0, n=sizeof(doc_types)/sizeof(doc_types[0]); i newFiles( files - myWatchDirFiles ); + const QString torrentSuffix = QString::fromAscii( ".torrent" ); foreach( QString name, newFiles ) { - if( name.endsWith( ".torrent", Qt::CaseInsensitive ) ) { + if( name.endsWith( torrentSuffix, Qt::CaseInsensitive ) ) { const QString filename = dir.absoluteFilePath( name ); switch( metainfoTest( filename ) ) { case OK: