Browse Source

- Fixed some signals/slots (safer)

- Forgot to remove temp file when the file was downloaded from an url (rare occasions)
adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
325a588526
  1. 1
      TODO
  2. 4
      src/FinishedTorrents.cpp
  3. 4
      src/FinishedTorrents.h
  4. 70
      src/GUI.cpp
  5. 28
      src/GUI.h
  6. 49
      src/bittorrent.cpp
  7. 50
      src/bittorrent.h
  8. 6
      src/downloadThread.h
  9. 2
      src/misc.h
  10. 2
      src/options_imp.cpp
  11. 4
      src/options_imp.h
  12. 4
      src/previewSelect.h
  13. 4
      src/properties_imp.h
  14. 33
      src/rss.h
  15. 16
      src/searchEngine.cpp
  16. 12
      src/searchEngine.h
  17. 4
      src/torrentAddition.h

1
TODO

@ -44,6 +44,7 @@
* beta3 * beta3
- Windows port (Chris - Peerkoel) - Windows port (Chris - Peerkoel)
- Translations update - Translations update
- Allow to abort a searchby launching another one
* beta2 * beta2
- Improve RSS code + cleanup (chris) - Improve RSS code + cleanup (chris)
- Wait for some bug fixes in libtorrent : - Wait for some bug fixes in libtorrent :

4
src/FinishedTorrents.cpp

@ -115,7 +115,7 @@ void FinishedTorrents::addFinishedSHA(QString hash){
} }
// Set the color of a row in data model // Set the color of a row in data model
void FinishedTorrents::setRowColor(int row, const QString& color){ void FinishedTorrents::setRowColor(int row, QString color){
for(int i=0; i<finishedListModel->columnCount(); ++i){ for(int i=0; i<finishedListModel->columnCount(); ++i){
finishedListModel->setData(finishedListModel->index(row, i), QVariant(QColor(color)), Qt::TextColorRole); finishedListModel->setData(finishedListModel->index(row, i), QVariant(QColor(color)), Qt::TextColorRole);
} }
@ -271,7 +271,7 @@ QStringList FinishedTorrents::getFinishedSHAs(){
return finishedSHAs; return finishedSHAs;
} }
int FinishedTorrents::getRowFromHash(const QString& hash) const{ int FinishedTorrents::getRowFromHash(QString hash) const{
unsigned int nbRows = finishedListModel->rowCount(); unsigned int nbRows = finishedListModel->rowCount();
for(unsigned int i=0; i<nbRows; ++i){ for(unsigned int i=0; i<nbRows; ++i){
if(finishedListModel->data(finishedListModel->index(i, HASH)) == hash){ if(finishedListModel->data(finishedListModel->index(i, HASH)) == hash){

4
src/FinishedTorrents.h

@ -45,7 +45,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding{
QTreeView* getFinishedList(); QTreeView* getFinishedList();
QStandardItemModel* getFinishedListModel(); QStandardItemModel* getFinishedListModel();
bool loadColWidthFinishedList(); bool loadColWidthFinishedList();
int getRowFromHash(const QString& hash) const; int getRowFromHash(QString hash) const;
public slots: public slots:
void addFinishedSHA(QString sha); void addFinishedSHA(QString sha);
@ -54,7 +54,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding{
void showProperties(const QModelIndex &index); void showProperties(const QModelIndex &index);
void propertiesSelection(); void propertiesSelection();
void displayFinishedListMenu(const QPoint&); void displayFinishedListMenu(const QPoint&);
void setRowColor(int row, const QString& color); void setRowColor(int row, QString color);
void saveColWidthFinishedList() const; void saveColWidthFinishedList() const;
void sortFinishedList(int index); void sortFinishedList(int index);
void sortFinishedListFloat(int index, Qt::SortOrder sortOrder); void sortFinishedListFloat(int index, Qt::SortOrder sortOrder);

70
src/GUI.cpp

@ -140,23 +140,23 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
// Hide hash column // Hide hash column
downloadList->hideColumn(HASH); downloadList->hideColumn(HASH);
connect(BTSession, SIGNAL(addedTorrent(const QString&, torrent_handle&, bool)), this, SLOT(torrentAdded(const QString&, torrent_handle&, bool))); connect(BTSession, SIGNAL(addedTorrent(QString, torrent_handle&, bool)), this, SLOT(torrentAdded(QString, torrent_handle&, bool)));
connect(BTSession, SIGNAL(duplicateTorrent(const QString&)), this, SLOT(torrentDuplicate(const QString&))); connect(BTSession, SIGNAL(duplicateTorrent(QString)), this, SLOT(torrentDuplicate(QString)));
connect(BTSession, SIGNAL(invalidTorrent(const QString&)), this, SLOT(torrentCorrupted(const QString&))); connect(BTSession, SIGNAL(invalidTorrent(QString)), this, SLOT(torrentCorrupted(QString)));
connect(BTSession, SIGNAL(finishedTorrent(torrent_handle&)), this, SLOT(finishedTorrent(torrent_handle&))); connect(BTSession, SIGNAL(finishedTorrent(torrent_handle&)), this, SLOT(finishedTorrent(torrent_handle&)));
connect(BTSession, SIGNAL(fullDiskError(torrent_handle&)), this, SLOT(fullDiskError(torrent_handle&))); connect(BTSession, SIGNAL(fullDiskError(torrent_handle&)), this, SLOT(fullDiskError(torrent_handle&)));
connect(BTSession, SIGNAL(portListeningFailure()), this, SLOT(portListeningFailure())); connect(BTSession, SIGNAL(portListeningFailure()), this, SLOT(portListeningFailure()));
connect(BTSession, SIGNAL(trackerError(const QString&, const QString&, const QString&)), this, SLOT(trackerError(const QString&, const QString&, const QString&))); connect(BTSession, SIGNAL(trackerError(QString, QString, QString)), this, SLOT(trackerError(QString, QString, QString)));
connect(BTSession,SIGNAL(allTorrentsFinishedChecking()), this, SLOT(sortProgressColumnDelayed())); connect(BTSession,SIGNAL(allTorrentsFinishedChecking()), this, SLOT(sortProgressColumnDelayed()));
connect(BTSession, SIGNAL(trackerAuthenticationRequired(torrent_handle&)), this, SLOT(trackerAuthenticationRequired(torrent_handle&))); connect(BTSession, SIGNAL(trackerAuthenticationRequired(torrent_handle&)), this, SLOT(trackerAuthenticationRequired(torrent_handle&)));
connect(BTSession, SIGNAL(peerBlocked(const QString&)), this, SLOT(addLogPeerBlocked(const QString))); connect(BTSession, SIGNAL(peerBlocked(QString)), this, SLOT(addLogPeerBlocked(const QString)));
connect(BTSession, SIGNAL(scanDirFoundTorrents(const QStringList&)), this, SLOT(processScannedFiles(const QStringList&))); connect(BTSession, SIGNAL(scanDirFoundTorrents(const QStringList&)), this, SLOT(processScannedFiles(const QStringList&)));
connect(BTSession, SIGNAL(newDownloadedTorrent(const QString&, const QString&)), this, SLOT(processDownloadedFiles(const QString&, const QString&))); connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString)));
connect(BTSession, SIGNAL(downloadFromUrlFailure(const QString&, const QString&)), this, SLOT(handleDownloadFromUrlFailure(const QString&, const QString&))); connect(BTSession, SIGNAL(downloadFromUrlFailure(QString, QString)), this, SLOT(handleDownloadFromUrlFailure(QString, QString)));
connect(BTSession, SIGNAL(aboutToDownloadFromUrl(const QString&)), this, SLOT(displayDownloadingUrlInfos(const QString&))); connect(BTSession, SIGNAL(aboutToDownloadFromUrl(QString)), this, SLOT(displayDownloadingUrlInfos(QString)));
// creating options // creating options
options = new options_imp(this); options = new options_imp(this);
connect(options, SIGNAL(status_changed(const QString&, bool)), this, SLOT(OptionsSaved(const QString&, bool))); connect(options, SIGNAL(status_changed(QString, bool)), this, SLOT(OptionsSaved(QString, bool)));
// Configure BT session according to options // Configure BT session according to options
configureSession(true); configureSession(true);
force_exit = false; force_exit = false;
@ -298,7 +298,7 @@ void GUI::readSettings() {
settings.endGroup(); settings.endGroup();
} }
void GUI::addLogPeerBlocked(const QString& ip){ void GUI::addLogPeerBlocked(QString ip){
static unsigned short nbLines = 0; static unsigned short nbLines = 0;
++nbLines; ++nbLines;
if(nbLines > 200){ if(nbLines > 200){
@ -309,7 +309,7 @@ void GUI::addLogPeerBlocked(const QString& ip){
} }
// Update Info Bar information // Update Info Bar information
void GUI::setInfoBar(const QString& info, const QString& color){ void GUI::setInfoBar(QString info, QString color){
qDebug("setInfoBar called"); qDebug("setInfoBar called");
static unsigned short nbLines = 0; static unsigned short nbLines = 0;
++nbLines; ++nbLines;
@ -395,7 +395,7 @@ void GUI::on_actionSet_upload_limit_triggered(){
new BandwidthAllocationDialog(this, true, BTSession, hashes); new BandwidthAllocationDialog(this, true, BTSession, hashes);
} }
void GUI::handleDownloadFromUrlFailure(const QString& url, const QString& reason){ void GUI::handleDownloadFromUrlFailure(QString url, QString reason){
// Display a message box // Display a message box
QMessageBox::critical(0, tr("Url download error"), tr("Couldn't download file at url: %1, reason: %2.").arg(url).arg(reason)); QMessageBox::critical(0, tr("Url download error"), tr("Couldn't download file at url: %1, reason: %2.").arg(url).arg(reason));
} }
@ -491,7 +491,7 @@ void GUI::displayGUIMenu(const QPoint& pos){
myGUIMenu.exec(mapToGlobal(pos)); myGUIMenu.exec(mapToGlobal(pos));
} }
void GUI::previewFile(const QString& filePath){ void GUI::previewFile(QString filePath){
// Check if there is already one preview running // Check if there is already one preview running
if(previewProcess->state() == QProcess::NotRunning){ if(previewProcess->state() == QProcess::NotRunning){
// First copy temporarily // First copy temporarily
@ -927,8 +927,8 @@ void GUI::dropEvent(QDropEvent *event){
foreach(file, files){ foreach(file, files){
if(useTorrentAdditionDialog){ if(useTorrentAdditionDialog){
torrentAdditionDialog *dialog = new torrentAdditionDialog(this); torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, bool, const QString&)), BTSession, SLOT(addTorrent(const QString&, bool, bool, const QString&))); connect(dialog, SIGNAL(torrentAddition(QString, bool, bool, QString)), BTSession, SLOT(addTorrent(QString, bool, bool, QString)));
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&))); connect(dialog, SIGNAL(setInfoBarGUI(QString, QString)), this, SLOT(setInfoBar(QString, QString)));
dialog->showLoad(file.trimmed().replace("file://", "")); dialog->showLoad(file.trimmed().replace("file://", ""));
}else{ }else{
BTSession->addTorrent(file.trimmed().replace("file://", "")); BTSession->addTorrent(file.trimmed().replace("file://", ""));
@ -966,8 +966,8 @@ void GUI::on_actionOpen_triggered(){
for(unsigned int i=0; i<listSize; ++i){ for(unsigned int i=0; i<listSize; ++i){
if(useTorrentAdditionDialog){ if(useTorrentAdditionDialog){
torrentAdditionDialog *dialog = new torrentAdditionDialog(this); torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, bool, const QString&)), BTSession, SLOT(addTorrent(const QString&, bool, bool, const QString&))); connect(dialog, SIGNAL(torrentAddition(QString, bool, bool, QString)), BTSession, SLOT(addTorrent(QString, bool, bool, QString)));
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&))); connect(dialog, SIGNAL(setInfoBarGUI(QString, QString)), this, SLOT(setInfoBar(QString, QString)));
dialog->showLoad(pathsList.at(i)); dialog->showLoad(pathsList.at(i));
}else{ }else{
BTSession->addTorrent(pathsList.at(i)); BTSession->addTorrent(pathsList.at(i));
@ -1124,7 +1124,7 @@ void GUI::on_actionDelete_triggered(){
} }
// Called when a torrent is added // Called when a torrent is added
void GUI::torrentAdded(const QString& path, torrent_handle& h, bool fastResume){ void GUI::torrentAdded(QString path, torrent_handle& h, bool fastResume){
QString hash = QString(misc::toString(h.info_hash()).c_str()); QString hash = QString(misc::toString(h.info_hash()).c_str());
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")){ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")){
finishedTorrentTab->addFinishedSHA(hash); finishedTorrentTab->addFinishedSHA(hash);
@ -1159,11 +1159,11 @@ void GUI::torrentAdded(const QString& path, torrent_handle& h, bool fastResume){
} }
// Called when trying to add a duplicate torrent // Called when trying to add a duplicate torrent
void GUI::torrentDuplicate(const QString& path){ void GUI::torrentDuplicate(QString path){
setInfoBar(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(path)); setInfoBar(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(path));
} }
void GUI::torrentCorrupted(const QString& path){ void GUI::torrentCorrupted(QString path){
setInfoBar(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(path), "red"); setInfoBar(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(path), "red");
setInfoBar(tr("This file is either corrupted or this isn't a torrent."),"red"); setInfoBar(tr("This file is either corrupted or this isn't a torrent."),"red");
} }
@ -1183,8 +1183,8 @@ void GUI::processParams(const QStringList& params){
}else{ }else{
if(useTorrentAdditionDialog){ if(useTorrentAdditionDialog){
torrentAdditionDialog *dialog = new torrentAdditionDialog(this); torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, bool, const QString&)), BTSession, SLOT(addTorrent(const QString&, bool, bool, const QString&))); connect(dialog, SIGNAL(torrentAddition(QString, bool, bool, QString)), BTSession, SLOT(addTorrent(QString, bool, bool, QString)));
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&))); connect(dialog, SIGNAL(setInfoBarGUI(QString, QString)), this, SLOT(setInfoBar(QString, QString)));
dialog->showLoad(param); dialog->showLoad(param);
}else{ }else{
BTSession->addTorrent(param); BTSession->addTorrent(param);
@ -1200,8 +1200,8 @@ void GUI::processScannedFiles(const QStringList& params){
foreach(param, params){ foreach(param, params){
if(useTorrentAdditionDialog){ if(useTorrentAdditionDialog){
torrentAdditionDialog *dialog = new torrentAdditionDialog(this); torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, bool, const QString&)), BTSession, SLOT(addTorrent(const QString&, bool, bool, const QString&))); connect(dialog, SIGNAL(torrentAddition(QString, bool, bool, QString)), BTSession, SLOT(addTorrent(QString, bool, bool, QString)));
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&))); connect(dialog, SIGNAL(setInfoBarGUI(QString, QString)), this, SLOT(setInfoBar(QString, QString)));
dialog->showLoad(param, true); dialog->showLoad(param, true);
}else{ }else{
BTSession->addTorrent(param, true); BTSession->addTorrent(param, true);
@ -1209,13 +1209,13 @@ void GUI::processScannedFiles(const QStringList& params){
} }
} }
void GUI::processDownloadedFiles(const QString& path, const QString& url){ void GUI::processDownloadedFiles(QString path, QString url){
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
bool useTorrentAdditionDialog = settings.value("Options/Misc/TorrentAdditionDialog/Enabled", true).toBool(); bool useTorrentAdditionDialog = settings.value("Options/Misc/TorrentAdditionDialog/Enabled", true).toBool();
if(useTorrentAdditionDialog){ if(useTorrentAdditionDialog){
torrentAdditionDialog *dialog = new torrentAdditionDialog(this); torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, bool, const QString&)), BTSession, SLOT(addTorrent(const QString&, bool, bool, const QString&))); connect(dialog, SIGNAL(torrentAddition(QString, bool, bool, QString)), BTSession, SLOT(addTorrent(QString, bool, bool, QString)));
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&))); connect(dialog, SIGNAL(setInfoBarGUI(QString, QString)), this, SLOT(setInfoBar(QString, QString)));
dialog->showLoad(path, false, url); dialog->showLoad(path, false, url);
}else{ }else{
BTSession->addTorrent(path, false, false, url); BTSession->addTorrent(path, false, false, url);
@ -1230,11 +1230,11 @@ void GUI::showProperties(const QModelIndex &index){
QStringList errors = trackerErrors.value(fileHash, QStringList(tr("None", "i.e: No error message"))); QStringList errors = trackerErrors.value(fileHash, QStringList(tr("None", "i.e: No error message")));
properties *prop = new properties(this, BTSession, h, errors); properties *prop = new properties(this, BTSession, h, errors);
connect(prop, SIGNAL(mustHaveFullAllocationMode(torrent_handle)), BTSession, SLOT(reloadTorrent(torrent_handle))); connect(prop, SIGNAL(mustHaveFullAllocationMode(torrent_handle)), BTSession, SLOT(reloadTorrent(torrent_handle)));
connect(prop, SIGNAL(filteredFilesChanged(const QString&)), this, SLOT(updateFileSize(const QString&))); connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSize(QString)));
prop->show(); prop->show();
} }
void GUI::updateFileSize(const QString& hash){ void GUI::updateFileSize(QString hash){
int row = getRowFromHash(hash); int row = getRowFromHash(hash);
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)BTSession->torrentEffectiveSize(hash))); DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)BTSession->torrentEffectiveSize(hash)));
} }
@ -1527,7 +1527,7 @@ void GUI::portListeningFailure(){
} }
// Called when we receive an error from tracker // Called when we receive an error from tracker
void GUI::trackerError(const QString& hash, const QString& time, const QString& msg){ void GUI::trackerError(QString hash, QString time, QString msg){
// Check trackerErrors list size and clear it if it is too big // Check trackerErrors list size and clear it if it is too big
if(trackerErrors.size() > 50){ if(trackerErrors.size() > 50){
trackerErrors.clear(); trackerErrors.clear();
@ -1594,7 +1594,7 @@ void GUI::checkConnectionStatus(){
*****************************************************/ *****************************************************/
// Set the color of a row in data model // Set the color of a row in data model
void GUI::setRowColor(int row, const QString& color){ void GUI::setRowColor(int row, QString color){
unsigned int nbColumns = DLListModel->columnCount(); unsigned int nbColumns = DLListModel->columnCount();
for(unsigned int i=0; i<nbColumns; ++i){ for(unsigned int i=0; i<nbColumns; ++i){
DLListModel->setData(DLListModel->index(row, i), QVariant(QColor(color)), Qt::TextColorRole); DLListModel->setData(DLListModel->index(row, i), QVariant(QColor(color)), Qt::TextColorRole);
@ -1603,7 +1603,7 @@ void GUI::setRowColor(int row, const QString& color){
// return the row of in data model // return the row of in data model
// corresponding to the given the filehash // corresponding to the given the filehash
int GUI::getRowFromHash(const QString& hash) const{ int GUI::getRowFromHash(QString hash) const{
unsigned int nbRows = DLListModel->rowCount(); unsigned int nbRows = DLListModel->rowCount();
for(unsigned int i=0; i<nbRows; ++i){ for(unsigned int i=0; i<nbRows; ++i){
if(DLListModel->data(DLListModel->index(i, HASH)) == hash){ if(DLListModel->data(DLListModel->index(i, HASH)) == hash){
@ -1617,7 +1617,7 @@ void GUI::downloadFromURLList(const QStringList& urls){
BTSession->downloadFromURLList(urls); BTSession->downloadFromURLList(urls);
} }
void GUI::displayDownloadingUrlInfos(const QString& url){ void GUI::displayDownloadingUrlInfos(QString url){
setInfoBar(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(url), "black"); setInfoBar(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(url), "black");
} }
@ -1652,12 +1652,12 @@ void GUI::createTrayIcon(){
// Display Program Options // Display Program Options
void GUI::on_actionOptions_triggered(){ void GUI::on_actionOptions_triggered(){
options = new options_imp(this); options = new options_imp(this);
connect(options, SIGNAL(status_changed(const QString&, bool)), this, SLOT(OptionsSaved(const QString&, bool))); connect(options, SIGNAL(status_changed(QString, bool)), this, SLOT(OptionsSaved(QString, bool)));
options->show(); options->show();
} }
// Is executed each time options are saved // Is executed each time options are saved
void GUI::OptionsSaved(const QString& info, bool deleteOptions){ void GUI::OptionsSaved(QString info, bool deleteOptions){
bool newSystrayIntegration = options->useSystrayIntegration(); bool newSystrayIntegration = options->useSystrayIntegration();
if(newSystrayIntegration && !systrayIntegration){ if(newSystrayIntegration && !systrayIntegration){
// create the trayicon // create the trayicon

28
src/GUI.h

@ -120,7 +120,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void dragEnterEvent(QDragEnterEvent *event); void dragEnterEvent(QDragEnterEvent *event);
void toggleVisibility(QSystemTrayIcon::ActivationReason e); void toggleVisibility(QSystemTrayIcon::ActivationReason e);
void on_actionAbout_triggered(); void on_actionAbout_triggered();
void setInfoBar(const QString& info, const QString& color="black"); void setInfoBar(QString info, QString color="black");
void updateDlList(bool force=false); void updateDlList(bool force=false);
void on_actionCreate_torrent_triggered(); void on_actionCreate_torrent_triggered();
void on_actionClearLog_triggered(); void on_actionClearLog_triggered();
@ -139,21 +139,21 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void displayInfoBarMenu(const QPoint& pos); void displayInfoBarMenu(const QPoint& pos);
void displayGUIMenu(const QPoint& pos); void displayGUIMenu(const QPoint& pos);
void on_actionPreview_file_triggered(); void on_actionPreview_file_triggered();
void previewFile(const QString& filePath); void previewFile(QString filePath);
void cleanTempPreviewFile(int, QProcess::ExitStatus); void cleanTempPreviewFile(int, QProcess::ExitStatus);
void balloonClicked(); void balloonClicked();
void writeSettings(); void writeSettings();
void readSettings(); void readSettings();
void on_actionExit_triggered(); void on_actionExit_triggered();
void createTrayIcon(); void createTrayIcon();
void addLogPeerBlocked(const QString&); void addLogPeerBlocked(QString);
// Keyboard shortcuts // Keyboard shortcuts
void createKeyboardShortcuts(); void createKeyboardShortcuts();
void displayDownTab(); void displayDownTab();
void displayUpTab(); void displayUpTab();
void displaySearchTab(); void displaySearchTab();
void displayRSSTab(); void displayRSSTab();
void handleDownloadFromUrlFailure(const QString&, const QString&); void handleDownloadFromUrlFailure(QString, QString);
// Torrent actions // Torrent actions
void showProperties(const QModelIndex &index); void showProperties(const QModelIndex &index);
void on_actionTorrent_Properties_triggered(); void on_actionTorrent_Properties_triggered();
@ -175,29 +175,29 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void processParams(const QStringList& params); void processParams(const QStringList& params);
void addUnauthenticatedTracker(QPair<torrent_handle,std::string> tracker); void addUnauthenticatedTracker(QPair<torrent_handle,std::string> tracker);
void processScannedFiles(const QStringList& params); void processScannedFiles(const QStringList& params);
void processDownloadedFiles(const QString& path, const QString& url); void processDownloadedFiles(QString path, QString url);
void downloadFromURLList(const QStringList& urls); void downloadFromURLList(const QStringList& urls);
void displayDownloadingUrlInfos(const QString& url); void displayDownloadingUrlInfos(QString url);
// Utils slots // Utils slots
void setRowColor(int row, const QString& color); void setRowColor(int row, QString color);
// Options slots // Options slots
void on_actionOptions_triggered(); void on_actionOptions_triggered();
void OptionsSaved(const QString& info, bool deleteOptions); void OptionsSaved(QString info, bool deleteOptions);
// HTTP slots // HTTP slots
void on_actionDownload_from_URL_triggered(); void on_actionDownload_from_URL_triggered();
public slots: public slots:
void torrentAdded(const QString& path, torrent_handle& h, bool fastResume); void torrentAdded(QString path, torrent_handle& h, bool fastResume);
void torrentDuplicate(const QString& path); void torrentDuplicate(QString path);
void torrentCorrupted(const QString& path); void torrentCorrupted(QString path);
void finishedTorrent(torrent_handle& h); void finishedTorrent(torrent_handle& h);
void fullDiskError(torrent_handle& h); void fullDiskError(torrent_handle& h);
void portListeningFailure(); void portListeningFailure();
void trackerError(const QString& hash, const QString& time, const QString& msg); void trackerError(QString hash, QString time, QString msg);
void trackerAuthenticationRequired(torrent_handle& h); void trackerAuthenticationRequired(torrent_handle& h);
void setTabText(int index, QString text); void setTabText(int index, QString text);
void updateFileSize(const QString& hash); void updateFileSize(QString hash);
void sortProgressColumnDelayed(); void sortProgressColumnDelayed();
protected: protected:
@ -209,7 +209,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList()); GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
~GUI(); ~GUI();
// Methods // Methods
int getRowFromHash(const QString& hash) const; int getRowFromHash(QString hash) const;
QPoint screenCenter(); QPoint screenCenter();
}; };

49
src/bittorrent.cpp

@ -50,8 +50,8 @@ bittorrent::bittorrent(){
ETARefresher.start(6000); ETARefresher.start(6000);
// To download from urls // To download from urls
downloader = new downloadThread(this); downloader = new downloadThread(this);
connect(downloader, SIGNAL(downloadFinished(const QString&, const QString&)), this, SLOT(processDownloadedFile(const QString&, const QString&))); connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
connect(downloader, SIGNAL(downloadFailure(const QString&, const QString&)), this, SLOT(HandleDownloadFailure(const QString&, const QString&))); connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(HandleDownloadFailure(QString, QString)));
} }
// Main destructor // Main destructor
@ -79,7 +79,7 @@ void bittorrent::setUploadLimit(QString hash, int val){
saveTorrentSpeedLimits(hash); saveTorrentSpeedLimits(hash);
} }
void bittorrent::HandleDownloadFailure(const QString& url, const QString& reason){ void bittorrent::HandleDownloadFailure(QString url, QString reason){
emit downloadFromUrlFailure(url, reason); emit downloadFromUrlFailure(url, reason);
} }
@ -114,13 +114,13 @@ long bittorrent::getETA(QString hash) const{
} }
// Return the torrent handle, given its hash // Return the torrent handle, given its hash
torrent_handle bittorrent::getTorrentHandle(const QString& hash) const{ torrent_handle bittorrent::getTorrentHandle(QString hash) const{
return s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString()))); return s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
} }
// Return true if the torrent corresponding to the // Return true if the torrent corresponding to the
// hash is paused // hash is paused
bool bittorrent::isPaused(const QString& hash) const{ bool bittorrent::isPaused(QString hash) const{
torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString()))); torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
if(!h.is_valid()){ if(!h.is_valid()){
qDebug("/!\\ Error: Invalid handle"); qDebug("/!\\ Error: Invalid handle");
@ -131,7 +131,7 @@ bool bittorrent::isPaused(const QString& hash) const{
// 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(const QString& hash, bool permanent){ void bittorrent::deleteTorrent(QString hash, bool permanent){
torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString()))); torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
if(!h.is_valid()){ if(!h.is_valid()){
qDebug("/!\\ Error: Invalid handle"); qDebug("/!\\ Error: Invalid handle");
@ -176,7 +176,7 @@ void bittorrent::cleanDeleter(deleteThread* deleter){
} }
// Pause a running torrent // Pause a running torrent
void bittorrent::pauseTorrent(const QString& hash){ void bittorrent::pauseTorrent(QString hash){
torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString()))); torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
if(h.is_valid() && !h.is_paused()){ if(h.is_valid() && !h.is_paused()){
h.pause(); h.pause();
@ -193,7 +193,7 @@ void bittorrent::pauseTorrent(const QString& hash){
} }
// Resume a torrent in paused state // Resume a torrent in paused state
void bittorrent::resumeTorrent(const QString& hash){ void bittorrent::resumeTorrent(QString hash){
torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString()))); torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
if(h.is_valid() && h.is_paused()){ if(h.is_valid() && h.is_paused()){
h.resume(); h.resume();
@ -203,7 +203,7 @@ void bittorrent::resumeTorrent(const QString& hash){
} }
// Add a torrent to the bittorrent session // Add a torrent to the bittorrent session
void bittorrent::addTorrent(const QString& path, bool fromScanDir, bool onStartup, const QString& from_url){ void bittorrent::addTorrent(QString path, bool fromScanDir, bool onStartup, QString from_url){
torrent_handle h; torrent_handle h;
entry resume_data; entry resume_data;
bool fastResume=false; bool fastResume=false;
@ -240,6 +240,8 @@ void bittorrent::addTorrent(const QString& path, bool fromScanDir, bool onStartu
// Update info Bar // Update info Bar
if(!fromScanDir){ if(!fromScanDir){
if(!from_url.isNull()){ if(!from_url.isNull()){
// If download from url, remove temp file
QFile::remove(file);
emit duplicateTorrent(from_url); emit duplicateTorrent(from_url);
}else{ }else{
emit duplicateTorrent(file); emit duplicateTorrent(file);
@ -288,6 +290,8 @@ void bittorrent::addTorrent(const QString& path, bool fromScanDir, bool onStartu
if(!h.is_valid()){ if(!h.is_valid()){
// No need to keep on, it failed. // No need to keep on, it failed.
qDebug("/!\\ Error: Invalid handle"); qDebug("/!\\ Error: Invalid handle");
// If download from url, remove temp file
if(!from_url.isNull()) QFile::remove(file);
return; return;
} }
// Is this really useful and appropriate ? // Is this really useful and appropriate ?
@ -326,11 +330,8 @@ void bittorrent::addTorrent(const QString& path, bool fromScanDir, bool onStartu
qDebug("Incremental download enabled for %s", t.name().c_str()); qDebug("Incremental download enabled for %s", t.name().c_str());
h.set_sequenced_download_threshold(15); h.set_sequenced_download_threshold(15);
} }
// If download from url // If download from url, remove temp file
if(!from_url.isNull()){ if(!from_url.isNull()) QFile::remove(file);
// remove temporary file
QFile::remove(file);
}
// Delete from scan dir to avoid trying to download it again // Delete from scan dir to avoid trying to download it again
if(fromScanDir){ if(fromScanDir){
QFile::remove(file); QFile::remove(file);
@ -383,7 +384,7 @@ void bittorrent::setMaxConnections(int maxConnec){
// Check in .priorities file if the user filtered files // Check in .priorities file if the user filtered files
// in this torrent. // in this torrent.
bool bittorrent::hasFilteredFiles(const QString& fileHash) const{ bool bittorrent::hasFilteredFiles(QString fileHash) const{
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".priorities"); QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".priorities");
// Read saved file // Read saved file
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){
@ -638,7 +639,7 @@ void bittorrent::saveFastResumeData(){
qDebug("Fast resume data saved"); qDebug("Fast resume data saved");
} }
bool bittorrent::isFilePreviewPossible(const QString& hash) const{ bool bittorrent::isFilePreviewPossible(QString hash) const{
// See if there are supported files in the torrent // See if there are supported files in the torrent
torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString()))); torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
if(!h.is_valid()){ if(!h.is_valid()){
@ -675,12 +676,12 @@ void bittorrent::scanDirectory(){
} }
} }
void bittorrent::setDefaultSavePath(const QString& savepath){ void bittorrent::setDefaultSavePath(QString savepath){
defaultSavePath = savepath; defaultSavePath = savepath;
} }
// Enable directory scanning // Enable directory scanning
void bittorrent::enableDirectoryScanning(const QString& _scan_dir){ void bittorrent::enableDirectoryScanning(QString _scan_dir){
if(!_scan_dir.isEmpty()){ if(!_scan_dir.isEmpty()){
scan_dir = _scan_dir; scan_dir = _scan_dir;
timerScan = new QTimer(this); timerScan = new QTimer(this);
@ -736,7 +737,7 @@ void bittorrent::setGlobalRatio(float ratio){
} }
} }
bool bittorrent::loadTrackerFile(const QString& hash){ bool bittorrent::loadTrackerFile(QString hash){
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup"); QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
QFile tracker_file(torrentBackup.path()+QDir::separator()+ hash + ".trackers"); QFile tracker_file(torrentBackup.path()+QDir::separator()+ hash + ".trackers");
if(!tracker_file.exists()) return false; if(!tracker_file.exists()) return false;
@ -760,7 +761,7 @@ bool bittorrent::loadTrackerFile(const QString& hash){
} }
} }
void bittorrent::saveTrackerFile(const QString& hash){ void bittorrent::saveTrackerFile(QString hash){
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup"); QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
QFile tracker_file(torrentBackup.path()+QDir::separator()+ hash + ".trackers"); QFile tracker_file(torrentBackup.path()+QDir::separator()+ hash + ".trackers");
if(tracker_file.exists()){ if(tracker_file.exists()){
@ -976,13 +977,13 @@ session_status bittorrent::getSessionStatus() const{
return s->status(); return s->status();
} }
bool bittorrent::inFullAllocationMode(const QString& hash) const{ bool bittorrent::inFullAllocationMode(QString hash) const{
if(fullAllocationModeList.indexOf(hash) != -1) if(fullAllocationModeList.indexOf(hash) != -1)
return true; return true;
return false; return false;
} }
QString bittorrent::getSavePath(const QString& hash){ QString bittorrent::getSavePath(QString hash){
QFile savepath_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".savepath"); QFile savepath_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".savepath");
QByteArray line; QByteArray line;
QString savePath; QString savePath;
@ -1011,14 +1012,14 @@ QString bittorrent::getSavePath(const QString& hash){
// Take an url string to a torrent file, // Take an url string to a torrent file,
// download the torrent file to a tmp location, then // download the torrent file to a tmp location, then
// add it to download list // add it to download list
void bittorrent::downloadFromUrl(const QString& url){ void bittorrent::downloadFromUrl(QString url){
emit aboutToDownloadFromUrl(url); emit aboutToDownloadFromUrl(url);
// Launch downloader thread // Launch downloader thread
downloader->downloadUrl(url); downloader->downloadUrl(url);
} }
// Add to bittorrent session the downloaded torrent file // Add to bittorrent session the downloaded torrent file
void bittorrent::processDownloadedFile(const QString& url, const QString& file_path){ void bittorrent::processDownloadedFile(QString url, QString file_path){
// Add file to torrent download list // Add file to torrent download list
emit newDownloadedTorrent(file_path, url); emit newDownloadedTorrent(file_path, url);
} }

50
src/bittorrent.h

@ -66,17 +66,17 @@ class bittorrent : public QObject{
QList<QString> fullAllocationModeList; QList<QString> fullAllocationModeList;
protected: protected:
QString getSavePath(const QString& hash); QString getSavePath(QString hash);
public: public:
// Constructor / Destructor // Constructor / Destructor
bittorrent(); bittorrent();
~bittorrent(); ~bittorrent();
torrent_handle getTorrentHandle(const QString& hash) const; torrent_handle getTorrentHandle(QString hash) const;
std::vector<torrent_handle> getTorrentHandles() const; std::vector<torrent_handle> getTorrentHandles() const;
bool isPaused(const QString& hash) const; bool isPaused(QString hash) const;
bool hasFilteredFiles(const QString& fileHash) const; bool hasFilteredFiles(QString fileHash) const;
bool isFilePreviewPossible(const QString& fileHash) const; bool isFilePreviewPossible(QString fileHash) const;
bool isDHTEnabled() const; bool isDHTEnabled() const;
float getPayloadDownloadRate() const; float getPayloadDownloadRate() const;
float getPayloadUploadRate() const; float getPayloadUploadRate() const;
@ -87,24 +87,24 @@ class bittorrent : public QObject{
QStringList getUncheckedTorrentsList() const; QStringList getUncheckedTorrentsList() const;
long getETA(QString hash) const; long getETA(QString hash) const;
size_type torrentEffectiveSize(QString hash) const; size_type torrentEffectiveSize(QString hash) const;
bool inFullAllocationMode(const QString& hash) const; bool inFullAllocationMode(QString hash) const;
float getRealRatio(QString hash) const; float getRealRatio(QString hash) const;
session* getSession() const; session* getSession() const;
public slots: public slots:
void addTorrent(const QString& path, bool fromScanDir = false, bool onStartup = false, const QString& from_url = QString()); void addTorrent(QString path, bool fromScanDir = false, bool onStartup = false, QString from_url = QString());
void downloadFromUrl(const QString& url); void downloadFromUrl(QString url);
void downloadFromURLList(const QStringList& url_list); void downloadFromURLList(const QStringList& url_list);
void deleteTorrent(const QString& hash, bool permanent = false); void deleteTorrent(QString hash, bool permanent = false);
void pauseTorrent(const QString& hash); void pauseTorrent(QString hash);
bool pauseAllTorrents(); bool pauseAllTorrents();
bool resumeAllTorrents(); bool resumeAllTorrents();
void resumeTorrent(const QString& hash); void resumeTorrent(QString hash);
void enableDHT(); void enableDHT();
void disableDHT(); void disableDHT();
void saveDHTEntry(); void saveDHTEntry();
void saveFastResumeData(); void saveFastResumeData();
void enableDirectoryScanning(const QString& scan_dir); void enableDirectoryScanning(QString scan_dir);
void disableDirectoryScanning(); void disableDirectoryScanning();
void enablePeerExchange(); void enablePeerExchange();
void enableIPFilter(ip_filter filter); void enableIPFilter(ip_filter filter);
@ -117,7 +117,7 @@ class bittorrent : public QObject{
void loadTorrentSpeedLimits(QString hash); void loadTorrentSpeedLimits(QString hash);
void saveDownloadUploadForTorrent(QString hash); void saveDownloadUploadForTorrent(QString hash);
void loadDownloadUploadForTorrent(QString hash); void loadDownloadUploadForTorrent(QString hash);
void HandleDownloadFailure(const QString& url, const QString& reason); void HandleDownloadFailure(QString url, QString reason);
// Session configuration - Setters // Session configuration - Setters
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports); void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
void setMaxConnections(int maxConnec); void setMaxConnections(int maxConnec);
@ -127,7 +127,7 @@ class bittorrent : public QObject{
void setDHTPort(int dht_port); void setDHTPort(int dht_port);
void setProxySettings(proxy_settings proxySettings, bool trackers=true, bool peers=true, bool web_seeds=true, bool dht=true); void setProxySettings(proxy_settings proxySettings, bool trackers=true, bool peers=true, bool web_seeds=true, bool dht=true);
void setSessionSettings(session_settings sessionSettings); void setSessionSettings(session_settings sessionSettings);
void setDefaultSavePath(const QString& savepath); void setDefaultSavePath(QString savepath);
void applyEncryptionSettings(pe_settings se); void applyEncryptionSettings(pe_settings se);
void loadFilesPriorities(torrent_handle& h); void loadFilesPriorities(torrent_handle& h);
void setDownloadLimit(QString hash, int val); void setDownloadLimit(QString hash, int val);
@ -137,27 +137,27 @@ class bittorrent : public QObject{
void cleanDeleter(deleteThread* deleter); void cleanDeleter(deleteThread* deleter);
void scanDirectory(); void scanDirectory();
void readAlerts(); void readAlerts();
void processDownloadedFile(const QString&, const QString&); void processDownloadedFile(QString, QString);
void resumeUnfinished(); void resumeUnfinished();
bool loadTrackerFile(const QString& hash); bool loadTrackerFile(QString hash);
void saveTrackerFile(const QString& hash); void saveTrackerFile(QString hash);
signals: signals:
void invalidTorrent(const QString& path); void invalidTorrent(QString path);
void duplicateTorrent(const QString& path); void duplicateTorrent(QString path);
void addedTorrent(const QString& path, torrent_handle& h, bool fastResume); void addedTorrent(QString path, torrent_handle& h, bool fastResume);
void finishedTorrent(torrent_handle& h); void finishedTorrent(torrent_handle& h);
void fullDiskError(torrent_handle& h); void fullDiskError(torrent_handle& h);
void trackerError(const QString& hash, const QString& time, const QString& msg); void trackerError(QString hash, QString time, QString msg);
void portListeningFailure(); void portListeningFailure();
void trackerAuthenticationRequired(torrent_handle& h); void trackerAuthenticationRequired(torrent_handle& h);
void scanDirFoundTorrents(const QStringList& pathList); void scanDirFoundTorrents(const QStringList& pathList);
void newDownloadedTorrent(const QString& path, const QString& url); void newDownloadedTorrent(QString path, QString url);
void aboutToDownloadFromUrl(const QString& url); void aboutToDownloadFromUrl(QString url);
void updateFileSize(QString hash); void updateFileSize(QString hash);
void allTorrentsFinishedChecking(); void allTorrentsFinishedChecking();
void peerBlocked(const QString&); void peerBlocked(QString);
void downloadFromUrlFailure(const QString& url, const QString& reason); void downloadFromUrlFailure(QString url, QString reason);
}; };

6
src/downloadThread.h

@ -48,8 +48,8 @@ class downloadThread : public QThread {
URLStream url_stream; URLStream url_stream;
signals: signals:
void downloadFinished(const QString& url, const QString& file_path); void downloadFinished(QString url, QString file_path);
void downloadFailure(const QString& url, const QString& reason); void downloadFailure(QString url, QString reason);
public: public:
downloadThread(QObject* parent) : QThread(parent){ downloadThread(QObject* parent) : QThread(parent){
@ -66,7 +66,7 @@ class downloadThread : public QThread {
wait(); wait();
} }
void downloadUrl(const QString& url){ void downloadUrl(QString url){
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);
url_list << url; url_list << url;
if(!isRunning()){ if(!isRunning()){

2
src/misc.h

@ -128,7 +128,7 @@ class misc : public QObject{
return true; return true;
} }
static QString findFileInDir(const QString& dir_path, const QString& fileName){ static QString findFileInDir(QString dir_path, QString fileName){
QDir dir(dir_path); QDir dir(dir_path);
if(dir.exists(fileName)){ if(dir.exists(fileName)){
return dir.filePath(fileName); return dir.filePath(fileName);

2
src/options_imp.cpp

@ -971,7 +971,7 @@ void options_imp::on_browse_button_clicked(){
// the rest of the line is ignored // the rest of the line is ignored
// //
// Lines may be commented using '#' or '//' // Lines may be commented using '#' or '//'
void options_imp::processFilterFile(const QString& filePath){ void options_imp::processFilterFile(QString filePath){
qDebug("Processing filter files"); qDebug("Processing filter files");
filtersList->clear(); filtersList->clear();
QString manualFilters= misc::qBittorrentPath() + "ipfilter.dat"; QString manualFilters= misc::qBittorrentPath() + "ipfilter.dat";

4
src/options_imp.h

@ -110,7 +110,7 @@ class options_imp : public QDialog, private Ui::Dialog{
void enableProxyAuth(int checkBoxValue); void enableProxyAuth(int checkBoxValue);
void enableDirScan(int checkBoxValue); void enableDirScan(int checkBoxValue);
void on_browse_button_clicked(); void on_browse_button_clicked();
void processFilterFile(const QString& filePath=QString()); void processFilterFile(QString filePath=QString());
void enableApplyButton(); void enableApplyButton();
void checkPortsLogic(); void checkPortsLogic();
void enableSavePath(int checkBoxValue); void enableSavePath(int checkBoxValue);
@ -122,7 +122,7 @@ class options_imp : public QDialog, private Ui::Dialog{
void useStyle(); void useStyle();
signals: signals:
void status_changed(const QString&, bool) const; void status_changed(QString, bool) const;
void exitWithCancel(); void exitWithCancel();
}; };

4
src/previewSelect.h

@ -47,7 +47,7 @@ class previewSelect: public QDialog, private Ui::preview {
torrent_handle h; torrent_handle h;
signals: signals:
void readyToPreviewFile(const QString&) const; void readyToPreviewFile(QString) const;
protected slots: protected slots:
void on_previewButton_clicked(){ void on_previewButton_clicked(){
@ -126,7 +126,7 @@ class previewSelect: public QDialog, private Ui::preview {
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file")); QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
close(); close();
} }
connect(this, SIGNAL(readyToPreviewFile(const QString&)), parent, SLOT(previewFile(const QString&))); connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString)));
if(previewListModel->rowCount() == 1){ if(previewListModel->rowCount() == 1){
// Only one file : no choice // Only one file : no choice
on_previewButton_clicked(); on_previewButton_clicked();

4
src/properties_imp.h

@ -64,8 +64,8 @@ class properties : public QDialog, private Ui::properties{
void maximumSelection(); void maximumSelection();
signals: signals:
void filteredFilesChanged(const QString& fileHash); void filteredFilesChanged(QString fileHash);
void fileSizeChanged(const QString& fileHash); void fileSizeChanged(QString fileHash);
void mustHaveFullAllocationMode(torrent_handle h); void mustHaveFullAllocationMode(torrent_handle h);
public: public:

33
src/rss.h

@ -133,11 +133,11 @@ class RssStream : public QObject{
bool downloadFailure; bool downloadFailure;
signals: signals:
void refreshFinished(const QString& msg, const unsigned short& type); void refreshFinished(QString msg, const unsigned short& type);
public slots : public slots :
// read and store the downloaded rss' informations // read and store the downloaded rss' informations
void processDownloadedFile(const QString&, const QString& file_path) { void processDownloadedFile(QString, QString file_path) {
// delete the former file // delete the former file
if(QFile::exists(filePath)) { if(QFile::exists(filePath)) {
QFile::remove(filePath); QFile::remove(filePath);
@ -149,7 +149,7 @@ class RssStream : public QObject{
} }
// display the icon in the rss window // display the icon in the rss window
void displayIcon(const QString&, const QString& file_path) { void displayIcon(QString, QString file_path) {
iconPath = file_path; iconPath = file_path;
qDebug("Icon tmp path is %s", (const char*) file_path.toUtf8()); qDebug("Icon tmp path is %s", (const char*) file_path.toUtf8());
openIcon(); openIcon();
@ -157,14 +157,14 @@ class RssStream : public QObject{
} }
public: public:
RssStream(const QString& _url) { RssStream(QString _url) {
url = _url; url = _url;
alias = url; alias = url;
read = true; read = true;
downloaderRss = new downloadThread(this); downloaderRss = new downloadThread(this);
downloaderIcon = new downloadThread(this); downloaderIcon = new downloadThread(this);
connect(downloaderRss, SIGNAL(downloadFinished(const QString&, const QString&)), this, SLOT(processDownloadedFile(const QString&, const QString&))); connect(downloaderRss, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
connect(downloaderRss, SIGNAL(downloadFailure(const QString&, const QString&)), this, SLOT(handleDownloadFailure(const QString&, const QString&))); connect(downloaderRss, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString)));
downloaderRss->downloadUrl(url); downloaderRss->downloadUrl(url);
// XXX: remove it when gif can be displayed // XXX: remove it when gif can be displayed
iconPath = ":/Icons/rss.png"; iconPath = ":/Icons/rss.png";
@ -204,7 +204,7 @@ class RssStream : public QObject{
} }
//prefer the RssManager::setAlias, do not save the changed ones //prefer the RssManager::setAlias, do not save the changed ones
void setAlias(const QString& _alias){ void setAlias(QString _alias){
alias = _alias; alias = _alias;
} }
@ -273,7 +273,7 @@ class RssStream : public QObject{
void getIcon() { void getIcon() {
QUrl siteUrl(url); QUrl siteUrl(url);
QString iconUrl = "http://"+siteUrl.host()+"/favicon.ico"; QString iconUrl = "http://"+siteUrl.host()+"/favicon.ico";
connect(downloaderIcon, SIGNAL(downloadFinished(const QString&, const QString&)), this, SLOT(displayIcon(const QString&, const QString&))); connect(downloaderIcon, SIGNAL(downloadFinished(QString, QString)), this, SLOT(displayIcon(QString, QString)));
downloaderIcon->downloadUrl(iconUrl); downloaderIcon->downloadUrl(iconUrl);
} }
@ -384,12 +384,11 @@ class RssStream : public QObject{
else else
iconPath = ":/Icons/rss.png"; iconPath = ":/Icons/rss.png";
} }
return;
} }
} }
protected slots: protected slots:
void handleDownloadFailure(const QString&, const QString&){ void handleDownloadFailure(QString, QString){
// Change the stream icon to a red cross // Change the stream icon to a red cross
iconPath = ":/Icons/unavailable.png"; iconPath = ":/Icons/unavailable.png";
downloadFailure = true; downloadFailure = true;
@ -409,7 +408,7 @@ class RssManager : public QObject{
void streamNeedRefresh(const unsigned short&, const unsigned short&); void streamNeedRefresh(const unsigned short&, const unsigned short&);
public slots : public slots :
void streamNeedRefresh(const QString& _url, const unsigned short& type) { void streamNeedRefresh(QString _url, const unsigned short& type) {
emit(streamNeedRefresh(hasStream(_url), type)); emit(streamNeedRefresh(hasStream(_url), type));
} }
@ -444,7 +443,7 @@ class RssManager : public QObject{
RssStream *stream = new RssStream(streamListUrl.at(i)); RssStream *stream = new RssStream(streamListUrl.at(i));
stream->setAlias(streamListAlias.at(i)); stream->setAlias(streamListAlias.at(i));
streamList.append(stream); streamList.append(stream);
connect(stream, SIGNAL(refreshFinished(const QString&, const unsigned short&)), this, SLOT(streamNeedRefresh(const QString&, const unsigned short&))); connect(stream, SIGNAL(refreshFinished(QString, const unsigned short&)), this, SLOT(streamNeedRefresh(QString, const unsigned short&)));
} }
} }
@ -468,7 +467,7 @@ class RssManager : public QObject{
if(hasStream(stream) < 0){ if(hasStream(stream) < 0){
streamList.append(stream); streamList.append(stream);
streamListUrl.append(stream->getUrl()); streamListUrl.append(stream->getUrl());
connect(stream, SIGNAL(refreshFinished(const QString&, const unsigned short&)), this, SLOT(streamNeedRefresh(const QString&, const unsigned short&))); connect(stream, SIGNAL(refreshFinished(QString, const unsigned short&)), this, SLOT(streamNeedRefresh(QString, const unsigned short&)));
}else{ }else{
qDebug("Not adding the Rss stream because it is already in the list"); qDebug("Not adding the Rss stream because it is already in the list");
} }
@ -480,7 +479,7 @@ class RssManager : public QObject{
RssStream* stream = new RssStream(url); RssStream* stream = new RssStream(url);
streamList.append(stream); streamList.append(stream);
streamListUrl.append(url); streamListUrl.append(url);
connect(stream, SIGNAL(refreshFinished(const QString&, const unsigned short&)), this, SLOT(streamNeedRefresh(const QString&, const unsigned short&))); connect(stream, SIGNAL(refreshFinished(QString, const unsigned short&)), this, SLOT(streamNeedRefresh(QString, const unsigned short&)));
}else { }else {
qDebug("Not adding the Rss stream because it is already in the list"); qDebug("Not adding the Rss stream because it is already in the list");
} }
@ -512,7 +511,7 @@ class RssManager : public QObject{
unsigned int streamListUrlSize = streamListUrl.size(); unsigned int streamListUrlSize = streamListUrl.size();
for(unsigned int i=0; i<streamListUrlSize; ++i){ for(unsigned int i=0; i<streamListUrlSize; ++i){
getStream(i)->refresh(); getStream(i)->refresh();
connect(getStream(i), SIGNAL(refreshFinished(const QString&, const unsigned short&)), this, SLOT(streamNeedRefresh(const QString&, const unsigned short&))); connect(getStream(i), SIGNAL(refreshFinished(QString, const unsigned short&)), this, SLOT(streamNeedRefresh(QString, const unsigned short&)));
} }
} }
@ -520,7 +519,7 @@ class RssManager : public QObject{
if(index>=0 && index<getNbStream()) { if(index>=0 && index<getNbStream()) {
if(getStream(index)->getLastRefreshElapsed()>REFRESH_FREQ_MAX) { if(getStream(index)->getLastRefreshElapsed()>REFRESH_FREQ_MAX) {
getStream(index)->refresh(); getStream(index)->refresh();
connect(getStream(index), SIGNAL(refreshFinished(const QString&, const unsigned short&)), this, SLOT(streamNeedRefresh(const QString&, const unsigned short&))); connect(getStream(index), SIGNAL(refreshFinished(QString, const unsigned short&)), this, SLOT(streamNeedRefresh(QString, const unsigned short&)));
} }
} }
} }
@ -530,7 +529,7 @@ class RssManager : public QObject{
return hasStream(stream->getUrl()); return hasStream(stream->getUrl());
} }
short hasStream(const QString& url) const{ short hasStream(QString url) const{
return streamListUrl.indexOf(url); return streamListUrl.indexOf(url);
} }

16
src/searchEngine.cpp

@ -47,8 +47,8 @@ SearchEngine::SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, b
this->BTSession = BTSession; this->BTSession = BTSession;
this->myTrayIcon = myTrayIcon; this->myTrayIcon = myTrayIcon;
downloader = new downloadThread(this); downloader = new downloadThread(this);
connect(downloader, SIGNAL(downloadFinished(const QString&, const QString&)), this, SLOT(novaUpdateDownloaded(const QString&, const QString&))); connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(novaUpdateDownloaded(QString, QString)));
connect(downloader, SIGNAL(downloadFailure(const QString&, const QString&)), this, SLOT(handleNovaDownloadFailure(const QString&, const QString&))); connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleNovaDownloadFailure(QString, QString)));
// Set Search results list model // Set Search results list model
SearchListModel = new QStandardItemModel(0,5); SearchListModel = new QStandardItemModel(0,5);
SearchListModel->setHeaderData(SEARCH_NAME, Qt::Horizontal, tr("Name", "i.e: file name")); SearchListModel->setHeaderData(SEARCH_NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
@ -117,7 +117,7 @@ SearchEngine::~SearchEngine(){
} }
// Set the color of a row in data model // Set the color of a row in data model
void SearchEngine::setRowColor(int row, const QString& color){ void SearchEngine::setRowColor(int row, QString color){
for(int i=0; i<SearchListModel->columnCount(); ++i){ for(int i=0; i<SearchListModel->columnCount(); ++i){
SearchListModel->setData(SearchListModel->index(row, i), QVariant(QColor(color)), Qt::TextColorRole); SearchListModel->setData(SearchListModel->index(row, i), QVariant(QColor(color)), Qt::TextColorRole);
} }
@ -361,7 +361,7 @@ void SearchEngine::readSearchOutput(){
} }
// Returns version of nova.py search engine // Returns version of nova.py search engine
float SearchEngine::getNovaVersion(const QString& novaPath) const{ float SearchEngine::getNovaVersion(QString novaPath) const{
QFile dest_nova(novaPath); QFile dest_nova(novaPath);
if(!dest_nova.exists()){ if(!dest_nova.exists()){
return 0.0; return 0.0;
@ -384,7 +384,7 @@ float SearchEngine::getNovaVersion(const QString& novaPath) const{
} }
// Returns changelog of nova.py search engine // Returns changelog of nova.py search engine
QByteArray SearchEngine::getNovaChangelog(const QString& novaPath) const{ QByteArray SearchEngine::getNovaChangelog(QString novaPath) const{
QFile dest_nova(novaPath); QFile dest_nova(novaPath);
if(!dest_nova.exists()){ if(!dest_nova.exists()){
return QByteArray("None"); return QByteArray("None");
@ -432,7 +432,7 @@ void SearchEngine::updateNova() const{
} }
} }
void SearchEngine::novaUpdateDownloaded(const QString& url, const QString& filePath){ void SearchEngine::novaUpdateDownloaded(QString url, QString filePath){
float version_on_server = getNovaVersion(filePath); float version_on_server = getNovaVersion(filePath);
qDebug("Version on qbittorrent.org: %.2f", version_on_server); qDebug("Version on qbittorrent.org: %.2f", version_on_server);
if(version_on_server > getNovaVersion(misc::qBittorrentPath()+"nova.py")){ if(version_on_server > getNovaVersion(misc::qBittorrentPath()+"nova.py")){
@ -467,7 +467,7 @@ void SearchEngine::novaUpdateDownloaded(const QString& url, const QString& fileP
QFile::remove(filePath); QFile::remove(filePath);
} }
void SearchEngine::handleNovaDownloadFailure(const QString& url, const QString& reason){ void SearchEngine::handleNovaDownloadFailure(QString url, QString reason){
if(url == "http://www.dchris.eu/nova/nova.zip"){ if(url == "http://www.dchris.eu/nova/nova.zip"){
qDebug("*Warning: Search plugin update download from primary server failed, trying secondary server..."); qDebug("*Warning: Search plugin update download from primary server failed, trying secondary server...");
downloader->downloadUrl("http://hydr0g3n.free.fr/nova/nova.py"); downloader->downloadUrl("http://hydr0g3n.free.fr/nova/nova.py");
@ -515,7 +515,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
// SLOT to append one line to search results list // SLOT to append one line to search results list
// Line is in the following form : // Line is in the following form :
// file url | file name | file size | nb seeds | nb leechers | Search engine url // file url | file name | file size | nb seeds | nb leechers | Search engine url
void SearchEngine::appendSearchResult(const QString& line){ void SearchEngine::appendSearchResult(QString line){
QStringList parts = line.split("|"); QStringList parts = line.split("|");
if(parts.size() != 6){ if(parts.size() != 6){
return; return;

12
src/searchEngine.h

@ -56,8 +56,8 @@ class SearchEngine : public QWidget, public Ui::search_engine{
public: public:
SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, bool systrayIntegration); SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, bool systrayIntegration);
~SearchEngine(); ~SearchEngine();
float getNovaVersion(const QString& novaPath) const; float getNovaVersion(QString novaPath) const;
QByteArray getNovaChangelog(const QString& novaPath) const; QByteArray getNovaChangelog(QString novaPath) const;
bool loadColWidthSearchList(); bool loadColWidthSearchList();
public slots: public slots:
@ -67,10 +67,10 @@ class SearchEngine : public QWidget, public Ui::search_engine{
void on_clear_button_clicked(); void on_clear_button_clicked();
void on_download_button_clicked(); void on_download_button_clicked();
void on_update_nova_button_clicked(); void on_update_nova_button_clicked();
void appendSearchResult(const QString& line); void appendSearchResult(QString line);
void searchFinished(int exitcode,QProcess::ExitStatus); void searchFinished(int exitcode,QProcess::ExitStatus);
void readSearchOutput(); void readSearchOutput();
void setRowColor(int row, const QString& color); void setRowColor(int row, QString color);
void searchStarted(); void searchStarted();
void downloadSelectedItem(const QModelIndex& index); void downloadSelectedItem(const QModelIndex& index);
void startSearchHistory(); void startSearchHistory();
@ -82,8 +82,8 @@ class SearchEngine : public QWidget, public Ui::search_engine{
void sortSearchList(int index); void sortSearchList(int index);
void sortSearchListInt(int index, Qt::SortOrder sortOrder); void sortSearchListInt(int index, Qt::SortOrder sortOrder);
void sortSearchListString(int index, Qt::SortOrder sortOrder); void sortSearchListString(int index, Qt::SortOrder sortOrder);
void novaUpdateDownloaded(const QString& url, const QString& path); void novaUpdateDownloaded(QString url, QString path);
void handleNovaDownloadFailure(const QString& url, const QString& reason); void handleNovaDownloadFailure(QString url, QString reason);
}; };
#endif #endif

4
src/torrentAddition.h

@ -44,8 +44,8 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
Q_OBJECT Q_OBJECT
signals: signals:
void setInfoBarGUI(const QString& info, const QString& color); void setInfoBarGUI(QString info, QString color);
void torrentAddition(const QString& filePath, bool fromScanDir, bool onStartup, const QString& from_url); void torrentAddition(QString filePath, bool fromScanDir, bool onStartup, QString from_url);
private: private:
QString fileName; QString fileName;

Loading…
Cancel
Save