Browse Source

More code cleanup

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
aec99ed14f
  1. 33
      src/bittorrent.cpp
  2. 8
      src/downloadthread.cpp
  3. 28
      src/engineselectdlg.cpp
  4. 4
      src/feeddownloader.h
  5. 8
      src/filesystemwatcher.h
  6. 6
      src/geoip.h
  7. 31
      src/headlessloader.h
  8. 10
      src/httpconnection.cpp
  9. 2
      src/main.cpp
  10. 8
      src/qtorrenthandle.cpp
  11. 8
      src/rss_imp.cpp
  12. 10
      src/searchengine.cpp
  13. 4
      src/searchengine.h
  14. 46
      src/torrentadditiondlg.h
  15. 8
      src/torrentfilesmodel.h
  16. 14
      src/torrentpersistentdata.h
  17. 32
      src/transferlistfilterswidget.h
  18. 6
      src/transferlistwidget.cpp

33
src/bittorrent.cpp

@ -108,9 +108,9 @@ Bittorrent::Bittorrent()
} }
} }
// Construct session // Construct session
s = new session(fingerprint(peer_id.toLocal8Bit().data(), version.at(0), version.at(1), version.at(2), version.at(3)), 0); s = new session(fingerprint(peer_id.toLocal8Bit().constData(), version.at(0), version.at(1), version.at(2), version.at(3)), 0);
std::cout << "Peer ID: " << fingerprint(peer_id.toLocal8Bit().data(), version.at(0), version.at(1), version.at(2), version.at(3)).to_string() << std::endl; std::cout << "Peer ID: " << fingerprint(peer_id.toLocal8Bit().constData(), version.at(0), version.at(1), version.at(2), version.at(3)).to_string() << std::endl;
addConsoleMessage("Peer ID: "+misc::toQString(fingerprint(peer_id.toLocal8Bit().data(), version.at(0), version.at(1), version.at(2), version.at(3)).to_string())); addConsoleMessage("Peer ID: "+misc::toQString(fingerprint(peer_id.toLocal8Bit().constData(), version.at(0), version.at(1), version.at(2), version.at(3)).to_string()));
// Set severity level of libtorrent session // Set severity level of libtorrent session
s->set_alert_mask(alert::error_notification | alert::peer_notification | alert::port_mapping_notification | alert::storage_notification | alert::tracker_notification | alert::status_notification | alert::ip_block_notification); s->set_alert_mask(alert::error_notification | alert::peer_notification | alert::port_mapping_notification | alert::storage_notification | alert::tracker_notification | alert::status_notification | alert::ip_block_notification);
@ -718,7 +718,7 @@ void Bittorrent::banIP(QString ip) {
// Delete a torrent from the session, given its hash // Delete a torrent from the session, given its hash
// permanent = true means that the torrent will be removed from the hard-drive too // permanent = true means that the torrent will be removed from the hard-drive too
void Bittorrent::deleteTorrent(QString hash, bool delete_local_files) { void Bittorrent::deleteTorrent(QString hash, bool delete_local_files) {
qDebug("Deleting torrent with hash: %s", hash.toLocal8Bit().data()); qDebug("Deleting torrent with hash: %s", qPrintable(hash));
const QTorrentHandle &h = getTorrentHandle(hash); const QTorrentHandle &h = getTorrentHandle(hash);
if(!h.is_valid()) { if(!h.is_valid()) {
qDebug("/!\\ Error: Invalid handle"); qDebug("/!\\ Error: Invalid handle");
@ -799,7 +799,7 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
} }
const QDir &torrentBackup(misc::BTBackupLocation()); const QDir &torrentBackup(misc::BTBackupLocation());
if(resumed) { if(resumed) {
qDebug("Resuming magnet URI: %s", hash.toLocal8Bit().data()); qDebug("Resuming magnet URI: %s", qPrintable(hash));
// Load metadata // Load metadata
if(QFile::exists(torrentBackup.path()+QDir::separator()+hash+QString(".torrent"))) if(QFile::exists(torrentBackup.path()+QDir::separator()+hash+QString(".torrent")))
return addTorrent(torrentBackup.path()+QDir::separator()+hash+QString(".torrent"), false, false, true); return addTorrent(torrentBackup.path()+QDir::separator()+hash+QString(".torrent"), false, false, true);
@ -811,7 +811,7 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
Q_ASSERT(magnet_uri.startsWith("magnet:")); Q_ASSERT(magnet_uri.startsWith("magnet:"));
// Check if torrent is already in download list // Check if torrent is already in download list
if(s->find_torrent(sha1_hash(hash.toLocal8Bit().data())).is_valid()) { if(s->find_torrent(sha1_hash(hash.toLocal8Bit().constData())).is_valid()) {
qDebug("/!\\ Torrent is already in download list"); qDebug("/!\\ Torrent is already in download list");
// Update info Bar // Update info Bar
addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(magnet_uri)); addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(magnet_uri));
@ -822,8 +822,8 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
//Getting fast resume data if existing //Getting fast resume data if existing
std::vector<char> buf; std::vector<char> buf;
if(resumed) { if(resumed) {
qDebug("Trying to load fastresume data: %s", (torrentBackup.path()+QDir::separator()+hash+QString(".fastresume")).toLocal8Bit().data()); qDebug("Trying to load fastresume data: %s", qPrintable(torrentBackup.path()+QDir::separator()+hash+QString(".fastresume")));
if (load_file((torrentBackup.path()+QDir::separator()+hash+QString(".fastresume")).toLocal8Bit().data(), buf) == 0) { if (load_file((torrentBackup.path()+QDir::separator()+hash+QString(".fastresume")).toLocal8Bit().constData(), buf) == 0) {
fastResume = true; fastResume = true;
p.resume_data = &buf; p.resume_data = &buf;
qDebug("Successfuly loaded"); qDebug("Successfuly loaded");
@ -929,7 +929,7 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
// create it if it is not // create it if it is not
if(! torrentBackup.exists()) { if(! torrentBackup.exists()) {
if(! torrentBackup.mkpath(torrentBackup.path())) { if(! torrentBackup.mkpath(torrentBackup.path())) {
std::cerr << "Couldn't create the directory: '" << torrentBackup.path().toLocal8Bit().data() << "'\n"; std::cerr << "Couldn't create the directory: '" << qPrintable(torrentBackup.path()) << "'\n";
exit(1); exit(1);
} }
} }
@ -1030,8 +1030,8 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
//Getting fast resume data if existing //Getting fast resume data if existing
std::vector<char> buf; std::vector<char> buf;
if(resumed) { if(resumed) {
qDebug("Trying to load fastresume data: %s", (torrentBackup.path()+QDir::separator()+hash+QString(".fastresume")).toLocal8Bit().data()); qDebug("Trying to load fastresume data: %s", qPrintable(torrentBackup.path()+QDir::separator()+hash+QString(".fastresume")));
if (load_file((torrentBackup.path()+QDir::separator()+hash+QString(".fastresume")).toLocal8Bit().data(), buf) == 0) { if (load_file((torrentBackup.path()+QDir::separator()+hash+QString(".fastresume")).toLocal8Bit().constData(), buf) == 0) {
fastResume = true; fastResume = true;
p.resume_data = &buf; p.resume_data = &buf;
qDebug("Successfuly loaded"); qDebug("Successfuly loaded");
@ -1130,7 +1130,7 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
} }
// Save save_path // Save save_path
if(!defaultTempPath.isEmpty()) { if(!defaultTempPath.isEmpty()) {
qDebug("addTorrent: Saving save_path in persistent data: %s", savePath.toLocal8Bit().data()); qDebug("addTorrent: Saving save_path in persistent data: %s", qPrintable(savePath));
TorrentPersistentData::saveSavePath(hash, savePath); TorrentPersistentData::saveSavePath(hash, savePath);
} }
#ifdef LIBTORRENT_0_15 #ifdef LIBTORRENT_0_15
@ -1315,7 +1315,7 @@ void Bittorrent::enableLSD(bool b) {
} }
void Bittorrent::loadSessionState() { void Bittorrent::loadSessionState() {
boost::filesystem::ifstream ses_state_file((misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state")).toLocal8Bit().data() boost::filesystem::ifstream ses_state_file((misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state")).toLocal8Bit().constData()
, std::ios_base::binary); , std::ios_base::binary);
ses_state_file.unsetf(std::ios_base::skipws); ses_state_file.unsetf(std::ios_base::skipws);
s->load_state(bdecode( s->load_state(bdecode(
@ -1326,7 +1326,7 @@ void Bittorrent::loadSessionState() {
void Bittorrent::saveSessionState() { void Bittorrent::saveSessionState() {
qDebug("Saving session state to disk..."); qDebug("Saving session state to disk...");
entry session_state = s->state(); entry session_state = s->state();
boost::filesystem::ofstream out((misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state")).toLocal8Bit().data() boost::filesystem::ofstream out((misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state")).toLocal8Bit().constData()
, std::ios_base::binary); , std::ios_base::binary);
out.unsetf(std::ios_base::skipws); out.unsetf(std::ios_base::skipws);
bencode(std::ostream_iterator<char>(out), session_state); bencode(std::ostream_iterator<char>(out), session_state);
@ -1339,7 +1339,7 @@ bool Bittorrent::enableDHT(bool b) {
entry dht_state; entry dht_state;
const QString &dht_state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state"); const QString &dht_state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state");
if(QFile::exists(dht_state_path)) { if(QFile::exists(dht_state_path)) {
boost::filesystem::ifstream dht_state_file(dht_state_path.toLocal8Bit().data(), std::ios_base::binary); boost::filesystem::ifstream dht_state_file(dht_state_path.toLocal8Bit().constData(), std::ios_base::binary);
dht_state_file.unsetf(std::ios_base::skipws); dht_state_file.unsetf(std::ios_base::skipws);
try{ try{
dht_state = bdecode(std::istream_iterator<char>(dht_state_file), std::istream_iterator<char>()); dht_state = bdecode(std::istream_iterator<char>(dht_state_file), std::istream_iterator<char>());
@ -1498,7 +1498,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
foreach(const QString &file, pathList) { foreach(const QString &file, pathList) {
qDebug("File %s added", qPrintable(file)); qDebug("File %s added", qPrintable(file));
try { try {
torrent_info t(file.toLocal8Bit().data()); torrent_info t(file.toLocal8Bit().constData());
if(t.is_valid()) if(t.is_valid())
addTorrent(file, true); addTorrent(file, true);
} catch(std::exception&) { } catch(std::exception&) {
@ -1954,7 +1954,6 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
#endif #endif
/*else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) { /*else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
qDebug("Received a torrent_paused_alert for %s", h.hash().toLocal8Bit().data());
if(h.is_valid()) { if(h.is_valid()) {
emit torrentPaused(h); emit torrentPaused(h);
} }

8
src/downloadthread.cpp

@ -59,7 +59,7 @@ void downloadThread::processDlFinished(QNetworkReply* reply) {
QVariant redirection = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); QVariant redirection = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
if(redirection.isValid()) { if(redirection.isValid()) {
// We should redirect // We should redirect
qDebug("Redirecting from %s to %s", url.toLocal8Bit().data(), redirection.toUrl().toString().toLocal8Bit().data()); qDebug("Redirecting from %s to %s", qPrintable(url), qPrintable(redirection.toUrl().toString()));
redirect_mapping.insert(redirection.toUrl().toString(), url); redirect_mapping.insert(redirection.toUrl().toString(), url);
downloadUrl(redirection.toUrl().toString()); downloadUrl(redirection.toUrl().toString());
return; return;
@ -74,7 +74,7 @@ void downloadThread::processDlFinished(QNetworkReply* reply) {
tmpfile.setAutoRemove(false); tmpfile.setAutoRemove(false);
if (tmpfile.open()) { if (tmpfile.open()) {
filePath = tmpfile.fileName(); filePath = tmpfile.fileName();
qDebug("Temporary filename is: %s", filePath.toLocal8Bit().data()); qDebug("Temporary filename is: %s", qPrintable(filePath));
if(reply->open(QIODevice::ReadOnly)) { if(reply->open(QIODevice::ReadOnly)) {
// TODO: Support GZIP compression // TODO: Support GZIP compression
tmpfile.write(reply->readAll()); tmpfile.write(reply->readAll());
@ -104,7 +104,7 @@ void downloadThread::downloadUrl(QString url){
// Spoof Firefox 3.5 user agent to avoid // Spoof Firefox 3.5 user agent to avoid
// Web server banning // Web server banning
request.setRawHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5"); request.setRawHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5");
qDebug("Downloading %s...", request.url().toString().toLocal8Bit().data()); qDebug("Downloading %s...", qPrintable(request.url().toString()));
networkManager->get(request); networkManager->get(request);
} }
@ -117,7 +117,7 @@ void downloadThread::applyProxySettings() {
QString IP = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/IP"), "0.0.0.0").toString(); QString IP = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/IP"), "0.0.0.0").toString();
proxy.setHostName(IP); proxy.setHostName(IP);
QString port = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Port"), 8080).toString(); QString port = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Port"), 8080).toString();
qDebug("Using proxy: %s", (IP+QString(":")+port).toLocal8Bit().data()); qDebug("Using proxy: %s", qPrintable(IP+QString(":")+port));
proxy.setPort(port.toUShort()); proxy.setPort(port.toUShort());
// Default proxy type is HTTP, we must change if it is SOCKS5 // Default proxy type is HTTP, we must change if it is SOCKS5
if(intValue == SOCKS5 || intValue == SOCKS5_PW) { if(intValue == SOCKS5 || intValue == SOCKS5_PW) {

28
src/engineselectdlg.cpp

@ -81,7 +81,7 @@ void engineSelectDlg::dropEvent(QDropEvent *event) {
QStringList files=event->mimeData()->text().split(QString::fromUtf8("\n")); QStringList files=event->mimeData()->text().split(QString::fromUtf8("\n"));
QString file; QString file;
foreach(file, files) { foreach(file, files) {
qDebug("dropped %s", file.toLocal8Bit().data()); qDebug("dropped %s", qPrintable(file));
file = file.replace("file://", ""); file = file.replace("file://", "");
if(file.startsWith("http://", Qt::CaseInsensitive) || file.startsWith("https://", Qt::CaseInsensitive) || file.startsWith("ftp://", Qt::CaseInsensitive)) { if(file.startsWith("http://", Qt::CaseInsensitive) || file.startsWith("https://", Qt::CaseInsensitive) || file.startsWith("ftp://", Qt::CaseInsensitive)) {
downloader->downloadUrl(file); downloader->downloadUrl(file);
@ -99,7 +99,7 @@ void engineSelectDlg::dropEvent(QDropEvent *event) {
void engineSelectDlg::dragEnterEvent(QDragEnterEvent *event) { void engineSelectDlg::dragEnterEvent(QDragEnterEvent *event) {
QString mime; QString mime;
foreach(mime, event->mimeData()->formats()){ foreach(mime, event->mimeData()->formats()){
qDebug("mimeData: %s", mime.toLocal8Bit().data()); qDebug("mimeData: %s", qPrintable(mime));
} }
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) { if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) {
event->acceptProposedAction(); event->acceptProposedAction();
@ -251,12 +251,12 @@ bool engineSelectDlg::isUpdateNeeded(QString plugin_name, float new_version) con
} }
void engineSelectDlg::installPlugin(QString path, QString plugin_name) { void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
qDebug("Asked to install plugin at %s", path.toLocal8Bit().data()); qDebug("Asked to install plugin at %s", qPrintable(path));
float new_version = SearchEngine::getPluginVersion(path); float new_version = SearchEngine::getPluginVersion(path);
qDebug("Version to be installed: %.2f", new_version); qDebug("Version to be installed: %.2f", new_version);
if(!isUpdateNeeded(plugin_name, new_version)) { if(!isUpdateNeeded(plugin_name, new_version)) {
qDebug("Apparently update is not needed, we have a more recent version"); qDebug("Apparently update is not needed, we have a more recent version");
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("A more recent version of %1 search engine plugin is already installed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data())); QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("A more recent version of %1 search engine plugin is already installed.", "%1 is the name of the search engine").arg(plugin_name));
return; return;
} }
// Process with install // Process with install
@ -280,12 +280,12 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
// restore backup // restore backup
QFile::copy(dest_path+".bak", dest_path); QFile::copy(dest_path+".bak", dest_path);
QFile::remove(dest_path+".bak"); QFile::remove(dest_path+".bak");
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be updated, keeping old version.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data())); QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be updated, keeping old version.", "%1 is the name of the search engine").arg(plugin_name));
return; return;
} else { } else {
// Remove broken file // Remove broken file
QFile::remove(dest_path); QFile::remove(dest_path);
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data())); QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name));
return; return;
} }
} }
@ -294,10 +294,10 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
QFile::remove(dest_path+".bak"); QFile::remove(dest_path+".bak");
} }
if(update) { if(update) {
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data())); QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name));
return; return;
} else { } else {
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully installed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data())); QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully installed.", "%1 is the name of the search engine").arg(plugin_name));
return; return;
} }
} }
@ -390,17 +390,17 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) {
plugin_name.chop(1); // remove trailing ':' plugin_name.chop(1); // remove trailing ':'
bool ok; bool ok;
float version = list.last().toFloat(&ok); float version = list.last().toFloat(&ok);
qDebug("read line %s: %.2f", plugin_name.toLocal8Bit().data(), version); qDebug("read line %s: %.2f", qPrintable(plugin_name), version);
if(!ok) continue; if(!ok) continue;
file_correct = true; file_correct = true;
if(isUpdateNeeded(plugin_name, version)) { if(isUpdateNeeded(plugin_name, version)) {
qDebug("Plugin: %s is outdated", plugin_name.toLocal8Bit().data()); qDebug("Plugin: %s is outdated", qPrintable(plugin_name));
// Downloading update // Downloading update
downloader->downloadUrl(UPDATE_URL+plugin_name+".py"); downloader->downloadUrl(UPDATE_URL+plugin_name+".py");
//downloader->downloadUrl(UPDATE_URL+plugin_name+".png"); //downloader->downloadUrl(UPDATE_URL+plugin_name+".png");
updated = true; updated = true;
}else { }else {
qDebug("Plugin: %s is up to date", plugin_name.toLocal8Bit().data()); qDebug("Plugin: %s is up to date", qPrintable(plugin_name));
} }
} }
// Close file // Close file
@ -414,7 +414,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) {
} }
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) { void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
qDebug("engineSelectDlg received %s", url.toLocal8Bit().data()); qDebug("engineSelectDlg received %s", qPrintable(url));
if(url.endsWith("favicon.ico", Qt::CaseInsensitive)){ if(url.endsWith("favicon.ico", Qt::CaseInsensitive)){
// Icon downloaded // Icon downloaded
QImage fileIcon; QImage fileIcon;
@ -456,7 +456,7 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
void engineSelectDlg::handleDownloadFailure(QString url, QString reason) { void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
if(url.endsWith("favicon.ico", Qt::CaseInsensitive)){ if(url.endsWith("favicon.ico", Qt::CaseInsensitive)){
qDebug("Could not download favicon: %s, reason: %s", url.toLocal8Bit().data(), reason.toLocal8Bit().data()); qDebug("Could not download favicon: %s, reason: %s", qPrintable(url), qPrintable(reason));
return; return;
} }
if(url.endsWith("versions.txt")) { if(url.endsWith("versions.txt")) {
@ -467,6 +467,6 @@ void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
// a plugin update download has been failed // a plugin update download has been failed
QString plugin_name = url.split('/').last(); QString plugin_name = url.split('/').last();
plugin_name.replace(".py", "", Qt::CaseInsensitive); plugin_name.replace(".py", "", Qt::CaseInsensitive);
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin install failed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data())); QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin install failed.", "%1 is the name of the search engine").arg(plugin_name));
} }
} }

4
src/feeddownloader.h

@ -64,11 +64,9 @@ public:
bool matches(QString s) { bool matches(QString s) {
QStringList match_tokens = getMatchingTokens(); QStringList match_tokens = getMatchingTokens();
//qDebug("Checking matching tokens: \"%s\"", getMatchingTokens_str().toLocal8Bit().data());
foreach(const QString& token, match_tokens) { foreach(const QString& token, match_tokens) {
if(token.isEmpty() || token == "") if(token.isEmpty() || token == "")
continue; continue;
//qDebug("Token: %s", token.toLocal8Bit().data());
QRegExp reg(token, Qt::CaseInsensitive, QRegExp::Wildcard); QRegExp reg(token, Qt::CaseInsensitive, QRegExp::Wildcard);
//reg.setMinimal(false); //reg.setMinimal(false);
if(reg.indexIn(s) < 0) return false; if(reg.indexIn(s) < 0) return false;
@ -226,7 +224,7 @@ public:
void save() { void save() {
QSettings qBTRSS("qBittorrent", "qBittorrent-rss"); QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QHash<QString, QVariant> all_feeds_filters = qBTRSS.value("feed_filters", QHash<QString, QVariant>()).toHash(); QHash<QString, QVariant> all_feeds_filters = qBTRSS.value("feed_filters", QHash<QString, QVariant>()).toHash();
qDebug("Saving filters for feed: %s (%d filters)", feed_url.toLocal8Bit().data(), (*this).size()); qDebug("Saving filters for feed: %s (%d filters)", qPrintable(feed_url), (*this).size());
all_feeds_filters[feed_url] = *this; all_feeds_filters[feed_url] = *this;
qBTRSS.setValue("feed_filters", all_feeds_filters); qBTRSS.setValue("feed_filters", all_feeds_filters);
} }

8
src/filesystemwatcher.h

@ -49,10 +49,10 @@ protected:
file += QDir::separator(); file += QDir::separator();
file += "."; file += ".";
struct statfs buf; struct statfs buf;
if(!statfs(file.toLocal8Bit().data(), &buf)) { if(!statfs(file.toLocal8Bit().constData(), &buf)) {
return (buf.f_type == (long)CIFS_MAGIC_NUMBER || buf.f_type == (long)NFS_SUPER_MAGIC); return (buf.f_type == (long)CIFS_MAGIC_NUMBER || buf.f_type == (long)NFS_SUPER_MAGIC);
} else { } else {
std::cerr << "Error: statfs() call failed for " << file.toLocal8Bit().data() << ". Supposing it is a local folder..." << std::endl; std::cerr << "Error: statfs() call failed for " << qPrintable(file) << ". Supposing it is a local folder..." << std::endl;
switch(errno) { switch(errno) {
case EACCES: case EACCES:
std::cerr << "Search permission is denied for a component of the path prefix of the path" << std::endl; std::cerr << "Search permission is denied for a component of the path prefix of the path" << std::endl;
@ -148,7 +148,7 @@ public:
} else { } else {
#endif #endif
// Normal mode // Normal mode
qDebug("FS Watching is watching %s in normal mode", path.toLocal8Bit().data()); qDebug("FS Watching is watching %s in normal mode", qPrintable(path));
QFileSystemWatcher::addPath(path); QFileSystemWatcher::addPath(path);
scanLocalFolder(path); scanLocalFolder(path);
#ifndef Q_WS_WIN #ifndef Q_WS_WIN
@ -190,7 +190,7 @@ protected slots:
QStringList torrents; QStringList torrents;
// Network folders scan // Network folders scan
foreach (const QDir &dir, watched_folders) { foreach (const QDir &dir, watched_folders) {
qDebug("FSWatcher: Polling manually folder %s", qPrintable(dir.path())); //qDebug("FSWatcher: Polling manually folder %s", qPrintable(dir.path()));
addTorrentsFromDir(dir, torrents); addTorrentsFromDir(dir, torrents);
} }
// Report detected torrent files // Report detected torrent files

6
src/geoip.h

@ -86,9 +86,9 @@ public:
exportEmbeddedDb(); exportEmbeddedDb();
#endif #endif
if(QFile::exists(geoipDBpath(false))) { if(QFile::exists(geoipDBpath(false))) {
qDebug("Loading GeoIP database from %s...", geoipDBpath(false).toLocal8Bit().data()); qDebug("Loading GeoIP database from %s...", qPrintable(geoipDBpath(false)));
if(!s->load_country_db(geoipDBpath(false).toLocal8Bit().data())) { if(!s->load_country_db(geoipDBpath(false).toLocal8Bit().constData())) {
std::cerr << "Failed to load Geoip Database at " << geoipDBpath(false).toLocal8Bit().data() << std::endl; std::cerr << "Failed to load Geoip Database at " << qPrintable(geoipDBpath(false)) << std::endl;
} }
} else { } else {
qDebug("ERROR: Impossible to find local Geoip Database"); qDebug("ERROR: Impossible to find local Geoip Database");

31
src/headlessloader.h

@ -41,10 +41,6 @@
class HeadlessLoader: QObject { class HeadlessLoader: QObject {
Q_OBJECT Q_OBJECT
private:
QLocalServer *localServer;
Bittorrent *BTSession;
public: public:
HeadlessLoader(QStringList torrentCmdLine) { HeadlessLoader(QStringList torrentCmdLine) {
// Enable Web UI // Enable Web UI
@ -58,29 +54,30 @@ class HeadlessLoader: QObject {
processParams(torrentCmdLine); processParams(torrentCmdLine);
// Use a tcp server to allow only one instance of qBittorrent // Use a tcp server to allow only one instance of qBittorrent
localServer = new QLocalServer(); localServer = new QLocalServer();
QString uid = QString::number(getuid()); const QString &uid = QString::number(getuid());
#ifdef Q_WS_X11 #ifdef Q_WS_X11
if(QFile::exists(QDir::tempPath()+QDir::separator()+QString("qBittorrent-")+uid)) { if(QFile::exists(QDir::tempPath()+QDir::separator()+QString("qBittorrent-")+uid)) {
// Socket was not closed cleanly // Socket was not closed cleanly
std::cerr << "Warning: Local domain socket was not closed cleanly, deleting file...\n"; std::cerr << "Warning: Local domain socket was not closed cleanly, deleting file..." << std::endl;
QFile::remove(QDir::tempPath()+QDir::separator()+QString("qBittorrent-")+uid); QFile::remove(QDir::tempPath()+QDir::separator()+QString("qBittorrent-")+uid);
} }
#endif #endif
if (!localServer->listen("qBittorrent-"+uid)) { if (!localServer->listen("qBittorrent-"+uid)) {
std::cerr << "Couldn't create socket, single instance mode won't work...\n"; std::cerr << "Couldn't create socket, single instance mode won't work..." << std::endl;
} }
connect(localServer, SIGNAL(newConnection()), this, SLOT(acceptConnection())); connect(localServer, SIGNAL(newConnection()), this, SLOT(acceptConnection()));
// Display some information to the user // Display some information to the user
std::cout << std::endl << "******** " << tr("Information").toLocal8Bit().data() << " ********" << std::endl; std::cout << std::endl << "******** " << qPrintable(tr("Information")) << " ********" << std::endl;
std::cout << tr("To control qBittorrent, access the Web UI at http://localhost:%1").arg(QString::number(Preferences::getWebUiPort())).toLocal8Bit().data() << std::endl; std::cout << qPrintable(tr("To control qBittorrent, access the Web UI at http://localhost:%1").arg(QString::number(Preferences::getWebUiPort()))) << std::endl;
std::cout << tr("The Web UI administrator user name is: %1").arg(Preferences::getWebUiUsername()).toLocal8Bit().data() << std::endl; std::cout << qPrintable(tr("The Web UI administrator user name is: %1").arg(Preferences::getWebUiUsername())) << std::endl;
if(Preferences::getWebUiPassword() == "f6fdffe48c908deb0f4c3bd36c032e72") { if(Preferences::getWebUiPassword() == "f6fdffe48c908deb0f4c3bd36c032e72") {
std::cout << tr("The Web UI administrator password is still the default one: %1").arg("adminadmin").toLocal8Bit().data() << std::endl; std::cout << qPrintable(tr("The Web UI administrator password is still the default one: %1").arg("adminadmin")) << std::endl;
std::cout << tr("This is a security risk, please consider changing your password from program preferences.").toLocal8Bit().data() << std::endl; std::cout << qPrintable(tr("This is a security risk, please consider changing your password from program preferences.")) << std::endl;
} }
} }
~HeadlessLoader() { ~HeadlessLoader() {
delete localServer;
delete BTSession; delete BTSession;
} }
@ -92,7 +89,7 @@ class HeadlessLoader: QObject {
} }
void displayConsoleMessage(QString msg) { void displayConsoleMessage(QString msg) {
std::cout << msg.toLocal8Bit().data() << std::endl; std::cout << qPrintable(msg) << std::endl;
} }
// As program parameters, we can get paths or urls. // As program parameters, we can get paths or urls.
@ -124,15 +121,19 @@ class HeadlessLoader: QObject {
void readParamsOnSocket() { void readParamsOnSocket() {
QLocalSocket *clientConnection = static_cast<QLocalSocket*>(sender()); QLocalSocket *clientConnection = static_cast<QLocalSocket*>(sender());
if(clientConnection) { if(clientConnection) {
QByteArray params = clientConnection->readAll(); const QByteArray &params = clientConnection->readAll();
if(!params.isEmpty()) { if(!params.isEmpty()) {
processParams(QString::fromUtf8(params.data()).split(QString::fromUtf8("\n"))); processParams(QString(params).split("\n"));
qDebug("Received parameters from another instance"); qDebug("Received parameters from another instance");
} }
clientConnection->deleteLater(); clientConnection->deleteLater();
} }
} }
private:
QLocalServer *localServer;
Bittorrent *BTSession;
}; };
#endif #endif

10
src/httpconnection.cpp

@ -117,7 +117,7 @@ QString HttpConnection::translateDocument(QString data) {
QString translation = word; QString translation = word;
int context_index= 0; int context_index= 0;
do { do {
translation = qApp->translate(contexts[context_index].c_str(), word.toLocal8Bit().data(), 0, QCoreApplication::UnicodeUTF8, 1); translation = qApp->translate(contexts[context_index].c_str(), word.toLocal8Bit().constData(), 0, QCoreApplication::UnicodeUTF8, 1);
++context_index; ++context_index;
}while(translation == word && context_index < 12); }while(translation == word && context_index < 12);
//qDebug("Translation is %s", translation.toUtf8().data()); //qDebug("Translation is %s", translation.toUtf8().data());
@ -139,11 +139,11 @@ void HttpConnection::respond() {
return; return;
} }
QString auth = parser.value("Authorization"); QString auth = parser.value("Authorization");
qDebug("Auth: %s", auth.split(" ").first().toLocal8Bit().data()); qDebug("Auth: %s", qPrintable(auth.split(" ").first()));
if (QString::compare(auth.split(" ").first(), "Digest", Qt::CaseInsensitive) != 0 || !parent->isAuthorized(auth.toLocal8Bit(), parser.method())) { if (QString::compare(auth.split(" ").first(), "Digest", Qt::CaseInsensitive) != 0 || !parent->isAuthorized(auth.toLocal8Bit(), parser.method())) {
// Update failed attempt counter // Update failed attempt counter
parent->client_failed_attempts.insert(socket->peerAddress().toString(), nb_fail+1); parent->client_failed_attempts.insert(socket->peerAddress().toString(), nb_fail+1);
qDebug("client IP: %s (%d failed attempts)", socket->peerAddress().toString().toLocal8Bit().data(), nb_fail); qDebug("client IP: %s (%d failed attempts)", qPrintable(socket->peerAddress().toString()), nb_fail);
// Return unauthorized header // Return unauthorized header
generator.setStatusLine(401, "Unauthorized"); generator.setStatusLine(401, "Unauthorized");
generator.setValue("WWW-Authenticate", "Digest realm=\""+QString(QBT_REALM)+"\", nonce=\""+parent->generateNonce()+"\", algorithm=\"MD5\", qop=\"auth\""); generator.setValue("WWW-Authenticate", "Digest realm=\""+QString(QBT_REALM)+"\", nonce=\""+parent->generateNonce()+"\", algorithm=\"MD5\", qop=\"auth\"");
@ -225,7 +225,6 @@ void HttpConnection::respond() {
else else
list.prepend("webui"); list.prepend("webui");
url = ":/" + list.join("/"); url = ":/" + list.join("/");
//qDebug("Resource URL: %s", url.toLocal8Bit().data());
QFile file(url); QFile file(url);
if(!file.open(QIODevice::ReadOnly)) if(!file.open(QIODevice::ReadOnly))
{ {
@ -261,7 +260,6 @@ void HttpConnection::respondJson()
QString string = json::toJson(manager->getEventList()); QString string = json::toJson(manager->getEventList());
generator.setStatusLine(200, "OK"); generator.setStatusLine(200, "OK");
generator.setContentTypeByExt("js"); generator.setContentTypeByExt("js");
//qDebug("JSON: %s", string.toLocal8Bit().data());
generator.setMessage(string); generator.setMessage(string);
write(); write();
} }
@ -290,7 +288,6 @@ void HttpConnection::respondFilesPropertiesJson(QString hash) {
generator.setStatusLine(200, "OK"); generator.setStatusLine(200, "OK");
generator.setContentTypeByExt("js"); generator.setContentTypeByExt("js");
generator.setMessage(string); generator.setMessage(string);
//qDebug("JSON: %s", string.toLocal8Bit().data());
write(); write();
} }
@ -391,7 +388,6 @@ void HttpConnection::respondCommand(QString command)
} }
if(command == "setPreferences") { if(command == "setPreferences") {
QString json_str = parser.post("json"); QString json_str = parser.post("json");
//qDebug("setPreferences, json: %s", json_str.toLocal8Bit().data());
EventManager* manager = parent->eventManager(); EventManager* manager = parent->eventManager();
manager->setGlobalPreferences(json::fromJson(json_str)); manager->setGlobalPreferences(json::fromJson(json_str));
} }

2
src/main.cpp

@ -73,7 +73,7 @@ class UsageDisplay: public QObject {
public: public:
static void displayUsage(char* prg_name) { static void displayUsage(char* prg_name) {
std::cout << tr("Usage:").toLocal8Bit().data() << std::endl; std::cout << qPrintable(tr("Usage:")) << std::endl;
std::cout << '\t' << prg_name << " --version: " << qPrintable(tr("displays program version")) << std::endl; std::cout << '\t' << prg_name << " --version: " << qPrintable(tr("displays program version")) << std::endl;
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
std::cout << '\t' << prg_name << " --no-splash: " << qPrintable(tr("disable splash screen")) << std::endl; std::cout << '\t' << prg_name << " --no-splash: " << qPrintable(tr("disable splash screen")) << std::endl;

8
src/qtorrenthandle.cpp

@ -548,7 +548,7 @@ void QTorrentHandle::set_sequential_download(bool b) {
void QTorrentHandle::set_tracker_login(QString username, QString password) { void QTorrentHandle::set_tracker_login(QString username, QString password) {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
h.set_tracker_login(std::string(username.toLocal8Bit().data()), std::string(password.toLocal8Bit().data())); h.set_tracker_login(std::string(username.toLocal8Bit().constData()), std::string(password.toLocal8Bit().constData()));
} }
void QTorrentHandle::force_recheck() const { void QTorrentHandle::force_recheck() const {
@ -558,7 +558,7 @@ void QTorrentHandle::force_recheck() const {
void QTorrentHandle::move_storage(QString new_path) const { void QTorrentHandle::move_storage(QString new_path) const {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
h.move_storage(new_path.toLocal8Bit().data()); h.move_storage(new_path.toLocal8Bit().constData());
} }
void QTorrentHandle::file_priority(int index, int priority) const { void QTorrentHandle::file_priority(int index, int priority) const {
@ -606,7 +606,7 @@ bool QTorrentHandle::save_torrent_file(QString path) {
torrent_file["info"] = meta; torrent_file["info"] = meta;
if(!h.trackers().empty()) if(!h.trackers().empty())
torrent_file["announce"] = h.trackers().front().url; torrent_file["announce"] = h.trackers().front().url;
boost::filesystem::ofstream out(path.toLocal8Bit().data(), std::ios_base::binary); boost::filesystem::ofstream out(path.toLocal8Bit().constData(), std::ios_base::binary);
out.unsetf(std::ios_base::skipws); out.unsetf(std::ios_base::skipws);
bencode(std::ostream_iterator<char>(out), torrent_file); bencode(std::ostream_iterator<char>(out), torrent_file);
return true; return true;
@ -676,7 +676,7 @@ void QTorrentHandle::prioritize_first_last_piece(bool b) {
} }
void QTorrentHandle::rename_file(int index, QString name) { void QTorrentHandle::rename_file(int index, QString name) {
h.rename_file(index, std::string(name.toLocal8Bit().data())); h.rename_file(index, std::string(name.toLocal8Bit().constData()));
} }
// //

8
src/rss_imp.cpp

@ -90,8 +90,8 @@ void RSSImp::displayItemsListMenu(const QPoint&){
if(selectedItems.size() > 0) { if(selectedItems.size() > 0) {
bool has_attachment = false; bool has_attachment = false;
foreach(QTreeWidgetItem *item, selectedItems) { foreach(QTreeWidgetItem *item, selectedItems) {
qDebug("text(3) URL: %s", item->text(NEWS_URL_COL).toLocal8Bit().data()); qDebug("text(3) URL: %s", qPrintable(item->text(NEWS_URL_COL)));
qDebug("text(2) TITLE: %s", item->text(NEWS_TITLE_COL).toLocal8Bit().data()); qDebug("text(2) TITLE: %s", qPrintable(item->text(NEWS_TITLE_COL)));
if(listStreams->getRSSItemFromUrl(item->text(NEWS_URL_COL))->getItem(item->text(NEWS_TITLE_COL))->has_attachment()) { if(listStreams->getRSSItemFromUrl(item->text(NEWS_URL_COL))->getItem(item->text(NEWS_TITLE_COL))->has_attachment()) {
has_attachment = true; has_attachment = true;
break; break;
@ -254,7 +254,7 @@ void RSSImp::loadFoldersOpenState() {
if(listStreams->getRSSItem(child)->getID() == name) { if(listStreams->getRSSItem(child)->getID() == name) {
parent = child; parent = child;
parent->setExpanded(true); parent->setExpanded(true);
qDebug("expanding folder %s", name.toLocal8Bit().data()); qDebug("expanding folder %s", qPrintable(name));
break; break;
} }
} }
@ -267,7 +267,7 @@ void RSSImp::saveFoldersOpenState() {
QList<QTreeWidgetItem*> items = listStreams->getAllOpenFolders(); QList<QTreeWidgetItem*> items = listStreams->getAllOpenFolders();
foreach(QTreeWidgetItem* item, items) { foreach(QTreeWidgetItem* item, items) {
QString path = listStreams->getItemPath(item).join("\\"); QString path = listStreams->getItemPath(item).join("\\");
qDebug("saving open folder: %s", path.toLocal8Bit().data()); qDebug("saving open folder: %s", qPrintable(path));
open_folders << path; open_folders << path;
} }
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");

10
src/searchengine.cpp

@ -96,7 +96,7 @@ void SearchEngine::fillCatCombobox() {
comboCategory->addItem(full_cat_names["all"], QVariant("all")); comboCategory->addItem(full_cat_names["all"], QVariant("all"));
QStringList supported_cat = supported_engines->supportedCategories(); QStringList supported_cat = supported_engines->supportedCategories();
foreach(QString cat, supported_cat) { foreach(QString cat, supported_cat) {
qDebug("Supported category: %s", cat.toLocal8Bit().data()); qDebug("Supported category: %s", qPrintable(cat));
comboCategory->addItem(full_cat_names[cat], QVariant(cat)); comboCategory->addItem(full_cat_names[cat], QVariant(cat));
} }
} }
@ -254,7 +254,7 @@ void SearchEngine::on_search_button_clicked(){
search_stopped = false; search_stopped = false;
params << misc::searchEngineLocation()+QDir::separator()+"nova2.py"; params << misc::searchEngineLocation()+QDir::separator()+"nova2.py";
params << supported_engines->enginesEnabled().join(","); params << supported_engines->enginesEnabled().join(",");
qDebug("Search with category: %s", selectedCategory().toLocal8Bit().data()); qDebug("Search with category: %s", qPrintable(selectedCategory()));
params << selectedCategory(); params << selectedCategory();
params << pattern.split(" "); params << pattern.split(" ");
// Update SearchEngine widgets // Update SearchEngine widgets
@ -433,12 +433,12 @@ void SearchEngine::updateNova() {
// Copy python classes // Copy python classes
if(file.endsWith(".py")) { if(file.endsWith(".py")) {
if(getPluginVersion(shipped_file) > getPluginVersion(destDir+file) ) { if(getPluginVersion(shipped_file) > getPluginVersion(destDir+file) ) {
qDebug("shippped %s is more recent then local plugin, updating", file.toLocal8Bit().data()); qDebug("shippped %s is more recent then local plugin, updating", qPrintable(file));
if(QFile::exists(destDir+file)) { if(QFile::exists(destDir+file)) {
qDebug("Removing old %s", (destDir+file).toLocal8Bit().data()); qDebug("Removing old %s", qPrintable(destDir+file));
QFile::remove(destDir+file); QFile::remove(destDir+file);
} }
qDebug("%s copied to %s", shipped_file.toLocal8Bit().data(), (destDir+file).toLocal8Bit().data()); qDebug("%s copied to %s", qPrintable(shipped_file), qPrintable(destDir+file));
QFile::copy(shipped_file, destDir+file); QFile::copy(shipped_file, destDir+file);
} }
} else { } else {

4
src/searchengine.h

@ -79,7 +79,7 @@ public:
static float getPluginVersion(QString filePath) { static float getPluginVersion(QString filePath) {
QFile plugin(filePath); QFile plugin(filePath);
if(!plugin.exists()){ if(!plugin.exists()){
qDebug("%s plugin does not exist, returning 0.0", filePath.toLocal8Bit().data()); qDebug("%s plugin does not exist, returning 0.0", qPrintable(filePath));
return 0.0; return 0.0;
} }
if(!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){
@ -91,7 +91,7 @@ public:
if(line.startsWith("#VERSION: ")){ if(line.startsWith("#VERSION: ")){
line = line.split(' ').last().trimmed(); line = line.split(' ').last().trimmed();
version = line.toFloat(); version = line.toFloat();
qDebug("plugin %s version: %.2f", filePath.toLocal8Bit().data(), version); qDebug("plugin %s version: %.2f", qPrintable(filePath), version);
break; break;
} }
} }

46
src/torrentadditiondlg.h

@ -114,7 +114,7 @@ public:
resize(settings.value(QString::fromUtf8("TorrentAdditionDlg/size"), size()).toSize()); resize(settings.value(QString::fromUtf8("TorrentAdditionDlg/size"), size()).toSize());
move(settings.value(QString::fromUtf8("TorrentAdditionDlg/pos"), misc::screenCenter(this)).toPoint()); move(settings.value(QString::fromUtf8("TorrentAdditionDlg/pos"), misc::screenCenter(this)).toPoint());
// Restore column width // Restore column width
QVariantList contentColsWidths = settings.value(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth"), QVariantList()).toList(); const QVariantList &contentColsWidths = settings.value(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth"), QVariantList()).toList();
if(contentColsWidths.empty()) { if(contentColsWidths.empty()) {
torrentContentList->header()->resizeSection(0, 200); torrentContentList->header()->resizeSection(0, 200);
} else { } else {
@ -222,7 +222,7 @@ public:
// Load custom labels // Load custom labels
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("TransferListFilters")); settings.beginGroup(QString::fromUtf8("TransferListFilters"));
QStringList customLabels = settings.value("customLabels", QStringList()).toStringList(); const QStringList &customLabels = settings.value("customLabels", QStringList()).toStringList();
comboLabel->addItem(""); comboLabel->addItem("");
foreach(const QString& label, customLabels) { foreach(const QString& label, customLabels) {
comboLabel->addItem(label); comboLabel->addItem(label);
@ -239,7 +239,7 @@ public slots:
void displayContentListMenu(const QPoint&) { void displayContentListMenu(const QPoint&) {
QMenu myFilesLlistMenu; QMenu myFilesLlistMenu;
QModelIndexList selectedRows = torrentContentList->selectionModel()->selectedRows(0); const QModelIndexList &selectedRows = torrentContentList->selectionModel()->selectedRows(0);
QAction *actRename = 0; QAction *actRename = 0;
if(selectedRows.size() == 1) { if(selectedRows.size() == 1) {
actRename = myFilesLlistMenu.addAction(QIcon(QString::fromUtf8(":/Icons/oxygen/edit_clear.png")), tr("Rename...")); actRename = myFilesLlistMenu.addAction(QIcon(QString::fromUtf8(":/Icons/oxygen/edit_clear.png")), tr("Rename..."));
@ -266,7 +266,7 @@ public slots:
} }
} }
qDebug("Setting files priority"); qDebug("Setting files priority");
foreach(QModelIndex index, selectedRows) { foreach(const QModelIndex &index, selectedRows) {
qDebug("Setting priority(%d) for file at row %d", prio, index.row()); qDebug("Setting priority(%d) for file at row %d", prio, index.row());
PropListModel->setData(PropListModel->index(index.row(), PRIORITY, index.parent()), prio); PropListModel->setData(PropListModel->index(index.row(), PRIORITY, index.parent()), prio);
} }
@ -275,12 +275,12 @@ public slots:
} }
void renameSelectedFile() { void renameSelectedFile() {
QModelIndexList selectedIndexes = torrentContentList->selectionModel()->selectedRows(0); const QModelIndexList &selectedIndexes = torrentContentList->selectionModel()->selectedRows(0);
Q_ASSERT(selectedIndexes.size() == 1); Q_ASSERT(selectedIndexes.size() == 1);
QModelIndex index = selectedIndexes.first(); const QModelIndex &index = selectedIndexes.first();
// Ask for new name // Ask for new name
bool ok; bool ok;
QString new_name_last = QInputDialog::getText(this, tr("Rename the file"), const QString &new_name_last = QInputDialog::getText(this, tr("Rename the file"),
tr("New name:"), QLineEdit::Normal, tr("New name:"), QLineEdit::Normal,
index.data().toString(), &ok); index.data().toString(), &ok);
if (ok && !new_name_last.isEmpty()) { if (ok && !new_name_last.isEmpty()) {
@ -292,12 +292,12 @@ public slots:
} }
if(PropListModel->getType(index)==TFILE) { if(PropListModel->getType(index)==TFILE) {
// File renaming // File renaming
uint file_index = PropListModel->getFileIndex(index); const uint file_index = PropListModel->getFileIndex(index);
QString old_name = files_path.at(file_index); const QString &old_name = files_path.at(file_index);
QStringList path_items = old_name.split(QDir::separator()); QStringList path_items = old_name.split(QDir::separator());
path_items.removeLast(); path_items.removeLast();
path_items << new_name_last; path_items << new_name_last;
QString new_name = path_items.join(QDir::separator()); const QString &new_name = path_items.join(QDir::separator());
if(old_name == new_name) { if(old_name == new_name) {
qDebug("Name did not change"); qDebug("Name did not change");
return; return;
@ -317,7 +317,7 @@ public slots:
return; return;
} }
} }
qDebug("Renaming %s to %s", old_name.toLocal8Bit().data(), new_name.toLocal8Bit().data()); qDebug("Renaming %s to %s", qPrintable(old_name), qPrintable(new_name));
// Rename file in files_path // Rename file in files_path
files_path.replace(file_index, new_name); files_path.replace(file_index, new_name);
// Rename in torrent files model too // Rename in torrent files model too
@ -331,14 +331,14 @@ public slots:
path_items.prepend(parent.data().toString()); path_items.prepend(parent.data().toString());
parent = PropListModel->parent(parent); parent = PropListModel->parent(parent);
} }
QString old_path = path_items.join(QDir::separator()); const QString &old_path = path_items.join(QDir::separator());
path_items.removeLast(); path_items.removeLast();
path_items << new_name_last; path_items << new_name_last;
QString new_path = path_items.join(QDir::separator()); QString new_path = path_items.join(QDir::separator());
if(!new_path.endsWith(QDir::separator())) new_path += QDir::separator(); if(!new_path.endsWith(QDir::separator())) new_path += QDir::separator();
// Check for overwriting // Check for overwriting
for(uint i=0; i<nbFiles; ++i) { for(uint i=0; i<nbFiles; ++i) {
QString current_name = files_path.at(i); const QString &current_name = files_path.at(i);
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
if(current_name.startsWith(new_path, Qt::CaseInsensitive)) { if(current_name.startsWith(new_path, Qt::CaseInsensitive)) {
#else #else
@ -352,11 +352,11 @@ public slots:
} }
// Replace path in all files // Replace path in all files
for(uint i=0; i<nbFiles; ++i) { for(uint i=0; i<nbFiles; ++i) {
QString current_name = files_path.at(i); const QString &current_name = files_path.at(i);
if(current_name.startsWith(old_path)) { if(current_name.startsWith(old_path)) {
QString new_name = current_name; QString new_name = current_name;
new_name.replace(0, old_path.length(), new_path); new_name.replace(0, old_path.length(), new_path);
qDebug("Rename %s to %s", current_name.toLocal8Bit().data(), new_name.toLocal8Bit().data()); qDebug("Rename %s to %s", qPrintable(current_name), qPrintable(new_name));
// Rename in files_path // Rename in files_path
files_path.replace(i, new_name); files_path.replace(i, new_name);
} }
@ -368,13 +368,13 @@ public slots:
} }
void updateDiskSpaceLabels() { void updateDiskSpaceLabels() {
long long available = misc::freeDiskSpaceOnPath(misc::expandPath(savePathTxt->text())); const long long available = misc::freeDiskSpaceOnPath(misc::expandPath(savePathTxt->text()));
lbl_disk_space->setText(misc::friendlyUnit(available)); lbl_disk_space->setText(misc::friendlyUnit(available));
if(!is_magnet) { if(!is_magnet) {
// Determine torrent size // Determine torrent size
qulonglong torrent_size = 0; qulonglong torrent_size = 0;
unsigned int nbFiles = t->num_files(); const unsigned int nbFiles = t->num_files();
std::vector<int> priorities = PropListModel->getFilesPriorities(nbFiles); const std::vector<int> &priorities = PropListModel->getFilesPriorities(nbFiles);
for(unsigned int i=0; i<nbFiles; ++i) { for(unsigned int i=0; i<nbFiles; ++i) {
if(priorities[i] > 0) if(priorities[i] > 0)
@ -400,8 +400,8 @@ public slots:
void on_browseButton_clicked(){ void on_browseButton_clicked(){
QString dir; QString dir;
QString save_path = misc::expandPath(savePathTxt->text()); const QString &save_path = misc::expandPath(savePathTxt->text());
QDir saveDir(save_path); const QDir &saveDir(save_path);
if(!save_path.isEmpty() && saveDir.exists()){ if(!save_path.isEmpty() && saveDir.exists()){
dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), saveDir.absolutePath()); dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), saveDir.absolutePath());
}else{ }else{
@ -422,7 +422,7 @@ public slots:
void savePiecesPriorities(){ void savePiecesPriorities(){
qDebug("Saving pieces priorities"); qDebug("Saving pieces priorities");
std::vector<int> priorities = PropListModel->getFilesPriorities(t->num_files()); const std::vector<int> &priorities = PropListModel->getFilesPriorities(t->num_files());
TorrentTempData::setFilesPriority(hash, priorities); TorrentTempData::setFilesPriority(hash, priorities);
} }
@ -439,14 +439,14 @@ public slots:
return; return;
} }
} }
QString current_label = comboLabel->currentText().trimmed(); const QString &current_label = comboLabel->currentText().trimmed();
if (!current_label.isEmpty() && !misc::isValidFileSystemName(current_label)) { if (!current_label.isEmpty() && !misc::isValidFileSystemName(current_label)) {
QMessageBox::warning(this, tr("Invalid label name"), tr("Please don't use any special characters in the label name.")); QMessageBox::warning(this, tr("Invalid label name"), tr("Please don't use any special characters in the label name."));
return; return;
} }
// Save savepath // Save savepath
TorrentTempData::setSavePath(hash, savePath.path()); TorrentTempData::setSavePath(hash, savePath.path());
qDebug("Torrent label is: %s", comboLabel->currentText().trimmed().toLocal8Bit().data()); qDebug("Torrent label is: %s", qPrintable(comboLabel->currentText().trimmed()));
if(!current_label.isEmpty()) if(!current_label.isEmpty())
TorrentTempData::setLabel(hash, current_label); TorrentTempData::setLabel(hash, current_label);
// Is download sequential? // Is download sequential?

8
src/torrentfilesmodel.h

@ -65,8 +65,8 @@ public:
if(name.endsWith(".!qB")) if(name.endsWith(".!qB"))
name.chop(4); name.chop(4);
itemData << name; itemData << name;
qDebug("Created a TreeItem file with name %s", getName().toLocal8Bit().data()); qDebug("Created a TreeItem file with name %s", qPrintable(getName()));
qDebug("parent is %s", parent->getName().toLocal8Bit().data()); qDebug("parent is %s", qPrintable(parent->getName()));
itemData << QVariant((qulonglong)f.size); itemData << QVariant((qulonglong)f.size);
total_done = 0; total_done = 0;
itemData << 0.; // Progress; itemData << 0.; // Progress;
@ -102,7 +102,7 @@ public:
} }
~TreeItem() { ~TreeItem() {
qDebug("Deleting item: %s", getName().toLocal8Bit().data()); qDebug("Deleting item: %s", qPrintable(getName()));
qDeleteAll(childItems); qDeleteAll(childItems);
} }
@ -168,7 +168,6 @@ public:
else else
progress = 1.; progress = 1.;
Q_ASSERT(progress >= 0. && progress <= 1.); Q_ASSERT(progress >= 0. && progress <= 1.);
//qDebug("setProgress(%s): %f", getName().toLocal8Bit().data(), progress);
itemData.replace(2, progress); itemData.replace(2, progress);
if(parentItem) if(parentItem)
parentItem->updateProgress(); parentItem->updateProgress();
@ -189,7 +188,6 @@ public:
if(type == ROOT) return; if(type == ROOT) return;
Q_ASSERT(type == FOLDER); Q_ASSERT(type == FOLDER);
total_done = 0; total_done = 0;
//qDebug("Folder %s is updating its progress", getName().toLocal8Bit().data());
foreach(TreeItem* child, childItems) { foreach(TreeItem* child, childItems) {
if(child->getPriority() > 0) if(child->getPriority() > 0)
total_done += child->getTotalDone(); total_done += child->getTotalDone();

14
src/torrentpersistentdata.h

@ -63,11 +63,11 @@ public:
} }
} }
static void setFilesPriority(QString hash, std::vector<int> pp) { static void setFilesPriority(QString hash, const std::vector<int> &pp) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash(); QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash(); QHash<QString, QVariant> data = all_data[hash].toHash();
std::vector<int>::iterator pp_it = pp.begin(); std::vector<int>::const_iterator pp_it = pp.begin();
QVariantList pieces_priority; QVariantList pieces_priority;
while(pp_it != pp.end()) { while(pp_it != pp.end()) {
pieces_priority << *pp_it; pieces_priority << *pp_it;
@ -78,7 +78,7 @@ public:
settings.setValue("torrents-tmp", all_data); settings.setValue("torrents-tmp", all_data);
} }
static void setFilesPath(QString hash, QStringList path_list) { static void setFilesPath(QString hash, const QStringList &path_list) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash(); QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash(); QHash<QString, QVariant> data = all_data[hash].toHash();
@ -225,7 +225,7 @@ public:
return dt; return dt;
} }
static void saveSeedDate(QTorrentHandle h) { static void saveSeedDate(const QTorrentHandle &h) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash(); QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[h.hash()].toHash(); QHash<QString, QVariant> data = all_data[h.hash()].toHash();
@ -253,7 +253,7 @@ public:
} }
} }
static void saveTorrentPersistentData(QTorrentHandle h, bool is_magnet = false) { static void saveTorrentPersistentData(const QTorrentHandle &h, bool is_magnet = false) {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
qDebug("Saving persistent data for %s", h.hash().toLocal8Bit().data()); qDebug("Saving persistent data for %s", h.hash().toLocal8Bit().data());
// First, remove temp data // First, remove temp data
@ -311,7 +311,7 @@ public:
settings.setValue("torrents", all_data); settings.setValue("torrents", all_data);
} }
static void savePriority(QTorrentHandle h) { static void savePriority(const QTorrentHandle &h) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash(); QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[h.hash()].toHash(); QHash<QString, QVariant> data = all_data[h.hash()].toHash();
@ -320,7 +320,7 @@ public:
settings.setValue("torrents", all_data); settings.setValue("torrents", all_data);
} }
static void saveSeedStatus(QTorrentHandle h) { static void saveSeedStatus(const QTorrentHandle &h) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash(); QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[h.hash()].toHash(); QHash<QString, QVariant> data = all_data[h.hash()].toHash();

32
src/transferlistfilterswidget.h

@ -73,7 +73,7 @@ public:
QString labelFromRow(int row) const { QString labelFromRow(int row) const {
Q_ASSERT(row > 1); Q_ASSERT(row > 1);
QString label = item(row)->text(); const QString &label = item(row)->text();
QStringList parts = label.split(" "); QStringList parts = label.split(" ");
Q_ASSERT(parts.size() >= 2); Q_ASSERT(parts.size() >= 2);
parts.removeLast(); // Remove trailing number parts.removeLast(); // Remove trailing number
@ -93,9 +93,7 @@ signals:
protected: protected:
void dragMoveEvent(QDragMoveEvent *event) { void dragMoveEvent(QDragMoveEvent *event) {
//qDebug("filters, dragmoveevent");
if(itemAt(event->pos()) && row(itemAt(event->pos())) > 0) { if(itemAt(event->pos()) && row(itemAt(event->pos())) > 0) {
//qDebug("Name: %s", itemAt(event->pos())->text().toLocal8Bit().data());
if(itemHover) { if(itemHover) {
if(itemHover != itemAt(event->pos())) { if(itemHover != itemAt(event->pos())) {
setItemHover(false); setItemHover(false);
@ -249,7 +247,7 @@ public:
QStringList label_list = settings.value("customLabels", QStringList()).toStringList(); QStringList label_list = settings.value("customLabels", QStringList()).toStringList();
foreach(const QString &label, label_list) { foreach(const QString &label, label_list) {
customLabels.insert(label, 0); customLabels.insert(label, 0);
qDebug("Creating label QListWidgetItem: %s", label.toLocal8Bit().data()); qDebug("Creating label QListWidgetItem: %s", qPrintable(label));
QListWidgetItem *newLabel = new QListWidgetItem(); QListWidgetItem *newLabel = new QListWidgetItem();
newLabel->setText(label + " (0)"); newLabel->setText(label + " (0)");
newLabel->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png")); newLabel->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png"));
@ -321,9 +319,9 @@ protected slots:
} }
void removeSelectedLabel() { void removeSelectedLabel() {
int row = labelFilters->row(labelFilters->selectedItems().first()); const int row = labelFilters->row(labelFilters->selectedItems().first());
Q_ASSERT(row > 1); Q_ASSERT(row > 1);
QString label = labelFilters->labelFromRow(row); const QString &label = labelFilters->labelFromRow(row);
Q_ASSERT(customLabels.contains(label)); Q_ASSERT(customLabels.contains(label));
customLabels.remove(label); customLabels.remove(label);
transferList->removeLabelFromRows(label); transferList->removeLabelFromRows(label);
@ -351,13 +349,13 @@ protected slots:
} }
void torrentChangedLabel(QString old_label, QString new_label) { void torrentChangedLabel(QString old_label, QString new_label) {
qDebug("Torrent label changed from %s to %s", old_label.toLocal8Bit().data(), new_label.toLocal8Bit().data()); qDebug("Torrent label changed from %s to %s", qPrintable(old_label), qPrintable(new_label));
if(!old_label.isEmpty()) { if(!old_label.isEmpty()) {
if(customLabels.contains(old_label)) { if(customLabels.contains(old_label)) {
int new_count = customLabels.value(old_label, 0) - 1; const int new_count = customLabels.value(old_label, 0) - 1;
Q_ASSERT(new_count >= 0); Q_ASSERT(new_count >= 0);
customLabels.insert(old_label, new_count); customLabels.insert(old_label, new_count);
int row = labelFilters->rowFromLabel(old_label); const int row = labelFilters->rowFromLabel(old_label);
Q_ASSERT(row >= 2); Q_ASSERT(row >= 2);
labelFilters->item(row)->setText(old_label + " ("+ QString::number(new_count) +")"); labelFilters->item(row)->setText(old_label + " ("+ QString::number(new_count) +")");
} }
@ -366,10 +364,10 @@ protected slots:
if(!new_label.isEmpty()) { if(!new_label.isEmpty()) {
if(!customLabels.contains(new_label)) if(!customLabels.contains(new_label))
addLabel(new_label); addLabel(new_label);
int new_count = customLabels.value(new_label, 0) + 1; const int new_count = customLabels.value(new_label, 0) + 1;
Q_ASSERT(new_count >= 1); Q_ASSERT(new_count >= 1);
customLabels.insert(new_label, new_count); customLabels.insert(new_label, new_count);
int row = labelFilters->rowFromLabel(new_label); const int row = labelFilters->rowFromLabel(new_label);
Q_ASSERT(row >= 2); Q_ASSERT(row >= 2);
labelFilters->item(row)->setText(new_label + " ("+ QString::number(new_count) +")"); labelFilters->item(row)->setText(new_label + " ("+ QString::number(new_count) +")");
++nb_labeled; ++nb_labeled;
@ -380,17 +378,17 @@ protected slots:
void torrentAdded(QModelIndex index) { void torrentAdded(QModelIndex index) {
Q_ASSERT(index.isValid()); Q_ASSERT(index.isValid());
if(!index.isValid()) return; if(!index.isValid()) return;
QString label = transferList->getSourceModel()->index(index.row(), TR_LABEL).data(Qt::DisplayRole).toString().trimmed(); const QString &label = transferList->getSourceModel()->index(index.row(), TR_LABEL).data(Qt::DisplayRole).toString().trimmed();
qDebug("New torrent was added with label: %s", label.toLocal8Bit().data()); qDebug("New torrent was added with label: %s", qPrintable(label));
if(!label.isEmpty()) { if(!label.isEmpty()) {
if(!customLabels.contains(label)) { if(!customLabels.contains(label)) {
addLabel(label); addLabel(label);
} }
// Update label counter // Update label counter
Q_ASSERT(customLabels.contains(label)); Q_ASSERT(customLabels.contains(label));
int new_count = customLabels.value(label, 0) + 1; const int new_count = customLabels.value(label, 0) + 1;
customLabels.insert(label, new_count); customLabels.insert(label, new_count);
int row = labelFilters->rowFromLabel(label); const int row = labelFilters->rowFromLabel(label);
qDebug("torrentAdded, Row: %d", row); qDebug("torrentAdded, Row: %d", row);
Q_ASSERT(row >= 2); Q_ASSERT(row >= 2);
Q_ASSERT(labelFilters->item(row)); Q_ASSERT(labelFilters->item(row));
@ -410,9 +408,9 @@ protected slots:
QString label = transferList->getSourceModel()->index(index.row(), TR_LABEL).data(Qt::DisplayRole).toString().trimmed(); QString label = transferList->getSourceModel()->index(index.row(), TR_LABEL).data(Qt::DisplayRole).toString().trimmed();
if(!label.isEmpty()) { if(!label.isEmpty()) {
// Update label counter // Update label counter
int new_count = customLabels.value(label, 0) - 1; const int new_count = customLabels.value(label, 0) - 1;
customLabels.insert(label, new_count); customLabels.insert(label, new_count);
int row = labelFilters->rowFromLabel(label); const int row = labelFilters->rowFromLabel(label);
Q_ASSERT(row >= 2); Q_ASSERT(row >= 2);
labelFilters->item(row)->setText(label + " ("+ QString::number(new_count) +")"); labelFilters->item(row)->setText(label + " ("+ QString::number(new_count) +")");
--nb_labeled; --nb_labeled;

6
src/transferlistwidget.cpp

@ -765,7 +765,7 @@ void TransferListWidget::setDlLimitSelectedTorrents() {
const long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Torrent Download Speed Limiting"), default_limit, Preferences::getGlobalDownloadLimit()*1024.); const long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Torrent Download Speed Limiting"), default_limit, Preferences::getGlobalDownloadLimit()*1024.);
if(ok) { if(ok) {
foreach(const QTorrentHandle &h, selected_torrents) { foreach(const QTorrentHandle &h, selected_torrents) {
qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (long)(new_limit/1024.), h.hash().toLocal8Bit().constData()); qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (long)(new_limit/1024.), qPrintable(h.hash()));
BTSession->setDownloadLimit(h.hash(), new_limit); BTSession->setDownloadLimit(h.hash(), new_limit);
} }
} }
@ -798,7 +798,7 @@ void TransferListWidget::setUpLimitSelectedTorrents() {
const long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Torrent Upload Speed Limiting"), default_limit, Preferences::getGlobalUploadLimit()*1024.); const long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Torrent Upload Speed Limiting"), default_limit, Preferences::getGlobalUploadLimit()*1024.);
if(ok) { if(ok) {
foreach(const QTorrentHandle &h, selected_torrents) { foreach(const QTorrentHandle &h, selected_torrents) {
qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (long)(new_limit/1024.), h.hash().toLocal8Bit().constData()); qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (long)(new_limit/1024.), qPrintable(h.hash()));
BTSession->setUploadLimit(h.hash(), new_limit); BTSession->setUploadLimit(h.hash(), new_limit);
} }
} }
@ -1296,7 +1296,7 @@ void TransferListWidget::applyLabelFilter(QString label) {
labelFilterModel->setFilterRegExp(QRegExp("^$")); labelFilterModel->setFilterRegExp(QRegExp("^$"));
return; return;
} }
qDebug("Applying Label filter: %s", label.toLocal8Bit().data()); qDebug("Applying Label filter: %s", qPrintable(label));
labelFilterModel->setFilterRegExp(QRegExp("^"+label+"$", Qt::CaseSensitive)); labelFilterModel->setFilterRegExp(QRegExp("^"+label+"$", Qt::CaseSensitive));
} }

Loading…
Cancel
Save