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( "<big>Transmission " LONG_VERSION_STRING "</big>" );
+ l = new QLabel( tr( "<big>Transmission %1</big>" ).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 );
l->setAlignment( Qt::AlignCenter );
v->addWidget( l );
- l = new QLabel( "<a href=\"http://www.transmissionbt.com/\">http://www.transmissionbt.com/</a>" );
+ l = new QLabel( QString::fromAscii( "<a href=\"http://www.transmissionbt.com/\">http://www.transmissionbt.com/</a>" ) );
l->setOpenExternalLinks( true );
l->setAlignment( Qt::AlignCenter );
v->addWidget( l );
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)" ) );
}
magnet = key;
type = MAGNET;
}
- else if ( Utils::isURL( key ) )
+ else if ( Utils::isUriWithSupportedScheme( key ) )
{
url = key;
type = URL;
}
else if( Utils::isHexHashcode( key ) )
{
- magnet = QString("magnet:?xt=urn:btih:") + key;
+ magnet = QString::fromAscii("magnet:?xt=urn:btih:") + key;
type = MAGNET;
}
else
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 );
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, "<path>" },
QApplication( argc, argv ),
myLastFullUpdateTime( 0 )
{
+ const QString MY_CONFIG_NAME = QString::fromAscii( "transmission" );
+
setApplicationName( MY_CONFIG_NAME );
// install the qt translator
// 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<int> 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
// 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 );
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 */
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<QVariant> 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;
QDBusMessage request = QDBusMessage::createMethodCall( DBUS_SERVICE,
DBUS_OBJECT_PATH,
DBUS_INTERFACE,
- "AddMetainfo" );
+ QString::fromAscii("AddMetainfo") );
QList<QVariant> arguments;
AddData a( addme[i] );
switch( a.type ) {
{
FileTreeItem * i( rootItem );
- foreach( QString token, filename.split( "/" ) )
+ foreach( QString token, filename.split( QChar::fromAscii('/') ) )
{
FileTreeItem * child( i->child( token ) );
if( !child )
{
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;
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
// get the tiers
int tier = 0;
QList<tr_tracker_info> trackers;
- foreach( QString line, myTrackerEdit->toPlainText().split("\n") ) {
+ foreach( QString line, myTrackerEdit->toPlainText().split(QChar::fromAscii('\n')) ) {
line = line.trimmed( );
if( line.isEmpty( ) )
++tier;
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,
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)),
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 );
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 );
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." ) );
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 );
{
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 );
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 );
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 ) );
PrefsDialog :: onUpdateBlocklistClicked( )
{
myBlocklistDialog = new QMessageBox( QMessageBox::Information,
- "",
+ QString(),
tr( "<b>Update Blocklist</b><p>Getting new blocklist..." ),
QMessageBox::Close,
this );
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()));
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<QCheckBox*>(l), b );
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 );
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<QCheckBox*>(l), b );
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<QCheckBox*>(l), b );
if( mySession.isServer() )
myPath = QDir::homePath( );
else
- myPath = QString( "/" );
+ myPath = QDir::rootPath( );
}
}
break;
default:
- str = "Error";
+ str = tr( "Error" );
break;
}
tr_benc * child;
while(( child = tr_bencListChild( trackers, i++ ))) {
if( tr_bencDictFindStr( child, "announce", &str )) {
- dynamic_cast<MyApp*>(QApplication::instance())->favicons.add( QUrl(str) );
+ dynamic_cast<MyApp*>(QApplication::instance())->favicons.add( QUrl(QString::fromUtf8(str)) );
list.append( QString::fromUtf8( str ) );
}
}
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 ) )
{
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<n; ++i )
+ suffixes[DOCUMENT] << QString::fromAscii(doc_types[i] );
+ fileIcons[DOCUMENT] = QIcon::fromTheme( QString::fromAscii("text-x-generic"), fallback );
+
+ const char * pic_types[] = {
+ "bmp", "gif", "jpg", "jpeg", "pcx", "png", "psd", "ras", "tga", "tiff" };
+ for( int i=0, n=sizeof(pic_types)/sizeof(pic_types[0]); i<n; ++i )
+ suffixes[PICTURE] << QString::fromAscii(pic_types[i]);
+ fileIcons[PICTURE] = QIcon::fromTheme( QString::fromAscii("image-x-generic"), fallback );
+
+ const char * vid_types[] = {
+ "3gp", "asf", "avi", "mov", "mpeg", "mpg", "mp4" "mkv", "mov",
+ "ogm", "ogv", "qt", "rm", "wmv" };
+ for( int i=0, n=sizeof(vid_types)/sizeof(vid_types[0]); i<n; ++i )
+ suffixes[VIDEO] << QString::fromAscii(vid_types[i]);
+ fileIcons[VIDEO] = QIcon::fromTheme( QString::fromAscii("video-x-generic"), fallback );
+
+ const char * arc_types[] = {
+ "7z", "ace", "bz2", "cbz", "gz", "gzip", "lzma", "rar", "sft", "tar", "zip" };
+ for( int i=0, n=sizeof(arc_types)/sizeof(arc_types[0]); i<n; ++i )
+ suffixes[VIDEO] << QString::fromAscii(arc_types[i]);
+ fileIcons[ARCHIVE] = QIcon::fromTheme( QString::fromAscii("package-x-generic"), fallback );
+
+ const char * aud_types[] = {
+ "aac", "ac3", "aiff", "ape", "au", "flac", "m3u", "m4a", "mid", "midi", "mp2",
+ "mp3", "mpc", "nsf", "oga", "ogg", "ra", "ram", "shn", "voc", "wav", "wma" };
+ for( int i=0, n=sizeof(aud_types)/sizeof(aud_types[0]); i<n; ++i )
+ suffixes[AUDIO] << QString::fromAscii(aud_types[i]);
+ fileIcons[AUDIO] = QIcon::fromTheme( QString::fromAscii("audio-x-generic"), fallback );
+
+ const char * exe_types[] = { "bat", "cmd", "com", "exe" };
+ for( int i=0, n=sizeof(exe_types)/sizeof(exe_types[0]); i<n; ++i )
+ suffixes[APP] << QString::fromAscii(exe_types[i]);
+ fileIcons[APP] = QIcon::fromTheme( QString::fromAscii("application-x-executable"), fallback );
}
QString suffix( QFileInfo( filename ).suffix( ).toLower( ) );
/// URLs
///
- static bool isMagnetLink( const QString& s ) { return s.startsWith( "magnet:?" ); }
+ static bool isMagnetLink( const QString& s ) { return s.startsWith( QString::fromAscii( "magnet:?" ) ); }
static bool isHexHashcode( const QString& s )
{
return true;
}
- static bool isURL( const QString& s ) { return s.startsWith( "http://" )
- || s.startsWith( "https://" )
- || s.startsWith( "ftp://" ); }
+ static bool isUriWithSupportedScheme( const QString& s )
+ {
+ static const QString ftp = QString::fromAscii( "ftp://" );
+ static const QString http = QString::fromAscii( "http://" );
+ static const QString https = QString::fromAscii( "https://" );
+ return s.startsWith(http) || s.startsWith(https) || s.startsWith(ftp);
+ }
};
const int err = tr_torrentParse( ctor, &inf );
if( err )
ret = ERROR;
- else if( myModel.hasTorrent( inf.hashString ) )
+ else if( myModel.hasTorrent( QString::fromAscii( inf.hashString ) ) )
ret = DUPLICATE;
else
ret = OK;
// try to add any new files which end in .torrent
const QSet<QString> 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: