Browse Source

Coding style clean up

adaptive-webui-19844
Christophe Dumez 13 years ago
parent
commit
f3448125c3
  1. 2
      src/about_imp.h
  2. 16
      src/downloadfromurldlg.h
  3. 4
      src/downloadthread.cpp
  4. 14
      src/main.cpp
  5. 4
      src/mainwindow.cpp
  6. 4
      src/misc.cpp
  7. 62
      src/preferences/options_imp.cpp
  8. 6
      src/previewlistdelegate.h
  9. 18
      src/previewselect.cpp
  10. 2
      src/properties/peeraddition.h
  11. 6
      src/properties/peerlistdelegate.h
  12. 16
      src/properties/propertieswidget.cpp
  13. 6
      src/properties/proplistdelegate.h
  14. 8
      src/properties/trackerlist.cpp
  15. 2
      src/properties/trackersadditiondlg.h
  16. 24
      src/qtlibtorrent/filterparserthread.h
  17. 18
      src/qtlibtorrent/qbtsession.cpp
  18. 6
      src/qtlibtorrent/torrentspeedmonitor.cpp
  19. 30
      src/rss/rss_imp.cpp
  20. 2
      src/rss/rssarticle.cpp
  21. 3
      src/rss/rssdownloadrulelist.h
  22. 8
      src/rss/rssfeed.cpp
  23. 2
      src/rss/rssfeed.h
  24. 8
      src/rss/rssmanager.cpp
  25. 18
      src/searchengine/engineselectdlg.cpp
  26. 4
      src/searchengine/pluginsource.h
  27. 64
      src/searchengine/searchengine.cpp
  28. 8
      src/searchengine/searchengine.h
  29. 6
      src/searchengine/searchlistdelegate.h
  30. 8
      src/searchengine/searchtab.cpp
  31. 4
      src/speedlimitdlg.h
  32. 22
      src/torrentadditiondlg.cpp
  33. 8
      src/torrentcreator/torrentcreatordlg.cpp
  34. 6
      src/torrentcreator/torrentcreatorthread.cpp
  35. 4
      src/torrentpersistentdata.h
  36. 8
      src/trackerlogin.h
  37. 6
      src/transferlistdelegate.h
  38. 6
      src/transferlistwidget.cpp
  39. 2
      src/webui/eventmanager.cpp
  40. 10
      src/webui/httpconnection.cpp

2
src/about_imp.h

@ -45,7 +45,7 @@ class about : public QDialog, private Ui::AboutDlg{ @@ -45,7 +45,7 @@ class about : public QDialog, private Ui::AboutDlg{
qDebug("Deleting about dlg");
}
about(QWidget *parent): QDialog(parent){
about(QWidget *parent): QDialog(parent) {
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
// Set icons

16
src/downloadfromurldlg.h

@ -43,7 +43,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{ @@ -43,7 +43,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
Q_OBJECT
public:
downloadFromURL(QWidget *parent): QDialog(parent){
downloadFromURL(QWidget *parent): QDialog(parent) {
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
setModal(true);
@ -55,26 +55,26 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{ @@ -55,26 +55,26 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
}
}
~downloadFromURL(){}
~downloadFromURL() {}
signals:
void urlsReadyToBeDownloaded(const QStringList& torrent_urls);
public slots:
void on_downloadButton_clicked(){
void on_downloadButton_clicked() {
QString urls = textUrls->toPlainText();
QStringList url_list = urls.split(QString::fromUtf8("\n"));
QString url;
QStringList url_list_cleaned;
foreach (url, url_list){
foreach (url, url_list) {
url = url.trimmed();
if (!url.isEmpty()){
if (url_list_cleaned.indexOf(QRegExp(url, Qt::CaseInsensitive, QRegExp::FixedString)) < 0){
if (!url.isEmpty()) {
if (url_list_cleaned.indexOf(QRegExp(url, Qt::CaseInsensitive, QRegExp::FixedString)) < 0) {
url_list_cleaned << url;
}
}
}
if (!url_list_cleaned.size()){
if (!url_list_cleaned.size()) {
QMessageBox::critical(0, tr("No URL entered"), tr("Please type at least one URL."));
return;
}
@ -83,7 +83,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{ @@ -83,7 +83,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
close();
}
void on_cancelButton_clicked(){
void on_cancelButton_clicked() {
close();
}
};

4
src/downloadthread.cpp

@ -133,7 +133,7 @@ void DownloadThread::downloadTorrentUrl(const QString &url) { @@ -133,7 +133,7 @@ void DownloadThread::downloadTorrentUrl(const QString &url) {
connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(checkDownloadSize(qint64,qint64)));
}
QNetworkReply* DownloadThread::downloadUrl(const QString &url){
QNetworkReply* DownloadThread::downloadUrl(const QString &url) {
// Update proxy settings
applyProxySettings();
#ifndef DISABLE_GUI
@ -208,7 +208,7 @@ void DownloadThread::applyProxySettings() { @@ -208,7 +208,7 @@ void DownloadThread::applyProxySettings() {
}
QString DownloadThread::errorCodeToString(QNetworkReply::NetworkError status) {
switch(status){
switch(status) {
case QNetworkReply::HostNotFoundError:
return tr("The remote host name was not found (invalid hostname)");
case QNetworkReply::OperationCanceledError:

14
src/main.cpp

@ -154,7 +154,7 @@ void sigabrtHandler(int) { @@ -154,7 +154,7 @@ void sigabrtHandler(int) {
#endif
// Main
int main(int argc, char *argv[]){
int main(int argc, char *argv[]) {
// Create Application
QString uid = misc::getUserIDString();
#ifdef DISABLE_GUI
@ -192,19 +192,19 @@ int main(int argc, char *argv[]){ @@ -192,19 +192,19 @@ int main(int argc, char *argv[]){
QString locale = pref.getLocale();
QTranslator qtTranslator;
QTranslator translator;
if (locale.isEmpty()){
if (locale.isEmpty()) {
locale = QLocale::system().name();
pref.setLocale(locale);
}
if (qtTranslator.load(
QString::fromUtf8("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)
)){
)) {
qDebug("Qt %s locale recognized, using translation.", qPrintable(locale));
}else{
qDebug("Qt %s locale unrecognized, using default (en_GB).", qPrintable(locale));
}
app.installTranslator(&qtTranslator);
if (translator.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
if (translator.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale));
}else{
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
@ -221,12 +221,12 @@ int main(int argc, char *argv[]){ @@ -221,12 +221,12 @@ int main(int argc, char *argv[]){
app.setApplicationName(QString::fromUtf8("qBittorrent"));
// Check for executable parameters
if (argc > 1){
if (QString::fromLocal8Bit(argv[1]) == QString::fromUtf8("--version")){
if (argc > 1) {
if (QString::fromLocal8Bit(argv[1]) == QString::fromUtf8("--version")) {
std::cout << "qBittorrent " << VERSION << '\n';
return 0;
}
if (QString::fromLocal8Bit(argv[1]) == QString::fromUtf8("--help")){
if (QString::fromLocal8Bit(argv[1]) == QString::fromUtf8("--help")) {
UsageDisplay::displayUsage(argv[0]);
return 0;
}

4
src/mainwindow.cpp

@ -584,7 +584,7 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(const QTorrentHandle &h @@ -584,7 +584,7 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(const QTorrentHandle &h
QString torrent_name;
try {
torrent_name = h.name();
} catch(invalid_handle&){
} catch(invalid_handle&) {
return;
}
QMessageBox confirmBox(QMessageBox::Question, tr("Recursive download confirmation"), tr("The torrent %1 contains torrent files, do you want to proceed with their download?").arg(torrent_name));
@ -897,7 +897,7 @@ void MainWindow::dropEvent(QDropEvent *event) { @@ -897,7 +897,7 @@ void MainWindow::dropEvent(QDropEvent *event) {
// Decode if we accept drag 'n drop or not
void MainWindow::dragEnterEvent(QDragEnterEvent *event) {
foreach (const QString &mime, event->mimeData()->formats()){
foreach (const QString &mime, event->mimeData()->formats()) {
qDebug("mimeData: %s", mime.toLocal8Bit().data());
}
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) {

4
src/misc.cpp

@ -622,7 +622,7 @@ QString misc::friendlyUnit(qreal val) { @@ -622,7 +622,7 @@ QString misc::friendlyUnit(qreal val) {
return QString::number(val, 'f', 1) + " " + tr(units[i].source, units[i].comment);
}
bool misc::isPreviewable(QString extension){
bool misc::isPreviewable(QString extension) {
if (extension.isEmpty()) return false;
extension = extension.toUpper();
if (extension == "AVI") return true;
@ -911,7 +911,7 @@ QString misc::parseHtmlLinks(const QString &raw_text) @@ -911,7 +911,7 @@ QString misc::parseHtmlLinks(const QString &raw_text)
")"
"|"
"(" // case 2b no scheme, no TLD, must have at least 2 aphanum strings plus uncommon TLD string --> del.icio.us
"([a-zA-Z0-9_-]+\\.){2,}" //2 or more domainpart. --> del.icio.
"([a-zA-Z0-9_-]+\\.) {2,}" //2 or more domainpart. --> del.icio.
"[a-zA-Z]{2,}" //one ab (2 char or longer) --> us
"([a-zA-Z0-9\\?%=&/_\\.:#;-]*)" // everything to 1st non-URI char, maybe nothing in case of del.icio.us/path
")"

62
src/preferences/options_imp.cpp

@ -81,8 +81,8 @@ options_imp::options_imp(QWidget *parent): @@ -81,8 +81,8 @@ options_imp::options_imp(QWidget *parent):
hsplitter->setCollapsible(1, false);
// Get apply button in button box
QList<QAbstractButton *> buttons = buttonBox->buttons();
foreach (QAbstractButton *button, buttons){
if (buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole){
foreach (QAbstractButton *button, buttons) {
if (buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) {
applyButton = button;
break;
}
@ -109,7 +109,7 @@ options_imp::options_imp(QWidget *parent): @@ -109,7 +109,7 @@ options_imp::options_imp(QWidget *parent):
// Load options
loadOptions();
// Disable systray integration if it is not supported by the system
if (!QSystemTrayIcon::isSystemTrayAvailable()){
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
checkShowSystray->setChecked(false);
checkShowSystray->setEnabled(false);
}
@ -279,7 +279,7 @@ void options_imp::initializeLanguageCombo() @@ -279,7 +279,7 @@ void options_imp::initializeLanguageCombo()
}
// Main destructor
options_imp::~options_imp(){
options_imp::~options_imp() {
qDebug("-> destructing Options");
foreach (const QString &path, addedScanDirs)
ScanFoldersModel::instance()->removePath(path);
@ -343,14 +343,14 @@ QSize options_imp::sizeFittingScreen() const { @@ -343,14 +343,14 @@ QSize options_imp::sizeFittingScreen() const {
return size();
}
void options_imp::saveOptions(){
void options_imp::saveOptions() {
applyButton->setEnabled(false);
Preferences pref;
// Load the translation
QString locale = getLocale();
if (pref.getLocale() != locale) {
QTranslator *translator = new QTranslator;
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale));
}else{
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
@ -454,7 +454,7 @@ void options_imp::saveOptions(){ @@ -454,7 +454,7 @@ void options_imp::saveOptions(){
// Misc preferences
// * IPFilter
pref.setFilteringEnabled(isFilteringEnabled());
if (isFilteringEnabled()){
if (isFilteringEnabled()) {
QString filter_path = textFilterPath->text();
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
filter_path.replace("\\", "/");
@ -508,12 +508,12 @@ int options_imp::getProxyType() const{ @@ -508,12 +508,12 @@ int options_imp::getProxyType() const{
return Proxy::SOCKS4;
break;
case 2:
if (isProxyAuthEnabled()){
if (isProxyAuthEnabled()) {
return Proxy::SOCKS5_PW;
}
return Proxy::SOCKS5;
case 3:
if (isProxyAuthEnabled()){
if (isProxyAuthEnabled()) {
return Proxy::HTTP_PW;
}
return Proxy::HTTP;
@ -522,7 +522,7 @@ int options_imp::getProxyType() const{ @@ -522,7 +522,7 @@ int options_imp::getProxyType() const{
}
}
void options_imp::loadOptions(){
void options_imp::loadOptions() {
int intValue;
qreal floatValue;
QString strValue;
@ -812,10 +812,10 @@ bool options_imp::isUPnPEnabled() const{ @@ -812,10 +812,10 @@ bool options_imp::isUPnPEnabled() const{
// [download,upload]
QPair<int,int> options_imp::getGlobalBandwidthLimits() const{
int DL = -1, UP = -1;
if (checkDownloadLimit->isChecked()){
if (checkDownloadLimit->isChecked()) {
DL = spinDownloadLimit->value();
}
if (checkUploadLimit->isChecked()){
if (checkUploadLimit->isChecked()) {
UP = spinUploadLimit->value();
}
return qMakePair(DL, UP);
@ -837,7 +837,7 @@ int options_imp::getDHTPort() const { @@ -837,7 +837,7 @@ int options_imp::getDHTPort() const {
// Return Share ratio
qreal options_imp::getMaxRatio() const{
if (checkMaxRatio->isChecked()){
if (checkMaxRatio->isChecked()) {
return spinMaxRatio->value();
}
return -1;
@ -845,7 +845,7 @@ qreal options_imp::getMaxRatio() const{ @@ -845,7 +845,7 @@ qreal options_imp::getMaxRatio() const{
// Return Save Path
QString options_imp::getSavePath() const{
if (textSavePath->text().trimmed().isEmpty()){
if (textSavePath->text().trimmed().isEmpty()) {
QString save_path = Preferences().getSavePath();
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
save_path.replace("/", "\\");
@ -865,7 +865,7 @@ bool options_imp::isTempPathEnabled() const { @@ -865,7 +865,7 @@ bool options_imp::isTempPathEnabled() const {
// Return max connections number
int options_imp::getMaxConnecs() const{
if (!checkMaxConnecs->isChecked()){
if (!checkMaxConnecs->isChecked()) {
return -1;
}else{
return spinMaxConnec->value();
@ -873,7 +873,7 @@ int options_imp::getMaxConnecs() const{ @@ -873,7 +873,7 @@ int options_imp::getMaxConnecs() const{
}
int options_imp::getMaxConnecsPerTorrent() const{
if (!checkMaxConnecsPerTorrent->isChecked()){
if (!checkMaxConnecsPerTorrent->isChecked()) {
return -1;
}else{
return spinMaxConnecPerTorrent->value();
@ -881,15 +881,15 @@ int options_imp::getMaxConnecsPerTorrent() const{ @@ -881,15 +881,15 @@ int options_imp::getMaxConnecsPerTorrent() const{
}
int options_imp::getMaxUploadsPerTorrent() const{
if (!checkMaxUploadsPerTorrent->isChecked()){
if (!checkMaxUploadsPerTorrent->isChecked()) {
return -1;
}else{
return spinMaxUploadsPerTorrent->value();
}
}
void options_imp::on_buttonBox_accepted(){
if (applyButton->isEnabled()){
void options_imp::on_buttonBox_accepted() {
if (applyButton->isEnabled()) {
saveOptions();
applyButton->setEnabled(false);
this->hide();
@ -900,18 +900,18 @@ void options_imp::on_buttonBox_accepted(){ @@ -900,18 +900,18 @@ void options_imp::on_buttonBox_accepted(){
}
void options_imp::applySettings(QAbstractButton* button) {
if (button == applyButton){
if (button == applyButton) {
saveOptions();
emit status_changed();
}
}
void options_imp::closeEvent(QCloseEvent *e){
void options_imp::closeEvent(QCloseEvent *e) {
setAttribute(Qt::WA_DeleteOnClose);
e->accept();
}
void options_imp::on_buttonBox_rejected(){
void options_imp::on_buttonBox_rejected() {
setAttribute(Qt::WA_DeleteOnClose);
reject();
}
@ -920,12 +920,12 @@ bool options_imp::useAdditionDialog() const{ @@ -920,12 +920,12 @@ bool options_imp::useAdditionDialog() const{
return checkAdditionDialog->isChecked();
}
void options_imp::enableApplyButton(){
void options_imp::enableApplyButton() {
applyButton->setEnabled(true);
}
void options_imp::enableProxy(int index){
if (index){
void options_imp::enableProxy(int index) {
if (index) {
//enable
lblProxyIP->setEnabled(true);
textProxyIP->setEnabled(true);
@ -1084,7 +1084,7 @@ void options_imp::on_browseExportDirButton_clicked() { @@ -1084,7 +1084,7 @@ void options_imp::on_browseExportDirButton_clicked() {
} else {
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), QDir::homePath());
}
if (!dir.isNull()){
if (!dir.isNull()) {
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
dir.replace("/", "\\");
#endif
@ -1101,7 +1101,7 @@ void options_imp::on_browseFilterButton_clicked() { @@ -1101,7 +1101,7 @@ void options_imp::on_browseFilterButton_clicked() {
} else {
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an ip filter file"), QDir::homePath(), tr("Filters")+QString(" (*.dat *.p2p *.p2b)"));
}
if (!ipfilter.isNull()){
if (!ipfilter.isNull()) {
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
ipfilter.replace("/", "\\");
#endif
@ -1110,7 +1110,7 @@ void options_imp::on_browseFilterButton_clicked() { @@ -1110,7 +1110,7 @@ void options_imp::on_browseFilterButton_clicked() {
}
// Display dialog to choose save dir
void options_imp::on_browseSaveDirButton_clicked(){
void options_imp::on_browseSaveDirButton_clicked() {
const QString save_path = misc::expandPath(textSavePath->text());
QDir saveDir(save_path);
QString dir;
@ -1119,7 +1119,7 @@ void options_imp::on_browseSaveDirButton_clicked(){ @@ -1119,7 +1119,7 @@ void options_imp::on_browseSaveDirButton_clicked(){
} else {
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
}
if (!dir.isNull()){
if (!dir.isNull()) {
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
dir.replace("/", "\\");
#endif
@ -1127,7 +1127,7 @@ void options_imp::on_browseSaveDirButton_clicked(){ @@ -1127,7 +1127,7 @@ void options_imp::on_browseSaveDirButton_clicked(){
}
}
void options_imp::on_browseTempDirButton_clicked(){
void options_imp::on_browseTempDirButton_clicked() {
const QString temp_path = misc::expandPath(textTempPath->text());
QDir tempDir(temp_path);
QString dir;
@ -1136,7 +1136,7 @@ void options_imp::on_browseTempDirButton_clicked(){ @@ -1136,7 +1136,7 @@ void options_imp::on_browseTempDirButton_clicked(){
} else {
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
}
if (!dir.isNull()){
if (!dir.isNull()) {
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
dir.replace("/", "\\");
#endif

6
src/previewlistdelegate.h

@ -45,15 +45,15 @@ class PreviewListDelegate: public QItemDelegate { @@ -45,15 +45,15 @@ class PreviewListDelegate: public QItemDelegate {
Q_OBJECT
public:
PreviewListDelegate(QObject *parent=0) : QItemDelegate(parent){}
PreviewListDelegate(QObject *parent=0) : QItemDelegate(parent) {}
~PreviewListDelegate(){}
~PreviewListDelegate() {}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
painter->save();
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
switch(index.column()){
switch(index.column()) {
case PreviewSelect::SIZE:
QItemDelegate::drawBackground(painter, opt, index);
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));

18
src/previewselect.cpp

@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
#include "previewlistdelegate.h"
#include "previewselect.h"
PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent), h(h){
PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent), h(h) {
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
// Preview list
@ -56,7 +56,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent) @@ -56,7 +56,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent)
std::vector<libtorrent::size_type> fp;
h.file_progress(fp);
unsigned int nbFiles = h.num_files();
for (unsigned int i=0; i<nbFiles; ++i){
for (unsigned int i=0; i<nbFiles; ++i) {
QString fileName = h.filename_at(i);
QString extension = fileName.split(QString::fromUtf8(".")).last().toUpper();
if (misc::isPreviewable(extension)) {
@ -71,12 +71,12 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent) @@ -71,12 +71,12 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent)
previewList->selectionModel()->select(previewListModel->index(0, NAME), QItemSelectionModel::Select);
previewList->selectionModel()->select(previewListModel->index(0, SIZE), QItemSelectionModel::Select);
previewList->selectionModel()->select(previewListModel->index(0, PROGRESS), QItemSelectionModel::Select);
if (!previewListModel->rowCount()){
if (!previewListModel->rowCount()) {
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
close();
}
connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString)));
if (previewListModel->rowCount() == 1){
if (previewListModel->rowCount() == 1) {
qDebug("Torrent file only contains one file, no need to display selection dialog before preview");
// Only one file : no choice
on_previewButton_clicked();
@ -86,13 +86,13 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent) @@ -86,13 +86,13 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent)
}
}
PreviewSelect::~PreviewSelect(){
PreviewSelect::~PreviewSelect() {
delete previewListModel;
delete listDelegate;
}
void PreviewSelect::on_previewButton_clicked(){
void PreviewSelect::on_previewButton_clicked() {
QModelIndex index;
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(NAME);
if (selectedIndexes.size() == 0) return;
@ -100,10 +100,10 @@ void PreviewSelect::on_previewButton_clicked(){ @@ -100,10 +100,10 @@ void PreviewSelect::on_previewButton_clicked(){
h.flush_cache();
QString path;
foreach (index, selectedIndexes){
foreach (index, selectedIndexes) {
path = h.absolute_files_path().at(indexes.at(index.row()));
// File
if (QFile::exists(path)){
if (QFile::exists(path)) {
emit readyToPreviewFile(path);
} else {
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
@ -116,6 +116,6 @@ void PreviewSelect::on_previewButton_clicked(){ @@ -116,6 +116,6 @@ void PreviewSelect::on_previewButton_clicked(){
close();
}
void PreviewSelect::on_cancelButton_clicked(){
void PreviewSelect::on_cancelButton_clicked() {
close();
}

2
src/properties/peeraddition.h

@ -55,7 +55,7 @@ public: @@ -55,7 +55,7 @@ public:
connect(buttonBox, SIGNAL(accepted()), this, SLOT(validateInput()));
}
~PeerAdditionDlg(){}
~PeerAdditionDlg() {}
QString getIP() const {
QHostAddress ip(lineIP->text());

6
src/properties/peerlistdelegate.h

@ -43,14 +43,14 @@ public: @@ -43,14 +43,14 @@ public:
TOT_DOWN, TOT_UP, IP_HIDDEN, COL_COUNT};
public:
PeerListDelegate(QObject *parent) : QItemDelegate(parent){}
PeerListDelegate(QObject *parent) : QItemDelegate(parent) {}
~PeerListDelegate(){}
~PeerListDelegate() {}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
painter->save();
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
switch(index.column()){
switch(index.column()) {
case TOT_DOWN:
case TOT_UP:
QItemDelegate::drawBackground(painter, opt, index);

16
src/properties/propertieswidget.cpp

@ -400,12 +400,12 @@ void PropertiesWidget::loadDynamicData() { @@ -400,12 +400,12 @@ void PropertiesWidget::loadDynamicData() {
} catch(invalid_handle e) {}
}
void PropertiesWidget::loadUrlSeeds(){
void PropertiesWidget::loadUrlSeeds() {
listWebSeeds->clear();
qDebug("Loading URL seeds");
const QStringList hc_seeds = h.url_seeds();
// Add url seeds
foreach (const QString &hc_seed, hc_seeds){
foreach (const QString &hc_seed, hc_seeds) {
qDebug("Loading URL seed: %s", qPrintable(hc_seed));
new QListWidgetItem(hc_seed, listWebSeeds);
}
@ -450,7 +450,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) { @@ -450,7 +450,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
}
}
void PropertiesWidget::displayFilesListMenu(const QPoint&){
void PropertiesWidget::displayFilesListMenu(const QPoint&) {
QMenu myFilesLlistMenu;
QModelIndexList selectedRows = filesList->selectionModel()->selectedRows(0);
QAction *actRename = 0;
@ -616,7 +616,7 @@ void PropertiesWidget::renameSelectedFile() { @@ -616,7 +616,7 @@ void PropertiesWidget::renameSelectedFile() {
}
}
void PropertiesWidget::askWebSeed(){
void PropertiesWidget::askWebSeed() {
bool ok;
// Ask user for a new url seed
const QString url_seed = QInputDialog::getText(this, tr("New url seed", "New HTTP source"),
@ -635,15 +635,15 @@ void PropertiesWidget::askWebSeed(){ @@ -635,15 +635,15 @@ void PropertiesWidget::askWebSeed(){
loadUrlSeeds();
}
void PropertiesWidget::deleteSelectedUrlSeeds(){
void PropertiesWidget::deleteSelectedUrlSeeds() {
const QList<QListWidgetItem *> selectedItems = listWebSeeds->selectedItems();
bool change = false;
foreach (const QListWidgetItem *item, selectedItems){
foreach (const QListWidgetItem *item, selectedItems) {
QString url_seed = item->text();
h.remove_url_seed(url_seed);
change = true;
}
if (change){
if (change) {
// Refresh list
loadUrlSeeds();
}
@ -674,7 +674,7 @@ void PropertiesWidget::on_changeSavePathButton_clicked() { @@ -674,7 +674,7 @@ void PropertiesWidget::on_changeSavePathButton_clicked() {
new_path = QFileDialog::getExistingDirectory(this, tr("Choose save path"), saveDir.absolutePath(),
QFileDialog::DontConfirmOverwrite|QFileDialog::ShowDirsOnly|QFileDialog::HideNameFilterDetails);
}
if (!new_path.isEmpty()){
if (!new_path.isEmpty()) {
// Check if savePath exists
QString save_path_dir = new_path.replace("\\", "/");
QString new_file_name;

6
src/properties/proplistdelegate.h

@ -60,15 +60,15 @@ signals: @@ -60,15 +60,15 @@ signals:
void filteredFilesChanged() const;
public:
PropListDelegate(PropertiesWidget* properties=0, QObject *parent=0) : QItemDelegate(parent), properties(properties){
PropListDelegate(PropertiesWidget* properties=0, QObject *parent=0) : QItemDelegate(parent), properties(properties) {
}
~PropListDelegate(){}
~PropListDelegate() {}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
painter->save();
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
switch(index.column()){
switch(index.column()) {
case PCSIZE:
QItemDelegate::drawBackground(painter, opt, index);
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));

8
src/properties/trackerlist.cpp

@ -108,7 +108,7 @@ void TrackerList::moveSelectionUp() { @@ -108,7 +108,7 @@ void TrackerList::moveSelectionUp() {
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
if (selected_items.isEmpty()) return;
bool change = false;
foreach (QTreeWidgetItem *item, selected_items){
foreach (QTreeWidgetItem *item, selected_items) {
int index = indexOfTopLevelItem(item);
if (index > NB_STICKY_ITEM) {
insertTopLevelItem(index-1, takeTopLevelItem(index));
@ -273,7 +273,7 @@ void TrackerList::loadTrackers() { @@ -273,7 +273,7 @@ void TrackerList::loadTrackers() {
}
// Ask the user for new trackers and add them to the torrent
void TrackerList::askForTrackers(){
void TrackerList::askForTrackers() {
QTorrentHandle h = properties->getCurrentTorrent();
if (!h.is_valid()) return;
QStringList trackers = TrackersAdditionDlg::askForTrackers(h);
@ -291,7 +291,7 @@ void TrackerList::askForTrackers(){ @@ -291,7 +291,7 @@ void TrackerList::askForTrackers(){
}
}
void TrackerList::deleteSelectedTrackers(){
void TrackerList::deleteSelectedTrackers() {
QTorrentHandle h = properties->getCurrentTorrent();
if (!h.is_valid()) {
clear();
@ -300,7 +300,7 @@ void TrackerList::deleteSelectedTrackers(){ @@ -300,7 +300,7 @@ void TrackerList::deleteSelectedTrackers(){
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
if (selected_items.isEmpty()) return;
QStringList urls_to_remove;
foreach (QTreeWidgetItem *item, selected_items){
foreach (QTreeWidgetItem *item, selected_items) {
QString tracker_url = item->data(COL_URL, Qt::DisplayRole).toString();
urls_to_remove << tracker_url;
tracker_items.remove(tracker_url);

2
src/properties/trackersadditiondlg.h

@ -58,7 +58,7 @@ public: @@ -58,7 +58,7 @@ public:
list_url->setCursorPosition(0);
}
~TrackersAdditionDlg(){}
~TrackersAdditionDlg() {}
QStringList newTrackers() const {
return trackers_list->toPlainText().trimmed().split("\n");

24
src/qtlibtorrent/filterparserthread.h

@ -59,7 +59,7 @@ public: @@ -59,7 +59,7 @@ public:
}
~FilterParserThread(){
~FilterParserThread() {
abort = true;
wait();
}
@ -68,8 +68,8 @@ public: @@ -68,8 +68,8 @@ public:
int parseDATFilterFile(QString filePath) {
int ruleCount = 0;
QFile file(filePath);
if (file.exists()){
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
if (file.exists()) {
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
std::cerr << "I/O Error: Could not open ip filer file in read mode." << std::endl;
return ruleCount;
}
@ -141,7 +141,7 @@ public: @@ -141,7 +141,7 @@ public:
try {
filter.add_rule(startAddr, endAddr, libtorrent::ip_filter::blocked);
++ruleCount;
}catch(exception){
}catch(exception) {
qDebug("Bad line in filter file, avoided crash...");
}
}
@ -154,8 +154,8 @@ public: @@ -154,8 +154,8 @@ public:
int parseP2PFilterFile(QString filePath) {
int ruleCount = 0;
QFile file(filePath);
if (file.exists()){
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
if (file.exists()) {
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
std::cerr << "I/O Error: Could not open ip filer file in read mode." << std::endl;
return ruleCount;
}
@ -168,7 +168,7 @@ public: @@ -168,7 +168,7 @@ public:
if (line.startsWith('#') || line.startsWith("//")) continue;
// Line is splitted by :
QList<QByteArray> partsList = line.split(':');
if (partsList.size() < 2){
if (partsList.size() < 2) {
qDebug("p2p file: line %d is malformed.", nbLine);
continue;
}
@ -246,8 +246,8 @@ public: @@ -246,8 +246,8 @@ public:
int parseP2BFilterFile(QString filePath) {
int ruleCount = 0;
QFile file(filePath);
if (file.exists()){
if (!file.open(QIODevice::ReadOnly)){
if (file.exists()) {
if (!file.open(QIODevice::ReadOnly)) {
std::cerr << "I/O Error: Could not open ip filer file in read mode." << std::endl;
return ruleCount;
}
@ -351,7 +351,7 @@ public: @@ -351,7 +351,7 @@ public:
// * eMule IP list (DAT): http://wiki.phoenixlabs.org/wiki/DAT_Format
// * PeerGuardian Text (P2P): http://wiki.phoenixlabs.org/wiki/P2P_Format
// * PeerGuardian Binary (P2B): http://wiki.phoenixlabs.org/wiki/P2B_Format
void processFilterFile(QString _filePath){
void processFilterFile(QString _filePath) {
// First, import current filter
filter = s->get_ip_filter();
if (isRunning()) {
@ -392,7 +392,7 @@ protected: @@ -392,7 +392,7 @@ protected:
return ip.toString();
}
void run(){
void run() {
qDebug("Processing filter file");
int ruleCount = 0;
if (filePath.endsWith(".p2p", Qt::CaseInsensitive)) {
@ -412,7 +412,7 @@ protected: @@ -412,7 +412,7 @@ protected:
try {
s->set_ip_filter(filter);
emit IPFilterParsed(ruleCount);
} catch(std::exception&){
} catch(std::exception&) {
emit IPFilterError();
}
qDebug("IP Filter thread: finished parsing, filter applied");

18
src/qtlibtorrent/qbtsession.cpp

@ -922,7 +922,7 @@ QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed) { @@ -922,7 +922,7 @@ QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed) {
// Adding torrent to Bittorrent session
try {
h = QTorrentHandle(add_magnet_uri(*s, magnet_uri.toStdString(), p));
}catch(std::exception e){
}catch(std::exception e) {
qDebug("Error: %s", e.what());
}
// Check if it worked
@ -1114,7 +1114,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr @@ -1114,7 +1114,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
// Adding torrent to Bittorrent session
try {
h = QTorrentHandle(s->add_torrent(p));
}catch(std::exception e){
}catch(std::exception e) {
qDebug("Error: %s", e.what());
}
// Check if it worked
@ -1585,7 +1585,7 @@ void QBtSession::saveTempFastResumeData() { @@ -1585,7 +1585,7 @@ void QBtSession::saveTempFastResumeData() {
if (h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking) continue;
qDebug("Saving fastresume data for %s", qPrintable(h.name()));
h.save_resume_data();
}catch(std::exception e){}
}catch(std::exception e) {}
}
}
@ -1630,7 +1630,7 @@ void QBtSession::saveFastResumeData() { @@ -1630,7 +1630,7 @@ void QBtSession::saveFastResumeData() {
// Remove torrent from session
if (rda->handle.is_valid())
s->remove_torrent(rda->handle);
}catch(libtorrent::libtorrent_exception){}
}catch(libtorrent::libtorrent_exception) {}
continue;
}
save_resume_data_alert const* rd = dynamic_cast<save_resume_data_alert const*>(a);
@ -1659,7 +1659,7 @@ void QBtSession::saveFastResumeData() { @@ -1659,7 +1659,7 @@ void QBtSession::saveFastResumeData() {
// Remove torrent from session
s->remove_torrent(rd->handle);
s->pop_alert();
} catch(libtorrent::invalid_handle&){}
} catch(libtorrent::invalid_handle&) {}
}
}
@ -2405,7 +2405,7 @@ void QBtSession::readAlerts() { @@ -2405,7 +2405,7 @@ void QBtSession::readAlerts() {
else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) {
// Level: fatal
QTorrentHandle h(p->handle);
if (h.is_valid()){
if (h.is_valid()) {
// Authentication
if (p->status_code != 401) {
qDebug("Received a tracker error for %s: %s", p->url.c_str(), p->msg.c_str());
@ -2422,7 +2422,7 @@ void QBtSession::readAlerts() { @@ -2422,7 +2422,7 @@ void QBtSession::readAlerts() {
}
else if (tracker_reply_alert* p = dynamic_cast<tracker_reply_alert*>(a.get())) {
const QTorrentHandle h(p->handle);
if (h.is_valid()){
if (h.is_valid()) {
qDebug("Received a tracker reply from %s (Num_peers=%d)", p->url.c_str(), p->num_peers);
// Connection was successful now. Remove possible old errors
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
@ -2435,7 +2435,7 @@ void QBtSession::readAlerts() { @@ -2435,7 +2435,7 @@ void QBtSession::readAlerts() {
}
} else if (tracker_warning_alert* p = dynamic_cast<tracker_warning_alert*>(a.get())) {
const QTorrentHandle h(p->handle);
if (h.is_valid()){
if (h.is_valid()) {
// Connection was successful now but there is a warning message
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
const QString tracker_url = misc::toQString(p->url);
@ -2504,7 +2504,7 @@ void QBtSession::readAlerts() { @@ -2504,7 +2504,7 @@ void QBtSession::readAlerts() {
}
else if (torrent_checked_alert* p = dynamic_cast<torrent_checked_alert*>(a.get())) {
QTorrentHandle h(p->handle);
if (h.is_valid()){
if (h.is_valid()) {
const QString hash = h.hash();
qDebug("%s have just finished checking", qPrintable(hash));
// Save seed status

6
src/qtlibtorrent/torrentspeedmonitor.cpp

@ -41,7 +41,7 @@ using namespace libtorrent; @@ -41,7 +41,7 @@ using namespace libtorrent;
class SpeedSample {
public:
SpeedSample(){}
SpeedSample() {}
void addSample(int s);
qreal average() const;
void clear();
@ -106,7 +106,7 @@ void TorrentSpeedMonitor::removeSamples(const QString &hash) @@ -106,7 +106,7 @@ void TorrentSpeedMonitor::removeSamples(const QString &hash)
void TorrentSpeedMonitor::removeSamples(const QTorrentHandle& h) {
try {
m_samples.remove(h.hash());
} catch(invalid_handle&){}
} catch(invalid_handle&) {}
}
qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const
@ -133,6 +133,6 @@ void TorrentSpeedMonitor::getSamples() @@ -133,6 +133,6 @@ void TorrentSpeedMonitor::getSamples()
if (!it->is_paused())
m_samples[misc::toQString(it->info_hash())].addSample(it->status().download_payload_rate);
#endif
} catch(invalid_handle&){}
} catch(invalid_handle&) {}
}
}

30
src/rss/rss_imp.cpp

@ -62,7 +62,7 @@ enum ArticleRoles { @@ -62,7 +62,7 @@ enum ArticleRoles {
}
// display a right-click menu
void RSSImp::displayRSSListMenu(const QPoint& pos){
void RSSImp::displayRSSListMenu(const QPoint& pos) {
if (!m_feedList->indexAt(pos).isValid()) {
// No item under the mouse, clear selection
m_feedList->clearSelection();
@ -99,7 +99,7 @@ void RSSImp::displayRSSListMenu(const QPoint& pos){ @@ -99,7 +99,7 @@ void RSSImp::displayRSSListMenu(const QPoint& pos){
myRSSListMenu.exec(QCursor::pos());
}
void RSSImp::displayItemsListMenu(const QPoint&){
void RSSImp::displayItemsListMenu(const QPoint&) {
QMenu myItemListMenu(this);
QList<QListWidgetItem*> selectedItems = listArticles->selectedItems();
if (selectedItems.size() > 0) {
@ -203,7 +203,7 @@ void RSSImp::on_newFeedButton_clicked() { @@ -203,7 +203,7 @@ void RSSImp::on_newFeedButton_clicked() {
QString newUrl = QInputDialog::getText(this, tr("Please type a rss stream url"), tr("Stream URL:"), QLineEdit::Normal, default_url, &ok);
if (ok) {
newUrl = newUrl.trimmed();
if (!newUrl.isEmpty()){
if (!newUrl.isEmpty()) {
if (m_feedList->hasFeed(newUrl)) {
QMessageBox::warning(this, tr("qBittorrent"),
tr("This rss feed is already in the list."),
@ -242,8 +242,8 @@ void RSSImp::deleteSelectedItems() { @@ -242,8 +242,8 @@ void RSSImp::deleteSelectedItems() {
tr("&Yes"), tr("&No"),
QString(), 0, 1);
if (!ret) {
foreach (QTreeWidgetItem *item, selectedItems){
if (m_feedList->currentFeed() == item){
foreach (QTreeWidgetItem *item, selectedItems) {
if (m_feedList->currentFeed() == item) {
textBrowser->clear();
m_currentArticle = 0;
listArticles->clear();
@ -374,7 +374,7 @@ void RSSImp::renameFiles() { @@ -374,7 +374,7 @@ void RSSImp::renameFiles() {
//right-click on stream : refresh it
void RSSImp::refreshSelectedItems() {
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems();
foreach (QTreeWidgetItem* item, selectedItems){
foreach (QTreeWidgetItem* item, selectedItems) {
RssFilePtr file = m_feedList->getRSSItem(item);
// Update icons
if (item == m_feedList->stickyUnreadItem()) {
@ -402,7 +402,7 @@ void RSSImp::copySelectedFeedsURL() { @@ -402,7 +402,7 @@ void RSSImp::copySelectedFeedsURL() {
QStringList URLs;
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems();
QTreeWidgetItem* item;
foreach (item, selectedItems){
foreach (item, selectedItems) {
if (m_feedList->isFeed(item))
URLs << m_feedList->getItemID(item);
}
@ -412,7 +412,7 @@ void RSSImp::copySelectedFeedsURL() { @@ -412,7 +412,7 @@ void RSSImp::copySelectedFeedsURL() {
void RSSImp::on_markReadButton_clicked() {
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems();
QTreeWidgetItem* item;
foreach (item, selectedItems){
foreach (item, selectedItems) {
RssFilePtr rss_item = m_feedList->getRSSItem(item);
rss_item->markAsRead();
updateItemInfos(item);
@ -428,7 +428,7 @@ void RSSImp::fillFeedsList(QTreeWidgetItem *parent, const RssFolderPtr& rss_pare @@ -428,7 +428,7 @@ void RSSImp::fillFeedsList(QTreeWidgetItem *parent, const RssFolderPtr& rss_pare
} else {
children = m_rssManager->getContent();
}
foreach (const RssFilePtr& rss_child, children){
foreach (const RssFilePtr& rss_child, children) {
QTreeWidgetItem* item;
if (!parent)
item = new QTreeWidgetItem(m_feedList);
@ -471,12 +471,12 @@ void RSSImp::refreshArticleList(QTreeWidgetItem* item) { @@ -471,12 +471,12 @@ void RSSImp::refreshArticleList(QTreeWidgetItem* item) {
m_currentArticle = 0;
listArticles->clear();
qDebug("Got the list of news");
foreach (const RssArticlePtr &article, news){
foreach (const RssArticlePtr &article, news) {
QListWidgetItem* it = new QListWidgetItem(listArticles);
it->setData(Article::TitleRole, article->title());
it->setData(Article::FeedUrlRole, article->parent()->url());
it->setData(Article::IdRole, article->guid());
if (article->isRead()){
if (article->isRead()) {
it->setData(Article::ColorRole, QVariant(QColor("grey")));
it->setData(Article::IconRole, QVariant(QIcon(":/Icons/sphere.png")));
}else{
@ -571,12 +571,12 @@ void RSSImp::updateItemInfos(QTreeWidgetItem *item) { @@ -571,12 +571,12 @@ void RSSImp::updateItemInfos(QTreeWidgetItem *item) {
updateItemInfos(item->parent());
}
void RSSImp::updateFeedIcon(const QString &url, const QString &icon_path){
void RSSImp::updateFeedIcon(const QString &url, const QString &icon_path) {
QTreeWidgetItem *item = m_feedList->getTreeItemFromUrl(url);
item->setData(0,Qt::DecorationRole, QVariant(QIcon(icon_path)));
}
void RSSImp::updateFeedInfos(const QString &url, const QString &display_name, uint nbUnread){
void RSSImp::updateFeedInfos(const QString &url, const QString &display_name, uint nbUnread) {
qDebug() << Q_FUNC_INFO << display_name;
QTreeWidgetItem *item = m_feedList->getTreeItemFromUrl(url);
RssFeedPtr stream = qSharedPointerCast<RssFeed>(m_feedList->getRSSItem(item));
@ -589,7 +589,7 @@ void RSSImp::updateFeedInfos(const QString &url, const QString &display_name, ui @@ -589,7 +589,7 @@ void RSSImp::updateFeedInfos(const QString &url, const QString &display_name, ui
// Update Unread item
updateItemInfos(m_feedList->stickyUnreadItem());
// If the feed is selected, update the displayed news
if (m_feedList->currentItem() == item ){
if (m_feedList->currentItem() == item ) {
refreshArticleList(item);
} else {
// Update unread items
@ -670,7 +670,7 @@ RSSImp::RSSImp(QWidget *parent) : QWidget(parent), m_rssManager(new RssManager) @@ -670,7 +670,7 @@ RSSImp::RSSImp(QWidget *parent) : QWidget(parent), m_rssManager(new RssManager)
qDebug("RSSImp constructed");
}
RSSImp::~RSSImp(){
RSSImp::~RSSImp() {
qDebug("Deleting RSSImp...");
saveFoldersOpenState();
delete m_feedList;

2
src/rss/rssarticle.cpp

@ -315,7 +315,7 @@ bool RssArticle::isRead() const{ @@ -315,7 +315,7 @@ bool RssArticle::isRead() const{
return m_read;
}
void RssArticle::markAsRead(){
void RssArticle::markAsRead() {
m_read = true;
}

3
src/rss/rssdownloadrulelist.h

@ -34,9 +34,8 @@ @@ -34,9 +34,8 @@
#include <QList>
#include <QHash>
#include <QVariantHash>
#include "rssdownloadrule.h"
s
// This class is not thread-safe (not required)
class RssDownloadRuleList
{

8
src/rss/rssfeed.cpp

@ -55,7 +55,7 @@ RssFeed::RssFeed(RssManager* manager, RssFolder* parent, const QString &url): @@ -55,7 +55,7 @@ RssFeed::RssFeed(RssManager* manager, RssFolder* parent, const QString &url):
loadItemsFromDisk();
}
RssFeed::~RssFeed(){
RssFeed::~RssFeed() {
if (!m_icon.startsWith(":/") && QFile::exists(m_icon))
QFile::remove(m_icon);
}
@ -136,7 +136,7 @@ QString RssFeed::title() const{ @@ -136,7 +136,7 @@ QString RssFeed::title() const{
return m_title;
}
void RssFeed::rename(const QString &new_name){
void RssFeed::rename(const QString &new_name) {
qDebug() << "Renaming stream to" << new_name;
m_alias = new_name;
}
@ -321,14 +321,14 @@ void RssFeed::resizeList() { @@ -321,14 +321,14 @@ void RssFeed::resizeList() {
RssArticleList listItems = m_articles.values();
RssManager::sortNewsList(listItems);
const int excess = nb_articles - max_articles;
for (uint i=nb_articles-excess; i<nb_articles; ++i){
for (uint i=nb_articles-excess; i<nb_articles; ++i) {
m_articles.remove(listItems.at(i)->guid());
}
}
}
// existing and opening test after download
bool RssFeed::parseXmlFile(const QString &file_path){
bool RssFeed::parseXmlFile(const QString &file_path) {
qDebug("openRss() called");
QFile fileRss(file_path);
if (!fileRss.open(QIODevice::ReadOnly | QIODevice::Text)) {

2
src/rss/rssfeed.h

@ -41,7 +41,7 @@ class RssManager; @@ -41,7 +41,7 @@ class RssManager;
typedef QHash<QString, RssArticlePtr> RssArticleHash;
typedef QSharedPointer<RssFeed> RssFeedPtr;
typedef QList<RssFeedPtr> RssFeedList;
typedef RssFeedList RssFeedList;
class RssFeed: public QObject, public RssFile {
Q_OBJECT

8
src/rss/rssmanager.cpp

@ -45,7 +45,7 @@ RssManager::RssManager(): @@ -45,7 +45,7 @@ RssManager::RssManager():
m_refreshTimer.start(m_refreshInterval*60000);
}
RssManager::~RssManager(){
RssManager::~RssManager() {
qDebug("Deleting RSSManager...");
delete m_rssDownloader;
delete m_downloadRules;
@ -54,7 +54,7 @@ RssManager::~RssManager(){ @@ -54,7 +54,7 @@ RssManager::~RssManager(){
qDebug("RSSManager deleted");
}
void RssManager::updateRefreshInterval(uint val){
void RssManager::updateRefreshInterval(uint val) {
if (m_refreshInterval != val) {
m_refreshInterval = val;
m_refreshTimer.start(m_refreshInterval*60000);
@ -66,13 +66,13 @@ void RssManager::loadStreamList() { @@ -66,13 +66,13 @@ void RssManager::loadStreamList() {
RssSettings settings;
const QStringList streamsUrl = settings.getRssFeedsUrls();
const QStringList aliases = settings.getRssFeedsAliases();
if (streamsUrl.size() != aliases.size()){
if (streamsUrl.size() != aliases.size()) {
std::cerr << "Corrupted Rss list, not loading it\n";
return;
}
uint i = 0;
qDebug() << Q_FUNC_INFO << streamsUrl;
foreach (QString s, streamsUrl){
foreach (QString s, streamsUrl) {
QStringList path = s.split("\\", QString::SkipEmptyParts);
if (path.empty()) continue;
const QString feed_url = path.takeLast();

18
src/searchengine/engineselectdlg.cpp

@ -96,7 +96,7 @@ void engineSelectDlg::dropEvent(QDropEvent *event) { @@ -96,7 +96,7 @@ void engineSelectDlg::dropEvent(QDropEvent *event) {
// Decode if we accept drag 'n drop or not
void engineSelectDlg::dragEnterEvent(QDragEnterEvent *event) {
QString mime;
foreach (mime, event->mimeData()->formats()){
foreach (mime, event->mimeData()->formats()) {
qDebug("mimeData: %s", qPrintable(mime));
}
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) {
@ -195,14 +195,14 @@ void engineSelectDlg::enableSelection(bool enable) { @@ -195,14 +195,14 @@ void engineSelectDlg::enableSelection(bool enable) {
}
// Set the color of a row in data model
void engineSelectDlg::setRowColor(int row, QString color){
void engineSelectDlg::setRowColor(int row, QString color) {
QTreeWidgetItem *item = pluginsTree->topLevelItem(row);
for (int i=0; i<pluginsTree->columnCount(); ++i){
for (int i=0; i<pluginsTree->columnCount(); ++i) {
item->setData(i, Qt::ForegroundRole, QVariant(QColor(color)));
}
}
QList<QTreeWidgetItem*> engineSelectDlg::findItemsWithUrl(QString url){
QList<QTreeWidgetItem*> engineSelectDlg::findItemsWithUrl(QString url) {
QList<QTreeWidgetItem*> res;
for (int i=0; i<pluginsTree->topLevelItemCount(); ++i) {
QTreeWidgetItem *item = pluginsTree->topLevelItem(i);
@ -212,7 +212,7 @@ QList<QTreeWidgetItem*> engineSelectDlg::findItemsWithUrl(QString url){ @@ -212,7 +212,7 @@ QList<QTreeWidgetItem*> engineSelectDlg::findItemsWithUrl(QString url){
return res;
}
QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id){
QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id) {
QList<QTreeWidgetItem*> res;
for (int i=0; i<pluginsTree->topLevelItemCount(); ++i) {
QTreeWidgetItem *item = pluginsTree->topLevelItem(i);
@ -353,7 +353,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) { @@ -353,7 +353,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) {
qDebug("Checking if update is needed");
bool file_correct = false;
QFile versions(versions_file);
if (!versions.open(QIODevice::ReadOnly | QIODevice::Text)){
if (!versions.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug("* Error: Could not read versions.txt file");
return false;
}
@ -398,13 +398,13 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) { @@ -398,13 +398,13 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) {
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
setCursor(QCursor(Qt::ArrowCursor));
qDebug("engineSelectDlg received %s", qPrintable(url));
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)){
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)) {
// Icon downloaded
QImage fileIcon;
if (fileIcon.load(filePath)) {
QList<QTreeWidgetItem*> items = findItemsWithUrl(url);
QTreeWidgetItem *item;
foreach (item, items){
foreach (item, items) {
QString id = item->text(ENGINE_ID);
QString iconPath;
QFile icon(filePath);
@ -439,7 +439,7 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) { @@ -439,7 +439,7 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
setCursor(QCursor(Qt::ArrowCursor));
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)){
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)) {
qDebug("Could not download favicon: %s, reason: %s", qPrintable(url), qPrintable(reason));
return;
}

4
src/searchengine/pluginsource.h

@ -53,13 +53,13 @@ class pluginSourceDlg: public QDialog, private Ui::pluginSourceDlg { @@ -53,13 +53,13 @@ class pluginSourceDlg: public QDialog, private Ui::pluginSourceDlg {
}
public:
pluginSourceDlg(QWidget* parent): QDialog(parent){
pluginSourceDlg(QWidget* parent): QDialog(parent) {
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
show();
}
~pluginSourceDlg(){}
~pluginSourceDlg() {}
};
#endif

64
src/searchengine/searchengine.cpp

@ -183,7 +183,7 @@ QString SearchEngine::selectedCategory() const { @@ -183,7 +183,7 @@ QString SearchEngine::selectedCategory() const {
return comboCategory->itemData(comboCategory->currentIndex()).toString();
}
SearchEngine::~SearchEngine(){
SearchEngine::~SearchEngine() {
qDebug("Search destruction");
// save the searchHistory for later uses
saveSearchHistory();
@ -273,7 +273,7 @@ void SearchEngine::on_enginesButton_clicked() { @@ -273,7 +273,7 @@ void SearchEngine::on_enginesButton_clicked() {
}
// get the last searchs from a QIniSettings to a QStringList
void SearchEngine::startSearchHistory(){
void SearchEngine::startSearchHistory() {
QIniSettings settings("qBittorrent", "qBittorrent");
searchHistory.setStringList(settings.value("Search/searchHistory",QStringList()).toStringList());
}
@ -294,7 +294,7 @@ void SearchEngine::giveFocusToSearchInput() { @@ -294,7 +294,7 @@ void SearchEngine::giveFocusToSearchInput() {
}
// Function called when we click on search button
void SearchEngine::on_search_button_clicked(){
void SearchEngine::on_search_button_clicked() {
#ifdef Q_WS_WIN
if (!has_python) {
if (QMessageBox::question(this, tr("Missing Python Interpreter"),
@ -306,7 +306,7 @@ void SearchEngine::on_search_button_clicked(){ @@ -306,7 +306,7 @@ void SearchEngine::on_search_button_clicked(){
return;
}
#endif
if (searchProcess->state() != QProcess::NotRunning){
if (searchProcess->state() != QProcess::NotRunning) {
#ifdef Q_WS_WIN
searchProcess->kill();
#else
@ -327,7 +327,7 @@ void SearchEngine::on_search_button_clicked(){ @@ -327,7 +327,7 @@ void SearchEngine::on_search_button_clicked(){
const QString pattern = search_pattern->text().trimmed();
// No search pattern entered
if (pattern.isEmpty()){
if (pattern.isEmpty()) {
QMessageBox::critical(0, tr("Empty search pattern"), tr("Please type a search pattern first"));
return;
}
@ -344,7 +344,7 @@ void SearchEngine::on_search_button_clicked(){ @@ -344,7 +344,7 @@ void SearchEngine::on_search_button_clicked(){
#endif
// if the pattern is not in the pattern
QStringList wordList = searchHistory.stringList();
if (wordList.indexOf(pattern) == -1){
if (wordList.indexOf(pattern) == -1) {
//update the searchHistory list
wordList.append(pattern);
// verify the max size of the history
@ -399,7 +399,7 @@ void SearchEngine::saveResultsColumnsWidth() { @@ -399,7 +399,7 @@ void SearchEngine::saveResultsColumnsWidth() {
if (!line.isEmpty()) {
width_list = line.split(' ');
}
for (short i=0; i<nbColumns; ++i){
for (short i=0; i<nbColumns; ++i) {
if (treeview->columnWidth(i)<1 && width_list.size() == nbColumns && width_list.at(i).toInt()>=1) {
// load the former width
new_width_list << width_list.at(i);
@ -439,7 +439,7 @@ void SearchEngine::downloadTorrent(QString engine_url, QString torrent_url) { @@ -439,7 +439,7 @@ void SearchEngine::downloadTorrent(QString engine_url, QString torrent_url) {
}
}
void SearchEngine::searchStarted(){
void SearchEngine::searchStarted() {
// Update SearchEngine widgets
search_status->setText(tr("Searching..."));
search_status->repaint();
@ -449,16 +449,16 @@ void SearchEngine::searchStarted(){ @@ -449,16 +449,16 @@ void SearchEngine::searchStarted(){
// search Qprocess return output as soon as it gets new
// stuff to read. We split it into lines and add each
// line to search results calling appendSearchResult().
void SearchEngine::readSearchOutput(){
void SearchEngine::readSearchOutput() {
QByteArray output = searchProcess->readAllStandardOutput();
output.replace("\r", "");
QList<QByteArray> lines_list = output.split('\n');
if (!search_result_line_truncated.isEmpty()){
if (!search_result_line_truncated.isEmpty()) {
QByteArray end_of_line = lines_list.takeFirst();
lines_list.prepend(search_result_line_truncated+end_of_line);
}
search_result_line_truncated = lines_list.takeLast().trimmed();
foreach (const QByteArray &line, lines_list){
foreach (const QByteArray &line, lines_list) {
appendSearchResult(QString::fromUtf8(line));
}
if (currentSearchTab)
@ -490,7 +490,7 @@ void SearchEngine::updateNova() { @@ -490,7 +490,7 @@ void SearchEngine::updateNova() {
QFile package_file(search_dir.absoluteFilePath("__init__.py"));
package_file.open(QIODevice::WriteOnly | QIODevice::Text);
package_file.close();
if (!search_dir.exists("engines")){
if (!search_dir.exists("engines")) {
search_dir.mkdir("engines");
}
QFile package_file2(search_dir.absolutePath().replace("\\", "/")+"/engines/__init__.py");
@ -508,7 +508,7 @@ void SearchEngine::updateNova() { @@ -508,7 +508,7 @@ void SearchEngine::updateNova() {
filePath = search_dir.absoluteFilePath("nova2dl.py");
if (getPluginVersion(":/"+nova_folder+"/nova2dl.py") > getPluginVersion(filePath)) {
if (QFile::exists(filePath)){
if (QFile::exists(filePath)) {
QFile::remove(filePath);
QFile::remove(filePath+"c");
}
@ -517,7 +517,7 @@ void SearchEngine::updateNova() { @@ -517,7 +517,7 @@ void SearchEngine::updateNova() {
filePath = search_dir.absoluteFilePath("novaprinter.py");
if (getPluginVersion(":/"+nova_folder+"/novaprinter.py") > getPluginVersion(filePath)) {
if (QFile::exists(filePath)){
if (QFile::exists(filePath)) {
QFile::remove(filePath);
QFile::remove(filePath+"c");
}
@ -526,7 +526,7 @@ void SearchEngine::updateNova() { @@ -526,7 +526,7 @@ void SearchEngine::updateNova() {
filePath = search_dir.absoluteFilePath("helpers.py");
if (getPluginVersion(":/"+nova_folder+"/helpers.py") > getPluginVersion(filePath)) {
if (QFile::exists(filePath)){
if (QFile::exists(filePath)) {
QFile::remove(filePath);
QFile::remove(filePath+"c");
}
@ -534,7 +534,7 @@ void SearchEngine::updateNova() { @@ -534,7 +534,7 @@ void SearchEngine::updateNova() {
}
filePath = search_dir.absoluteFilePath("socks.py");
if (QFile::exists(filePath)){
if (QFile::exists(filePath)) {
QFile::remove(filePath);
QFile::remove(filePath+"c");
}
@ -542,7 +542,7 @@ void SearchEngine::updateNova() { @@ -542,7 +542,7 @@ void SearchEngine::updateNova() {
if (nova_folder == "nova3") {
filePath = search_dir.absoluteFilePath("sgmllib3.py");
if (QFile::exists(filePath)){
if (QFile::exists(filePath)) {
QFile::remove(filePath);
QFile::remove(filePath+"c");
}
@ -551,7 +551,7 @@ void SearchEngine::updateNova() { @@ -551,7 +551,7 @@ void SearchEngine::updateNova() {
QDir destDir(QDir(misc::searchEngineLocation()).absoluteFilePath("engines"));
QDir shipped_subDir(":/"+nova_folder+"/engines/");
QStringList files = shipped_subDir.entryList();
foreach (const QString &file, files){
foreach (const QString &file, files) {
QString shipped_file = shipped_subDir.absoluteFilePath(file);
// Copy python classes
if (file.endsWith(".py")) {
@ -580,7 +580,7 @@ void SearchEngine::updateNova() { @@ -580,7 +580,7 @@ void SearchEngine::updateNova() {
// Slot called when search is Finished
// Search can be finished for 3 reasons :
// Error | Stopped by user | Finished normally
void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus) {
if (searchTimeout->isActive()) {
searchTimeout->stop();
}
@ -589,17 +589,17 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){ @@ -589,17 +589,17 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
if (useNotificationBalloons && mp_mainWindow->getCurrentTabWidget() != this) {
mp_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Search has finished"));
}
if (exitcode){
if (exitcode) {
#ifdef Q_WS_WIN
search_status->setText(tr("Search aborted"));
#else
search_status->setText(tr("An error occured during search..."));
#endif
}else{
if (search_stopped){
if (search_stopped) {
search_status->setText(tr("Search aborted"));
}else{
if (no_search_results){
if (no_search_results) {
search_status->setText(tr("Search returned no results"));
}else{
search_status->setText(tr("Search has finished"));
@ -614,9 +614,9 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){ @@ -614,9 +614,9 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
// SLOT to append one line to search results list
// Line is in the following form :
// file url | file name | file size | nb seeds | nb leechers | Search engine url
void SearchEngine::appendSearchResult(const QString &line){
void SearchEngine::appendSearchResult(const QString &line) {
if (!currentSearchTab) {
if (searchProcess->state() != QProcess::NotRunning){
if (searchProcess->state() != QProcess::NotRunning) {
searchProcess->terminate();
}
if (searchTimeout->isActive()) {
@ -627,7 +627,7 @@ void SearchEngine::appendSearchResult(const QString &line){ @@ -627,7 +627,7 @@ void SearchEngine::appendSearchResult(const QString &line){
}
const QStringList parts = line.split("|");
const int nb_fields = parts.size();
if (nb_fields < NB_PLUGIN_COLUMNS-1){ //-1 because desc_link is optional
if (nb_fields < NB_PLUGIN_COLUMNS-1) { //-1 because desc_link is optional
return;
}
Q_ASSERT(currentSearchTab);
@ -669,7 +669,7 @@ void SearchEngine::appendSearchResult(const QString &line){ @@ -669,7 +669,7 @@ void SearchEngine::appendSearchResult(const QString &line){
void SearchEngine::closeTab(int index) {
if (index == tabWidget->indexOf(currentSearchTab)) {
qDebug("Deleted current search Tab");
if (searchProcess->state() != QProcess::NotRunning){
if (searchProcess->state() != QProcess::NotRunning) {
searchProcess->terminate();
}
if (searchTimeout->isActive()) {
@ -686,13 +686,13 @@ void SearchEngine::closeTab(int index) { @@ -686,13 +686,13 @@ void SearchEngine::closeTab(int index) {
}
#else
// Clear search results list
void SearchEngine::closeTab_button_clicked(){
void SearchEngine::closeTab_button_clicked() {
if (all_tab.size()) {
qDebug("currentTab rank: %d", tabWidget->currentIndex());
qDebug("currentSearchTab rank: %d", tabWidget->indexOf(currentSearchTab));
if (tabWidget->currentIndex() == tabWidget->indexOf(currentSearchTab)) {
qDebug("Deleted current search Tab");
if (searchProcess->state() != QProcess::NotRunning){
if (searchProcess->state() != QProcess::NotRunning) {
searchProcess->terminate();
}
if (searchTimeout->isActive()) {
@ -711,11 +711,11 @@ void SearchEngine::closeTab_button_clicked(){ @@ -711,11 +711,11 @@ void SearchEngine::closeTab_button_clicked(){
#endif
// Download selected items in search results list
void SearchEngine::on_download_button_clicked(){
void SearchEngine::on_download_button_clicked() {
//QModelIndexList selectedIndexes = currentSearchTab->getCurrentTreeView()->selectionModel()->selectedIndexes();
QModelIndexList selectedIndexes = all_tab.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
foreach (const QModelIndex &index, selectedIndexes){
if (index.column() == NAME){
foreach (const QModelIndex &index, selectedIndexes) {
if (index.column() == NAME) {
// Get Item url
QSortFilterProxyModel* model = all_tab.at(tabWidget->currentIndex())->getCurrentSearchListProxy();
QString torrent_url = model->data(model->index(index.row(), URL_COLUMN)).toString();
@ -729,7 +729,7 @@ void SearchEngine::on_download_button_clicked(){ @@ -729,7 +729,7 @@ void SearchEngine::on_download_button_clicked(){
void SearchEngine::on_goToDescBtn_clicked()
{
QModelIndexList selectedIndexes = all_tab.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
foreach (const QModelIndex &index, selectedIndexes){
foreach (const QModelIndex &index, selectedIndexes) {
if (index.column() == NAME) {
QSortFilterProxyModel* model = all_tab.at(tabWidget->currentIndex())->getCurrentSearchListProxy();
const QString desc_url = model->data(model->index(index.row(), DESC_LINK)).toString();

8
src/searchengine/searchengine.h

@ -65,17 +65,17 @@ public: @@ -65,17 +65,17 @@ public:
static qreal getPluginVersion(QString filePath) {
QFile plugin(filePath);
if (!plugin.exists()){
if (!plugin.exists()) {
qDebug("%s plugin does not exist, returning 0.0", qPrintable(filePath));
return 0.0;
}
if (!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){
if (!plugin.open(QIODevice::ReadOnly | QIODevice::Text)) {
return 0.0;
}
qreal version = 0.0;
while (!plugin.atEnd()){
while (!plugin.atEnd()) {
QByteArray line = plugin.readLine();
if (line.startsWith("#VERSION: ")){
if (line.startsWith("#VERSION: ")) {
line = line.split(' ').last().trimmed();
version = line.toFloat();
qDebug("plugin %s version: %.2f", qPrintable(filePath), version);

6
src/searchengine/searchlistdelegate.h

@ -44,14 +44,14 @@ class SearchListDelegate: public QItemDelegate { @@ -44,14 +44,14 @@ class SearchListDelegate: public QItemDelegate {
Q_OBJECT
public:
SearchListDelegate(QObject *parent=0) : QItemDelegate(parent){}
SearchListDelegate(QObject *parent=0) : QItemDelegate(parent) {}
~SearchListDelegate(){}
~SearchListDelegate() {}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
painter->save();
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
switch(index.column()){
switch(index.column()) {
case SearchEngine::SIZE:
QItemDelegate::drawBackground(painter, opt, index);
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));

8
src/searchengine/searchtab.cpp

@ -77,7 +77,7 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent) @@ -77,7 +77,7 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
connect(resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(downloadSelectedItem(const QModelIndex&)));
// Load last columns width for search results list
if (!loadColWidthResultsList()){
if (!loadColWidthResultsList()) {
resultsBrowser->header()->resizeSection(0, 275);
}
@ -114,7 +114,7 @@ bool SearchTab::loadColWidthResultsList() { @@ -114,7 +114,7 @@ bool SearchTab::loadColWidthResultsList() {
if (width_list.size() < SearchListModel->columnCount())
return false;
unsigned int listSize = width_list.size();
for (unsigned int i=0; i<listSize; ++i){
for (unsigned int i=0; i<listSize; ++i) {
resultsBrowser->header()->resizeSection(i, width_list.at(i).toInt());
}
return true;
@ -141,9 +141,9 @@ QStandardItemModel* SearchTab::getCurrentSearchListModel() const @@ -141,9 +141,9 @@ QStandardItemModel* SearchTab::getCurrentSearchListModel() const
}
// Set the color of a row in data model
void SearchTab::setRowColor(int row, QString color){
void SearchTab::setRowColor(int row, QString color) {
proxyModel->setDynamicSortFilter(false);
for (int i=0; i<proxyModel->columnCount(); ++i){
for (int i=0; i<proxyModel->columnCount(); ++i) {
proxyModel->setData(proxyModel->index(row, i), QVariant(QColor(color)), Qt::ForegroundRole);
}
proxyModel->setDynamicSortFilter(true);

4
src/speedlimitdlg.h

@ -50,7 +50,7 @@ class SpeedLimitDialog : public QDialog, private Ui_bandwidth_dlg { @@ -50,7 +50,7 @@ class SpeedLimitDialog : public QDialog, private Ui_bandwidth_dlg {
move(misc::screenCenter(this));
}
~SpeedLimitDialog(){
~SpeedLimitDialog() {
qDebug("Deleting bandwidth allocation dialog");
}
@ -75,7 +75,7 @@ class SpeedLimitDialog : public QDialog, private Ui_bandwidth_dlg { @@ -75,7 +75,7 @@ class SpeedLimitDialog : public QDialog, private Ui_bandwidth_dlg {
protected slots:
void updateSpinValue(int val) const {
qDebug("Called updateSpinValue with %d", val);
if (val <= 0){
if (val <= 0) {
spinBandwidth->setValue(0);
spinBandwidth->setSpecialValueText(QString::fromUtf8(""));
spinBandwidth->setSuffix(QString::fromUtf8(""));

22
src/torrentadditiondlg.cpp

@ -253,7 +253,7 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) { @@ -253,7 +253,7 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) {
throw std::exception();
} catch(std::exception&) {
qDebug("Caught error loading torrent");
if (!from_url.isNull()){
if (!from_url.isNull()) {
QBtSession::instance()->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
QFile::remove(filePath);
}else{
@ -278,7 +278,7 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) { @@ -278,7 +278,7 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) {
hash = misc::toQString(t->info_hash());
// Use left() to remove .old extension
QString newFileName;
if (fileName.endsWith(QString::fromUtf8(".old"))){
if (fileName.endsWith(QString::fromUtf8(".old"))) {
newFileName = fileName.left(fileName.size()-4);
}else{
newFileName = fileName;
@ -526,7 +526,7 @@ void torrentAdditionDialog::updateDiskSpaceLabels() { @@ -526,7 +526,7 @@ void torrentAdditionDialog::updateDiskSpaceLabels() {
}
}
void torrentAdditionDialog::on_browseButton_clicked(){
void torrentAdditionDialog::on_browseButton_clicked() {
Q_ASSERT(!is_magnet);
QString new_path;
QString root_folder;
@ -546,7 +546,7 @@ void torrentAdditionDialog::on_browseButton_clicked(){ @@ -546,7 +546,7 @@ void torrentAdditionDialog::on_browseButton_clicked(){
}
} else {
QString truncated_path = getCurrentTruncatedSavePath(&root_folder);
if (!truncated_path.isEmpty() && QDir(truncated_path).exists()){
if (!truncated_path.isEmpty() && QDir(truncated_path).exists()) {
new_path = QFileDialog::getExistingDirectory(this, tr("Choose save path"), truncated_path);
}else{
new_path = QFileDialog::getExistingDirectory(this, tr("Choose save path"), QDir::homePath());
@ -583,7 +583,7 @@ void torrentAdditionDialog::on_browseButton_clicked(){ @@ -583,7 +583,7 @@ void torrentAdditionDialog::on_browseButton_clicked(){
}
}
void torrentAdditionDialog::on_CancelButton_clicked(){
void torrentAdditionDialog::on_CancelButton_clicked() {
close();
}
@ -592,17 +592,17 @@ bool torrentAdditionDialog::allFiltered() const { @@ -592,17 +592,17 @@ bool torrentAdditionDialog::allFiltered() const {
return PropListModel->model()->allFiltered();
}
void torrentAdditionDialog::savePiecesPriorities(){
void torrentAdditionDialog::savePiecesPriorities() {
qDebug("Saving pieces priorities");
Q_ASSERT(!is_magnet);
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities(t->num_files());
TorrentTempData::setFilesPriority(hash, priorities);
}
void torrentAdditionDialog::on_OkButton_clicked(){
void torrentAdditionDialog::on_OkButton_clicked() {
Preferences pref;
qDebug() << "void torrentAdditionDialog::on_OkButton_clicked() - ENTER";
if (savePathTxt->currentText().trimmed().isEmpty()){
if (savePathTxt->currentText().trimmed().isEmpty()) {
QMessageBox::critical(0, tr("Empty save path"), tr("Please enter a save path"));
return;
}
@ -671,7 +671,7 @@ void torrentAdditionDialog::on_OkButton_clicked(){ @@ -671,7 +671,7 @@ void torrentAdditionDialog::on_OkButton_clicked(){
}
}
// Check if there is at least one selected file
if (!is_magnet && t->num_files() > 1 && allFiltered()){
if (!is_magnet && t->num_files() > 1 && allFiltered()) {
QMessageBox::warning(0, tr("Invalid file selection"), tr("You must select at least one file in the torrent"));
return;
}
@ -683,8 +683,8 @@ void torrentAdditionDialog::on_OkButton_clicked(){ @@ -683,8 +683,8 @@ void torrentAdditionDialog::on_OkButton_clicked(){
pref.setSavePath(getCurrentTruncatedSavePath());
// Check if savePath exists
if (!savePath.exists()){
if (!savePath.mkpath(savePath.path())){
if (!savePath.exists()) {
if (!savePath.mkpath(savePath.path())) {
QMessageBox::critical(0, tr("Save path creation error"), tr("Could not create the save path"));
return;
}

8
src/torrentcreator/torrentcreatordlg.cpp

@ -67,7 +67,7 @@ TorrentCreatorDlg::~TorrentCreatorDlg() { @@ -67,7 +67,7 @@ TorrentCreatorDlg::~TorrentCreatorDlg() {
delete creatorThread;
}
void TorrentCreatorDlg::on_addFolder_button_clicked(){
void TorrentCreatorDlg::on_addFolder_button_clicked() {
QIniSettings settings("qBittorrent", "qBittorrent");
QString last_path = settings.value("CreateTorrent/last_add_path", QDir::homePath()).toString();
QString dir = QFileDialog::getExistingDirectory(this, tr("Select a folder to add to the torrent"), last_path, QFileDialog::ShowDirsOnly);
@ -83,7 +83,7 @@ void TorrentCreatorDlg::on_addFolder_button_clicked(){ @@ -83,7 +83,7 @@ void TorrentCreatorDlg::on_addFolder_button_clicked(){
}
}
void TorrentCreatorDlg::on_addFile_button_clicked(){
void TorrentCreatorDlg::on_addFile_button_clicked() {
QIniSettings settings("qBittorrent", "qBittorrent");
QString last_path = settings.value("CreateTorrent/last_add_path", QDir::homePath()).toString();
QString file = QFileDialog::getOpenFileName(this, tr("Select a file to add to the torrent"), last_path);
@ -104,11 +104,11 @@ int TorrentCreatorDlg::getPieceSize() const { @@ -104,11 +104,11 @@ int TorrentCreatorDlg::getPieceSize() const {
}
// Main function that create a .torrent file
void TorrentCreatorDlg::on_createButton_clicked(){
void TorrentCreatorDlg::on_createButton_clicked() {
QString input = textInputPath->text().trimmed();
if (input.endsWith(QDir::separator()))
input.chop(1);
if (input.isEmpty()){
if (input.isEmpty()) {
QMessageBox::critical(0, tr("No input path set"), tr("Please type an input path first"));
return;
}

6
src/torrentcreator/torrentcreatorthread.cpp

@ -89,7 +89,7 @@ void TorrentCreatorThread::create(QString _input_path, QString _save_path, QStri @@ -89,7 +89,7 @@ void TorrentCreatorThread::create(QString _input_path, QString _save_path, QStri
start();
}
void sendProgressUpdateSignal(int i, int num, TorrentCreatorThread *parent){
void sendProgressUpdateSignal(int i, int num, TorrentCreatorThread *parent) {
parent->sendProgressSignal((int)(i*100./(float)num));
}
@ -108,7 +108,7 @@ void TorrentCreatorThread::run() { @@ -108,7 +108,7 @@ void TorrentCreatorThread::run() {
create_torrent t(fs, piece_size);
// Add url seeds
foreach (const QString &seed, url_seeds){
foreach (const QString &seed, url_seeds) {
t.add_url_seed(seed.trimmed().toStdString());
}
foreach (const QString &tracker, trackers) {
@ -138,7 +138,7 @@ void TorrentCreatorThread::run() { @@ -138,7 +138,7 @@ void TorrentCreatorThread::run() {
} else {
throw std::exception();
}
} catch (std::exception& e){
} catch (std::exception& e) {
emit creationFailure(QString::fromLocal8Bit(e.what()));
}
}

4
src/torrentpersistentdata.h

@ -118,7 +118,7 @@ public: @@ -118,7 +118,7 @@ public:
return data.value("sequential", false).toBool();
}
static void setSeedingMode(QString hash,bool seed){
static void setSeedingMode(QString hash,bool seed) {
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
QHash<QString, QVariant> data = all_data.value(hash).toHash();
@ -127,7 +127,7 @@ public: @@ -127,7 +127,7 @@ public:
settings.setValue("torrents-tmp", all_data);
}
static bool isSeedingMode(QString hash){
static bool isSeedingMode(QString hash) {
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
const QHash<QString, QVariant> data = all_data.value(hash).toHash();

8
src/trackerlogin.h

@ -44,7 +44,7 @@ class trackerLogin : public QDialog, private Ui::authentication{ @@ -44,7 +44,7 @@ class trackerLogin : public QDialog, private Ui::authentication{
QTorrentHandle h;
public:
trackerLogin(QWidget *parent, QTorrentHandle h): QDialog(parent), h(h){
trackerLogin(QWidget *parent, QTorrentHandle h): QDialog(parent), h(h) {
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
login_logo->setPixmap(QPixmap(QString::fromUtf8(":/Icons/oxygen/encrypted.png")));
@ -53,19 +53,19 @@ class trackerLogin : public QDialog, private Ui::authentication{ @@ -53,19 +53,19 @@ class trackerLogin : public QDialog, private Ui::authentication{
show();
}
~trackerLogin(){}
~trackerLogin() {}
signals:
void trackerLoginCancelled(QPair<QTorrentHandle,QString> tracker);
public slots:
void on_loginButton_clicked(){
void on_loginButton_clicked() {
// login
h.set_tracker_login(lineUsername->text(), linePasswd->text());
close();
}
void on_cancelButton_clicked(){
void on_cancelButton_clicked() {
// Emit a signal to GUI to stop asking for authentication
emit trackerLoginCancelled(QPair<QTorrentHandle,QString>(h, h.current_tracker()));
close();

6
src/transferlistdelegate.h

@ -53,14 +53,14 @@ class TransferListDelegate: public QItemDelegate { @@ -53,14 +53,14 @@ class TransferListDelegate: public QItemDelegate {
Q_OBJECT
public:
TransferListDelegate(QObject *parent) : QItemDelegate(parent){}
TransferListDelegate(QObject *parent) : QItemDelegate(parent) {}
~TransferListDelegate(){}
~TransferListDelegate() {}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
painter->save();
switch(index.column()){
switch(index.column()) {
case TorrentModelItem::TR_AMOUNT_DOWNLOADED:
case TorrentModelItem::TR_AMOUNT_LEFT:
case TorrentModelItem::TR_SIZE:{

6
src/transferlistwidget.cpp

@ -323,7 +323,7 @@ void TransferListWidget::increasePrioSelectedTorrents() { @@ -323,7 +323,7 @@ void TransferListWidget::increasePrioSelectedTorrents() {
if (!h.is_seed()) {
torrent_queue.push(qMakePair(h.queue_position(), h));
}
}catch(invalid_handle&){}
}catch(invalid_handle&) {}
}
// Increase torrents priority (starting with the ones with highest priority)
while(!torrent_queue.empty()) {
@ -347,7 +347,7 @@ void TransferListWidget::decreasePrioSelectedTorrents() { @@ -347,7 +347,7 @@ void TransferListWidget::decreasePrioSelectedTorrents() {
if (!h.is_seed()) {
torrent_queue.push(qMakePair(h.queue_position(), h));
}
}catch(invalid_handle&){}
}catch(invalid_handle&) {}
}
// Decrease torrents priority (starting with the ones with lowest priority)
while(!torrent_queue.empty()) {
@ -520,7 +520,7 @@ void TransferListWidget::recheckSelectedTorrents() { @@ -520,7 +520,7 @@ void TransferListWidget::recheckSelectedTorrents() {
}
// hide/show columns menu
void TransferListWidget::displayDLHoSMenu(const QPoint&){
void TransferListWidget::displayDLHoSMenu(const QPoint&) {
QMenu hideshowColumn(this);
hideshowColumn.setTitle(tr("Column visibility"));
QList<QAction*> actions;

2
src/webui/eventmanager.cpp

@ -120,7 +120,7 @@ void EventManager::setGlobalPreferences(QVariantMap m) { @@ -120,7 +120,7 @@ void EventManager::setGlobalPreferences(QVariantMap m) {
QString locale = m["locale"].toString();
if (pref.getLocale() != locale) {
QTranslator *translator = new QTranslator;
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale));
}else{
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));

10
src/webui/httpconnection.cpp

@ -394,9 +394,9 @@ void HttpConnection::respondCommand(const QString& command) { @@ -394,9 +394,9 @@ void HttpConnection::respondCommand(const QString& command) {
if (command == "download") {
QString urls = m_parser.post("urls");
QStringList list = urls.split('\n');
foreach (QString url, list){
foreach (QString url, list) {
url = url.trimmed();
if (!url.isEmpty()){
if (!url.isEmpty()) {
if (url.startsWith("bc://bt/", Qt::CaseInsensitive)) {
qDebug("Converting bc link to magnet link");
url = misc::bcLinkToMagnet(url);
@ -600,7 +600,7 @@ void HttpConnection::respondCommand(const QString& command) { @@ -600,7 +600,7 @@ void HttpConnection::respondCommand(const QString& command) {
}
return;
}
if (command == "recheck"){
if (command == "recheck") {
QBtSession::instance()->recheckTorrent(m_parser.post("hash"));
return;
}
@ -618,7 +618,7 @@ void HttpConnection::decreaseTorrentsPriority(const QStringList &hashes) { @@ -618,7 +618,7 @@ void HttpConnection::decreaseTorrentsPriority(const QStringList &hashes) {
if (!h.is_seed()) {
torrent_queue.push(qMakePair(h.queue_position(), h));
}
}catch(invalid_handle&){}
}catch(invalid_handle&) {}
}
// Decrease torrents priority (starting with the ones with lowest priority)
while(!torrent_queue.empty()) {
@ -643,7 +643,7 @@ void HttpConnection::increaseTorrentsPriority(const QStringList &hashes) @@ -643,7 +643,7 @@ void HttpConnection::increaseTorrentsPriority(const QStringList &hashes)
if (!h.is_seed()) {
torrent_queue.push(qMakePair(h.queue_position(), h));
}
}catch(invalid_handle&){}
}catch(invalid_handle&) {}
}
// Increase torrents priority (starting with the ones with highest priority)
while(!torrent_queue.empty()) {

Loading…
Cancel
Save