1
mirror of https://github.com/qbittorrent/qBittorrent synced 2025-10-26 06:12:17 +01:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Christophe Dumez
89c9a646ad Tagged v2.1.4 bugfix release 2010-02-08 19:30:01 +00:00
23 changed files with 102 additions and 144 deletions

View File

@@ -1,19 +1,3 @@
* Thu Mar 4 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.6
- BUGFIX: Fix Web UI authentication with Konqueror
- BUGFIX: Fix save path display in properties
- BUGFIX: Fix ratio calculation for directly seeded torrents (Thanks phorane)
- BUGFIX: Fix memory leak in RSS parser
- BUGFIX: Only one log window can be opened at a time
- BUGFIX: Command-line parameters are no longer required to be in UTF-8
* Web Feb 10 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.5
- BUGFIX: Fix actions on selected torrents (non-selected torrents could be affected)
- BUGFIX: Only one program preferences dialog is allowed at a time
- BUGFIX: Link against boost and ssl to fix issues with gold linker
- BUGFIX: Fix memory leak in RSS
- BUGFIX: Improved HTTP gzip compression detection in downloader
- BUGFIX: Fix possible race condition in search engine
* Mon Feb 8 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.4 * Mon Feb 8 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.4
- BUGFIX: Fix file prioritizing in a torrent - BUGFIX: Fix file prioritizing in a torrent
- BUGFIX: Make sure seeding torrents display a progress of 100% - BUGFIX: Make sure seeding torrents display a progress of 100%

10
configure vendored
View File

@@ -359,18 +359,12 @@ public:
return false; return false;
for(int n = 0; n < incs.count(); ++n) for(int n = 0; n < incs.count(); ++n)
conf->addIncludePath(incs[n]); conf->addIncludePath(incs[n]);
//if(!libs.isEmpty()) if(!libs.isEmpty())
// conf->addLib(libs); conf->addLib(libs);
if(!conf->findPkgConfig("libtorrent-rasterbar", mode, adv_ver, &version, &incs, &libs, &other)) if(!conf->findPkgConfig("libtorrent-rasterbar", mode, adv_ver, &version, &incs, &libs, &other))
printf("\nWarning: libtorrent-rasterbar v%s was detected. Some feature will be disabled because they require v%s.\n", version.toLocal8Bit().data(), adv_ver.toUtf8().data()); printf("\nWarning: libtorrent-rasterbar v%s was detected. Some feature will be disabled because they require v%s.\n", version.toLocal8Bit().data(), adv_ver.toUtf8().data());
else else
conf->addDefine("LIBTORRENT_0_15"); conf->addDefine("LIBTORRENT_0_15");
// Get linking parameters
QStringList params;
QByteArray staticlibs;
params << "--static" << "--libs" << "libtorrent-rasterbar";
conf->doCommand("pkg-config", params, &staticlibs);
conf->addLib(staticlibs.trimmed());
return true; return true;
} }
}; };

View File

@@ -20,18 +20,12 @@ public:
return false; return false;
for(int n = 0; n < incs.count(); ++n) for(int n = 0; n < incs.count(); ++n)
conf->addIncludePath(incs[n]); conf->addIncludePath(incs[n]);
//if(!libs.isEmpty()) if(!libs.isEmpty())
// conf->addLib(libs); conf->addLib(libs);
if(!conf->findPkgConfig("libtorrent-rasterbar", mode, adv_ver, &version, &incs, &libs, &other)) if(!conf->findPkgConfig("libtorrent-rasterbar", mode, adv_ver, &version, &incs, &libs, &other))
printf("\nWarning: libtorrent-rasterbar v%s was detected. Some feature will be disabled because they require v%s.\n", version.toLocal8Bit().data(), adv_ver.toUtf8().data()); printf("\nWarning: libtorrent-rasterbar v%s was detected. Some feature will be disabled because they require v%s.\n", version.toLocal8Bit().data(), adv_ver.toUtf8().data());
else else
conf->addDefine("LIBTORRENT_0_15"); conf->addDefine("LIBTORRENT_0_15");
// Get linking parameters
QStringList params;
QByteArray staticlibs;
params << "--static" << "--libs" << "libtorrent-rasterbar";
conf->doCommand("pkg-config", params, &staticlibs);
conf->addLib(staticlibs.trimmed());
return true; return true;
} }
}; };

View File

@@ -217,10 +217,7 @@ GUI::~GUI() {
delete status_bar; delete status_bar;
delete transferList; delete transferList;
delete guiUpdater; delete guiUpdater;
if (console)
delete console;
if(options)
delete options;
if(rssWidget) if(rssWidget)
delete rssWidget; delete rssWidget;
delete searchEngine; delete searchEngine;
@@ -396,7 +393,7 @@ void GUI::readParamsOnSocket() {
if(clientConnection) { if(clientConnection) {
QByteArray params = clientConnection->readAll(); QByteArray params = clientConnection->readAll();
if(!params.isEmpty()) { if(!params.isEmpty()) {
processParams(QString::fromLocal8Bit(params.constData()).split("\n")); processParams(QString::fromUtf8(params.data()).split(QString::fromUtf8("\n")));
qDebug("Received parameters from another instance"); qDebug("Received parameters from another instance");
} }
clientConnection->deleteLater(); clientConnection->deleteLater();
@@ -423,11 +420,7 @@ void GUI::on_actionSet_global_upload_limit_triggered() {
} }
void GUI::on_actionShow_console_triggered() { void GUI::on_actionShow_console_triggered() {
if(!console) { new consoleDlg(this, BTSession);
console = new consoleDlg(this, BTSession);
} else {
console->setFocus();
}
} }
void GUI::on_actionSet_global_download_limit_triggered() { void GUI::on_actionSet_global_download_limit_triggered() {
@@ -915,13 +908,8 @@ void GUI::createTrayIcon() {
// Display Program Options // Display Program Options
void GUI::on_actionOptions_triggered() { void GUI::on_actionOptions_triggered() {
if(!options) { options = new options_imp(this);
options = new options_imp(this); connect(options, SIGNAL(status_changed()), this, SLOT(optionsSaved()));
connect(options, SIGNAL(status_changed()), this, SLOT(optionsSaved()));
} else {
// Get focus
options->setFocus();
}
} }
/***************************************************** /*****************************************************

View File

@@ -55,7 +55,6 @@ class TransferListFiltersWidget;
class QSplitter; class QSplitter;
class PropertiesWidget; class PropertiesWidget;
class StatusBar; class StatusBar;
class consoleDlg;
class GUI : public QMainWindow, private Ui::MainWindow{ class GUI : public QMainWindow, private Ui::MainWindow{
Q_OBJECT Q_OBJECT
@@ -69,7 +68,6 @@ private:
QTabWidget *tabs; QTabWidget *tabs;
StatusBar *status_bar; StatusBar *status_bar;
QPointer<options_imp> options; QPointer<options_imp> options;
QPointer<consoleDlg> console;
QPointer<QSystemTrayIcon> systrayIcon; QPointer<QSystemTrayIcon> systrayIcon;
QPointer<QTimer> systrayCreator; QPointer<QTimer> systrayCreator;
QMenu *myTrayIconMenu; QMenu *myTrayIconMenu;

View File

@@ -1,6 +1,6 @@
[Desktop Entry] [Desktop Entry]
Categories=Qt;Network;P2P; Categories=Qt;Network;P2P;
Comment=V2.1.6 Comment=V2.1.4
Exec=qbittorrent %f Exec=qbittorrent %f
GenericName=Bittorrent client GenericName=Bittorrent client
GenericName[bg]=Торент клиент GenericName[bg]=Торент клиент

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

View File

@@ -1232,14 +1232,14 @@ bool Bittorrent::enableDHT(bool b) {
float Bittorrent::getRealRatio(QString hash) const{ float Bittorrent::getRealRatio(QString hash) const{
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
Q_ASSERT(h.total_done() >= 0); Q_ASSERT(h.all_time_download() >= 0);
Q_ASSERT(h.all_time_upload() >= 0); Q_ASSERT(h.all_time_upload() >= 0);
if(h.total_done() == 0) { if(h.all_time_download() == 0) {
if(h.all_time_upload() == 0) if(h.all_time_upload() == 0)
return 0; return 0;
return 101; return 101;
} }
float ratio = (float)h.all_time_upload()/(float)h.total_done(); float ratio = (float)h.all_time_upload()/(float)h.all_time_download();
Q_ASSERT(ratio >= 0.); Q_ASSERT(ratio >= 0.);
if(ratio > 100.) if(ratio > 100.)
ratio = 100.; ratio = 100.;

View File

@@ -103,7 +103,6 @@ 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");
request.setRawHeader("Accept-Encoding", "");
qDebug("Downloading %s...", request.url().toString().toLocal8Bit().data()); qDebug("Downloading %s...", request.url().toString().toLocal8Bit().data());
networkManager->get(request); networkManager->get(request);
} }

View File

@@ -282,9 +282,7 @@ QVariantMap EventManager::getPropGeneralInfo(QString hash) const {
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid() && h.has_metadata()) { if(h.is_valid() && h.has_metadata()) {
// Save path // Save path
QString p = TorrentPersistentData::getSavePath(hash); data["save_path"] = TorrentPersistentData::getSavePath(hash);
if(p.isEmpty()) p = h.save_path();
data["save_path"] = p;
// Creation date // Creation date
data["creation_date"] = h.creation_date(); data["creation_date"] = h.creation_date();
// Comment // Comment

View File

@@ -138,7 +138,6 @@ void HttpConnection::respond() {
return; return;
} }
QString auth = parser.value("Authorization"); QString auth = parser.value("Authorization");
qDebug("Auth: %s", auth.split(" ").first().toLocal8Bit().data());
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);

View File

@@ -207,7 +207,7 @@ bool HttpServer::isAuthorized(QByteArray auth, QString method) const {
} }
QByteArray prop_cnonce = regex_cnonce.cap(1).toLocal8Bit(); QByteArray prop_cnonce = regex_cnonce.cap(1).toLocal8Bit();
qDebug("prop cnonce is: %s", prop_cnonce.data()); qDebug("prop cnonce is: %s", prop_cnonce.data());
QRegExp regex_qop(".*qop=[\"]?(\\w+)[\"]?.*"); QRegExp regex_qop(".*qop=(\\w+).*");
if(regex_qop.indexIn(auth) < 0) { if(regex_qop.indexIn(auth) < 0) {
qDebug("AUTH-PROB: missing qop"); qDebug("AUTH-PROB: missing qop");
return false; return false;

View File

@@ -40,7 +40,6 @@
#include "qgnomelook.h" #include "qgnomelook.h"
#include <QMotifStyle> #include <QMotifStyle>
#include <QCDEStyle> #include <QCDEStyle>
#include <QPushButton>
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
#include <QWindowsXPStyle> #include <QWindowsXPStyle>
#endif #endif
@@ -113,7 +112,7 @@ public:
msgBox.setText(tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.\n\nNo further notices will be issued.")); msgBox.setText(tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.\n\nNo further notices will be issued."));
msgBox.setWindowTitle(tr("Legal notice")); msgBox.setWindowTitle(tr("Legal notice"));
msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole); msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
QAbstractButton *agree_button =msgBox.addButton(tr("I Agree"), QMessageBox::AcceptRole); QAbstractButton *agree_button =(QAbstractButton*)msgBox.addButton(tr("I Agree"), QMessageBox::AcceptRole);
msgBox.exec(); msgBox.exec();
if(msgBox.clickedButton() == agree_button) { if(msgBox.clickedButton() == agree_button) {
// Save the answer // Save the answer
@@ -256,12 +255,12 @@ int main(int argc, char *argv[]){
// Check for executable parameters // Check for executable parameters
if(argc > 1){ if(argc > 1){
if(QString::fromLocal8Bit(argv[1]) == QString::fromUtf8("--version")){ if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--version")){
std::cout << "qBittorrent " << VERSION << '\n'; std::cout << "qBittorrent " << VERSION << '\n';
delete app; delete app;
return 0; return 0;
} }
if(QString::fromLocal8Bit(argv[1]) == QString::fromUtf8("--help")){ if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--help")){
UsageDisplay::displayUsage(argv[0]); UsageDisplay::displayUsage(argv[0]);
delete app; delete app;
return 0; return 0;
@@ -269,11 +268,11 @@ int main(int argc, char *argv[]){
for(int i=1; i<argc; ++i) { for(int i=1; i<argc; ++i) {
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
if(QString::fromLocal8Bit(argv[i]) == QString::fromUtf8("--no-splash")) { if(QString::fromUtf8(argv[i]) == QString::fromUtf8("--no-splash")) {
no_splash = true; no_splash = true;
} else { } else {
#endif #endif
if(QString::fromLocal8Bit(argv[i]).startsWith("--webui-port=")) { if(QString::fromUtf8(argv[i]).startsWith("--webui-port=")) {
QStringList parts = QString::fromUtf8(argv[i]).split("="); QStringList parts = QString::fromUtf8(argv[i]).split("=");
if(parts.size() == 2) { if(parts.size() == 2) {
bool ok = false; bool ok = false;

View File

@@ -208,10 +208,7 @@ Bittorrent* PropertiesWidget::getBTSession() const {
void PropertiesWidget::updateSavePath(QTorrentHandle& _h) { void PropertiesWidget::updateSavePath(QTorrentHandle& _h) {
if(h.is_valid() && h == _h) { if(h.is_valid() && h == _h) {
QString p = TorrentPersistentData::getSavePath(h.hash()); save_path->setText(TorrentPersistentData::getSavePath(h.hash()));
if(p.isEmpty())
p = h.save_path();
save_path->setText(p);
} }
} }
@@ -226,10 +223,7 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
try { try {
// Save path // Save path
QString p = TorrentPersistentData::getSavePath(h.hash()); save_path->setText(TorrentPersistentData::getSavePath(h.hash()));
if(p.isEmpty())
p = h.save_path();
save_path->setText(p);
// Creation date // Creation date
lbl_creationDate->setText(h.creation_date()); lbl_creationDate->setText(h.creation_date());
// Hash // Hash

View File

@@ -336,11 +336,6 @@ bool QTorrentHandle::is_checking() const {
return h.status().state == torrent_status::checking_files || h.status().state == torrent_status::checking_resume_data; return h.status().state == torrent_status::checking_files || h.status().state == torrent_status::checking_resume_data;
} }
size_type QTorrentHandle::total_done() {
Q_ASSERT(h.is_valid());
return h.status().total_done;
}
size_type QTorrentHandle::all_time_download() { size_type QTorrentHandle::all_time_download() {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
return h.status().all_time_download; return h.status().all_time_download;

View File

@@ -107,7 +107,6 @@ class QTorrentHandle {
size_type total_payload_upload(); size_type total_payload_upload();
size_type all_time_upload(); size_type all_time_upload();
size_type all_time_download(); size_type all_time_download();
size_type total_done();
QStringList files_path() const; QStringList files_path() const;
int num_uploads() const; int num_uploads() const;
bool is_seed() const; bool is_seed() const;

View File

@@ -391,8 +391,6 @@ RssStream::RssStream(RssFolder* parent, RssManager *rssmanager, Bittorrent *BTSe
RssItem *rss_item = RssItem::fromHash(this, item); RssItem *rss_item = RssItem::fromHash(this, item);
if(rss_item->isValid()) { if(rss_item->isValid()) {
(*this)[rss_item->getTitle()] = rss_item; (*this)[rss_item->getTitle()] = rss_item;
} else {
delete rss_item;
} }
} }
} }

View File

@@ -92,7 +92,6 @@ public:
enum FileType {STREAM, FOLDER}; enum FileType {STREAM, FOLDER};
RssFile(): QObject() {} RssFile(): QObject() {}
virtual ~RssFile() {}
virtual unsigned int getNbUnRead() const = 0; virtual unsigned int getNbUnRead() const = 0;
virtual FileType getType() const = 0; virtual FileType getType() const = 0;

View File

@@ -22,7 +22,7 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
#VERSION: 1.31 #VERSION: 1.3
# Author: # Author:
# Christophe DUMEZ (chris@qbittorrent.org) # Christophe DUMEZ (chris@qbittorrent.org)
@@ -84,14 +84,15 @@ def download_file(url, referer=None):
req.add_header('referer', referer) req.add_header('referer', referer)
response = urllib2.urlopen(req) response = urllib2.urlopen(req)
dat = response.read() dat = response.read()
# Check if it is gzipped # Check if data is gzip encoded
if dat[:2] == '\037\213': response_info = response.info()
content_encoding = response_info.get('Content-Encoding')
if content_encoding is not None and 'gzip' in content_encoding:
# Data is gzip encoded, decode it # Data is gzip encoded, decode it
compressedstream = StringIO.StringIO(dat) compressedstream = StringIO.StringIO(dat)
gzipper = gzip.GzipFile(fileobj=compressedstream) gzipper = gzip.GzipFile(fileobj=compressedstream)
extracted_data = gzipper.read() extracted_data = gzipper.read()
dat = extracted_data dat = extracted_data
# Write it to a file # Write it to a file
file.write(dat) file.write(dat)
file.close() file.close()

View File

@@ -210,7 +210,6 @@ void SearchEngine::on_search_button_clicked(){
search_button->setText("Search"); search_button->setText("Search");
return; return;
} }
searchProcess->waitForFinished();
// Reload environment variables (proxy) // Reload environment variables (proxy)
searchProcess->setEnvironment(QProcess::systemEnvironment()); searchProcess->setEnvironment(QProcess::systemEnvironment());

View File

@@ -11,10 +11,10 @@ CONFIG += qt \
thread thread
# Update this VERSION for each release # Update this VERSION for each release
DEFINES += VERSION=\\\"v2.1.6\\\" DEFINES += VERSION=\\\"v2.1.4\\\"
DEFINES += VERSION_MAJOR=2 DEFINES += VERSION_MAJOR=2
DEFINES += VERSION_MINOR=1 DEFINES += VERSION_MINOR=1
DEFINES += VERSION_BUGFIX=6 DEFINES += VERSION_BUGFIX=4
# NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL # NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL
DEFINES += VERSION_TYPE=NORMAL DEFINES += VERSION_TYPE=NORMAL
@@ -105,7 +105,6 @@ contains(DEFINES, DISABLE_GUI) {
unix:QMAKE_LFLAGS_SHAPP += -rdynamic unix:QMAKE_LFLAGS_SHAPP += -rdynamic
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
PKGCONFIG += "libtorrent-rasterbar" PKGCONFIG += "libtorrent-rasterbar"
QT += network QT += network
!contains(DEFINES, DISABLE_GUI) { !contains(DEFINES, DISABLE_GUI) {
QT += xml QT += xml

View File

@@ -567,25 +567,19 @@ void TransferListWidget::torrentDoubleClicked(QModelIndex index) {
} }
} }
QStringList TransferListWidget::getSelectedTorrentsHashes() const { void TransferListWidget::startSelectedTorrents() {
QStringList hashes;
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
foreach(const QModelIndex &index, selectedIndexes) { foreach(const QModelIndex &index, selectedIndexes) {
hashes << getHashFromRow(mapToSource(index).row()); // Get the file hash
} int row = mapToSource(index).row();
return hashes; QString hash = getHashFromRow(row);
}
void TransferListWidget::startSelectedTorrents() {
QStringList hashes = getSelectedTorrentsHashes();
foreach(const QString &hash, hashes) {
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid() && h.is_paused()) { if(h.is_valid() && h.is_paused()) {
h.resume(); h.resume();
resumeTorrent(getRowFromHash(hash), false); resumeTorrent(row, false);
} }
} }
if(!hashes.empty()) if(!selectedIndexes.empty())
refreshList(); refreshList();
} }
@@ -601,15 +595,18 @@ void TransferListWidget::startAllTorrents() {
} }
void TransferListWidget::pauseSelectedTorrents() { void TransferListWidget::pauseSelectedTorrents() {
QStringList hashes = getSelectedTorrentsHashes(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
foreach(const QString &hash, hashes) { foreach(const QModelIndex &index, selectedIndexes) {
// Get the file hash
int row = mapToSource(index).row();
QString hash = getHashFromRow(row);
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid() && !h.is_paused()) { if(h.is_valid() && !h.is_paused()) {
h.pause(); h.pause();
pauseTorrent(getRowFromHash(hash), false); pauseTorrent(row, false);
} }
} }
if(!hashes.empty()) if(!selectedIndexes.empty())
refreshList(); refreshList();
} }
@@ -626,10 +623,15 @@ void TransferListWidget::pauseAllTorrents() {
void TransferListWidget::deleteSelectedTorrents() { void TransferListWidget::deleteSelectedTorrents() {
if(main_window->getCurrentTabIndex() != TAB_TRANSFER) return; if(main_window->getCurrentTabIndex() != TAB_TRANSFER) return;
QStringList hashes = getSelectedTorrentsHashes(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
if(!hashes.empty()) { if(!selectedIndexes.empty()) {
bool delete_local_files = false; bool delete_local_files = false;
if(DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files)) { if(DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files)) {
QStringList hashes;
foreach(const QModelIndex &index, selectedIndexes) {
// Get the file hash
hashes << getHashFromRow(mapToSource(index).row());
}
foreach(const QString &hash, hashes) { foreach(const QString &hash, hashes) {
int row = getRowFromHash(hash); int row = getRowFromHash(hash);
deleteTorrent(row, false); deleteTorrent(row, false);
@@ -642,9 +644,9 @@ void TransferListWidget::deleteSelectedTorrents() {
// FIXME: Should work only if the tab is displayed // FIXME: Should work only if the tab is displayed
void TransferListWidget::increasePrioSelectedTorrents() { void TransferListWidget::increasePrioSelectedTorrents() {
QStringList hashes = getSelectedTorrentsHashes(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
foreach(const QString &hash, hashes) { foreach(const QModelIndex &index, selectedIndexes) {
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row()));
if(h.is_valid() && !h.is_seed()) { if(h.is_valid() && !h.is_seed()) {
h.queue_position_up(); h.queue_position_up();
} }
@@ -654,9 +656,9 @@ void TransferListWidget::increasePrioSelectedTorrents() {
// FIXME: Should work only if the tab is displayed // FIXME: Should work only if the tab is displayed
void TransferListWidget::decreasePrioSelectedTorrents() { void TransferListWidget::decreasePrioSelectedTorrents() {
QStringList hashes = getSelectedTorrentsHashes(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
foreach(const QString &hash, hashes) { foreach(const QModelIndex &index, selectedIndexes) {
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row()));
if(h.is_valid() && !h.is_seed()) { if(h.is_valid() && !h.is_seed()) {
h.queue_position_down(); h.queue_position_down();
} }
@@ -665,19 +667,19 @@ void TransferListWidget::decreasePrioSelectedTorrents() {
} }
void TransferListWidget::buySelectedTorrents() const { void TransferListWidget::buySelectedTorrents() const {
QStringList hashes = getSelectedTorrentsHashes(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
foreach(const QString &hash, hashes) { foreach(const QModelIndex &index, selectedIndexes) {
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row()));
if(h.is_valid()) if(h.is_valid())
QDesktopServices::openUrl("http://match.sharemonkey.com/?info_hash="+h.hash()+"&n="+h.name()+"&cid=33"); QDesktopServices::openUrl("http://match.sharemonkey.com/?info_hash="+h.hash()+"&n="+h.name()+"&cid=33");
} }
} }
void TransferListWidget::copySelectedMagnetURIs() const { void TransferListWidget::copySelectedMagnetURIs() const {
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
QStringList magnet_uris; QStringList magnet_uris;
QStringList hashes = getSelectedTorrentsHashes(); foreach(const QModelIndex &index, selectedIndexes) {
foreach(const QString &hash, hashes) { QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row()));
QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid() && h.has_metadata()) if(h.is_valid() && h.has_metadata())
magnet_uris << misc::toQString(make_magnet_uri(h.get_torrent_info())); magnet_uris << misc::toQString(make_magnet_uri(h.get_torrent_info()));
} }
@@ -689,10 +691,10 @@ void TransferListWidget::hidePriorityColumn(bool hide) {
} }
void TransferListWidget::openSelectedTorrentsFolder() const { void TransferListWidget::openSelectedTorrentsFolder() const {
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
QStringList pathsList; QStringList pathsList;
QStringList hashes = getSelectedTorrentsHashes(); foreach(const QModelIndex &index, selectedIndexes) {
foreach(const QString &hash, hashes) { QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row()));
QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid()) { if(h.is_valid()) {
QString savePath = h.root_path(); QString savePath = h.root_path();
if(!pathsList.contains(savePath)) { if(!pathsList.contains(savePath)) {
@@ -704,10 +706,10 @@ void TransferListWidget::openSelectedTorrentsFolder() const {
} }
void TransferListWidget::previewSelectedTorrents() { void TransferListWidget::previewSelectedTorrents() {
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
QStringList pathsList; QStringList pathsList;
QStringList hashes = getSelectedTorrentsHashes(); foreach(const QModelIndex &index, selectedIndexes) {
foreach(const QString &hash, hashes) { QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row()));
QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid() && h.has_metadata()) { if(h.is_valid() && h.has_metadata()) {
new previewSelect(this, h); new previewSelect(this, h);
} }
@@ -715,11 +717,14 @@ void TransferListWidget::previewSelectedTorrents() {
} }
void TransferListWidget::setDlLimitSelectedTorrents() { void TransferListWidget::setDlLimitSelectedTorrents() {
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
QStringList hashes;
QList<QTorrentHandle> selected_torrents; QList<QTorrentHandle> selected_torrents;
bool first = true; bool first = true;
bool all_same_limit = true; bool all_same_limit = true;
QStringList hashes = getSelectedTorrentsHashes(); foreach(const QModelIndex &index, selectedIndexes) {
foreach(const QString &hash, hashes) { // Get the file hash
QString hash = getHashFromRow(mapToSource(index).row());
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid() && !h.is_seed()) { if(h.is_valid() && !h.is_seed()) {
selected_torrents << h; selected_torrents << h;
@@ -748,11 +753,14 @@ void TransferListWidget::setDlLimitSelectedTorrents() {
} }
void TransferListWidget::setUpLimitSelectedTorrents() { void TransferListWidget::setUpLimitSelectedTorrents() {
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
QStringList hashes;
QList<QTorrentHandle> selected_torrents; QList<QTorrentHandle> selected_torrents;
bool first = true; bool first = true;
bool all_same_limit = true; bool all_same_limit = true;
QStringList hashes = getSelectedTorrentsHashes(); foreach(const QModelIndex &index, selectedIndexes) {
foreach(const QString &hash, hashes) { // Get the file hash
QString hash = getHashFromRow(mapToSource(index).row());
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid()) { if(h.is_valid()) {
selected_torrents << h; selected_torrents << h;
@@ -781,9 +789,13 @@ void TransferListWidget::setUpLimitSelectedTorrents() {
} }
void TransferListWidget::recheckSelectedTorrents() { void TransferListWidget::recheckSelectedTorrents() {
QStringList hashes = getSelectedTorrentsHashes(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
foreach(const QString &hash, hashes) { foreach(const QModelIndex &index, selectedIndexes){
BTSession->recheckTorrent(hash); QString hash = getHashFromRow(mapToSource(index).row());
QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid()) {
BTSession->recheckTorrent(h.hash());
}
} }
} }
@@ -851,8 +863,10 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&){
#ifdef LIBTORRENT_0_15 #ifdef LIBTORRENT_0_15
void TransferListWidget::toggleSelectedTorrentsSuperSeeding() { void TransferListWidget::toggleSelectedTorrentsSuperSeeding() {
QStringList hashes = getSelectedTorrentsHashes(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
foreach(const QString &hash, hashes) { foreach(const QModelIndex &index, selectedIndexes) {
// Get the file hash
QString hash = getHashFromRow(mapToSource(index).row());
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid() && h.has_metadata()) { if(h.is_valid() && h.has_metadata()) {
h.super_seeding(!h.super_seeding()); h.super_seeding(!h.super_seeding());
@@ -862,8 +876,10 @@ void TransferListWidget::toggleSelectedTorrentsSuperSeeding() {
#endif #endif
void TransferListWidget::toggleSelectedTorrentsSequentialDownload() { void TransferListWidget::toggleSelectedTorrentsSequentialDownload() {
QStringList hashes = getSelectedTorrentsHashes(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
foreach(const QString &hash, hashes) { foreach(const QModelIndex &index, selectedIndexes) {
// Get the file hash
QString hash = getHashFromRow(mapToSource(index).row());
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid() && h.has_metadata()) { if(h.is_valid() && h.has_metadata()) {
h.set_sequential_download(!h.is_sequential_download()); h.set_sequential_download(!h.is_sequential_download());
@@ -872,8 +888,10 @@ void TransferListWidget::toggleSelectedTorrentsSequentialDownload() {
} }
void TransferListWidget::toggleSelectedFirstLastPiecePrio() { void TransferListWidget::toggleSelectedFirstLastPiecePrio() {
QStringList hashes = getSelectedTorrentsHashes(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
foreach(const QString &hash, hashes) { foreach(const QModelIndex &index, selectedIndexes) {
// Get the file hash
QString hash = getHashFromRow(mapToSource(index).row());
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid() && h.has_metadata()) { if(h.is_valid() && h.has_metadata()) {
h.prioritize_first_last_piece(!h.first_last_piece_first()); h.prioritize_first_last_piece(!h.first_last_piece_first());
@@ -919,8 +937,12 @@ void TransferListWidget::renameSelectedTorrent() {
} }
void TransferListWidget::setSelectionLabel(QString label) { void TransferListWidget::setSelectionLabel(QString label) {
QStringList hashes = getSelectedTorrentsHashes(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
foreach(const QString &hash, hashes) { QStringList hashes;
foreach(const QModelIndex &index, selectedIndexes) {
hashes << getHashFromRow(mapToSource(index).row());
}
foreach(const QString& hash, hashes) {
Q_ASSERT(!hash.isEmpty()); Q_ASSERT(!hash.isEmpty());
int row = getRowFromHash(hash); int row = getRowFromHash(hash);
QString old_label = listModel->data(listModel->index(row, TR_LABEL)).toString(); QString old_label = listModel->data(listModel->index(row, TR_LABEL)).toString();

View File

@@ -71,7 +71,6 @@ protected:
bool loadColWidthList(); bool loadColWidthList();
void saveLastSortedColumn(); void saveLastSortedColumn();
void loadLastSortedColumn(); void loadLastSortedColumn();
QStringList getSelectedTorrentsHashes() const;
protected slots: protected slots:
int updateTorrent(int row); int updateTorrent(int row);