mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Make use of Fast concatenation feature in Qt 4.6
This commit is contained in:
parent
6d7fba1a6c
commit
a468404ab5
@ -822,8 +822,9 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
|
||||
//Getting fast resume data if existing
|
||||
std::vector<char> buf;
|
||||
if(resumed) {
|
||||
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().constData(), buf) == 0) {
|
||||
const QString &fastresume_path = torrentBackup.path()+QDir::separator()+hash+QString(".fastresume");
|
||||
qDebug("Trying to load fastresume data: %s", qPrintable(fastresume_path));
|
||||
if (load_file(fastresume_path.toLocal8Bit().constData(), buf) == 0) {
|
||||
fastResume = true;
|
||||
p.resume_data = &buf;
|
||||
qDebug("Successfuly loaded");
|
||||
@ -1030,8 +1031,9 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
|
||||
//Getting fast resume data if existing
|
||||
std::vector<char> buf;
|
||||
if(resumed) {
|
||||
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().constData(), buf) == 0) {
|
||||
const QString &fastresume_path = torrentBackup.path()+QDir::separator()+hash+QString(".fastresume");
|
||||
qDebug("Trying to load fastresume data: %s", qPrintable(fastresume_path));
|
||||
if (load_file(fastresume_path.toLocal8Bit().constData(), buf) == 0) {
|
||||
fastResume = true;
|
||||
p.resume_data = &buf;
|
||||
qDebug("Successfuly loaded");
|
||||
@ -1315,7 +1317,8 @@ void Bittorrent::enableLSD(bool b) {
|
||||
}
|
||||
|
||||
void Bittorrent::loadSessionState() {
|
||||
boost::filesystem::ifstream ses_state_file((misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state")).toLocal8Bit().constData()
|
||||
const QString &state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state");
|
||||
boost::filesystem::ifstream ses_state_file(state_path.toLocal8Bit().constData()
|
||||
, std::ios_base::binary);
|
||||
ses_state_file.unsetf(std::ios_base::skipws);
|
||||
s->load_state(bdecode(
|
||||
@ -1326,7 +1329,8 @@ void Bittorrent::loadSessionState() {
|
||||
void Bittorrent::saveSessionState() {
|
||||
qDebug("Saving session state to disk...");
|
||||
entry session_state = s->state();
|
||||
boost::filesystem::ofstream out((misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state")).toLocal8Bit().constData()
|
||||
const QString &state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state");
|
||||
boost::filesystem::ofstream out(state_path.toLocal8Bit().constData()
|
||||
, std::ios_base::binary);
|
||||
out.unsetf(std::ios_base::skipws);
|
||||
bencode(std::ostream_iterator<char>(out), session_state);
|
||||
@ -2217,7 +2221,8 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||
if(DHTEnabled) {
|
||||
try{
|
||||
entry dht_state = s->dht_state();
|
||||
boost::filesystem::ofstream out((misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state")).toLocal8Bit().constData(), std::ios_base::binary);
|
||||
const QString &dht_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state");
|
||||
boost::filesystem::ofstream out(dht_path.toLocal8Bit().constData(), std::ios_base::binary);
|
||||
out.unsetf(std::ios_base::skipws);
|
||||
bencode(std::ostream_iterator<char>(out), dht_state);
|
||||
qDebug("DHT entry saved");
|
||||
|
@ -117,7 +117,7 @@ void downloadThread::applyProxySettings() {
|
||||
QString IP = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/IP"), "0.0.0.0").toString();
|
||||
proxy.setHostName(IP);
|
||||
QString port = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Port"), 8080).toString();
|
||||
qDebug("Using proxy: %s", qPrintable(IP+QString(":")+port));
|
||||
qDebug("Using proxy: %s", qPrintable(IP));
|
||||
proxy.setPort(port.toUShort());
|
||||
// Default proxy type is HTTP, we must change if it is SOCKS5
|
||||
if(intValue == SOCKS5 || intValue == SOCKS5_PW) {
|
||||
|
@ -295,23 +295,23 @@ QVariantMap EventManager::getPropGeneralInfo(QString hash) const {
|
||||
data["creation_date"] = h.creation_date();
|
||||
// Comment
|
||||
data["comment"] = h.comment();
|
||||
data["total_wasted"] = misc::friendlyUnit(h.total_failed_bytes()+h.total_redundant_bytes());
|
||||
data["total_uploaded"] = misc::friendlyUnit(h.all_time_upload()) + " ("+misc::friendlyUnit(h.total_payload_upload())+" "+tr("this session")+")";
|
||||
data["total_downloaded"] = misc::friendlyUnit(h.all_time_download()) + " ("+misc::friendlyUnit(h.total_payload_download())+" "+tr("this session")+")";
|
||||
data["total_wasted"] = QVariant(misc::friendlyUnit(h.total_failed_bytes()+h.total_redundant_bytes()));
|
||||
data["total_uploaded"] = QVariant(misc::friendlyUnit(h.all_time_upload()) + " ("+misc::friendlyUnit(h.total_payload_upload())+" "+tr("this session")+")");
|
||||
data["total_downloaded"] = QVariant(misc::friendlyUnit(h.all_time_download()) + " ("+misc::friendlyUnit(h.total_payload_download())+" "+tr("this session")+")");
|
||||
if(h.upload_limit() <= 0)
|
||||
data["up_limit"] = QString::fromUtf8("∞");
|
||||
else
|
||||
data["up_limit"] = misc::friendlyUnit(h.upload_limit())+tr("/s", "/second (i.e. per second)");
|
||||
data["up_limit"] = QVariant(misc::friendlyUnit(h.upload_limit())+tr("/s", "/second (i.e. per second)"));
|
||||
if(h.download_limit() <= 0)
|
||||
data["dl_limit"] = QString::fromUtf8("∞");
|
||||
else
|
||||
data["dl_limit"] = misc::friendlyUnit(h.download_limit())+tr("/s", "/second (i.e. per second)");
|
||||
data["dl_limit"] = QVariant(misc::friendlyUnit(h.download_limit())+tr("/s", "/second (i.e. per second)"));
|
||||
QString elapsed_txt = misc::userFriendlyDuration(h.active_time());
|
||||
if(h.is_seed()) {
|
||||
elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(misc::userFriendlyDuration(h.seeding_time()))+")";
|
||||
}
|
||||
data["time_elapsed"] = elapsed_txt;
|
||||
data["nb_connections"] = QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")";
|
||||
data["nb_connections"] = QVariant(QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")");
|
||||
// Update ratio info
|
||||
double ratio = BTSession->getRealRatio(h.hash());
|
||||
if(ratio > 100.)
|
||||
|
@ -329,7 +329,8 @@ public:
|
||||
#ifndef Q_WS_WIN
|
||||
unsigned long long available;
|
||||
struct statfs stats;
|
||||
const int ret = statfs ((dir_path.path()+"/.").toLocal8Bit().data(), &stats) ;
|
||||
const QString &statfs_path = dir_path.path()+"/.";
|
||||
const int ret = statfs (qPrintable(statfs_path), &stats) ;
|
||||
if(ret == 0) {
|
||||
available = ((unsigned long long)stats.f_bavail) *
|
||||
((unsigned long long)stats.f_bsize) ;
|
||||
|
@ -279,7 +279,7 @@ void PeerListWidget::saveSettings() const {
|
||||
else
|
||||
sortOrderLetter = QString::fromUtf8("d");
|
||||
int index = header()->sortIndicatorSection();
|
||||
settings.setValue(QString::fromUtf8("TorrentProperties/Peers/PeerListSortedCol"), QString::number(index)+sortOrderLetter);
|
||||
settings.setValue(QString::fromUtf8("TorrentProperties/Peers/PeerListSortedCol"), QVariant(QString::number(index)+sortOrderLetter));
|
||||
}
|
||||
|
||||
void PeerListWidget::loadPeers(const QTorrentHandle &h, bool force_hostname_resolution) {
|
||||
|
@ -121,11 +121,7 @@ public:
|
||||
// Downloads
|
||||
static QString getSavePath() {
|
||||
QSettings settings("qBittorrent", "qBittorrent");
|
||||
QString home = QDir::homePath();
|
||||
if(home[home.length()-1] != QDir::separator()){
|
||||
home += QDir::separator();
|
||||
}
|
||||
return settings.value(QString::fromUtf8("Preferences/Downloads/SavePath"), home+"qBT_dir").toString();
|
||||
return settings.value(QString::fromUtf8("Preferences/Downloads/SavePath"), QDir::home().absoluteFilePath("qBT_dir")).toString();
|
||||
}
|
||||
|
||||
static void setSavePath(QString save_path) {
|
||||
@ -145,8 +141,8 @@ public:
|
||||
|
||||
static QString getTempPath() {
|
||||
QSettings settings("qBittorrent", "qBittorrent");
|
||||
QString home = QDir::homePath();
|
||||
return settings.value(QString::fromUtf8("Preferences/Downloads/TempPath"), home+"qBT_dir"+QDir::separator()+"temp").toString();
|
||||
QString temp = QDir::home().absoluteFilePath("qBT_dir")+QDir::separator()+"temp";
|
||||
return settings.value(QString::fromUtf8("Preferences/Downloads/TempPath"), temp).toString();
|
||||
}
|
||||
|
||||
static void setTempPath(QString path) {
|
||||
|
@ -293,7 +293,7 @@ void PropertiesWidget::saveSettings() {
|
||||
sizes = slideSizes;
|
||||
qDebug("Sizes: %d", sizes.size());
|
||||
if(sizes.size() == 2) {
|
||||
settings.setValue(QString::fromUtf8("TorrentProperties/SplitterSizes"), QString::number(sizes.first())+','+QString::number(sizes.last()));
|
||||
settings.setValue(QString::fromUtf8("TorrentProperties/SplitterSizes"), QVariant(QString::number(sizes.first())+','+QString::number(sizes.last())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -480,7 +480,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
|
||||
h.flush_cache();
|
||||
#endif
|
||||
if(QFile::exists(file_path))
|
||||
QDesktopServices::openUrl("file://"+file_path);
|
||||
QDesktopServices::openUrl(QUrl("file://"+file_path));
|
||||
else
|
||||
QMessageBox::warning(this, tr("I/O Error"), tr("This file does not exist yet."));
|
||||
} else {
|
||||
@ -501,7 +501,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
|
||||
h.flush_cache();
|
||||
#endif
|
||||
if(QFile::exists(file_path))
|
||||
QDesktopServices::openUrl("file://"+file_path);
|
||||
QDesktopServices::openUrl(QUrl("file://"+file_path));
|
||||
else
|
||||
QMessageBox::warning(this, tr("I/O Error"), tr("This folder does not exist yet."));
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ void RSSImp::fillFeedsList(QTreeWidgetItem *parent, RssFolder *rss_parent) {
|
||||
item = new QTreeWidgetItem(listStreams);
|
||||
else
|
||||
item = new QTreeWidgetItem(parent);
|
||||
item->setData(0, Qt::DisplayRole, rss_child->getName()+ QString::fromUtf8(" (")+QString::number(rss_child->getNbUnRead(), 10)+QString(")"));
|
||||
item->setData(0, Qt::DisplayRole, QVariant(rss_child->getName()+ QString::fromUtf8(" (")+QString::number(rss_child->getNbUnRead(), 10)+QString(")")));
|
||||
// Notify TreeWidget of item addition
|
||||
listStreams->itemAdded(item, rss_child);
|
||||
// Set Icon
|
||||
|
@ -432,14 +432,15 @@ void SearchEngine::updateNova() {
|
||||
QString shipped_file = shipped_subDir.path()+"/"+file;
|
||||
// Copy python classes
|
||||
if(file.endsWith(".py")) {
|
||||
if(getPluginVersion(shipped_file) > getPluginVersion(destDir+file) ) {
|
||||
const QString &dest_file = destDir+file;
|
||||
if(getPluginVersion(shipped_file) > getPluginVersion(dest_file) ) {
|
||||
qDebug("shippped %s is more recent then local plugin, updating", qPrintable(file));
|
||||
if(QFile::exists(destDir+file)) {
|
||||
qDebug("Removing old %s", qPrintable(destDir+file));
|
||||
QFile::remove(destDir+file);
|
||||
if(QFile::exists(dest_file)) {
|
||||
qDebug("Removing old %s", qPrintable(dest_file));
|
||||
QFile::remove(dest_file);
|
||||
}
|
||||
qDebug("%s copied to %s", qPrintable(shipped_file), qPrintable(destDir+file));
|
||||
QFile::copy(shipped_file, destDir+file);
|
||||
qDebug("%s copied to %s", qPrintable(shipped_file), qPrintable(dest_file));
|
||||
QFile::copy(shipped_file, dest_file);
|
||||
}
|
||||
} else {
|
||||
// Copy icons
|
||||
|
@ -108,6 +108,9 @@ QT += network
|
||||
|
||||
DEFINES += QT_NO_CAST_TO_ASCII
|
||||
|
||||
# Fast concatenation (Qt >= 4.6)
|
||||
DEFINES += QT_USE_FAST_CONCATENATION QT_USE_FAST_OPERATOR_PLUS
|
||||
|
||||
# Windows
|
||||
# usually built as static
|
||||
# win32:LIBS += -ltorrent -lboost_system
|
||||
|
@ -172,19 +172,19 @@ public:
|
||||
vLayout->setSpacing(2);
|
||||
// Add status filters
|
||||
QListWidgetItem *all = new QListWidgetItem(statusFilters);
|
||||
all->setData(Qt::DisplayRole, tr("All") + " (0)");
|
||||
all->setData(Qt::DisplayRole, QVariant(tr("All") + " (0)"));
|
||||
all->setData(Qt::DecorationRole, QIcon(":/Icons/skin/filterall.png"));
|
||||
QListWidgetItem *downloading = new QListWidgetItem(statusFilters);
|
||||
downloading->setData(Qt::DisplayRole, tr("Downloading") + " (0)");
|
||||
downloading->setData(Qt::DisplayRole, QVariant(tr("Downloading") + " (0)"));
|
||||
downloading->setData(Qt::DecorationRole, QIcon(":/Icons/skin/downloading.png"));
|
||||
QListWidgetItem *completed = new QListWidgetItem(statusFilters);
|
||||
completed->setData(Qt::DisplayRole, tr("Completed") + " (0)");
|
||||
completed->setData(Qt::DisplayRole, QVariant(tr("Completed") + " (0)"));
|
||||
completed->setData(Qt::DecorationRole, QIcon(":/Icons/skin/uploading.png"));
|
||||
QListWidgetItem *active = new QListWidgetItem(statusFilters);
|
||||
active->setData(Qt::DisplayRole, tr("Active") + " (0)");
|
||||
active->setData(Qt::DisplayRole, QVariant(tr("Active") + " (0)"));
|
||||
active->setData(Qt::DecorationRole, QIcon(":/Icons/skin/filteractive.png"));
|
||||
QListWidgetItem *inactive = new QListWidgetItem(statusFilters);
|
||||
inactive->setData(Qt::DisplayRole, tr("Inactive") + " (0)");
|
||||
inactive->setData(Qt::DisplayRole, QVariant(tr("Inactive") + " (0)"));
|
||||
inactive->setData(Qt::DecorationRole, QIcon(":/Icons/skin/filterinactive.png"));
|
||||
|
||||
// SIGNAL/SLOT
|
||||
@ -198,10 +198,10 @@ public:
|
||||
|
||||
// Add Label filters
|
||||
QListWidgetItem *allLabels = new QListWidgetItem(labelFilters);
|
||||
allLabels->setData(Qt::DisplayRole, tr("All labels") + " (0)");
|
||||
allLabels->setData(Qt::DisplayRole, QVariant(tr("All labels") + " (0)"));
|
||||
allLabels->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png"));
|
||||
QListWidgetItem *noLabel = new QListWidgetItem(labelFilters);
|
||||
noLabel->setData(Qt::DisplayRole, tr("Unlabeled") + " (0)");
|
||||
noLabel->setData(Qt::DisplayRole, QVariant(tr("Unlabeled") + " (0)"));
|
||||
noLabel->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png"));
|
||||
|
||||
// Load settings
|
||||
@ -257,11 +257,11 @@ public:
|
||||
|
||||
protected slots:
|
||||
void updateTorrentNumbers(uint nb_downloading, uint nb_seeding, uint nb_active, uint nb_inactive) {
|
||||
statusFilters->item(FILTER_ALL)->setData(Qt::DisplayRole, tr("All")+" ("+QString::number(nb_active+nb_inactive)+")");
|
||||
statusFilters->item(FILTER_DOWNLOADING)->setData(Qt::DisplayRole, tr("Downloading")+" ("+QString::number(nb_downloading)+")");
|
||||
statusFilters->item(FILTER_COMPLETED)->setData(Qt::DisplayRole, tr("Completed")+" ("+QString::number(nb_seeding)+")");
|
||||
statusFilters->item(FILTER_ACTIVE)->setData(Qt::DisplayRole, tr("Active")+" ("+QString::number(nb_active)+")");
|
||||
statusFilters->item(FILTER_INACTIVE)->setData(Qt::DisplayRole, tr("Inactive")+" ("+QString::number(nb_inactive)+")");
|
||||
statusFilters->item(FILTER_ALL)->setData(Qt::DisplayRole, QVariant(tr("All")+" ("+QString::number(nb_active+nb_inactive)+")"));
|
||||
statusFilters->item(FILTER_DOWNLOADING)->setData(Qt::DisplayRole, QVariant(tr("Downloading")+" ("+QString::number(nb_downloading)+")"));
|
||||
statusFilters->item(FILTER_COMPLETED)->setData(Qt::DisplayRole, QVariant(tr("Completed")+" ("+QString::number(nb_seeding)+")"));
|
||||
statusFilters->item(FILTER_ACTIVE)->setData(Qt::DisplayRole, QVariant(tr("Active")+" ("+QString::number(nb_active)+")"));
|
||||
statusFilters->item(FILTER_INACTIVE)->setData(Qt::DisplayRole, QVariant(tr("Inactive")+" ("+QString::number(nb_inactive)+")"));
|
||||
}
|
||||
|
||||
void torrentDropped(int row) {
|
||||
|
@ -295,7 +295,7 @@ void TransferListWidget::updateMetadata(QTorrentHandle &h) {
|
||||
}
|
||||
|
||||
void TransferListWidget::previewFile(QString filePath) {
|
||||
QDesktopServices::openUrl(QString("file://")+filePath);
|
||||
QDesktopServices::openUrl(QUrl(QString("file://")+filePath));
|
||||
}
|
||||
|
||||
int TransferListWidget::updateTorrent(int row) {
|
||||
@ -584,9 +584,9 @@ void TransferListWidget::torrentDoubleClicked(const QModelIndex& index) {
|
||||
break;
|
||||
case OPEN_DEST:
|
||||
if(h.has_metadata())
|
||||
QDesktopServices::openUrl("file://" + h.root_path());
|
||||
QDesktopServices::openUrl(QUrl("file://" + h.root_path()));
|
||||
else
|
||||
QDesktopServices::openUrl("file://" + h.save_path());
|
||||
QDesktopServices::openUrl(QUrl("file://" + h.save_path()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -693,7 +693,7 @@ void TransferListWidget::buySelectedTorrents() const {
|
||||
foreach(const QString &hash, hashes) {
|
||||
const QTorrentHandle &h = BTSession->getTorrentHandle(hash);
|
||||
if(h.is_valid())
|
||||
QDesktopServices::openUrl("http://match.sharemonkey.com/?info_hash="+h.hash()+"&n="+h.name()+"&cid=33");
|
||||
QDesktopServices::openUrl(QUrl("http://match.sharemonkey.com/?info_hash="+h.hash()+"&n="+h.name()+"&cid=33"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1257,7 +1257,7 @@ void TransferListWidget::saveLastSortedColumn() {
|
||||
else
|
||||
sortOrderLetter = QString::fromUtf8("d");
|
||||
const int index = header()->sortIndicatorSection();
|
||||
settings.setValue(QString::fromUtf8("TransferListSortedCol"), QString::number(index)+sortOrderLetter);
|
||||
settings.setValue(QString::fromUtf8("TransferListSortedCol"), QVariant(QString::number(index)+sortOrderLetter));
|
||||
}
|
||||
|
||||
void TransferListWidget::loadLastSortedColumn() {
|
||||
|
Loading…
Reference in New Issue
Block a user