Compare commits

...

39 Commits

Author SHA1 Message Date
sledgehammer999
d753988729 Bump to v3.3.1 2015-12-08 00:45:15 +02:00
sledgehammer999
a6b948077a Update Changelog. 2015-12-08 00:42:19 +02:00
sledgehammer999
3276cc4987 Sync translations from Transifex and run lupdate. 2015-12-08 00:28:20 +02:00
sledgehammer999
71557fe784 Fix possible deadlock during application exit. 2015-12-08 00:28:20 +02:00
sledgehammer999
29fc5bc80d Bump WebUI API_VERSION. 2015-12-08 00:28:19 +02:00
sledgehammer999
db07551e4c Change update URL to FossHub. Closes #4188. 2015-12-08 00:28:19 +02:00
sledgehammer999
8f6eb795e3 Follow project coding style. Issue #2192. 2015-12-08 00:28:19 +02:00
sledgehammer999
0a37799e6e Remove unused parameter. 2015-12-08 00:28:18 +02:00
buinsky
76d6d9a4f9 Implement torrent peers table in WebUI 2015-12-08 00:28:18 +02:00
buinsky
0c8abd0abb Implement sync/torrent_peers request 2015-12-08 00:28:18 +02:00
buinsky
ddc8420810 Follow project coding style. Issue #2192. 2015-12-08 00:28:17 +02:00
buinsky
a4ff039abc Rename 'context_menu' variable to 'torrents_table_context_menu' 2015-12-08 00:28:17 +02:00
buinsky
c8be062e19 Rename 'myTable' variable to 'torrentsTable' 2015-12-08 00:28:17 +02:00
buinsky
29443a2c10 Split the DynamicTable class into 2 classes 2015-12-08 00:28:16 +02:00
buinsky
e402556e91 Add seeds tab to WebUI 2015-12-08 00:28:16 +02:00
Vladimir Golovnev (Glassez)
4ed4ebcdb7 Rename Core to Base (Closes #3733). 2015-12-08 00:28:16 +02:00
Vladimir Golovnev (Glassez)
a280467270 Fix RSS isn't automarking articles as read
Closes: #4260, #4233, #4221, #4133
2015-12-08 00:28:15 +02:00
sledgehammer999
9b1090332b Use simpler DEFINE for detecting Qt5 so moc will work too. 2015-12-08 00:28:12 +02:00
Vladimir Golovnev (Glassez)
18a520c9f9 Remove unused LineEdit slot. Fix compiler warning. 2015-12-08 00:27:33 +02:00
Vladimir Golovnev (Glassez)
af871ef8af Fix wrong encoding for listen failed error message. 2015-12-08 00:24:21 +02:00
sledgehammer999
3af7eb8e03 Add clarifying comment. 2015-12-08 00:24:21 +02:00
sledgehammer999
3439300cda Partially revert b4c9c7cde. 2015-12-08 00:24:20 +02:00
Vladimir Golovnev (Glassez)
a8027565c9 Improve upgrade to v3.3. Fixes #4195. 2015-12-08 00:24:20 +02:00
Vladimir Golovnev (Glassez)
3d4e1a8127 Improve torrent export feature. Closes #4205. 2015-12-08 00:24:20 +02:00
Vladimir Golovnev (Glassez)
7b6a1a1955 Fix scan dirs settings saving. Closes #4254, #4239, #4187. 2015-12-08 00:24:19 +02:00
Chocobo1
3f8dc60680 Add CONTRIBUTING.md 2015-12-08 00:24:19 +02:00
vlakoff
9be449dd7f Support wildcards for filtering torrent list and torrent content 2015-12-08 00:24:19 +02:00
Chocobo1
c46f2ba097 Change text description for half-open connection 2015-12-08 00:24:19 +02:00
Chocobo1
c2c441ed08 Fix -1 is displayed instead of C_INFINITY symbol 2015-12-08 00:24:18 +02:00
Chocobo1
c1e52fa1cd Use QLineEdit built-in ClearButton (Qt5 only) 2015-12-08 00:24:18 +02:00
Chocobo1
fbed5dc606 Reduce mainwindow border width 2015-12-08 00:24:18 +02:00
Chocobo1
97978068c6 Cleanup "Content" page layout
Limit lineEdit maximum size
2015-12-08 00:24:17 +02:00
Chocobo1
006e34880a Cleanup "Peers" page layout
Cleanup "HTTP Sources" page layout
Cleanup "Speed" page layout
2015-12-08 00:24:17 +02:00
Chocobo1
1fd5c5d8b5 Cleanup "Trackers" page layout 2015-12-08 00:24:17 +02:00
takiz
68ac9fda2d "Set as default label" option 2015-12-08 00:24:16 +02:00
Naikel Aparicio
c5d807ef65 Cookies support on WebUI when downloading torrent from a URL. Modified download and upload windows to allow autocompletion of browsers.
Fixed the spinner in the WebUI upload page. Modified height of the WebUI download page.

Fixed all the JavaScript functions for download and upload pages.
2015-12-08 00:24:16 +02:00
sledgehammer999
e17f10ae6b Delete from the repo the qt4 translations used in the Windows installer. 2015-11-30 00:17:25 +02:00
sledgehammer999
78c5d1c12f Bump to v3.3.0 2015-11-29 21:57:06 +02:00
sledgehammer999
26fb54299b Update Transifex config file. 2015-11-29 21:54:06 +02:00
240 changed files with 37139 additions and 33977 deletions

View File

@@ -1,7 +1,7 @@
[main] [main]
host = https://www.transifex.com host = https://www.transifex.com
[qbittorrent.qbittorrent_master] [qbittorrent.qbittorrent_v3_3_x]
file_filter = src/lang/qbittorrent_<lang>.ts file_filter = src/lang/qbittorrent_<lang>.ts
source_file = src/lang/qbittorrent_en.ts source_file = src/lang/qbittorrent_en.ts
source_lang = en source_lang = en

36
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,36 @@
# Filing an issue
### Must read
* If you aren't sure, you can ask on the [**forum**](http://forum.qbittorrent.org) or read our [**wiki**](http://wiki.qbittorrent.org) first.
* Do a quick **search**. Others might already reported the issue.
* Write in **English**!
* Provide **version** information: (You can find version numbers at menu `Help -> About -> Libraries`)
```
qBittorrent:
Qt:
libtorrent:
boost:
OS version:
```
* Provide **steps** to reproduce the problem, it will be easier to pinpoint the fault.
* **Screenshots**! A screenshot is worth a thousand words. just upload it. [(How?)](https://help.github.com/articles/file-attachments-on-issues-and-pull-requests)
### Good to know
* **Patience**. The dev team is small and resource limited. Devs finding their free time, analyzing the problem and fixing the issue, it all takes time. :clock3:
* If you can code, why not become a **contributor** by fixing the issue and open a pull request? :wink:
* Harsh words or threats won't help your situation. What's worse, your complain will (very likely) to be **ignored**. :fearful:
# Opening a pull request
### Must read
* Read our [**coding guidelines**](https://github.com/qbittorrent/qBittorrent/blob/master/CODING_GUIDELINES.md). There are some scripts to help you: [uncrustify script](https://gist.github.com/sledgehammer999/1cb1d9224d7fec8fa632), [astyle script](https://gist.github.com/Chocobo1/539cee860d1eef0acfa6), [(related thread)](https://github.com/qbittorrent/qBittorrent/issues/2192).
* Keep the title **short** and provide a **clear** description about what your pull request does.
* Provide **screenshots** for UI related changes.
* Keep your git commit history **clean** and **precise**. Commits like `xxx fixup` should not appear.
* If your commit fix a reported issue (for example #4134), add the following message to the commit `Closes #4134.`. Example [here](https://github.com/qbittorrent/qBittorrent/commit/a74bac20c4e8de9776bf9bb77fdc7526135d1988).
### Good to know
* **Search** pull request history! Others might already implemented your idea and is waiting to be merged (or got rejected already). Save your precious time by doing a search first.
* When resolving merge conflicts, do `git rebase <target_branch_name>`, don't do `git pull`. Then you can start fixing the conflicts. Here is a good explanation: [link](https://www.atlassian.com/git/tutorials/merging-vs-rebasing).

View File

@@ -1,3 +1,27 @@
* Tue Dec 08 2015 - sledgehammer999 <sledgehammer999@qbittorrent.org> - v3.3.1
- FEATURE: New "Set as default label" option in Add torrent dialog. (takiz)
- FEATURE: Support wildcards for filtering torrent list and torrent content (vlakoff)
- BUGFIX: Fix -1 is displayed instead of the infinity symbol (Chocobo1)
- BUGFIX: Fix scan dirs settings saving. Closes #4254, #4239, #4187. (glassez)
- BUGFIX: Exported torrents now use name instead of hash. Closes #4205. (glassez)
- BUGFIX: Improve upgrade to v3.3.0. Now undownloaded magnets will be migrated too. Fixes #4195. (glassez)
- BUGFIX: Fix wrong encoding for listen failed error message. (glassez)
- BUGFIX: Fix RSS not automarking articles as read. (glassez)
- BUGFIX: Fix possible deadlock during application exit. (sledgehammer999)
- WEBUI: Cookies support on WebUI when downloading torrent from a URL. (Naikel Aparicio)
- WEBUI: Modified download and upload windows to allow autocompletion of browsers. (Naikel Aparicio)
- WEBUI: Fixed the spinner in the WebUI upload page. (Naikel Aparicio)
- WEBUI: Modified height of the WebUI download page. (Naikel Aparicio)
- WEBUI: Fixed all the JavaScript functions for download and upload pages. (Naikel Aparicio)
- WEBUI: Add seeds tab to WebUI (buinsky)
- WEBUI: Bump WebUI API_VERSION.
- COSMETIC: Cleanup "Trackers", "Peers", "HTTP Sources", "Speed" and "Content" page layout (Chocobo1)
- COSMETIC: Reduce mainwindow border width (Chocobo1)
- COSMETIC: Use QLineEdit built-in ClearButton (Qt5 only) (Chocobo1)
- COSMETIC: Change text description for half-open connection (Chocobo1)
- OTHER: Change update URL to FossHub. Closes #4188. (sledgehammer999)
* Sun Nov 29 2015 - sledgehammer999 <sledgehammer999@qbittorrent.org> - v3.3.0 * Sun Nov 29 2015 - sledgehammer999 <sledgehammer999@qbittorrent.org> - v3.3.0
- FEATURE: Huge core code refactoring. Problems with labels, temp folders etc should be eliminated. Smoother UI should be observed too. (glassez) - FEATURE: Huge core code refactoring. Problems with labels, temp folders etc should be eliminated. Smoother UI should be observed too. (glassez)
- FEATURE: Speed graph (Anton Lashkov) - FEATURE: Speed graph (Anton Lashkov)

2
dist/mac/Info.plist vendored
View File

@@ -45,7 +45,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>3.3.0</string> <string>3.3.1</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>qBit</string> <string>qBit</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>

View File

@@ -41,7 +41,10 @@ installer-translations
translations translations
qt_ar.qm qt_ar.qm
... ...
(all the .qm files found in dist/qt-translations in every source release) (all the .qm files found in the 'translations' folder of your Qt install. Those files differ between Qt4 and Qt5.
If you want to distribute Qt4 translations it is better to use the ones found in this repo under the path "dist/qt-translations".
They contain extra languages not distributed via the official qt4 sources.
Don't forget to edit the filelist in installer.nsi + uninstaller.nsi to include all your .qm files.)
qt_zh_TW.qm qt_zh_TW.qm
installer.nsi installer.nsi
license.txt license.txt

View File

@@ -31,13 +31,13 @@ Section $(inst_qbt_req) ;"qBittorrent (required)"
File "qbittorrent.pdb" File "qbittorrent.pdb"
File "qt.conf" File "qt.conf"
File /oname=translations\qt_ar.qm "translations\qt_ar.qm" File /oname=translations\qt_ar.qm "translations\qt_ar.qm"
File /oname=translations\qt_bg.qm "translations\qt_bg.qm"
File /oname=translations\qt_ca.qm "translations\qt_ca.qm" File /oname=translations\qt_ca.qm "translations\qt_ca.qm"
File /oname=translations\qt_cs.qm "translations\qt_cs.qm" File /oname=translations\qt_cs.qm "translations\qt_cs.qm"
File /oname=translations\qt_da.qm "translations\qt_da.qm" File /oname=translations\qt_da.qm "translations\qt_da.qm"
File /oname=translations\qt_de.qm "translations\qt_de.qm" File /oname=translations\qt_de.qm "translations\qt_de.qm"
File /oname=translations\qt_en.qm "translations\qt_en.qm"
File /oname=translations\qt_es.qm "translations\qt_es.qm" File /oname=translations\qt_es.qm "translations\qt_es.qm"
File /oname=translations\qt_eu.qm "translations\qt_eu.qm" File /oname=translations\qt_fa.qm "translations\qt_fa.qm"
File /oname=translations\qt_fi.qm "translations\qt_fi.qm" File /oname=translations\qt_fi.qm "translations\qt_fi.qm"
File /oname=translations\qt_fr.qm "translations\qt_fr.qm" File /oname=translations\qt_fr.qm "translations\qt_fr.qm"
File /oname=translations\qt_gl.qm "translations\qt_gl.qm" File /oname=translations\qt_gl.qm "translations\qt_gl.qm"
@@ -47,14 +47,12 @@ Section $(inst_qbt_req) ;"qBittorrent (required)"
File /oname=translations\qt_ja.qm "translations\qt_ja.qm" File /oname=translations\qt_ja.qm "translations\qt_ja.qm"
File /oname=translations\qt_ko.qm "translations\qt_ko.qm" File /oname=translations\qt_ko.qm "translations\qt_ko.qm"
File /oname=translations\qt_lt.qm "translations\qt_lt.qm" File /oname=translations\qt_lt.qm "translations\qt_lt.qm"
File /oname=translations\qt_nl.qm "translations\qt_nl.qm"
File /oname=translations\qt_pl.qm "translations\qt_pl.qm" File /oname=translations\qt_pl.qm "translations\qt_pl.qm"
File /oname=translations\qt_pt.qm "translations\qt_pt.qm" File /oname=translations\qt_pt.qm "translations\qt_pt.qm"
File /oname=translations\qt_pt_BR.qm "translations\qt_pt_BR.qm"
File /oname=translations\qt_ru.qm "translations\qt_ru.qm" File /oname=translations\qt_ru.qm "translations\qt_ru.qm"
File /oname=translations\qt_sk.qm "translations\qt_sk.qm" File /oname=translations\qt_sk.qm "translations\qt_sk.qm"
File /oname=translations\qt_sl.qm "translations\qt_sl.qm"
File /oname=translations\qt_sv.qm "translations\qt_sv.qm" File /oname=translations\qt_sv.qm "translations\qt_sv.qm"
File /oname=translations\qt_tr.qm "translations\qt_tr.qm"
File /oname=translations\qt_uk.qm "translations\qt_uk.qm" File /oname=translations\qt_uk.qm "translations\qt_uk.qm"
File /oname=translations\qt_zh_CN.qm "translations\qt_zh_CN.qm" File /oname=translations\qt_zh_CN.qm "translations\qt_zh_CN.qm"
File /oname=translations\qt_zh_TW.qm "translations\qt_zh_TW.qm" File /oname=translations\qt_zh_TW.qm "translations\qt_zh_TW.qm"

View File

@@ -19,7 +19,7 @@ XPStyle on
!define CSIDL_APPDATA '0x1A' ;Application Data path !define CSIDL_APPDATA '0x1A' ;Application Data path
!define CSIDL_LOCALAPPDATA '0x1C' ;Local Application Data path !define CSIDL_LOCALAPPDATA '0x1C' ;Local Application Data path
!define PROG_VERSION "3.3.0" !define PROG_VERSION "3.3.1"
!define MUI_FINISHPAGE_RUN !define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION PageFinishRun !define MUI_FINISHPAGE_RUN_FUNCTION PageFinishRun
!define MUI_FINISHPAGE_RUN_TEXT $(launch_qbt) !define MUI_FINISHPAGE_RUN_TEXT $(launch_qbt)

View File

@@ -6,13 +6,12 @@
Delete "$INSTDIR\qbittorrent.pdb" Delete "$INSTDIR\qbittorrent.pdb"
Delete "$INSTDIR\qt.conf" Delete "$INSTDIR\qt.conf"
Delete "$INSTDIR\translations\qt_ar.qm" Delete "$INSTDIR\translations\qt_ar.qm"
Delete "$INSTDIR\translations\qt_bg.qm"
Delete "$INSTDIR\translations\qt_ca.qm" Delete "$INSTDIR\translations\qt_ca.qm"
Delete "$INSTDIR\translations\qt_cs.qm" Delete "$INSTDIR\translations\qt_cs.qm"
Delete "$INSTDIR\translations\qt_da.qm" Delete "$INSTDIR\translations\qt_da.qm"
Delete "$INSTDIR\translations\qt_de.qm" Delete "$INSTDIR\translations\qt_de.qm"
Delete "$INSTDIR\translations\qt_en.qm"
Delete "$INSTDIR\translations\qt_es.qm" Delete "$INSTDIR\translations\qt_es.qm"
Delete "$INSTDIR\translations\qt_eu.qm"
Delete "$INSTDIR\translations\qt_fa.qm" Delete "$INSTDIR\translations\qt_fa.qm"
Delete "$INSTDIR\translations\qt_fi.qm" Delete "$INSTDIR\translations\qt_fi.qm"
Delete "$INSTDIR\translations\qt_fr.qm" Delete "$INSTDIR\translations\qt_fr.qm"
@@ -23,15 +22,12 @@
Delete "$INSTDIR\translations\qt_ja.qm" Delete "$INSTDIR\translations\qt_ja.qm"
Delete "$INSTDIR\translations\qt_ko.qm" Delete "$INSTDIR\translations\qt_ko.qm"
Delete "$INSTDIR\translations\qt_lt.qm" Delete "$INSTDIR\translations\qt_lt.qm"
Delete "$INSTDIR\translations\qt_nl.qm"
Delete "$INSTDIR\translations\qt_pl.qm" Delete "$INSTDIR\translations\qt_pl.qm"
Delete "$INSTDIR\translations\qt_pt.qm" Delete "$INSTDIR\translations\qt_pt.qm"
Delete "$INSTDIR\translations\qt_pt_BR.qm"
Delete "$INSTDIR\translations\qt_ru.qm" Delete "$INSTDIR\translations\qt_ru.qm"
Delete "$INSTDIR\translations\qt_sk.qm" Delete "$INSTDIR\translations\qt_sk.qm"
Delete "$INSTDIR\translations\qt_sl.qm" Delete "$INSTDIR\translations\qt_sl.qm"
Delete "$INSTDIR\translations\qt_sv.qm" Delete "$INSTDIR\translations\qt_sv.qm"
Delete "$INSTDIR\translations\qt_tr.qm"
Delete "$INSTDIR\translations\qt_uk.qm" Delete "$INSTDIR\translations\qt_uk.qm"
Delete "$INSTDIR\translations\qt_zh_CN.qm" Delete "$INSTDIR\translations\qt_zh_CN.qm"
Delete "$INSTDIR\translations\qt_zh_TW.qm" Delete "$INSTDIR\translations\qt_zh_TW.qm"

View File

@@ -58,17 +58,17 @@
#endif #endif
#include "application.h" #include "application.h"
#include "core/logger.h" #include "base/logger.h"
#include "core/preferences.h" #include "base/preferences.h"
#include "core/utils/fs.h" #include "base/utils/fs.h"
#include "core/utils/misc.h" #include "base/utils/misc.h"
#include "core/iconprovider.h" #include "base/iconprovider.h"
#include "core/scanfoldersmodel.h" #include "base/scanfoldersmodel.h"
#include "core/net/smtp.h" #include "base/net/smtp.h"
#include "core/net/downloadmanager.h" #include "base/net/downloadmanager.h"
#include "core/net/geoipmanager.h" #include "base/net/geoipmanager.h"
#include "core/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "core/bittorrent/torrenthandle.h" #include "base/bittorrent/torrenthandle.h"
static const char PARAMS_SEPARATOR[] = "|"; static const char PARAMS_SEPARATOR[] = "|";
@@ -357,7 +357,7 @@ void Application::initializeTranslation()
} }
if (m_qtTranslator.load( if (m_qtTranslator.load(
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
QString::fromUtf8("qtbase_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) || QString::fromUtf8("qtbase_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) ||
m_qtTranslator.load( m_qtTranslator.load(
#endif #endif

View File

@@ -50,7 +50,7 @@ QT_END_NAMESPACE
typedef QtSingleCoreApplication BaseApplication; typedef QtSingleCoreApplication BaseApplication;
#endif #endif
#include "core/utils/misc.h" #include "base/utils/misc.h"
#ifndef DISABLE_WEBUI #ifndef DISABLE_WEBUI
class WebUI; class WebUI;

View File

@@ -42,7 +42,7 @@
#include <QSplashScreen> #include <QSplashScreen>
#ifdef QBT_STATIC_QT #ifdef QBT_STATIC_QT
#include <QtPlugin> #include <QtPlugin>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
Q_IMPORT_PLUGIN(QICOPlugin) Q_IMPORT_PLUGIN(QICOPlugin)
#else #else
Q_IMPORT_PLUGIN(qico) Q_IMPORT_PLUGIN(qico)
@@ -72,8 +72,8 @@ Q_IMPORT_PLUGIN(qico)
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include "application.h" #include "application.h"
#include "core/utils/misc.h" #include "base/utils/misc.h"
#include "core/preferences.h" #include "base/preferences.h"
#include "upgrade.h" #include "upgrade.h"

View File

@@ -40,9 +40,11 @@
#include <QMessageBox> #include <QMessageBox>
#endif #endif
#include "core/logger.h" #include "base/logger.h"
#include "core/utils/fs.h" #include "base/utils/fs.h"
#include "core/utils/misc.h" #include "base/utils/misc.h"
#include "base/utils/string.h"
#include "base/qinisettings.h"
bool userAcceptsUpgrade() bool userAcceptsUpgrade()
{ {
@@ -73,7 +75,7 @@ bool userAcceptsUpgrade()
return false; return false;
} }
bool upgradeResumeFile(const QString &filepath) bool upgradeResumeFile(const QString &filepath, const QVariantHash &oldTorrent, int &maxPrio)
{ {
QFile file1(filepath); QFile file1(filepath);
if (!file1.open(QIODevice::ReadOnly)) if (!file1.open(QIODevice::ReadOnly))
@@ -91,6 +93,12 @@ bool upgradeResumeFile(const QString &filepath)
fastNew = fastOld; fastNew = fastOld;
int priority = fastOld.dict_find_int_value("qBt-queuePosition"); int priority = fastOld.dict_find_int_value("qBt-queuePosition");
if (priority > maxPrio)
maxPrio = priority;
fastNew["qBt-name"] = Utils::String::toStdString(oldTorrent.value("name").toString());
fastNew["qBt-tempPathDisabled"] = false;
QFile file2(QString("%1.%2").arg(filepath).arg(priority > 0 ? priority : 0)); QFile file2(QString("%1.%2").arg(filepath).arg(priority > 0 ? priority : 0));
QVector<char> out; QVector<char> out;
libtorrent::bencode(std::back_inserter(out), fastNew); libtorrent::bencode(std::back_inserter(out), fastNew);
@@ -106,25 +114,62 @@ bool upgradeResumeFile(const QString &filepath)
bool upgrade(bool ask = true) bool upgrade(bool ask = true)
{ {
QIniSettings *oldResumeSettings = new QIniSettings("qBittorrent", "qBittorrent-resume");
QString oldResumeFilename = oldResumeSettings->fileName();
QVariantHash oldResumeData = oldResumeSettings->value("torrents").toHash();
delete oldResumeSettings;
if (oldResumeData.isEmpty())
Utils::Fs::forceRemove(oldResumeFilename);
QString backupFolderPath = Utils::Fs::expandPathAbs(Utils::Fs::QDesktopServicesDataLocation() + "BT_backup"); QString backupFolderPath = Utils::Fs::expandPathAbs(Utils::Fs::QDesktopServicesDataLocation() + "BT_backup");
QDir backupFolderDir(backupFolderPath); QDir backupFolderDir(backupFolderPath);
if (!backupFolderDir.exists()) return true;
QStringList backupFiles = backupFolderDir.entryList(QStringList() << QLatin1String("*.fastresume"), QDir::Files, QDir::Unsorted); QStringList backupFiles = backupFolderDir.entryList(QStringList() << QLatin1String("*.fastresume"), QDir::Files, QDir::Unsorted);
if (!backupFiles.isEmpty()) { if (backupFiles.isEmpty() && oldResumeData.isEmpty()) return true;
if (ask && !userAcceptsUpgrade()) return false; if (ask && !userAcceptsUpgrade()) return false;
int maxPrio = 0;
QRegExp rx(QLatin1String("^([A-Fa-f0-9]{40})\\.fastresume$")); QRegExp rx(QLatin1String("^([A-Fa-f0-9]{40})\\.fastresume$"));
foreach (QString backupFile, backupFiles) { foreach (QString backupFile, backupFiles) {
if (rx.indexIn(backupFile) != -1) { if (rx.indexIn(backupFile) != -1) {
if (!upgradeResumeFile(backupFolderDir.absoluteFilePath(backupFile))) if (upgradeResumeFile(backupFolderDir.absoluteFilePath(backupFile), oldResumeData[rx.cap(1)].toHash(), maxPrio))
oldResumeData.remove(rx.cap(1));
else
Logger::instance()->addMessage(QObject::tr("Couldn't migrate torrent with hash: %1").arg(rx.cap(1)), Log::WARNING); Logger::instance()->addMessage(QObject::tr("Couldn't migrate torrent with hash: %1").arg(rx.cap(1)), Log::WARNING);
} }
else { else {
Logger::instance()->addMessage(QObject::tr("Couldn't migrate torrent. Invalid fastresume file name: %1").arg(backupFile), Log::WARNING); Logger::instance()->addMessage(QObject::tr("Couldn't migrate torrent. Invalid fastresume file name: %1").arg(backupFile), Log::WARNING);
} }
} }
foreach (const QString &hash, oldResumeData.keys()) {
QVariantHash oldTorrent = oldResumeData[hash].toHash();
if (oldTorrent.value("is_magnet", false).toBool()) {
libtorrent::entry resumeData;
resumeData["qBt-magnetUri"] = Utils::String::toStdString(oldTorrent.value("magnet_uri").toString());
resumeData["qBt-paused"] = false;
resumeData["qBt-forced"] = false;
resumeData["qBt-savePath"] = Utils::String::toStdString(oldTorrent.value("save_path").toString());
resumeData["qBt-ratioLimit"] = Utils::String::toStdString(QString::number(oldTorrent.value("max_ratio", -2).toReal()));
resumeData["qBt-label"] = Utils::String::toStdString(oldTorrent.value("label").toString());
resumeData["qBt-name"] = Utils::String::toStdString(oldTorrent.value("name").toString());
resumeData["qBt-seedStatus"] = oldTorrent.value("seed").toBool();
resumeData["qBt-tempPathDisabled"] = false;
QString filename = QString("%1.fastresume.%2").arg(hash).arg(++maxPrio);
QString filepath = backupFolderDir.absoluteFilePath(filename);
QFile resumeFile(filepath);
QVector<char> out;
libtorrent::bencode(std::back_inserter(out), resumeData);
if (resumeFile.open(QIODevice::WriteOnly))
resumeFile.write(&out[0], out.size());
} }
}
if (!oldResumeData.isEmpty())
QFile(oldResumeFilename).rename(oldResumeFilename + ".bak");
return true; return true;
} }

View File

@@ -30,7 +30,7 @@
#include <libtorrent/error_code.hpp> #include <libtorrent/error_code.hpp>
#include <libtorrent/magnet_uri.hpp> #include <libtorrent/magnet_uri.hpp>
#include "core/utils/string.h" #include "base/utils/string.h"
#include "magneturi.h" #include "magneturi.h"
namespace libt = libtorrent; namespace libt = libtorrent;

View File

@@ -26,9 +26,10 @@
* exception statement from your version. * exception statement from your version.
*/ */
#include "core/net/geoipmanager.h" #include "base/net/geoipmanager.h"
#include "core/utils/string.h" #include "base/utils/string.h"
#include "core/unicodestrings.h" #include "base/unicodestrings.h"
#include "base/bittorrent/torrenthandle.h"
#include "peerinfo.h" #include "peerinfo.h"
namespace libt = libtorrent; namespace libt = libtorrent;
@@ -49,9 +50,11 @@ PeerAddress::PeerAddress(QHostAddress ip, ushort port)
// PeerInfo // PeerInfo
PeerInfo::PeerInfo(const libt::peer_info &nativeInfo) PeerInfo::PeerInfo(const TorrentHandle *torrent, const libt::peer_info &nativeInfo)
: m_nativeInfo(nativeInfo) : m_nativeInfo(nativeInfo)
{ {
calcRelevance(torrent);
determineFlags();
} }
bool PeerInfo::fromDHT() const bool PeerInfo::fromDHT() const
@@ -253,3 +256,155 @@ QString PeerInfo::connectionType() const
return connection; return connection;
} }
void PeerInfo::calcRelevance(const TorrentHandle *torrent)
{
const QBitArray &allPieces = torrent->pieces();
const QBitArray &peerPieces = pieces();
int localMissing = 0;
int remoteHaves = 0;
for (int i = 0; i < allPieces.size(); ++i) {
if (!allPieces[i]) {
++localMissing;
if (peerPieces[i])
++remoteHaves;
}
}
if (localMissing == 0)
m_relevance = 0.0;
else
m_relevance = static_cast<qreal>(remoteHaves) / localMissing;
}
qreal PeerInfo::relevance() const
{
return m_relevance;
}
void PeerInfo::determineFlags()
{
if (isInteresting()) {
//d = Your client wants to download, but peer doesn't want to send (interested and choked)
if (isRemoteChocked()) {
m_flags += "d ";
m_flagsDescription += tr("interested(local) and choked(peer)");
m_flagsDescription += ", ";
}
else {
//D = Currently downloading (interested and not choked)
m_flags += "D ";
m_flagsDescription += tr("interested(local) and unchoked(peer)");
m_flagsDescription += ", ";
}
}
if (isRemoteInterested()) {
//u = Peer wants your client to upload, but your client doesn't want to (interested and choked)
if (isChocked()) {
m_flags += "u ";
m_flagsDescription += tr("interested(peer) and choked(local)");
m_flagsDescription += ", ";
}
else {
//U = Currently uploading (interested and not choked)
m_flags += "U ";
m_flagsDescription += tr("interested(peer) and unchoked(local)");
m_flagsDescription += ", ";
}
}
//O = Optimistic unchoke
if (optimisticUnchoke()) {
m_flags += "O ";
m_flagsDescription += tr("optimistic unchoke");
m_flagsDescription += ", ";
}
//S = Peer is snubbed
if (isSnubbed()) {
m_flags += "S ";
m_flagsDescription += tr("peer snubbed");
m_flagsDescription += ", ";
}
//I = Peer is an incoming connection
if (!isLocalConnection()) {
m_flags += "I ";
m_flagsDescription += tr("incoming connection");
m_flagsDescription += ", ";
}
//K = Peer is unchoking your client, but your client is not interested
if (!isRemoteChocked() && !isInteresting()) {
m_flags += "K ";
m_flagsDescription += tr("not interested(local) and unchoked(peer)");
m_flagsDescription += ", ";
}
//? = Your client unchoked the peer but the peer is not interested
if (!isChocked() && !isRemoteInterested()) {
m_flags += "? ";
m_flagsDescription += tr("not interested(peer) and unchoked(local)");
m_flagsDescription += ", ";
}
//X = Peer was included in peerlists obtained through Peer Exchange (PEX)
if (fromPeX()) {
m_flags += "X ";
m_flagsDescription += tr("peer from PEX");
m_flagsDescription += ", ";
}
//H = Peer was obtained through DHT
if (fromDHT()) {
m_flags += "H ";
m_flagsDescription += tr("peer from DHT");
m_flagsDescription += ", ";
}
//E = Peer is using Protocol Encryption (all traffic)
if (isRC4Encrypted()) {
m_flags += "E ";
m_flagsDescription += tr("encrypted traffic");
m_flagsDescription += ", ";
}
//e = Peer is using Protocol Encryption (handshake)
if (isPlaintextEncrypted()) {
m_flags += "e ";
m_flagsDescription += tr("encrypted handshake");
m_flagsDescription += ", ";
}
//P = Peer is using uTorrent uTP
if (useUTPSocket()) {
m_flags += "P ";
m_flagsDescription += QString::fromUtf8(C_UTP);
m_flagsDescription += ", ";
}
//L = Peer is local
if (fromLSD()) {
m_flags += "L";
m_flagsDescription += tr("peer from LSD");
}
m_flags = m_flags.trimmed();
m_flagsDescription = m_flagsDescription.trimmed();
if (m_flagsDescription.endsWith(',', Qt::CaseInsensitive))
m_flagsDescription.chop(1);
}
QString PeerInfo::flags() const
{
return m_flags;
}
QString PeerInfo::flagsDescription() const
{
return m_flagsDescription;
}

View File

@@ -33,9 +33,12 @@
#include <QHostAddress> #include <QHostAddress>
#include <QBitArray> #include <QBitArray>
#include <QCoreApplication>
namespace BitTorrent namespace BitTorrent
{ {
class TorrentHandle;
struct PeerAddress struct PeerAddress
{ {
QHostAddress ip; QHostAddress ip;
@@ -47,8 +50,10 @@ namespace BitTorrent
class PeerInfo class PeerInfo
{ {
Q_DECLARE_TR_FUNCTIONS(PeerInfo)
public: public:
PeerInfo(const libtorrent::peer_info &nativeInfo); PeerInfo(const TorrentHandle *torrent, const libtorrent::peer_info &nativeInfo);
bool fromDHT() const; bool fromDHT() const;
bool fromPeX() const; bool fromPeX() const;
@@ -89,12 +94,21 @@ namespace BitTorrent
qlonglong totalDownload() const; qlonglong totalDownload() const;
QBitArray pieces() const; QBitArray pieces() const;
QString connectionType() const; QString connectionType() const;
qreal relevance() const;
QString flags() const;
QString flagsDescription() const;
#ifndef DISABLE_COUNTRIES_RESOLUTION #ifndef DISABLE_COUNTRIES_RESOLUTION
QString country() const; QString country() const;
#endif #endif
private: private:
void calcRelevance(const TorrentHandle *torrent);
void determineFlags();
libtorrent::peer_info m_nativeInfo; libtorrent::peer_info m_nativeInfo;
qreal m_relevance;
QString m_flags;
QString m_flagsDescription;
}; };
} }

View File

@@ -31,7 +31,7 @@
#include <QTime> #include <QTime>
#include <QDateTime> #include <QDateTime>
#include "core/preferences.h" #include "base/preferences.h"
#include "bandwidthscheduler.h" #include "bandwidthscheduler.h"
BandwidthScheduler::BandwidthScheduler(QObject *parent) BandwidthScheduler::BandwidthScheduler(QObject *parent)

View File

@@ -36,7 +36,7 @@
#include <libtorrent/session.hpp> #include <libtorrent/session.hpp>
#include <libtorrent/ip_filter.hpp> #include <libtorrent/ip_filter.hpp>
#include "core/logger.h" #include "base/logger.h"
#include "filterparserthread.h" #include "filterparserthread.h"
namespace libt = libtorrent; namespace libt = libtorrent;

View File

@@ -2,10 +2,10 @@
#include <libtorrent/session.hpp> #include <libtorrent/session.hpp>
#include "core/qinisettings.h" #include "base/qinisettings.h"
#include "core/preferences.h" #include "base/preferences.h"
#include "core/bittorrent/sessionstatus.h" #include "base/bittorrent/sessionstatus.h"
#include "core/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "statistics.h" #include "statistics.h"
static const qint64 SAVE_INTERVAL = 15 * 60 * 1000; static const qint64 SAVE_INTERVAL = 15 * 60 * 1000;
@@ -83,7 +83,7 @@ void Statistics::load()
// Don't forget to remove: // Don't forget to remove:
// 1. Preferences::getStats() // 1. Preferences::getStats()
// 2. Preferences::removeStats() // 2. Preferences::removeStats()
// 3. #include "core/preferences.h" // 3. #include "base/preferences.h"
Preferences* const pref = Preferences::instance(); Preferences* const pref = Preferences::instance();
QIniSettings s("qBittorrent", "qBittorrent-data"); QIniSettings s("qBittorrent", "qBittorrent-data");
QVariantHash v = pref->getStats(); QVariantHash v = pref->getStats();

View File

@@ -63,20 +63,20 @@ using namespace BitTorrent;
//#include <libtorrent/extensions/metadata_transfer.hpp> //#include <libtorrent/extensions/metadata_transfer.hpp>
#ifndef DISABLE_COUNTRIES_RESOLUTION #ifndef DISABLE_COUNTRIES_RESOLUTION
#include "core/net/geoipmanager.h" #include "base/net/geoipmanager.h"
#endif #endif
#include "core/utils/misc.h" #include "base/utils/misc.h"
#include "core/utils/fs.h" #include "base/utils/fs.h"
#include "core/utils/string.h" #include "base/utils/string.h"
#include "core/unicodestrings.h" #include "base/unicodestrings.h"
#include "core/logger.h" #include "base/logger.h"
#include "core/preferences.h" #include "base/preferences.h"
#include "core/torrentfilter.h" #include "base/torrentfilter.h"
#include "core/net/downloadmanager.h" #include "base/net/downloadmanager.h"
#include "core/net/downloadhandler.h" #include "base/net/downloadhandler.h"
#include "core/net/portforwarder.h" #include "base/net/portforwarder.h"
#include "core/utils/string.h" #include "base/utils/string.h"
#include "private/filterparserthread.h" #include "private/filterparserthread.h"
#include "private/statistics.h" #include "private/statistics.h"
#include "private/bandwidthscheduler.h" #include "private/bandwidthscheduler.h"
@@ -466,7 +466,8 @@ void Session::configure()
m_torrentExportEnabled = torrentExportEnabled; m_torrentExportEnabled = torrentExportEnabled;
if (m_torrentExportEnabled) { if (m_torrentExportEnabled) {
qDebug("Torrent export is enabled, exporting the current torrents"); qDebug("Torrent export is enabled, exporting the current torrents");
exportTorrentFiles(pref->getTorrentExportDir()); for (auto torrent: m_torrents)
exportTorrentFile(torrent);
} }
} }
@@ -1151,60 +1152,25 @@ void Session::exportTorrentFile(TorrentHandle *const torrent, TorrentExportFolde
Q_ASSERT(((folder == TorrentExportFolder::Regular) && m_torrentExportEnabled) || Q_ASSERT(((folder == TorrentExportFolder::Regular) && m_torrentExportEnabled) ||
((folder == TorrentExportFolder::Finished) && m_finishedTorrentExportEnabled)); ((folder == TorrentExportFolder::Finished) && m_finishedTorrentExportEnabled));
QString validName = Utils::Fs::toValidFileSystemName(torrent->name());
QString torrentFilename = QString("%1.torrent").arg(torrent->hash()); QString torrentFilename = QString("%1.torrent").arg(torrent->hash());
QString torrentExportFilename = QString("%1.torrent").arg(validName);
QString torrentPath = QDir(m_resumeFolderPath).absoluteFilePath(torrentFilename); QString torrentPath = QDir(m_resumeFolderPath).absoluteFilePath(torrentFilename);
QDir exportPath(folder == TorrentExportFolder::Regular ? Preferences::instance()->getTorrentExportDir() : Preferences::instance()->getFinishedTorrentExportDir()); QDir exportPath(folder == TorrentExportFolder::Regular ? Preferences::instance()->getTorrentExportDir() : Preferences::instance()->getFinishedTorrentExportDir());
if (exportPath.exists() || exportPath.mkpath(exportPath.absolutePath())) { if (exportPath.exists() || exportPath.mkpath(exportPath.absolutePath())) {
QString newTorrentPath = exportPath.absoluteFilePath(torrentFilename); QString newTorrentPath = exportPath.absoluteFilePath(torrentExportFilename);
if (QFile::exists(newTorrentPath) && Utils::Fs::sameFiles(torrentPath, newTorrentPath)) { int counter = 0;
// Append hash to torrent name to make it unique while (QFile::exists(newTorrentPath) && !Utils::Fs::sameFiles(torrentPath, newTorrentPath)) {
newTorrentPath = exportPath.absoluteFilePath(torrent->name() + "-" + torrentFilename); // Append number to torrent name to make it unique
torrentExportFilename = QString("%1 %2.torrent").arg(validName).arg(++counter);
newTorrentPath = exportPath.absoluteFilePath(torrentExportFilename);
} }
if (!QFile::exists(newTorrentPath))
QFile::copy(torrentPath, newTorrentPath); QFile::copy(torrentPath, newTorrentPath);
} }
} }
void Session::exportTorrentFiles(QString path)
{
// NOTE: Maybe create files from current metadata here?
Q_ASSERT(m_torrentExportEnabled);
QDir exportDir(path);
if (!exportDir.exists()) {
if (!exportDir.mkpath(exportDir.absolutePath())) {
Logger::instance()->addMessage(tr("Error: Could not create torrent export directory: '%1'").arg(exportDir.absolutePath()), Log::CRITICAL);
return;
}
}
QDir resumeDataDir(m_resumeFolderPath);
foreach (TorrentHandle *const torrent, m_torrents) {
if (!torrent->isValid()) {
Logger::instance()->addMessage(tr("Torrent Export: torrent is invalid, skipping..."), Log::CRITICAL);
continue;
}
const QString srcPath(resumeDataDir.absoluteFilePath(QString("%1.torrent").arg(torrent->hash())));
if (QFile::exists(srcPath)) {
QString dstPath = exportDir.absoluteFilePath(QString("%1.torrent").arg(torrent->name()));
if (QFile::exists(dstPath)) {
if (!Utils::Fs::sameFiles(srcPath, dstPath)) {
dstPath = exportDir.absoluteFilePath(QString("%1-%2.torrent").arg(torrent->name()).arg(torrent->hash()));
}
else {
qDebug("Torrent Export: Destination file exists, skipping...");
continue;
}
}
qDebug("Export Torrent: %s -> %s", qPrintable(srcPath), qPrintable(dstPath));
QFile::copy(srcPath, dstPath);
}
else {
Logger::instance()->addMessage(tr("Error: could not export torrent '%1', maybe it has not metadata yet.").arg(torrent->hash()), Log::CRITICAL);
}
}
}
void Session::setMaxConnectionsPerTorrent(int max) void Session::setMaxConnectionsPerTorrent(int max)
{ {
qDebug() << Q_FUNC_INFO << max; qDebug() << Q_FUNC_INFO << max;
@@ -1433,6 +1399,8 @@ void Session::networkOnlineStateChanged(const bool online)
void Session::networkConfigurationChange(const QNetworkConfiguration& cfg) void Session::networkConfigurationChange(const QNetworkConfiguration& cfg)
{ {
const QString configuredInterfaceName = Preferences::instance()->getNetworkInterface(); const QString configuredInterfaceName = Preferences::instance()->getNetworkInterface();
// Empty means "Any Interface". In this case libtorrent has binded to 0.0.0.0 so any change to any interface will
// be automatically picked up. Otherwise we would rebinding here to 0.0.0.0 again.
if (configuredInterfaceName.isEmpty()) if (configuredInterfaceName.isEmpty())
return; return;
const QString changedInterface = cfg.name(); const QString changedInterface = cfg.name();
@@ -1511,7 +1479,7 @@ void Session::setListeningPort()
m_nativeSession->listen_on(ports, ec, 0, libt::session::listen_no_system_port); m_nativeSession->listen_on(ports, ec, 0, libt::session::listen_no_system_port);
if (ec) if (ec)
logger->addMessage(tr("qBittorrent failed to listen on any interface port: %1. Reason: %2", "e.g: qBittorrent failed to listen on any interface port: TCP/6881. Reason: no such interface" ).arg(QString::number(port)).arg(Utils::String::fromStdString(ec.message())), Log::CRITICAL); logger->addMessage(tr("qBittorrent failed to listen on any interface port: %1. Reason: %2.", "e.g: qBittorrent failed to listen on any interface port: TCP/6881. Reason: no such interface" ).arg(QString::number(port)).arg(QString::fromLocal8Bit(ec.message().c_str())), Log::CRITICAL);
return; return;
} }
@@ -1996,7 +1964,7 @@ void Session::getPendingAlerts(QVector<libt::alert *> &out, ulong time)
QMutexLocker lock(&m_alertsMutex); QMutexLocker lock(&m_alertsMutex);
while (m_alerts.empty()) if (m_alerts.empty())
m_alertsWaitCondition.wait(&m_alertsMutex, time); m_alertsWaitCondition.wait(&m_alertsMutex, time);
m_alerts.swap(out); m_alerts.swap(out);
@@ -2304,10 +2272,10 @@ void Session::handleListenFailedAlert(libt::listen_failed_alert *p)
proto = "SOCKS5"; proto = "SOCKS5";
qDebug() << "Failed listening on " << proto << p->endpoint.address().to_string(ec).c_str() << "/" << p->endpoint.port(); qDebug() << "Failed listening on " << proto << p->endpoint.address().to_string(ec).c_str() << "/" << p->endpoint.port();
Logger::instance()->addMessage( Logger::instance()->addMessage(
tr("qBittorrent failed listening on interface %1 port: %2/%3. Reason: %4", tr("qBittorrent failed listening on interface %1 port: %2/%3. Reason: %4.",
"e.g: qBittorrent failed listening on interface 192.168.0.1 port: TCP/6881. Reason: already in use") "e.g: qBittorrent failed listening on interface 192.168.0.1 port: TCP/6881. Reason: already in use")
.arg(p->endpoint.address().to_string(ec).c_str()).arg(proto).arg(QString::number(p->endpoint.port())) .arg(p->endpoint.address().to_string(ec).c_str()).arg(proto).arg(QString::number(p->endpoint.port()))
.arg(Utils::String::fromStdString(p->error.message())), Log::CRITICAL); .arg(QString::fromLocal8Bit(p->error.message().c_str())), Log::CRITICAL);
} }
void Session::handleExternalIPAlert(libt::external_ip_alert *p) void Session::handleExternalIPAlert(libt::external_ip_alert *p)

View File

@@ -38,8 +38,8 @@
#include <QWaitCondition> #include <QWaitCondition>
#include <QNetworkConfigurationManager> #include <QNetworkConfigurationManager>
#include "core/tristatebool.h" #include "base/tristatebool.h"
#include "core/types.h" #include "base/types.h"
#include "torrentinfo.h" #include "torrentinfo.h"
namespace libtorrent namespace libtorrent
@@ -293,7 +293,6 @@ namespace BitTorrent
void updateRatioTimer(); void updateRatioTimer();
void exportTorrentFile(TorrentHandle *const torrent, TorrentExportFolder folder = TorrentExportFolder::Regular); void exportTorrentFile(TorrentHandle *const torrent, TorrentExportFolder folder = TorrentExportFolder::Regular);
void exportTorrentFiles(QString path);
void saveTorrentResumeData(TorrentHandle *const torrent); void saveTorrentResumeData(TorrentHandle *const torrent);
void handleAlert(libtorrent::alert *a); void handleAlert(libtorrent::alert *a);

View File

@@ -43,9 +43,9 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include "core/utils/fs.h" #include "base/utils/fs.h"
#include "core/utils/misc.h" #include "base/utils/misc.h"
#include "core/utils/string.h" #include "base/utils/string.h"
#include "torrentcreatorthread.h" #include "torrentcreatorthread.h"
namespace libt = libtorrent; namespace libt = libtorrent;

View File

@@ -46,11 +46,11 @@
#include <Windows.h> #include <Windows.h>
#endif #endif
#include "core/logger.h" #include "base/logger.h"
#include "core/preferences.h" #include "base/preferences.h"
#include "core/utils/string.h" #include "base/utils/string.h"
#include "core/utils/fs.h" #include "base/utils/fs.h"
#include "core/utils/misc.h" #include "base/utils/misc.h"
#include "session.h" #include "session.h"
#include "peerinfo.h" #include "peerinfo.h"
#include "trackerentry.h" #include "trackerentry.h"
@@ -960,7 +960,7 @@ QList<PeerInfo> TorrentHandle::peers() const
SAFE_CALL(get_peer_info, nativePeers); SAFE_CALL(get_peer_info, nativePeers);
foreach (const libt::peer_info &peer, nativePeers) foreach (const libt::peer_info &peer, nativePeers)
peers << peer; peers << PeerInfo(this, peer);
return peers; return peers;
} }

View File

@@ -40,7 +40,7 @@
#include <libtorrent/torrent_handle.hpp> #include <libtorrent/torrent_handle.hpp>
#include <boost/function.hpp> #include <boost/function.hpp>
#include "core/tristatebool.h" #include "base/tristatebool.h"
#include "private/speedmonitor.h" #include "private/speedmonitor.h"
#include "infohash.h" #include "infohash.h"
#include "torrentinfo.h" #include "torrentinfo.h"

View File

@@ -33,9 +33,9 @@
#include <libtorrent/error_code.hpp> #include <libtorrent/error_code.hpp>
#include "core/utils/misc.h" #include "base/utils/misc.h"
#include "core/utils/fs.h" #include "base/utils/fs.h"
#include "core/utils/string.h" #include "base/utils/string.h"
#include "infohash.h" #include "infohash.h"
#include "trackerentry.h" #include "trackerentry.h"
#include "torrentinfo.h" #include "torrentinfo.h"

View File

@@ -33,9 +33,9 @@
#include <libtorrent/bencode.hpp> #include <libtorrent/bencode.hpp>
#include <libtorrent/entry.hpp> #include <libtorrent/entry.hpp>
#include "core/preferences.h" #include "base/preferences.h"
#include "core/http/server.h" #include "base/http/server.h"
#include "core/utils/string.h" #include "base/utils/string.h"
#include "tracker.h" #include "tracker.h"
// static limits // static limits

View File

@@ -33,9 +33,9 @@
#define BITTORRENT_TRACKER_H #define BITTORRENT_TRACKER_H
#include <QHash> #include <QHash>
#include "core/http/types.h" #include "base/http/types.h"
#include "core/http/responsebuilder.h" #include "base/http/responsebuilder.h"
#include "core/http/irequesthandler.h" #include "base/http/irequesthandler.h"
namespace libtorrent namespace libtorrent
{ {

View File

@@ -28,8 +28,8 @@
#include <QString> #include <QString>
#include "core/utils/misc.h" #include "base/utils/misc.h"
#include "core/utils/string.h" #include "base/utils/string.h"
#include "trackerentry.h" #include "trackerentry.h"
using namespace BitTorrent; using namespace BitTorrent;

View File

@@ -12,9 +12,9 @@
#endif #endif
#endif #endif
#include "core/preferences.h" #include "base/preferences.h"
#include "core/bittorrent/torrentinfo.h" #include "base/bittorrent/torrentinfo.h"
#include "core/bittorrent/magneturi.h" #include "base/bittorrent/magneturi.h"
#include "filesystemwatcher.h" #include "filesystemwatcher.h"
#ifndef CIFS_MAGIC_NUMBER #ifndef CIFS_MAGIC_NUMBER

View File

@@ -31,7 +31,7 @@
#include <QStringList> #include <QStringList>
#include <QUrl> #include <QUrl>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
#include <QUrlQuery> #include <QUrlQuery>
#endif #endif
#include <QDir> #include <QDir>
@@ -117,7 +117,7 @@ bool RequestParser::parseStartingLine(const QString &line)
m_request.path = url.path(); // Path m_request.path = url.path(); // Path
// Parse GET parameters // Parse GET parameters
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) #ifndef QBT_USES_QT5
QListIterator<QPair<QString, QString> > i(url.queryItems()); QListIterator<QPair<QString, QString> > i(url.queryItems());
#else #else
QListIterator<QPair<QString, QString> > i(QUrlQuery(url).queryItems()); QListIterator<QPair<QString, QString> > i(QUrlQuery(url).queryItems());
@@ -216,7 +216,7 @@ bool RequestParser::parseContent(const QByteArray& data)
// Parse url-encoded POST data // Parse url-encoded POST data
if (m_request.headers["content-type"].startsWith("application/x-www-form-urlencoded")) { if (m_request.headers["content-type"].startsWith("application/x-www-form-urlencoded")) {
QUrl url; QUrl url;
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) #ifndef QBT_USES_QT5
url.setEncodedQuery(data); url.setEncodedQuery(data);
QListIterator<QPair<QString, QString> > i(url.queryItems()); QListIterator<QPair<QString, QString> > i(url.queryItems());
#else #else

View File

@@ -29,7 +29,7 @@
* Contact : chris@qbittorrent.org * Contact : chris@qbittorrent.org
*/ */
#include "core/utils/gzip.h" #include "base/utils/gzip.h"
#include "responsegenerator.h" #include "responsegenerator.h"
using namespace Http; using namespace Http;

View File

@@ -67,7 +67,7 @@ void Server::disableHttps()
} }
#endif #endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
void Server::incomingConnection(qintptr socketDescriptor) void Server::incomingConnection(qintptr socketDescriptor)
#else #else
void Server::incomingConnection(int socketDescriptor) void Server::incomingConnection(int socketDescriptor)

View File

@@ -59,7 +59,7 @@ namespace Http
#endif #endif
private: private:
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
void incomingConnection(qintptr socketDescriptor); void incomingConnection(qintptr socketDescriptor);
#else #else
void incomingConnection(int socketDescriptor); void incomingConnection(int socketDescriptor);

View File

@@ -32,11 +32,11 @@
#include <QDebug> #include <QDebug>
#include <QRegExp> #include <QRegExp>
#include <QStringList> #include <QStringList>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
#include <QUrlQuery> #include <QUrlQuery>
#endif #endif
#include "core/logger.h" #include "base/logger.h"
#include "dnsupdater.h" #include "dnsupdater.h"
using namespace Net; using namespace Net;
@@ -160,7 +160,7 @@ QUrl DNSUpdater::getUpdateUrl() const
} }
url.setPath("/nic/update"); url.setPath("/nic/update");
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) #ifndef QBT_USES_QT5
url.addQueryItem("hostname", m_domain); url.addQueryItem("hostname", m_domain);
url.addQueryItem("myip", m_lastIP.toString()); url.addQueryItem("myip", m_lastIP.toString());
#else #else

View File

@@ -36,7 +36,7 @@
#include <QNetworkReply> #include <QNetworkReply>
#include <QDateTime> #include <QDateTime>
#include <QTimer> #include <QTimer>
#include "core/preferences.h" #include "base/preferences.h"
namespace Net namespace Net
{ {

View File

@@ -36,9 +36,9 @@
#include <QUrl> #include <QUrl>
#include <QDebug> #include <QDebug>
#include "core/utils/fs.h" #include "base/utils/fs.h"
#include "core/utils/gzip.h" #include "base/utils/gzip.h"
#include "core/utils/misc.h" #include "base/utils/misc.h"
#include "downloadmanager.h" #include "downloadmanager.h"
#include "downloadhandler.h" #include "downloadhandler.h"

View File

@@ -36,7 +36,7 @@
#include <QUrl> #include <QUrl>
#include <QDebug> #include <QDebug>
#include "core/preferences.h" #include "base/preferences.h"
#include "downloadhandler.h" #include "downloadhandler.h"
#include "downloadmanager.h" #include "downloadmanager.h"

View File

@@ -33,10 +33,10 @@
#include <QHostAddress> #include <QHostAddress>
#include <QDateTime> #include <QDateTime>
#include "core/logger.h" #include "base/logger.h"
#include "core/preferences.h" #include "base/preferences.h"
#include "core/utils/fs.h" #include "base/utils/fs.h"
#include "core/utils/gzip.h" #include "base/utils/gzip.h"
#include "downloadmanager.h" #include "downloadmanager.h"
#include "downloadhandler.h" #include "downloadhandler.h"
#include "private/geoipdatabase.h" #include "private/geoipdatabase.h"

View File

@@ -30,8 +30,8 @@
#include <libtorrent/session.hpp> #include <libtorrent/session.hpp>
#include "core/logger.h" #include "base/logger.h"
#include "core/preferences.h" #include "base/preferences.h"
#include "portforwarder.h" #include "portforwarder.h"
namespace libt = libtorrent; namespace libt = libtorrent;

View File

@@ -33,7 +33,7 @@
#include <QDateTime> #include <QDateTime>
#include <QFile> #include <QFile>
#include "core/types.h" #include "base/types.h"
#include "geoipdatabase.h" #include "geoipdatabase.h"
namespace namespace
@@ -66,7 +66,7 @@ namespace
Float = 15 Float = 15
}; };
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) #ifndef QBT_USES_QT5
Q_IPV6ADDR createMappedAddress(quint32 ip4); Q_IPV6ADDR createMappedAddress(quint32 ip4);
#endif #endif
} }
@@ -166,7 +166,7 @@ QDateTime GeoIPDatabase::buildEpoch() const
QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
{ {
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) #ifndef QBT_USES_QT5
Q_IPV6ADDR addr = hostAddr.protocol() == QAbstractSocket::IPv4Protocol Q_IPV6ADDR addr = hostAddr.protocol() == QAbstractSocket::IPv4Protocol
? createMappedAddress(hostAddr.toIPv4Address()) ? createMappedAddress(hostAddr.toIPv4Address())
: hostAddr.toIPv6Address(); : hostAddr.toIPv6Address();
@@ -499,7 +499,7 @@ QVariant GeoIPDatabase::readArrayValue(quint32 &offset, quint32 count) const
namespace namespace
{ {
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) #ifndef QBT_USES_QT5
Q_IPV6ADDR createMappedAddress(quint32 ip4) Q_IPV6ADDR createMappedAddress(quint32 ip4)
{ {
Q_IPV6ADDR ip6; Q_IPV6ADDR ip6;

View File

@@ -33,8 +33,8 @@
*/ */
#include "smtp.h" #include "smtp.h"
#include "core/preferences.h" #include "base/preferences.h"
#include "core/logger.h" #include "base/logger.h"
#include <QTextStream> #include <QTextStream>
#ifndef QT_NO_OPENSSL #ifndef QT_NO_OPENSSL

View File

@@ -52,8 +52,8 @@
#endif #endif
#include <cstdlib> #include <cstdlib>
#include "core/utils/fs.h" #include "base/utils/fs.h"
#include "core/utils/misc.h" #include "base/utils/misc.h"
Preferences* Preferences::m_instance = 0; Preferences* Preferences::m_instance = 0;
@@ -504,7 +504,7 @@ QList<bool> Preferences::getDownloadInScanDirs() const
void Preferences::setDownloadInScanDirs(const QList<bool> &list) void Preferences::setDownloadInScanDirs(const QList<bool> &list)
{ {
setValue("Preferences/Downloads/ScanDirsDownloadPaths", Utils::Misc::toStringList(list)); setValue("Preferences/Downloads/DownloadInScanDirs", Utils::Misc::toStringList(list));
} }
void Preferences::setScanDirsDownloadPaths(const QStringList &downloadpaths) void Preferences::setScanDirsDownloadPaths(const QStringList &downloadpaths)
@@ -514,7 +514,7 @@ void Preferences::setScanDirsDownloadPaths(const QStringList &downloadpaths)
QStringList Preferences::getScanDirsDownloadPaths() const QStringList Preferences::getScanDirsDownloadPaths() const
{ {
return value("Preferences/Downloads/DownloadPaths").toStringList(); return value("Preferences/Downloads/ScanDirsDownloadPaths").toStringList();
} }
QString Preferences::getScanDirsLastPath() const QString Preferences::getScanDirsLastPath() const
@@ -1662,6 +1662,16 @@ void Preferences::removeTorrentLabel(const QString& label)
setValue("TransferListFilters/customLabels", labels); setValue("TransferListFilters/customLabels", labels);
} }
QString Preferences::getDefaultLabel() const
{
return value("Preferences/Downloads/DefaultLabel").toString();
}
void Preferences::setDefaultLabel(const QString &defaultLabel)
{
setValue("Preferences/Downloads/DefaultLabel", defaultLabel);
}
bool Preferences::recursiveDownloadDisabled() const bool Preferences::recursiveDownloadDisabled() const
{ {
return value("Preferences/Advanced/DisableRecursiveDownload", false).toBool(); return value("Preferences/Advanced/DisableRecursiveDownload", false).toBool();
@@ -1966,7 +1976,7 @@ void Preferences::setTrayIconStyle(TrayIcon::Style style)
// in the same file. // in the same file.
QByteArray Preferences::getAddNewTorrentDialogState() const QByteArray Preferences::getAddNewTorrentDialogState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
return value("AddNewTorrentDialog/qt5/treeHeaderState").toByteArray(); return value("AddNewTorrentDialog/qt5/treeHeaderState").toByteArray();
#else #else
return value("AddNewTorrentDialog/treeHeaderState").toByteArray(); return value("AddNewTorrentDialog/treeHeaderState").toByteArray();
@@ -1975,7 +1985,7 @@ QByteArray Preferences::getAddNewTorrentDialogState() const
void Preferences::setAddNewTorrentDialogState(const QByteArray &state) void Preferences::setAddNewTorrentDialogState(const QByteArray &state)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
setValue("AddNewTorrentDialog/qt5/treeHeaderState", state); setValue("AddNewTorrentDialog/qt5/treeHeaderState", state);
#else #else
setValue("AddNewTorrentDialog/treeHeaderState", state); setValue("AddNewTorrentDialog/treeHeaderState", state);
@@ -2064,7 +2074,7 @@ void Preferences::setMainGeometry(const QByteArray &geometry)
QByteArray Preferences::getMainVSplitterState() const QByteArray Preferences::getMainVSplitterState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
return value("MainWindow/qt5/vsplitterState").toByteArray(); return value("MainWindow/qt5/vsplitterState").toByteArray();
#else #else
return value("MainWindow/vsplitterState").toByteArray(); return value("MainWindow/vsplitterState").toByteArray();
@@ -2073,7 +2083,7 @@ QByteArray Preferences::getMainVSplitterState() const
void Preferences::setMainVSplitterState(const QByteArray &state) void Preferences::setMainVSplitterState(const QByteArray &state)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
setValue("MainWindow/qt5/vsplitterState", state); setValue("MainWindow/qt5/vsplitterState", state);
#else #else
setValue("MainWindow/vsplitterState", state); setValue("MainWindow/vsplitterState", state);
@@ -2124,7 +2134,7 @@ void Preferences::setPrefHSplitterSizes(const QStringList &sizes)
QByteArray Preferences::getPeerListState() const QByteArray Preferences::getPeerListState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
return value("TorrentProperties/Peers/qt5/PeerListState").toByteArray(); return value("TorrentProperties/Peers/qt5/PeerListState").toByteArray();
#else #else
return value("TorrentProperties/Peers/PeerListState").toByteArray(); return value("TorrentProperties/Peers/PeerListState").toByteArray();
@@ -2133,7 +2143,7 @@ QByteArray Preferences::getPeerListState() const
void Preferences::setPeerListState(const QByteArray &state) void Preferences::setPeerListState(const QByteArray &state)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
setValue("TorrentProperties/Peers/qt5/PeerListState", state); setValue("TorrentProperties/Peers/qt5/PeerListState", state);
#else #else
setValue("TorrentProperties/Peers/PeerListState", state); setValue("TorrentProperties/Peers/PeerListState", state);
@@ -2152,7 +2162,7 @@ void Preferences::setPropSplitterSizes(const QString &sizes)
QByteArray Preferences::getPropFileListState() const QByteArray Preferences::getPropFileListState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
return value("TorrentProperties/qt5/FilesListState").toByteArray(); return value("TorrentProperties/qt5/FilesListState").toByteArray();
#else #else
return value("TorrentProperties/FilesListState").toByteArray(); return value("TorrentProperties/FilesListState").toByteArray();
@@ -2161,7 +2171,7 @@ QByteArray Preferences::getPropFileListState() const
void Preferences::setPropFileListState(const QByteArray &state) void Preferences::setPropFileListState(const QByteArray &state)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
setValue("TorrentProperties/qt5/FilesListState", state); setValue("TorrentProperties/qt5/FilesListState", state);
#else #else
setValue("TorrentProperties/FilesListState", state); setValue("TorrentProperties/FilesListState", state);
@@ -2190,7 +2200,7 @@ void Preferences::setPropVisible(const bool visible)
QByteArray Preferences::getPropTrackerListState() const QByteArray Preferences::getPropTrackerListState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
return value("TorrentProperties/Trackers/qt5/TrackerListState").toByteArray(); return value("TorrentProperties/Trackers/qt5/TrackerListState").toByteArray();
#else #else
return value("TorrentProperties/Trackers/TrackerListState").toByteArray(); return value("TorrentProperties/Trackers/TrackerListState").toByteArray();
@@ -2199,7 +2209,7 @@ QByteArray Preferences::getPropTrackerListState() const
void Preferences::setPropTrackerListState(const QByteArray &state) void Preferences::setPropTrackerListState(const QByteArray &state)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
setValue("TorrentProperties/Trackers/qt5/TrackerListState", state); setValue("TorrentProperties/Trackers/qt5/TrackerListState", state);
#else #else
setValue("TorrentProperties/Trackers/TrackerListState", state); setValue("TorrentProperties/Trackers/TrackerListState", state);
@@ -2218,7 +2228,7 @@ void Preferences::setRssGeometry(const QByteArray &geometry)
QByteArray Preferences::getRssHSplitterSizes() const QByteArray Preferences::getRssHSplitterSizes() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
return value("RssFeedDownloader/qt5/hsplitterSizes").toByteArray(); return value("RssFeedDownloader/qt5/hsplitterSizes").toByteArray();
#else #else
return value("RssFeedDownloader/hsplitterSizes").toByteArray(); return value("RssFeedDownloader/hsplitterSizes").toByteArray();
@@ -2227,7 +2237,7 @@ QByteArray Preferences::getRssHSplitterSizes() const
void Preferences::setRssHSplitterSizes(const QByteArray &sizes) void Preferences::setRssHSplitterSizes(const QByteArray &sizes)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
setValue("RssFeedDownloader/qt5/hsplitterSizes", sizes); setValue("RssFeedDownloader/qt5/hsplitterSizes", sizes);
#else #else
setValue("RssFeedDownloader/hsplitterSizes", sizes); setValue("RssFeedDownloader/hsplitterSizes", sizes);
@@ -2246,7 +2256,7 @@ void Preferences::setRssOpenFolders(const QStringList &folders)
QByteArray Preferences::getRssHSplitterState() const QByteArray Preferences::getRssHSplitterState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
return value("Rss/qt5/splitter_h").toByteArray(); return value("Rss/qt5/splitter_h").toByteArray();
#else #else
return value("Rss/splitter_h").toByteArray(); return value("Rss/splitter_h").toByteArray();
@@ -2255,7 +2265,7 @@ QByteArray Preferences::getRssHSplitterState() const
void Preferences::setRssHSplitterState(const QByteArray &state) void Preferences::setRssHSplitterState(const QByteArray &state)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
setValue("Rss/qt5/splitter_h", state); setValue("Rss/qt5/splitter_h", state);
#else #else
setValue("Rss/splitter_h", state); setValue("Rss/splitter_h", state);
@@ -2264,7 +2274,7 @@ void Preferences::setRssHSplitterState(const QByteArray &state)
QByteArray Preferences::getRssVSplitterState() const QByteArray Preferences::getRssVSplitterState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
return value("Rss/qt5/splitter_v").toByteArray(); return value("Rss/qt5/splitter_v").toByteArray();
#else #else
return value("Rss/splitter_v").toByteArray(); return value("Rss/splitter_v").toByteArray();
@@ -2273,7 +2283,7 @@ QByteArray Preferences::getRssVSplitterState() const
void Preferences::setRssVSplitterState(const QByteArray &state) void Preferences::setRssVSplitterState(const QByteArray &state)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
setValue("Rss/qt5/splitter_v", state); setValue("Rss/qt5/splitter_v", state);
#else #else
setValue("Rss/splitter_v", state); setValue("Rss/splitter_v", state);
@@ -2412,7 +2422,7 @@ void Preferences::setTransSelFilter(const int &index)
QByteArray Preferences::getTransHeaderState() const QByteArray Preferences::getTransHeaderState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
return value("TransferList/qt5/HeaderState").toByteArray(); return value("TransferList/qt5/HeaderState").toByteArray();
#else #else
return value("TransferList/HeaderState").toByteArray(); return value("TransferList/HeaderState").toByteArray();
@@ -2421,7 +2431,7 @@ QByteArray Preferences::getTransHeaderState() const
void Preferences::setTransHeaderState(const QByteArray &state) void Preferences::setTransHeaderState(const QByteArray &state)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
setValue("TransferList/qt5/HeaderState", state); setValue("TransferList/qt5/HeaderState", state);
#else #else
setValue("TransferList/HeaderState", state); setValue("TransferList/HeaderState", state);

View File

@@ -41,7 +41,7 @@
#include <QNetworkCookie> #include <QNetworkCookie>
#include <QVariant> #include <QVariant>
#include "core/types.h" #include "base/types.h"
enum scheduler_days enum scheduler_days
{ {
@@ -160,6 +160,8 @@ public:
void setTempPathEnabled(bool enabled); void setTempPathEnabled(bool enabled);
QString getTempPath() const; QString getTempPath() const;
void setTempPath(const QString &path); void setTempPath(const QString &path);
QString getDefaultLabel() const;
void setDefaultLabel(const QString &defaultLabel);
bool useIncompleteFilesExtension() const; bool useIncompleteFilesExtension() const;
void useIncompleteFilesExtension(bool enabled); void useIncompleteFilesExtension(bool enabled);
bool appendTorrentLabel() const; bool appendTorrentLabel() const;

View File

@@ -55,7 +55,7 @@
#include <winbase.h> #include <winbase.h>
#endif #endif
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) #ifndef QBT_USES_QT5
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
#include <QDesktopServices> #include <QDesktopServices>
@@ -182,7 +182,7 @@ bool Utils::Fs::forceRemove(const QString& file_path)
*/ */
void Utils::Fs::removeDirRecursive(const QString& dirName) void Utils::Fs::removeDirRecursive(const QString& dirName)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
QDir(dirName).removeRecursively(); QDir(dirName).removeRecursively();
#else #else
QDir dir(dirName); QDir dir(dirName);
@@ -250,13 +250,15 @@ bool Utils::Fs::sameFiles(const QString& path1, const QString& path2)
return same; return same;
} }
QString Utils::Fs::toValidFileSystemName(QString filename) QString Utils::Fs::toValidFileSystemName(const QString &filename)
{ {
qDebug("toValidFSName: %s", qPrintable(filename)); static const QRegExp regex("[\\\\/:?\"*<>|]");
const QRegExp regex("[\\\\/:?\"*<>|]");
filename.replace(regex, " "); QString validName = filename.trimmed();
qDebug("toValidFSName, result: %s", qPrintable(filename)); validName.replace(regex, " ");
return filename.trimmed(); qDebug() << "toValidFileSystemName:" << filename << "=>" << validName;
return validName;
} }
bool Utils::Fs::isValidFileSystemName(const QString& filename) bool Utils::Fs::isValidFileSystemName(const QString& filename)
@@ -437,7 +439,7 @@ QString Utils::Fs::QDesktopServicesCacheLocation()
QString Utils::Fs::QDesktopServicesDownloadLocation() QString Utils::Fs::QDesktopServicesDownloadLocation()
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #ifdef QBT_USES_QT5
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
if (QSysInfo::windowsVersion() <= QSysInfo::WV_XP) // Windows XP if (QSysInfo::windowsVersion() <= QSysInfo::WV_XP) // Windows XP
return QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).absoluteFilePath( return QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).absoluteFilePath(

View File

@@ -48,7 +48,7 @@ namespace Utils
QString folderName(const QString& file_path); QString folderName(const QString& file_path);
qint64 computePathSize(const QString& path); qint64 computePathSize(const QString& path);
bool sameFiles(const QString& path1, const QString& path2); bool sameFiles(const QString& path1, const QString& path2);
QString toValidFileSystemName(QString filename); QString toValidFileSystemName(const QString &filename);
bool isValidFileSystemName(const QString& filename); bool isValidFileSystemName(const QString& filename);
qlonglong freeDiskSpaceOnPath(QString path); qlonglong freeDiskSpaceOnPath(QString path);
QString branchPath(const QString& file_path, QString* removed = 0); QString branchPath(const QString& file_path, QString* removed = 0);

View File

@@ -72,9 +72,9 @@ const int UNLEN = 256;
#include <QProcess> #include <QProcess>
#endif #endif
#include "core/utils/string.h" #include "base/utils/string.h"
#include "core/unicodestrings.h" #include "base/unicodestrings.h"
#include "core/logger.h" #include "base/logger.h"
#include "misc.h" #include "misc.h"
#include "fs.h" #include "fs.h"

View File

@@ -39,7 +39,7 @@
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
#include <QUrl> #include <QUrl>
#include "core/types.h" #include "base/types.h"
/* Miscellaneous functions that can be useful */ /* Miscellaneous functions that can be useful */

View File

@@ -36,7 +36,7 @@
#include <QtGlobal> #include <QtGlobal>
#include <libtorrent/version.hpp> #include <libtorrent/version.hpp>
#include <boost/version.hpp> #include <boost/version.hpp>
#include "core/unicodestrings.h" #include "base/unicodestrings.h"
class about : public QDialog, private Ui::AboutDlg{ class about : public QDialog, private Ui::AboutDlg{
Q_OBJECT Q_OBJECT

View File

@@ -35,16 +35,16 @@
#include <QMenu> #include <QMenu>
#include <QFileDialog> #include <QFileDialog>
#include "core/preferences.h" #include "base/preferences.h"
#include "core/net/downloadmanager.h" #include "base/net/downloadmanager.h"
#include "core/net/downloadhandler.h" #include "base/net/downloadhandler.h"
#include "core/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "core/bittorrent/magneturi.h" #include "base/bittorrent/magneturi.h"
#include "core/bittorrent/torrentinfo.h" #include "base/bittorrent/torrentinfo.h"
#include "core/bittorrent/torrenthandle.h" #include "base/bittorrent/torrenthandle.h"
#include "core/utils/fs.h" #include "base/utils/fs.h"
#include "core/utils/misc.h" #include "base/utils/misc.h"
#include "core/unicodestrings.h" #include "base/unicodestrings.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "autoexpandabledialog.h" #include "autoexpandabledialog.h"
#include "messageboxraised.h" #include "messageboxraised.h"
@@ -77,9 +77,16 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent)
// Load labels // Load labels
const QStringList customLabels = pref->getTorrentLabels(); const QStringList customLabels = pref->getTorrentLabels();
const QString defaultLabel = pref->getDefaultLabel();
if (!defaultLabel.isEmpty())
ui->label_combo->addItem(defaultLabel);
ui->label_combo->addItem(""); ui->label_combo->addItem("");
foreach (const QString& label, customLabels) foreach (const QString& label, customLabels)
if (label != defaultLabel)
ui->label_combo->addItem(label); ui->label_combo->addItem(label);
ui->label_combo->model()->sort(0); ui->label_combo->model()->sort(0);
ui->content_tree->header()->setSortIndicator(0, Qt::AscendingOrder); ui->content_tree->header()->setSortIndicator(0, Qt::AscendingOrder);
loadState(); loadState();
@@ -587,6 +594,9 @@ void AddNewTorrentDialog::accept()
// Label // Label
params.label = ui->label_combo->currentText(); params.label = ui->label_combo->currentText();
if (ui->defaultLabel->isChecked())
pref->setDefaultLabel(params.label);
// Save file priorities // Save file priorities
if (m_contentModel) if (m_contentModel)
params.filePriorities = m_contentModel->model()->getFilePriorities(); params.filePriorities = m_contentModel->model()->getFilePriorities();

View File

@@ -35,8 +35,8 @@
#include <QDialog> #include <QDialog>
#include <QUrl> #include <QUrl>
#include "core/bittorrent/infohash.h" #include "base/bittorrent/infohash.h"
#include "core/bittorrent/torrentinfo.h" #include "base/bittorrent/torrentinfo.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { namespace Ui {

View File

@@ -127,6 +127,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QCheckBox" name="defaultLabel">
<property name="text">
<string>Set as default label</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

Some files were not shown because too many files have changed in this diff Show More