Compare commits
44 Commits
release-1.
...
release-0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff277fe5bb | ||
|
|
7140a532ed | ||
|
|
db4f3ab08a | ||
|
|
1deb7b88bc | ||
|
|
0d40bb0d68 | ||
|
|
b033893d39 | ||
|
|
e9693d3829 | ||
|
|
bc7d9d00ab | ||
|
|
0c05c893a0 | ||
|
|
8b3c4f8143 | ||
|
|
90bc79d4e1 | ||
|
|
676d6764b9 | ||
|
|
cb08280180 | ||
|
|
ecede8b53e | ||
|
|
f6a54f6fcf | ||
|
|
6039851f13 | ||
|
|
f1decc5432 | ||
|
|
12629a9e38 | ||
|
|
14f13d0406 | ||
|
|
e0213dc6c3 | ||
|
|
2f065bd9ea | ||
|
|
b87882dd59 | ||
|
|
df06fcac03 | ||
|
|
3de95cdb04 | ||
|
|
062fd6d81c | ||
|
|
82d9e19e96 | ||
|
|
22eead5f9a | ||
|
|
f5627e4345 | ||
|
|
da867a767b | ||
|
|
b751954566 | ||
|
|
f774228529 | ||
|
|
4d6aad8cab | ||
|
|
188e3956d8 | ||
|
|
88d7400644 | ||
|
|
41254bcdf4 | ||
|
|
067aa010b6 | ||
|
|
f94197816c | ||
|
|
78e976e97e | ||
|
|
225d8bcc5b | ||
|
|
9bd29ebdb0 | ||
|
|
7565902fc1 | ||
|
|
0b8a1f8c1f | ||
|
|
8800614077 | ||
|
|
156001f51d |
7
AUTHORS
@@ -1,6 +1 @@
|
|||||||
Author:
|
Christophe Dumez <chris@qbittorrent.org>
|
||||||
* Christophe Dumez <chris@qbittorrent.org>
|
|
||||||
|
|
||||||
Contributors:
|
|
||||||
* Arnaud Demaizière <arnaud@qbittorrent.org>
|
|
||||||
* Ishan Arora <ishanarora@gmail.com>
|
|
||||||
|
|||||||
121
Changelog
@@ -1,119 +1,10 @@
|
|||||||
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.1.0
|
|
||||||
- FEATURE: Web interface to control qbittorrent (Ishan Arora)
|
|
||||||
- FEATURE: Can spoof Azureus peer id to avoid ban
|
|
||||||
- FEATURE: Allow to hide/show some columns in download and seeding lists
|
|
||||||
- FEATURE: Option to start qBittorrent minimized in systray
|
|
||||||
- FEATURE: Allow to define double-click actions in torrents lists
|
|
||||||
- FEATURE: Allow to open torrent destination folder
|
|
||||||
- FEATURE: Real progress bar in torrent properties that displays downloaded pieces
|
|
||||||
- FEATURE: Allow to buy downloads using ShareMonkey
|
|
||||||
- FEATURE: Display if UPnP/NAT-PMP was successful or not
|
|
||||||
- FEATURE: Threadified torrent creation
|
|
||||||
- FEATURE: Improved eMule DAT ip filter parser
|
|
||||||
- FEATURE: Added support for PeerGuardian p2p filters (text)
|
|
||||||
- FEATURE: Added support for PeerGuardian p2b filters (binary)
|
|
||||||
- FEATURE: Allow to customize folder scan interval
|
|
||||||
- FEATURE: Allow to add several trackers at once
|
|
||||||
- BUGFIX: Do not display seeds number in seeding list (always 0)
|
|
||||||
- BUGFIX: Threadified IP filter file parser to avoid GUI freeze
|
|
||||||
- COSMETIC: Do not display progress bar in seeding list (always 100%)
|
|
||||||
- COSMETIC: Added a progress bar for torrent creation
|
|
||||||
- COSMETIC: Display tracker errors in a cleaner way
|
|
||||||
- COSMETIC: Display "unpaused/total_torrent" in download/upload tabs
|
|
||||||
- COSMETIC: Allow to resize RSS column
|
|
||||||
- COSMETIC: Global UP/DL speeds and ratio are displayed above tabs
|
|
||||||
|
|
||||||
* Fri Apr 11 2008 - Christophe Dumez <chris@qbittorrent.org> - v1.0.0
|
|
||||||
- FEATURE: Based on new libtorrent v0.13
|
|
||||||
- FEATURE: Added UPnP / NAT-PMP port forwarding support
|
|
||||||
- FEATURE: Added encryption support (compatible with Azureus)
|
|
||||||
- FEATURE: Bittorrent FAST extension support
|
|
||||||
- FEATURE: Added RSS support
|
|
||||||
- FEATURE: Support files prioritizing in a torrent
|
|
||||||
- FEATURE: Brand new search engine plugins system
|
|
||||||
- FEATURE: Filtered files don't appear on hard disk anymore
|
|
||||||
- FEATURE: Finished torrents are now moved to another tab for seeding
|
|
||||||
- FEATURE: Display more infos about the torrent in its properties
|
|
||||||
- FEATURE: Allow the user to edit torrents' trackers
|
|
||||||
- FEATURE: Allow user to change qBT's style (Plastique, Cleanlooks, Motif, CDE, MacOSX, WinXP)
|
|
||||||
- FEATURE: Allow the user to disable system tray integration
|
|
||||||
- FEATURE: Search engine is now using one thread per website for faster results
|
|
||||||
- FEATURE: Improved a lot the torrent creation module
|
|
||||||
- FEATURE: Allow to set upload/download limit per torrent (right click)
|
|
||||||
- FEATURE: Ask for exit confirmation only if download list is not empty
|
|
||||||
- FEATURE: Allow to use a proxy for trackers / web seeds / peers / DHT connections
|
|
||||||
- FEATURE: Supports SOCKS5 proxies as well as HTTP ones
|
|
||||||
- FEATURE: Better systems integration (buttons, dialogs...)
|
|
||||||
- FEATURE: Filtered files are not allocated on the hard-drive anymore (sparse file support)
|
|
||||||
- FEATURE: IPs blocked by filter are now logged in GUI
|
|
||||||
- FEATURE: Added a way to link against static libtorrent (useful for deb packages)
|
|
||||||
- FEATURE: Allow to set global upload/download limits from tray icon menu
|
|
||||||
- FEATURE: IPv6 is now fully supported
|
|
||||||
- FEATURE: Real torrent share ratio is now displayed in transfer list
|
|
||||||
- FEATURE: Added keyboard shortcuts for main actions (see wiki)
|
|
||||||
- FEATURE: Added a popup menu to set priority for multiple files at once
|
|
||||||
- FEATURE: Improved a lot downloading from urls (using libcommoncpp2 instead of libcurl)
|
|
||||||
- FEATURE: A search request can now be terminated by another
|
|
||||||
- FEATURE: User is now warned when fast resume data was rejected
|
|
||||||
- FEATURE: Url seeds are now displayed in torrent properties and are editable
|
|
||||||
- FEATURE: Allow to drag 'n drop urls on the main window
|
|
||||||
- FEATURE: Improved search engine (multipage support in all plugins)
|
|
||||||
- FEATURE: Added BTJunkie search engine plugin
|
|
||||||
- FEATURE: Added an option to force full disk allocation for all torrents
|
|
||||||
- FEATURE: Added an option to add torrents in paused state
|
|
||||||
- FEATURE: Added an option to set the max number of connections per torrent
|
|
||||||
- FEATURE: Added an option to set the max number of uploads per torrent
|
|
||||||
- FEATURE: Added an option to automatically delete torrents when they reach a given ratio (>= 1.0)
|
|
||||||
- FEATURE: Added an option to display current transfer speeds in title bar
|
|
||||||
- FEATURE: Torrent content is now displayed as a tree
|
|
||||||
- I18N: Added Hungarian translation
|
|
||||||
- I18N: Added Brazilian translation
|
|
||||||
- BUGFIX: Progress of paused torrents is now correct on restart
|
|
||||||
- BUGFIX: Progress column gets sorted on restart it is was during last execution
|
|
||||||
- BUGFIX: Made ETA more reliable using stats instead of instant values
|
|
||||||
- BUGFIX: Remove torrent from hard drive used to delete parent folder if empty
|
|
||||||
- BUGFIX: Fixed a crash when filtering all the files in a torrent
|
|
||||||
- BUGFIX: Reload torrent only when necessary (properties)
|
|
||||||
- BUGFIX: qBittorrent is not exiting anymore when a dialog is closed and main window is hidden
|
|
||||||
- BUGFIX: Search plugin update is not making the GUI freeze anymore (moved to a thread)
|
|
||||||
- BUGFIX: DHT settings were not saved correctly
|
|
||||||
- BUGFIX: Workaround to build on Fedora system (pkg-config problem)
|
|
||||||
- BUGFIX: search plugin update - do not display only last version changelog
|
|
||||||
- BUGFIX: Search plugin update - fixed missing new lines in changelog
|
|
||||||
- BUGFIX: The number of search results was not reset when clicking on 'Clear' button
|
|
||||||
- BUGFIX: Update torrent progress when its content changed (filtered files)
|
|
||||||
- BUGFIX: Improved the way menu icons are installed to avoid problems on some systems
|
|
||||||
- BUGFIX: Improved incremental download
|
|
||||||
- BUGFIX: Improved unicode support
|
|
||||||
- BUGFIX: Made torrent deletion from hard-drive safer
|
|
||||||
- BUGFIX: Prevent downloadFromUrl flooding
|
|
||||||
- BUGFIX: ETA was wrong for torrents with filtered files
|
|
||||||
- BUGFIX: Fixed drag'n drop on non-KDE systems
|
|
||||||
- BUGFIX: Removed build dependency on Python
|
|
||||||
- BUGFIX: Catching DHT exception in case there is a problem
|
|
||||||
- COSMETIC: Redesigned torrent properties a little
|
|
||||||
- COSMETIC: Totally redesigned program preferences
|
|
||||||
- COSMETIC: Display more logs messages concerning features
|
|
||||||
- COSMETIC: Improved lists renderers
|
|
||||||
- COSMETIC: Use a different icon for torrents being checked and for connecting ones
|
|
||||||
- COSMETIC: Improved some icons
|
|
||||||
- COSMETIC: Improved systray tooltip style
|
|
||||||
|
|
||||||
* Mon May 07 2007 - Christophe Dumez <chris@qbittorrent.org> - v0.9.3
|
|
||||||
- BUGFIX: Fixed pause toggle on double-click in download list
|
|
||||||
- BUGFIX: The torrent size displayed now only takes unfiltered files into account
|
|
||||||
- BUGFIX: Fixed compiling errors with libtorrent svn (future v0.13 with UPnP enabled)
|
|
||||||
- BUGFIX: Remember sorted column in download list on restart
|
|
||||||
- BUGFIX: Small fix in the german translation
|
|
||||||
- BUGFIX: Some fixes in slovak translation
|
|
||||||
|
|
||||||
* Tue Apr 10 2007 - Christophe Dumez <chris@qbittorrent.org> - v0.9.2
|
* Tue Apr 10 2007 - Christophe Dumez <chris@qbittorrent.org> - v0.9.2
|
||||||
- BUGFIX: Window can now stay maximized on exit
|
- BUGFIX: Window can now stay maximized on exit
|
||||||
- BUGFIX: Use PKGCONFIG again for configuring libtorrent
|
- BUGFIX: Use PKGCONFIG again for configuring libtorrent
|
||||||
- BUGFIX: Allow to compile with libtorrent v0.11
|
- BUGFIX: Allow to compile with libtorrent v0.11
|
||||||
- BUGFIX: Disabled main window context menu (annoying)
|
- BUGFIX: Disabled main window context menu (annoying)
|
||||||
- I18N: Added Japanese translation
|
- I18N: Added Japanese translation
|
||||||
- I18N: Updated Turkish translation
|
- I18N: Updated Turkish translation
|
||||||
|
|
||||||
* Wed Apr 04 2007 - Christophe Dumez <chris@qbittorrent.org> - v0.9.1
|
* Wed Apr 04 2007 - Christophe Dumez <chris@qbittorrent.org> - v0.9.1
|
||||||
- BUGFIX: A lot of fixes in configure file
|
- BUGFIX: A lot of fixes in configure file
|
||||||
|
|||||||
26
INSTALL
@@ -1,4 +1,4 @@
|
|||||||
qBittorrent - A BitTorrent client in C++ / Qt4
|
qBittorrent - A BitTorrent client in C++ / Qt4.2
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
*** Necessary if qt3 is default on your system ***
|
*** Necessary if qt3 is default on your system ***
|
||||||
@@ -14,12 +14,11 @@ qbittorrent
|
|||||||
will install and execute qBittorrent hopefully without any problems.
|
will install and execute qBittorrent hopefully without any problems.
|
||||||
|
|
||||||
Dependencies:
|
Dependencies:
|
||||||
- Qt >= 4.3.0 (libqt-devel, libqtgui, libqtcore, libqtnetwork, libqtxml)
|
- Qt >= 4.2 (libqt-devel, libqtgui, libqtcore, libqtnetwork)
|
||||||
|
|
||||||
- rblibtorrent by Arvid Norberg (>= v0.13 REQUIRED)
|
- libtorrent by Arvid Norberg (>= v0.11 REQUIRED, >= 0.12 ADVISED)
|
||||||
-> http://www.qbittorrent.org/download.php (advised)
|
-> http://libtorrent.sf.net
|
||||||
-> http://www.libtorrent.net
|
Be carefull: another library (the one used by rtorrent) use the same name.
|
||||||
Be careful: another library (the one used by rTorrent) use the same name.
|
|
||||||
These are TWO different libraries and qBittorrent will only work with the one provided
|
These are TWO different libraries and qBittorrent will only work with the one provided
|
||||||
on sourceforge (created by Arvid Norberg). The two libraries conflicts with each other.
|
on sourceforge (created by Arvid Norberg). The two libraries conflicts with each other.
|
||||||
|
|
||||||
@@ -27,20 +26,11 @@ Dependencies:
|
|||||||
|
|
||||||
- libcurl
|
- libcurl
|
||||||
|
|
||||||
- python >= 2.3 (needed by search engine)
|
- python >= 2.3 (previous might work - not tested): needed by search engine.
|
||||||
|
|
||||||
- libmagick++ (advised, not required)
|
NOTE FOR GNOME USERS:
|
||||||
* Needed for favicons support (RSS / Search plugins)
|
- qt4-qtconfig package is advised or qBittorrent interface will be ugly
|
||||||
|
|
||||||
- libzzip (advised, not required)
|
|
||||||
* Needed for zip support (Search plugins)
|
|
||||||
|
|
||||||
NOTE FOR NON-KDE USERS:
|
|
||||||
- qt4-qtconfig package is advised when using other systems than KDE.
|
|
||||||
You can also change qBittorrent style to Cleanlooks (GNOME like)
|
|
||||||
|
|
||||||
DOCUMENTATION:
|
|
||||||
Please note that there is a documentation with a "compiling howto" at http://wiki.qbittorrent.org.
|
|
||||||
|
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
Christophe Dumez <chris@qbittorrent.org>
|
Christophe Dumez <chris@qbittorrent.org>
|
||||||
|
|||||||
16
README
@@ -1,32 +1,32 @@
|
|||||||
qBittorrent - A BitTorrent client in Qt4
|
qBittorrent - A BitTorrent client in Qt4.2
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
Description:
|
Description:
|
||||||
********************************
|
********************************
|
||||||
qBittorrent is a bittorrent client programmed in C++ / Qt4 that uses
|
qBittorrent is a bittorrent client programmed in C++ / Qt4.2 that use
|
||||||
libtorrent (sometimes called rblibtorrent) by Arvid Norberg.
|
libtorrent (sometimes called rb_libtorrent) by Arvid Norberg.
|
||||||
|
|
||||||
It aims to be a good alternative to all other bittorrent clients
|
It aims to be a good alternative to all other bittorrent clients
|
||||||
out there. qBittorrent is fast, stable and provides unicode
|
out there. qBittorrent is fast, stable and provides unicode
|
||||||
support as well as many features.
|
support.
|
||||||
|
|
||||||
Installation:
|
Installation:
|
||||||
********************************
|
********************************
|
||||||
For installation, follow the instructions from INSTALL file, but simple:
|
For installation follow the instructions from INSTALL file, but simple
|
||||||
|
|
||||||
./configure
|
./configure
|
||||||
make && make install
|
make && make install
|
||||||
qbittorrent
|
qbittorrent
|
||||||
|
|
||||||
will install and execute qBittorrent hopefully without any problem.
|
will install and execute qBittorrent hopefully without any problems.
|
||||||
|
|
||||||
For more information please visit:
|
For more information please visit:
|
||||||
http://www.qbittorrent.org
|
http://www.qbittorrent.org
|
||||||
|
|
||||||
Please report any bug (or feature request) to:
|
Please report any bug (or feature requests) to:
|
||||||
http://bugs.qbittorrent.org
|
http://bugs.qbittorrent.org
|
||||||
|
|
||||||
You can also meet me (chris-qBT) on IRC:
|
You can also meet me on IRC:
|
||||||
#qbittorrent on irc.freenode.net
|
#qbittorrent on irc.freenode.net
|
||||||
|
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|||||||
50
TODO
@@ -1,37 +1,41 @@
|
|||||||
// Easy
|
// Easy
|
||||||
|
- Write documentation
|
||||||
- Translations into as many languages as possible
|
- Translations into as many languages as possible
|
||||||
- Use Launchpad/Rosetta for translations once it supports TS files
|
- Improve man page
|
||||||
|
- Add more keyboard shortcuts
|
||||||
|
|
||||||
// Intermediate
|
// Intermediate
|
||||||
- Port on MacOS, Windows (and create an installer for Windows) - Slow progress
|
- Port on MacOS, Windows (and create an installer for Windows) - Progressing
|
||||||
- Add some transparency (menus,...), improve look / usabilty
|
- Add some transparency (menus,...)
|
||||||
- Skins support? (contact Mateusz)
|
- Add upnp port forwarding support
|
||||||
|
|
||||||
// Harder
|
// Harder
|
||||||
- Torrent scheduler ala µtorrent/Bitcomet
|
- Allow user to organize the downloads into categories/folders
|
||||||
|
- Display new searches in new tabs
|
||||||
|
- Display a progress bar that really displays the pieces we have (like in eMule)
|
||||||
|
|
||||||
// Waiting for libtorrent
|
// Waiting for libtorrent
|
||||||
- Allow to prioritize torrents (may code this in qBittorrent?)
|
- Encryption support (v0.13?)
|
||||||
|
- File selection in a torrent in compact mode
|
||||||
|
- Allow to prioritize files within a torrent
|
||||||
|
- Allow to prioritize torrents
|
||||||
|
|
||||||
// Unsure
|
// Unsure
|
||||||
- Display the peers we are connected to for each torrent with infos (like flag, dl/up speeds, ...)
|
|
||||||
- Azureus spoofing to prevent ban from trackers?
|
- Azureus spoofing to prevent ban from trackers?
|
||||||
|
- Web interface?
|
||||||
|
- Use downloader class to download search plugin updates
|
||||||
|
- Allow to set upload limit for each torrent
|
||||||
- Option to shutdown computer when downloads are finished
|
- Option to shutdown computer when downloads are finished
|
||||||
- NAT checker/Tester
|
- Add a torrent scheduler
|
||||||
- Display hard drive space left?
|
|
||||||
- Make use of dbus on Linux for the single instance instead of socket communication?
|
|
||||||
(http://techbase.kde.org/Development/Tutorials/D-Bus/Accessing_Interfaces)
|
|
||||||
- When favicon can't be downloaded, try to parse the webpage for:
|
|
||||||
<link rel="icon" href="http://example.com/favicon.ico" type="image/vnd.microsoft.icon">
|
|
||||||
* Be careful, the link can be relative
|
|
||||||
- Improve search plugin install (choose in a list taken from plugins.qbittorrent.org)
|
|
||||||
- support zipped torrents? (useful?)
|
|
||||||
- Allow to limit the number of downloading torrents simultaneously (other are paused until a download finishes)
|
|
||||||
|
|
||||||
// in v1.2.0
|
// in v1.0.0 (partial)
|
||||||
- Allow user to organize the downloads into categories/folders?
|
- Download from RSS feeds (WIP by gtsoul)
|
||||||
|
- Move finished torrent to another tab and keep on seeding them even after restart
|
||||||
// in v1.1.0
|
- Allow to edit the trackers for a torrent
|
||||||
- Stop calculating ETAs when ETA column is hidden
|
- Improve torrent creation dialog (look & features)
|
||||||
-> See https://blueprints.launchpad.net/qbittorrent
|
- Add IPv6 support (at least start working on it)
|
||||||
|
- UPnP support?
|
||||||
|
|
||||||
|
// In v0.9.0
|
||||||
|
- Update translations (FR, SV, NB, PL, RU, DE, SK, KO, ZH_CN, EL, BG, ES, DA, UK, PT, IT, NL done)
|
||||||
|
- Wait for libtorrent v0.12 official release
|
||||||
|
|||||||
413
configure
vendored
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Generated by qconf 1.4 ( http://delta.affinix.com/qconf/ )
|
# Generated by qconf 1.3 ( http://delta.affinix.com/qconf/ )
|
||||||
#
|
#
|
||||||
|
|
||||||
show_usage() {
|
show_usage() {
|
||||||
@@ -18,18 +18,11 @@ Main options:
|
|||||||
--help This help text.
|
--help This help text.
|
||||||
|
|
||||||
Dependency options:
|
Dependency options:
|
||||||
--with-libtorrent-inc=[path] Path to libtorrent include files
|
--with-libtorrent-inc=[path] Path to libtorrent include files
|
||||||
--with-libtorrent-lib=[path] Path to libtorrent library files
|
--with-libtorrent-lib=[path] Path to libtorrent library files
|
||||||
--with-libtorrent-static-lib=[path] Path to libtorrent .a file
|
--with-libboost-inc=[path] Path to libboost include files
|
||||||
--with-libboost-inc=[path] Path to libboost include files
|
--with-libcurl-inc=[path] Path to libcurl include files
|
||||||
--with-libcurl-inc=[path] Path to libcurl include files
|
--with-libcurl-lib=[path] Path to libcurl library files
|
||||||
--with-libcurl-lib=[path] Path to libcurl library files
|
|
||||||
--disable-libmagick Disable use of libmagick
|
|
||||||
--with-libmagick-inc=[path] Path to libmagick++ include files
|
|
||||||
--with-libmagick-lib=[path] Path to libmagick++ library files
|
|
||||||
--disable-libzzip Disable use of libzzip
|
|
||||||
--with-libzzip-inc=[path] Path to libzzip++ include files
|
|
||||||
--with-libzzip-lib=[path] Path to libzzip++ library files
|
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
}
|
}
|
||||||
@@ -156,11 +149,6 @@ while [ $# -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--with-libtorrent-static-lib=*)
|
|
||||||
QC_WITH_LIBTORRENT_STATIC_LIB=$optarg
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
--with-libboost-inc=*)
|
--with-libboost-inc=*)
|
||||||
QC_WITH_LIBBOOST_INC=$optarg
|
QC_WITH_LIBBOOST_INC=$optarg
|
||||||
shift
|
shift
|
||||||
@@ -176,38 +164,8 @@ while [ $# -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--disable-libmagick)
|
|
||||||
QC_DISABLE_libmagick="Y"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
--with-libmagick-inc=*)
|
|
||||||
QC_WITH_LIBMAGICK_INC=$optarg
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
--with-libmagick-lib=*)
|
|
||||||
QC_WITH_LIBMAGICK_LIB=$optarg
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
--disable-libzzip)
|
|
||||||
QC_DISABLE_libzzip="Y"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
--with-libzzip-inc=*)
|
|
||||||
QC_WITH_LIBZZIP_INC=$optarg
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
--with-libzzip-lib=*)
|
|
||||||
QC_WITH_LIBZZIP_LIB=$optarg
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
--verbose)
|
--verbose)
|
||||||
QC_VERBOSE="Y"
|
QC_DEBUG="Y"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--help) show_usage; exit ;;
|
--help) show_usage; exit ;;
|
||||||
@@ -221,7 +179,7 @@ DATADIR=${DATADIR:-$PREFIX/share}
|
|||||||
|
|
||||||
echo "Configuring qbittorrent ..."
|
echo "Configuring qbittorrent ..."
|
||||||
|
|
||||||
if [ "$QC_VERBOSE" = "Y" ]; then
|
if [ "$QC_DEBUG" = "Y" ]; then
|
||||||
echo
|
echo
|
||||||
echo PREFIX=$PREFIX
|
echo PREFIX=$PREFIX
|
||||||
echo BINDIR=$BINDIR
|
echo BINDIR=$BINDIR
|
||||||
@@ -229,65 +187,39 @@ echo DATADIR=$DATADIR
|
|||||||
echo EX_QTDIR=$EX_QTDIR
|
echo EX_QTDIR=$EX_QTDIR
|
||||||
echo QC_WITH_LIBTORRENT_INC=$QC_WITH_LIBTORRENT_INC
|
echo QC_WITH_LIBTORRENT_INC=$QC_WITH_LIBTORRENT_INC
|
||||||
echo QC_WITH_LIBTORRENT_LIB=$QC_WITH_LIBTORRENT_LIB
|
echo QC_WITH_LIBTORRENT_LIB=$QC_WITH_LIBTORRENT_LIB
|
||||||
echo QC_WITH_LIBTORRENT_STATIC_LIB=$QC_WITH_LIBTORRENT_STATIC_LIB
|
|
||||||
echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC
|
echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC
|
||||||
echo QC_WITH_LIBCURL_INC=$QC_WITH_LIBCURL_INC
|
echo QC_WITH_LIBCURL_INC=$QC_WITH_LIBCURL_INC
|
||||||
echo QC_WITH_LIBCURL_LIB=$QC_WITH_LIBCURL_LIB
|
echo QC_WITH_LIBCURL_LIB=$QC_WITH_LIBCURL_LIB
|
||||||
echo QC_DISABLE_libmagick=$QC_DISABLE_libmagick
|
|
||||||
echo QC_WITH_LIBMAGICK_INC=$QC_WITH_LIBMAGICK_INC
|
|
||||||
echo QC_WITH_LIBMAGICK_LIB=$QC_WITH_LIBMAGICK_LIB
|
|
||||||
echo QC_DISABLE_libzzip=$QC_DISABLE_libzzip
|
|
||||||
echo QC_WITH_LIBZZIP_INC=$QC_WITH_LIBZZIP_INC
|
|
||||||
echo QC_WITH_LIBZZIP_LIB=$QC_WITH_LIBZZIP_LIB
|
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "Verifying Qt 4 build environment ... "
|
printf "Verifying Qt 4 build environment ... "
|
||||||
|
|
||||||
# run qmake -v and check version
|
if [ "$QC_DEBUG" = "Y" ]; then
|
||||||
qmake_check_v4() {
|
|
||||||
if [ -x "$1" ]; then
|
|
||||||
if echo `$1 -v 2>&1` | grep "Qt version 4\." >/dev/null 2>&1; then
|
|
||||||
return 0
|
|
||||||
elif [ "$QC_VERBOSE" = "Y" ]; then
|
|
||||||
echo "Warning: $1 not for Qt 4"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "$QC_VERBOSE" = "Y" ]; then
|
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
qm=""
|
qm=""
|
||||||
names="qmake-qt4 qmake4 qmake"
|
|
||||||
|
|
||||||
# qt4 check: --qtdir
|
# qt4 check: --qtdir
|
||||||
if [ -z "$qm" ] && [ ! -z "$EX_QTDIR" ]; then
|
if [ -z "$qm" ]; then
|
||||||
for n in $names; do
|
qstr=$EX_QTDIR/bin/qmake
|
||||||
qstr=$EX_QTDIR/bin/$n
|
if [ -x "$qstr" ]; then
|
||||||
if qmake_check_v4 "$qstr"; then
|
qm=$qstr
|
||||||
qm=$qstr
|
fi
|
||||||
break;
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
|
if [ -z "$qm" ] && [ "$QC_DEBUG" = "Y" ]; then
|
||||||
echo "Warning: qmake not found via --qtdir"
|
echo "Warning: qmake not found via --qtdir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# qt4 check: QTDIR
|
# qt4 check: QTDIR
|
||||||
if [ -z "$qm" ] && [ ! -z "$QTDIR" ]; then
|
if [ -z "$qm" ]; then
|
||||||
for n in $names; do
|
qstr=$QTDIR/bin/qmake
|
||||||
qstr=$QTDIR/bin/$n
|
if [ -x "$qstr" ]; then
|
||||||
if qmake_check_v4 "$qstr"; then
|
qm=$qstr
|
||||||
qm=$qstr
|
fi
|
||||||
break;
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
|
if [ -z "$qm" ] && [ "$QC_DEBUG" = "Y" ]; then
|
||||||
echo "Warning: qmake not found via \$QTDIR"
|
echo "Warning: qmake not found via \$QTDIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -295,66 +227,60 @@ fi
|
|||||||
if [ -z "$qm" ]; then
|
if [ -z "$qm" ]; then
|
||||||
str=`pkg-config QtCore --variable=exec_prefix 2>/dev/null`
|
str=`pkg-config QtCore --variable=exec_prefix 2>/dev/null`
|
||||||
if [ ! -z "$str" ]; then
|
if [ ! -z "$str" ]; then
|
||||||
for n in $names; do
|
qstr=$str/bin/qmake
|
||||||
qstr=$str/bin/$n
|
if [ -x "$qstr" ]; then
|
||||||
if qmake_check_v4 "$qstr"; then
|
qm=$qstr
|
||||||
qm=$qstr
|
fi
|
||||||
break;
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
|
if [ -z "$qm" ] && [ "$QC_DEBUG" = "Y" ]; then
|
||||||
echo "Warning: qmake not found via pkg-config"
|
echo "Warning: qmake not found via pkg-config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# qt4 check: PATH
|
# qt4 check: PATH
|
||||||
if [ -z "$qm" ]; then
|
if [ -z "$qm" ]; then
|
||||||
for n in $names; do
|
qstr=`$WHICH qmake 2>/dev/null`
|
||||||
qstr=`$WHICH $n 2>/dev/null`
|
if [ -x "$qstr" ]; then
|
||||||
if qmake_check_v4 "$qstr"; then
|
qm=$qstr
|
||||||
qm=$qstr
|
fi
|
||||||
break;
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
|
if [ -z "$qm" ] && [ "$QC_DEBUG" = "Y" ]; then
|
||||||
echo "Warning: qmake not found via \$PATH"
|
echo "Warning: qmake not found via \$PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$qm" ]; then
|
if [ -z "$qm" ]; then
|
||||||
if [ "$QC_VERBOSE" = "Y" ]; then
|
if [ "$QC_DEBUG" = "Y" ]; then
|
||||||
echo " -> fail"
|
echo " -> fail"
|
||||||
else
|
else
|
||||||
echo "fail"
|
echo "fail"
|
||||||
fi
|
fi
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf "Reason: Unable to find the 'qmake' tool for Qt 4.\n"
|
printf "Reason: Unable to find the 'qmake' tool.\n"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
show_qt_info
|
show_qt_info
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
if [ "$QC_VERBOSE" = "Y" ]; then
|
if [ "$QC_DEBUG" = "Y" ]; then
|
||||||
echo qmake found in $qm
|
echo qmake found in $qm
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gen_files() {
|
gen_files() {
|
||||||
cat >$1/modules.cpp <<EOT
|
cat >$1/modules.cpp <<EOT
|
||||||
#line 1 "qt4.qcm"
|
#line 1 "qt42.qcm"
|
||||||
/*
|
/*
|
||||||
-----BEGIN QCMOD-----
|
-----BEGIN QCMOD-----
|
||||||
name: Qt >= 4.3
|
name: Qt >= 4.2
|
||||||
-----END QCMOD-----
|
-----END QCMOD-----
|
||||||
*/
|
*/
|
||||||
class qc_qt4 : public ConfObj
|
class qc_qt42 : public ConfObj
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
qc_qt4(Conf *c) : ConfObj(c) {}
|
qc_qt42(Conf *c) : ConfObj(c) {}
|
||||||
QString name() const { return "Qt >= 4.3"; }
|
QString name() const { return "Qt >= 4.2"; }
|
||||||
QString shortname() const { return "Qt 4.3"; }
|
QString shortname() const { return "qt42"; }
|
||||||
bool exec()
|
bool exec()
|
||||||
{
|
{
|
||||||
return(QT_VERSION >= 0x040300);
|
return(QT_VERSION >= 0x040200);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#line 1 "libtorrent.qcm"
|
#line 1 "libtorrent.qcm"
|
||||||
@@ -363,21 +289,24 @@ public:
|
|||||||
name: libtorrent
|
name: libtorrent
|
||||||
arg: with-libtorrent-inc=[path], Path to libtorrent include files
|
arg: with-libtorrent-inc=[path], Path to libtorrent include files
|
||||||
arg: with-libtorrent-lib=[path], Path to libtorrent library files
|
arg: with-libtorrent-lib=[path], Path to libtorrent library files
|
||||||
arg: with-libtorrent-static-lib=[path], Path to libtorrent .a file
|
|
||||||
-----END QCMOD-----
|
-----END QCMOD-----
|
||||||
*/
|
*/
|
||||||
class qc_libtorrent : public ConfObj
|
class qc_libtorrent : public ConfObj
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
qc_libtorrent(Conf *c) : ConfObj(c) {}
|
qc_libtorrent(Conf *c) : ConfObj(c) {}
|
||||||
QString name() const { return "libtorrent >= 0.13"; }
|
QString name() const { return "libtorrent >= 0.11 (>= 0.12 ADVISED)"; }
|
||||||
QString shortname() const { return "libtorrent"; }
|
QString shortname() const { return "libtorrent"; }
|
||||||
bool exec(){
|
bool exec(){
|
||||||
QString s;
|
QString s;
|
||||||
s = conf->getenv("QC_WITH_LIBTORRENT_INC");
|
s = conf->getenv("QC_WITH_LIBTORRENT_INC");
|
||||||
if(!s.isEmpty()) {
|
if(!s.isEmpty()) {
|
||||||
if(!conf->checkHeader(s, "libtorrent/lsd.hpp")) {
|
if(!conf->checkHeader(s, "libtorrent/kademlia/node.hpp")){
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
if(!conf->checkHeader(s, "libtorrent/extensions/ut_pex.hpp")) {
|
||||||
|
qWarning("Libtorrent >= v0.12 was not detected, PeX will be disabled.");
|
||||||
|
conf->addDefine("NO_PEX");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
QStringList sl;
|
QStringList sl;
|
||||||
@@ -385,24 +314,20 @@ public:
|
|||||||
sl << "/usr/local/include";
|
sl << "/usr/local/include";
|
||||||
bool found = false;
|
bool found = false;
|
||||||
foreach(s, sl){
|
foreach(s, sl){
|
||||||
if(conf->checkHeader(s, "libtorrent/lsd.hpp")){
|
if(conf->checkHeader(s, "libtorrent/kademlia/node.hpp")){
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!found) {
|
if(!found) return false;
|
||||||
return false;
|
if(!conf->checkHeader(s, "libtorrent/extensions/ut_pex.hpp")){
|
||||||
}
|
qWarning("Libtorrent >= v0.12 was not detected, PeX will be disabled.");
|
||||||
|
conf->addDefine("NO_PEX");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
conf->addIncludePath(s);
|
conf->addIncludePath(s);
|
||||||
conf->addIncludePath(s+QDir::separator()+"libtorrent");
|
conf->addIncludePath(s+QDir::separator()+"libtorrent");
|
||||||
|
|
||||||
s = conf->getenv("QC_WITH_LIBTORRENT_STATIC_LIB");
|
|
||||||
if(!s.isEmpty() && QFile::exists(s) && s.endsWith(".a")){
|
|
||||||
conf->addLib(s);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
s = conf->getenv("QC_WITH_LIBTORRENT_LIB");
|
s = conf->getenv("QC_WITH_LIBTORRENT_LIB");
|
||||||
if(!s.isEmpty()) {
|
if(!s.isEmpty()) {
|
||||||
if(!conf->checkLibrary(s, "torrent")) {
|
if(!conf->checkLibrary(s, "torrent")) {
|
||||||
@@ -412,9 +337,7 @@ public:
|
|||||||
}else{
|
}else{
|
||||||
QStringList sl;
|
QStringList sl;
|
||||||
sl << "/usr/lib/";
|
sl << "/usr/lib/";
|
||||||
sl << "/usr/lib64/";
|
|
||||||
sl << "/usr/local/lib/";
|
sl << "/usr/local/lib/";
|
||||||
sl << "/usr/local/lib64/";
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
foreach(s, sl){
|
foreach(s, sl){
|
||||||
if(conf->checkLibrary(s, "torrent")){
|
if(conf->checkLibrary(s, "torrent")){
|
||||||
@@ -425,6 +348,7 @@ public:
|
|||||||
if(!found) return false;
|
if(!found) return false;
|
||||||
conf->addLib(QString("-L") + s);
|
conf->addLib(QString("-L") + s);
|
||||||
}
|
}
|
||||||
|
//conf->addLib("-ltorrent");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -488,7 +412,7 @@ public:
|
|||||||
#line 1 "libcurl.qcm"
|
#line 1 "libcurl.qcm"
|
||||||
/*
|
/*
|
||||||
-----BEGIN QCMOD-----
|
-----BEGIN QCMOD-----
|
||||||
name: libcommoncpp2
|
name: libcurl
|
||||||
arg: with-libcurl-inc=[path], Path to libcurl include files
|
arg: with-libcurl-inc=[path], Path to libcurl include files
|
||||||
arg: with-libcurl-lib=[path], Path to libcurl library files
|
arg: with-libcurl-lib=[path], Path to libcurl library files
|
||||||
-----END QCMOD-----
|
-----END QCMOD-----
|
||||||
@@ -500,12 +424,12 @@ public:
|
|||||||
QString name() const { return "libcurl"; }
|
QString name() const { return "libcurl"; }
|
||||||
QString shortname() const { return "libcurl"; }
|
QString shortname() const { return "libcurl"; }
|
||||||
bool exec(){
|
bool exec(){
|
||||||
QString s;
|
QString s;
|
||||||
s = conf->getenv("QC_WITH_LIBCURL_INC");
|
s = conf->getenv("QC_WITH_LIBCURL_INC");
|
||||||
if(!s.isEmpty()) {
|
if(!s.isEmpty()) {
|
||||||
if(!conf->checkHeader(s, "curl/curl.h")) {
|
if(!conf->checkHeader(s, "curl/curl.h")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
QStringList sl;
|
QStringList sl;
|
||||||
sl << "/usr/include";
|
sl << "/usr/include";
|
||||||
@@ -519,24 +443,23 @@ public:
|
|||||||
}
|
}
|
||||||
if(!found) {
|
if(!found) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conf->addIncludePath(s);
|
conf->addIncludePath(s);
|
||||||
|
|
||||||
s = conf->getenv("QC_WITH_LIBCURL_LIB");
|
s = conf->getenv("QC_WITH_LIBCURL_LIB");
|
||||||
if(!s.isEmpty()) {
|
if(!s.isEmpty()) {
|
||||||
if(!QFile::exists(s+QString("/libcurl.so")))
|
if(!conf->checkLibrary(s, "curl")) {
|
||||||
return false;
|
return false;
|
||||||
conf->addLib(QString("-L") + s);
|
}
|
||||||
|
conf->addLib(QString("-L") + s);
|
||||||
}else{
|
}else{
|
||||||
QStringList sl;
|
QStringList sl;
|
||||||
sl << "/usr/lib/";
|
sl << "/usr/lib/";
|
||||||
sl << "/usr/lib64/";
|
|
||||||
sl << "/usr/local/lib/";
|
sl << "/usr/local/lib/";
|
||||||
sl << "/usr/local/lib64/";
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
foreach(s, sl){
|
foreach(s, sl){
|
||||||
if(QFile::exists(s+QString("libcurl.so"))){
|
if(conf->checkLibrary(s, "curl")){
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -544,165 +467,34 @@ public:
|
|||||||
if(!found) return false;
|
if(!found) return false;
|
||||||
conf->addLib(QString("-L") + s);
|
conf->addLib(QString("-L") + s);
|
||||||
}
|
}
|
||||||
|
conf->addLib("-lcurl");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#line 1 "libmagick.qcm"
|
#line 1 "python.qcm"
|
||||||
/*
|
/*
|
||||||
-----BEGIN QCMOD-----
|
-----BEGIN QCMOD-----
|
||||||
name: libmagick
|
name: python
|
||||||
arg: with-libmagick-inc=[path], Path to libmagick++ include files
|
|
||||||
arg: with-libmagick-lib=[path], Path to libmagick++ library files
|
|
||||||
-----END QCMOD-----
|
-----END QCMOD-----
|
||||||
*/
|
*/
|
||||||
#include <QProcess>
|
class qc_python : public ConfObj
|
||||||
class qc_libmagick : public ConfObj
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
qc_libmagick(Conf *c) : ConfObj(c) {}
|
qc_python(Conf *c) : ConfObj(c) {}
|
||||||
QString name() const { return "ImageMagick library (libmagick++)"; }
|
QString name() const { return "python >= 2.3"; }
|
||||||
QString shortname() const { return "libmagick++"; }
|
QString shortname() const { return "python"; }
|
||||||
QString checkString() const {
|
|
||||||
if(!conf->getenv("QC_DISABLE_libmagick").isEmpty())
|
|
||||||
return "";
|
|
||||||
return ConfObj::checkString();
|
|
||||||
}
|
|
||||||
bool exec(){
|
bool exec(){
|
||||||
if(!conf->getenv("QC_DISABLE_libmagick").isEmpty())
|
int r = conf->doCommand("python testpython.py");
|
||||||
return false;
|
if(r == 0)
|
||||||
QString s;
|
return true;
|
||||||
s = conf->getenv("QC_WITH_LIBMAGICK_INC");
|
else
|
||||||
if(!s.isEmpty()) {
|
return false;
|
||||||
if(!conf->checkHeader(s, "Magick++.h")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
QStringList sl;
|
|
||||||
sl << "/usr/include";
|
|
||||||
sl << "/usr/local/include";
|
|
||||||
bool found = false;
|
|
||||||
foreach(s, sl){
|
|
||||||
if(conf->checkHeader(s, "Magick++.h")){
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
conf->addIncludePath(s);
|
|
||||||
|
|
||||||
s = conf->getenv("QC_WITH_LIBMAGICK_LIB");
|
|
||||||
if(!s.isEmpty()) {
|
|
||||||
if(!conf->checkLibrary(s, "Magick++")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
QStringList sl;
|
|
||||||
sl << "/usr/lib/";
|
|
||||||
sl << "/usr/lib64/";
|
|
||||||
sl << "/usr/local/lib/";
|
|
||||||
sl << "/usr/local/lib64/";
|
|
||||||
bool found = false;
|
|
||||||
foreach(s, sl){
|
|
||||||
if(conf->checkLibrary(s, "Magick++")) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
conf->addLib(QString("-L") + s);
|
|
||||||
QProcess magickConfig;
|
|
||||||
QStringList params;
|
|
||||||
params << "--libs";
|
|
||||||
magickConfig.start("Magick++-config", params, QIODevice::ReadOnly);
|
|
||||||
magickConfig.waitForStarted();
|
|
||||||
magickConfig.waitForFinished();
|
|
||||||
QByteArray result = magickConfig.readAll();
|
|
||||||
result = result.replace("\n", "");
|
|
||||||
conf->addLib(result.data());
|
|
||||||
conf->addDefine("HAVE_MAGICK");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#line 1 "libzzip.qcm"
|
|
||||||
/*
|
|
||||||
-----BEGIN QCMOD-----
|
|
||||||
name: libzzip
|
|
||||||
arg: with-libzzip-inc=[path], Path to libzzip++ include files
|
|
||||||
arg: with-libzzip-lib=[path], Path to libzzip++ library files
|
|
||||||
-----END QCMOD-----
|
|
||||||
*/
|
|
||||||
#include <QProcess>
|
|
||||||
class qc_libzzip : public ConfObj
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
qc_libzzip(Conf *c) : ConfObj(c) {}
|
|
||||||
QString name() const { return "Zzip library (libzzip)"; }
|
|
||||||
QString shortname() const { return "libzzip"; }
|
|
||||||
QString checkString() const {
|
|
||||||
if(!conf->getenv("QC_DISABLE_LIBZZIP").isEmpty())
|
|
||||||
return "";
|
|
||||||
return ConfObj::checkString();
|
|
||||||
}
|
|
||||||
bool exec(){
|
|
||||||
if(!conf->getenv("QC_DISABLE_LIBZZIP").isEmpty())
|
|
||||||
return false;
|
|
||||||
QString s;
|
|
||||||
s = conf->getenv("QC_WITH_LIBZZIP_INC");
|
|
||||||
if(!s.isEmpty()) {
|
|
||||||
if(!conf->checkHeader(s, "zzip/zzip.h")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
QStringList sl;
|
|
||||||
sl << "/usr/include";
|
|
||||||
sl << "/usr/local/include";
|
|
||||||
bool found = false;
|
|
||||||
foreach(s, sl){
|
|
||||||
if(conf->checkHeader(s, "zzip/zzip.h")){
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
conf->addIncludePath(s);
|
|
||||||
|
|
||||||
s = conf->getenv("QC_WITH_LIBZZIP_LIB");
|
|
||||||
if(!s.isEmpty()) {
|
|
||||||
if(!QFile::exists(s+QString("/libzzip.so"))){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
QStringList sl;
|
|
||||||
sl << "/usr/lib/";
|
|
||||||
sl << "/usr/lib64/";
|
|
||||||
sl << "/usr/local/lib/";
|
|
||||||
sl << "/usr/local/lib64/";
|
|
||||||
bool found = false;
|
|
||||||
foreach(s, sl){
|
|
||||||
if(QFile::exists(s+QString("libzzip.so"))){
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
conf->addLib(QString("-L") + s);
|
|
||||||
conf->addLib("-lzzip");
|
|
||||||
conf->addDefine("HAVE_ZZIP");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
cat >$1/modules_new.cpp <<EOT
|
cat >$1/modules_new.cpp <<EOT
|
||||||
o = new qc_qt4(conf);
|
o = new qc_qt42(conf);
|
||||||
o->required = true;
|
o->required = true;
|
||||||
o->disabled = false;
|
o->disabled = false;
|
||||||
o = new qc_libtorrent(conf);
|
o = new qc_libtorrent(conf);
|
||||||
@@ -714,17 +506,12 @@ cat >$1/modules_new.cpp <<EOT
|
|||||||
o = new qc_libcurl(conf);
|
o = new qc_libcurl(conf);
|
||||||
o->required = true;
|
o->required = true;
|
||||||
o->disabled = false;
|
o->disabled = false;
|
||||||
o = new qc_libmagick(conf);
|
o = new qc_python(conf);
|
||||||
o->required = false;
|
o->required = true;
|
||||||
o->disabled = false;
|
|
||||||
o = new qc_libzzip(conf);
|
|
||||||
o->required = false;
|
|
||||||
o->disabled = false;
|
o->disabled = false;
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
cat >$1/conf4.h <<EOT
|
cat >$1/conf4.h <<EOT
|
||||||
// For license information, see the COPYING file in the qconf base directory.
|
|
||||||
|
|
||||||
#ifndef QC_CONF4_H
|
#ifndef QC_CONF4_H
|
||||||
#define QC_CONF4_H
|
#define QC_CONF4_H
|
||||||
|
|
||||||
@@ -829,8 +616,6 @@ private:
|
|||||||
|
|
||||||
EOT
|
EOT
|
||||||
cat >$1/conf4.cpp <<EOT
|
cat >$1/conf4.cpp <<EOT
|
||||||
// For license information, see the COPYING file in the qconf base directory.
|
|
||||||
|
|
||||||
#include "conf4.h"
|
#include "conf4.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -981,18 +766,6 @@ void qc_splitcflags(const QString &cflags, QStringList *incs, QStringList *other
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString qc_escapeArg(const QString &str)
|
|
||||||
{
|
|
||||||
QString out;
|
|
||||||
for(int n = 0; n < (int)str.length(); ++n) {
|
|
||||||
if(str[n] == '-')
|
|
||||||
out += '_';
|
|
||||||
else
|
|
||||||
out += str[n];
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// ConfObj
|
// ConfObj
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -1109,14 +882,14 @@ bool Conf::exec()
|
|||||||
// if this was a disabled-by-default option, check if it was enabled
|
// if this was a disabled-by-default option, check if it was enabled
|
||||||
if(o->disabled)
|
if(o->disabled)
|
||||||
{
|
{
|
||||||
QString v = QString("QC_ENABLE_") + qc_escapeArg(o->shortname());
|
QString v = QString("QC_ENABLE_") + o->shortname();
|
||||||
if(getenv(v) != "Y")
|
if(getenv(v) != "Y")
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// and the opposite?
|
// and the opposite?
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString v = QString("QC_DISABLE_") + qc_escapeArg(o->shortname());
|
QString v = QString("QC_DISABLE_") + o->shortname();
|
||||||
if(getenv(v) == "Y")
|
if(getenv(v) == "Y")
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1543,7 +1316,7 @@ int main()
|
|||||||
# include"modules_new.cpp"
|
# include"modules_new.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
conf->debug_enabled = (qc_getenv("QC_VERBOSE") == "Y") ? true: false;
|
conf->debug_enabled = (qc_getenv("QC_DEBUG") == "Y") ? true: false;
|
||||||
if(conf->debug_enabled)
|
if(conf->debug_enabled)
|
||||||
printf(" -> ok\n");
|
printf(" -> ok\n");
|
||||||
else
|
else
|
||||||
@@ -1599,9 +1372,6 @@ int main()
|
|||||||
var = qc_getenv("BINDIR");
|
var = qc_getenv("BINDIR");
|
||||||
if(!var.isEmpty())
|
if(!var.isEmpty())
|
||||||
str += QString("BINDIR = %1\n").arg(var);
|
str += QString("BINDIR = %1\n").arg(var);
|
||||||
var = qc_getenv("INCDIR");
|
|
||||||
if(!var.isEmpty())
|
|
||||||
str += QString("INCDIR = %1\n").arg(var);
|
|
||||||
var = qc_getenv("LIBDIR");
|
var = qc_getenv("LIBDIR");
|
||||||
if(!var.isEmpty())
|
if(!var.isEmpty())
|
||||||
str += QString("LIBDIR = %1\n").arg(var);
|
str += QString("LIBDIR = %1\n").arg(var);
|
||||||
@@ -1667,17 +1437,10 @@ export DATADIR
|
|||||||
export EX_QTDIR
|
export EX_QTDIR
|
||||||
export QC_WITH_LIBTORRENT_INC
|
export QC_WITH_LIBTORRENT_INC
|
||||||
export QC_WITH_LIBTORRENT_LIB
|
export QC_WITH_LIBTORRENT_LIB
|
||||||
export QC_WITH_LIBTORRENT_STATIC_LIB
|
|
||||||
export QC_WITH_LIBBOOST_INC
|
export QC_WITH_LIBBOOST_INC
|
||||||
export QC_WITH_LIBCURL_INC
|
export QC_WITH_LIBCURL_INC
|
||||||
export QC_WITH_LIBCURL_LIB
|
export QC_WITH_LIBCURL_LIB
|
||||||
export QC_DISABLE_libmagick
|
export QC_DEBUG
|
||||||
export QC_WITH_LIBMAGICK_INC
|
|
||||||
export QC_WITH_LIBMAGICK_LIB
|
|
||||||
export QC_DISABLE_libzzip
|
|
||||||
export QC_WITH_LIBZZIP_INC
|
|
||||||
export QC_WITH_LIBZZIP_LIB
|
|
||||||
export QC_VERBOSE
|
|
||||||
rm -rf .qconftemp
|
rm -rf .qconftemp
|
||||||
(
|
(
|
||||||
mkdir .qconftemp
|
mkdir .qconftemp
|
||||||
@@ -1690,7 +1453,7 @@ rm -rf .qconftemp
|
|||||||
|
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
rm -rf .qconftemp
|
rm -rf .qconftemp
|
||||||
if [ "$QC_VERBOSE" = "Y" ]; then
|
if [ "$QC_DEBUG" = "Y" ]; then
|
||||||
echo " -> fail"
|
echo " -> fail"
|
||||||
else
|
else
|
||||||
echo "fail"
|
echo "fail"
|
||||||
@@ -1699,7 +1462,7 @@ if [ "$?" != "0" ]; then
|
|||||||
printf "Reason: There was an error compiling 'conf'. See conf.log for details.\n"
|
printf "Reason: There was an error compiling 'conf'. See conf.log for details.\n"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
show_qt_info
|
show_qt_info
|
||||||
if [ "$QC_VERBOSE" = "Y" ]; then
|
if [ "$QC_DEBUG" = "Y" ]; then
|
||||||
echo "conf.log:"
|
echo "conf.log:"
|
||||||
cat conf.log
|
cat conf.log
|
||||||
fi
|
fi
|
||||||
@@ -1723,7 +1486,7 @@ if [ "$ret" = "1" ]; then
|
|||||||
else
|
else
|
||||||
if [ "$ret" != "0" ]; then
|
if [ "$ret" != "0" ]; then
|
||||||
rm -rf .qconftemp
|
rm -rf .qconftemp
|
||||||
if [ "$QC_VERBOSE" = "Y" ]; then
|
if [ "$QC_DEBUG" = "Y" ]; then
|
||||||
echo " -> fail"
|
echo " -> fail"
|
||||||
else
|
else
|
||||||
echo "fail"
|
echo "fail"
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
.\" This manpage has been automatically generated by docbook2man
|
|
||||||
.\" from a DocBook document. This tool can be found at:
|
|
||||||
.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/>.
|
|
||||||
.TH "QBITTORRENT" "1" "September 1st 2007" "Bittorrent client written in C++ / Qt4" ""
|
|
||||||
|
|
||||||
.SH NAME
|
|
||||||
qBittorrent \- a Bittorrent client written in C++ / Qt4
|
|
||||||
.SH SYNOPSIS
|
|
||||||
|
|
||||||
\fBqbittorrent\fR [FILE | URL] [FILE | URL...]
|
|
||||||
|
|
||||||
\fBqbittorrent\fR \-\-help
|
|
||||||
|
|
||||||
\fBqbittorrent\fR \-\-version
|
|
||||||
.PP
|
|
||||||
.SH "DESCRIPTION"
|
|
||||||
|
|
||||||
\fBqBittorrent\fR is an advanced Bittorrent client written in C++ / Qt4,
|
|
||||||
using the \fBrblibtorrent\fR library by Arvid Norberg. qBittorrent aims
|
|
||||||
to be a good alternative to all other bittorrent clients out there. qBittorrent
|
|
||||||
is fast, stable, light, it supports unicode and it provides a good integrated search engine.
|
|
||||||
It also comes with UPnP port forwarding / NAT-PMP, encryption (Azureus compatible), FAST extension (mainline) and PeX support (utorrent compatible).
|
|
||||||
|
|
||||||
Please report any problem to http://bugs.qbittorrent.org
|
|
||||||
.PP
|
|
||||||
.SH "AUTHOR"
|
|
||||||
|
|
||||||
Christophe Dumez <chris@qbittorrent.org>
|
|
||||||
BIN
doc/qbittorrent.1.gz
Normal file
@@ -1,199 +0,0 @@
|
|||||||
<?xml version = '1.0'?>
|
|
||||||
<kdevelop>
|
|
||||||
<general>
|
|
||||||
<author>Christophe Dumez</author>
|
|
||||||
<email>chris@qbittorrent.org</email>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<projectmanagement>KDevTrollProject</projectmanagement>
|
|
||||||
<primarylanguage>C++</primarylanguage>
|
|
||||||
<keywords>
|
|
||||||
<keyword>Qt</keyword>
|
|
||||||
</keywords>
|
|
||||||
<projectname>qBittorrent</projectname>
|
|
||||||
<ignoreparts/>
|
|
||||||
<projectdirectory>.</projectdirectory>
|
|
||||||
<absoluteprojectpath>false</absoluteprojectpath>
|
|
||||||
<description/>
|
|
||||||
<defaultencoding/>
|
|
||||||
<versioncontrol>kdevsubversion</versioncontrol>
|
|
||||||
</general>
|
|
||||||
<kdevfileview>
|
|
||||||
<groups>
|
|
||||||
<group pattern="*.cpp;*.cxx;*.h" name="Sources" />
|
|
||||||
<group pattern="*.ui" name="User Interface" />
|
|
||||||
<group pattern="*.png" name="Icons" />
|
|
||||||
<group pattern="*" name="Others" />
|
|
||||||
<hidenonprojectfiles>false</hidenonprojectfiles>
|
|
||||||
<hidenonlocation>false</hidenonlocation>
|
|
||||||
</groups>
|
|
||||||
<tree>
|
|
||||||
<hidepatterns>*.o,*.lo,CVS</hidepatterns>
|
|
||||||
<hidenonprojectfiles>false</hidenonprojectfiles>
|
|
||||||
<showvcsfields>false</showvcsfields>
|
|
||||||
</tree>
|
|
||||||
</kdevfileview>
|
|
||||||
<kdevdoctreeview>
|
|
||||||
<ignoretocs>
|
|
||||||
<toc>bash</toc>
|
|
||||||
<toc>bash_bugs</toc>
|
|
||||||
<toc>clanlib</toc>
|
|
||||||
<toc>w3c-dom-level2-html</toc>
|
|
||||||
<toc>fortran_bugs_gcc</toc>
|
|
||||||
<toc>gnome1</toc>
|
|
||||||
<toc>gnustep</toc>
|
|
||||||
<toc>gtk</toc>
|
|
||||||
<toc>gtk_bugs</toc>
|
|
||||||
<toc>haskell</toc>
|
|
||||||
<toc>haskell_bugs_ghc</toc>
|
|
||||||
<toc>java_bugs_gcc</toc>
|
|
||||||
<toc>java_bugs_sun</toc>
|
|
||||||
<toc>kde2book</toc>
|
|
||||||
<toc>opengl</toc>
|
|
||||||
<toc>pascal_bugs_fp</toc>
|
|
||||||
<toc>php</toc>
|
|
||||||
<toc>php_bugs</toc>
|
|
||||||
<toc>perl</toc>
|
|
||||||
<toc>perl_bugs</toc>
|
|
||||||
<toc>python</toc>
|
|
||||||
<toc>python_bugs</toc>
|
|
||||||
<toc>qt-kdev3</toc>
|
|
||||||
<toc>ruby</toc>
|
|
||||||
<toc>ruby_bugs</toc>
|
|
||||||
<toc>sdl</toc>
|
|
||||||
<toc>stl</toc>
|
|
||||||
<toc>w3c-svg</toc>
|
|
||||||
<toc>sw</toc>
|
|
||||||
<toc>w3c-uaag10</toc>
|
|
||||||
<toc>wxwidgets_bugs</toc>
|
|
||||||
</ignoretocs>
|
|
||||||
<ignoredoxygen>
|
|
||||||
<toc>KDE Libraries (Doxygen)</toc>
|
|
||||||
</ignoredoxygen>
|
|
||||||
</kdevdoctreeview>
|
|
||||||
<kdevdebugger>
|
|
||||||
<general>
|
|
||||||
<dbgshell/>
|
|
||||||
<gdbpath/>
|
|
||||||
<configGdbScript/>
|
|
||||||
<runShellScript/>
|
|
||||||
<runGdbScript/>
|
|
||||||
<breakonloadinglibs>true</breakonloadinglibs>
|
|
||||||
<separatetty>false</separatetty>
|
|
||||||
<floatingtoolbar>false</floatingtoolbar>
|
|
||||||
</general>
|
|
||||||
<display>
|
|
||||||
<staticmembers>false</staticmembers>
|
|
||||||
<demanglenames>true</demanglenames>
|
|
||||||
<outputradix>10</outputradix>
|
|
||||||
</display>
|
|
||||||
</kdevdebugger>
|
|
||||||
<kdevcppsupport>
|
|
||||||
<qt>
|
|
||||||
<version>4</version>
|
|
||||||
<used>true</used>
|
|
||||||
<includestyle>4</includestyle>
|
|
||||||
<designerintegration>ExternalDesigner</designerintegration>
|
|
||||||
<root>/usr/lib/qt4</root>
|
|
||||||
<qmake>/usr/bin/qmake</qmake>
|
|
||||||
<designer>/usr/bin/designer</designer>
|
|
||||||
<designerpluginpaths/>
|
|
||||||
</qt>
|
|
||||||
<references>
|
|
||||||
<pcs>automatic_%2Fhome%2Fishanarora%2Fprojects%2Fqbittorrent</pcs>
|
|
||||||
</references>
|
|
||||||
<codecompletion>
|
|
||||||
<automaticCodeCompletion>true</automaticCodeCompletion>
|
|
||||||
<automaticArgumentsHint>true</automaticArgumentsHint>
|
|
||||||
<automaticHeaderCompletion>true</automaticHeaderCompletion>
|
|
||||||
<codeCompletionDelay>250</codeCompletionDelay>
|
|
||||||
<argumentsHintDelay>400</argumentsHintDelay>
|
|
||||||
<headerCompletionDelay>250</headerCompletionDelay>
|
|
||||||
<showOnlyAccessibleItems>false</showOnlyAccessibleItems>
|
|
||||||
<completionBoxItemOrder>0</completionBoxItemOrder>
|
|
||||||
<howEvaluationContextMenu>true</howEvaluationContextMenu>
|
|
||||||
<showCommentWithArgumentHint>true</showCommentWithArgumentHint>
|
|
||||||
<statusBarTypeEvaluation>false</statusBarTypeEvaluation>
|
|
||||||
<namespaceAliases>std=_GLIBCXX_STD;__gnu_cxx=std</namespaceAliases>
|
|
||||||
<processPrimaryTypes>true</processPrimaryTypes>
|
|
||||||
<processFunctionArguments>true</processFunctionArguments>
|
|
||||||
<preProcessAllHeaders>true</preProcessAllHeaders>
|
|
||||||
<parseMissingHeadersExperimental>true</parseMissingHeadersExperimental>
|
|
||||||
<resolveIncludePathsUsingMakeExperimental>true</resolveIncludePathsUsingMakeExperimental>
|
|
||||||
<alwaysParseInBackground>true</alwaysParseInBackground>
|
|
||||||
<usePermanentCaching>true</usePermanentCaching>
|
|
||||||
<alwaysIncludeNamespaces>false</alwaysIncludeNamespaces>
|
|
||||||
<includePaths>.;</includePaths>
|
|
||||||
</codecompletion>
|
|
||||||
<creategettersetter>
|
|
||||||
<prefixGet>get</prefixGet>
|
|
||||||
<prefixSet>set</prefixSet>
|
|
||||||
<prefixVariable>m_,_</prefixVariable>
|
|
||||||
<parameterName>theValue</parameterName>
|
|
||||||
<inlineGet>true</inlineGet>
|
|
||||||
<inlineSet>true</inlineSet>
|
|
||||||
</creategettersetter>
|
|
||||||
<splitheadersource>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
<synchronize>true</synchronize>
|
|
||||||
<orientation>Vertical</orientation>
|
|
||||||
</splitheadersource>
|
|
||||||
</kdevcppsupport>
|
|
||||||
<kdevfilecreate>
|
|
||||||
<filetypes/>
|
|
||||||
<useglobaltypes>
|
|
||||||
<type ext="ui" />
|
|
||||||
<type ext="cpp" />
|
|
||||||
<type ext="h" />
|
|
||||||
</useglobaltypes>
|
|
||||||
</kdevfilecreate>
|
|
||||||
<kdevtrollproject>
|
|
||||||
<general>
|
|
||||||
<activedir>src</activedir>
|
|
||||||
</general>
|
|
||||||
<run>
|
|
||||||
<directoryradio>executable</directoryradio>
|
|
||||||
<mainprogram>/home/ishanarora/projects/qbittorrent/src/qbittorrent</mainprogram>
|
|
||||||
<programargs/>
|
|
||||||
<globaldebugarguments/>
|
|
||||||
<globalcwd>/home/ishanarora/projects/qbittorrent</globalcwd>
|
|
||||||
<useglobalprogram>true</useglobalprogram>
|
|
||||||
<terminal>false</terminal>
|
|
||||||
<autocompile>true</autocompile>
|
|
||||||
<autoinstall>false</autoinstall>
|
|
||||||
<autokdesu>false</autokdesu>
|
|
||||||
<envvars/>
|
|
||||||
</run>
|
|
||||||
<make>
|
|
||||||
<abortonerror>true</abortonerror>
|
|
||||||
<runmultiplejobs>false</runmultiplejobs>
|
|
||||||
<numberofjobs>1</numberofjobs>
|
|
||||||
<dontact>false</dontact>
|
|
||||||
<makebin/>
|
|
||||||
<prio>0</prio>
|
|
||||||
<envvars/>
|
|
||||||
</make>
|
|
||||||
<qmake>
|
|
||||||
<savebehaviour>2</savebehaviour>
|
|
||||||
<replacePaths>false</replacePaths>
|
|
||||||
<disableDefaultOpts>true</disableDefaultOpts>
|
|
||||||
</qmake>
|
|
||||||
</kdevtrollproject>
|
|
||||||
<cppsupportpart>
|
|
||||||
<filetemplates>
|
|
||||||
<interfacesuffix>.h</interfacesuffix>
|
|
||||||
<implementationsuffix>.cpp</implementationsuffix>
|
|
||||||
</filetemplates>
|
|
||||||
</cppsupportpart>
|
|
||||||
<ctagspart>
|
|
||||||
<customArguments/>
|
|
||||||
<customTagfilePath>/home/ishanarora/projects/qbittorrent/tags</customTagfilePath>
|
|
||||||
<activeTagsFiles/>
|
|
||||||
</ctagspart>
|
|
||||||
<kdevdocumentation>
|
|
||||||
<projectdoc>
|
|
||||||
<docsystem/>
|
|
||||||
<docurl/>
|
|
||||||
<usermanualurl/>
|
|
||||||
</projectdoc>
|
|
||||||
</kdevdocumentation>
|
|
||||||
</kdevelop>
|
|
||||||
@@ -2,8 +2,7 @@
|
|||||||
<name>qbittorrent</name>
|
<name>qbittorrent</name>
|
||||||
<profile>qbittorrent.pro</profile>
|
<profile>qbittorrent.pro</profile>
|
||||||
<moddir>qcm</moddir>
|
<moddir>qcm</moddir>
|
||||||
<datadir/>
|
<dep type='qt42'>
|
||||||
<dep type='qt4'>
|
|
||||||
<required/>
|
<required/>
|
||||||
</dep>
|
</dep>
|
||||||
<dep type='libtorrent'>
|
<dep type='libtorrent'>
|
||||||
@@ -15,6 +14,7 @@
|
|||||||
<dep type='libcurl'>
|
<dep type='libcurl'>
|
||||||
<required/>
|
<required/>
|
||||||
</dep>
|
</dep>
|
||||||
<dep type='libmagick'/>
|
<dep type='python'>
|
||||||
<dep type='libzzip'/>
|
<required/>
|
||||||
|
</dep>
|
||||||
</qconf>
|
</qconf>
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
-----BEGIN QCMOD-----
|
|
||||||
name: libcommoncpp2
|
|
||||||
arg: with-libcommoncpp2-inc=[path], Path to libcommoncpp2 include files
|
|
||||||
arg: with-libcommoncpp2-lib=[path], Path to libcommoncpp2 library files
|
|
||||||
-----END QCMOD-----
|
|
||||||
*/
|
|
||||||
class qc_libcommoncpp2 : public ConfObj
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
qc_libcommoncpp2(Conf *c) : ConfObj(c) {}
|
|
||||||
QString name() const { return "GNU Common C++ library (libcommoncpp2)"; }
|
|
||||||
QString shortname() const { return "libcommoncpp2"; }
|
|
||||||
bool exec(){
|
|
||||||
QString s;
|
|
||||||
s = conf->getenv("QC_WITH_LIBCOMMONCPP2_INC");
|
|
||||||
if(!s.isEmpty()) {
|
|
||||||
if(!conf->checkHeader(s, "cc++/url.h")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
QStringList sl;
|
|
||||||
sl << "/usr/include";
|
|
||||||
sl << "/usr/local/include";
|
|
||||||
bool found = false;
|
|
||||||
foreach(s, sl){
|
|
||||||
if(conf->checkHeader(s, "cc++/url.h")){
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
conf->addIncludePath(s);
|
|
||||||
|
|
||||||
s = conf->getenv("QC_WITH_LIBCOMMONCPP2_LIB");
|
|
||||||
if(!s.isEmpty()) {
|
|
||||||
if(!QFile::exists(s+QString("/libccext2.so")))
|
|
||||||
return false;
|
|
||||||
if(!QFile::exists(s+QString("/libccgnu2.so")))
|
|
||||||
return false;
|
|
||||||
conf->addLib(QString("-L") + s);
|
|
||||||
}else{
|
|
||||||
QStringList sl;
|
|
||||||
sl << "/usr/lib/";
|
|
||||||
sl << "/usr/lib64/";
|
|
||||||
sl << "/usr/local/lib/";
|
|
||||||
sl << "/usr/local/lib64/";
|
|
||||||
bool found = false;
|
|
||||||
foreach(s, sl){
|
|
||||||
if(QFile::exists(s+QString("libccext2.so"))){
|
|
||||||
if(QFile::exists(s+QString("libccgnu2.so"))){
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found) return false;
|
|
||||||
conf->addLib(QString("-L") + s);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
-----BEGIN QCMOD-----
|
-----BEGIN QCMOD-----
|
||||||
name: libcommoncpp2
|
name: libcurl
|
||||||
arg: with-libcurl-inc=[path], Path to libcurl include files
|
arg: with-libcurl-inc=[path], Path to libcurl include files
|
||||||
arg: with-libcurl-lib=[path], Path to libcurl library files
|
arg: with-libcurl-lib=[path], Path to libcurl library files
|
||||||
-----END QCMOD-----
|
-----END QCMOD-----
|
||||||
@@ -12,12 +12,12 @@ public:
|
|||||||
QString name() const { return "libcurl"; }
|
QString name() const { return "libcurl"; }
|
||||||
QString shortname() const { return "libcurl"; }
|
QString shortname() const { return "libcurl"; }
|
||||||
bool exec(){
|
bool exec(){
|
||||||
QString s;
|
QString s;
|
||||||
s = conf->getenv("QC_WITH_LIBCURL_INC");
|
s = conf->getenv("QC_WITH_LIBCURL_INC");
|
||||||
if(!s.isEmpty()) {
|
if(!s.isEmpty()) {
|
||||||
if(!conf->checkHeader(s, "curl/curl.h")) {
|
if(!conf->checkHeader(s, "curl/curl.h")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
QStringList sl;
|
QStringList sl;
|
||||||
sl << "/usr/include";
|
sl << "/usr/include";
|
||||||
@@ -31,24 +31,23 @@ public:
|
|||||||
}
|
}
|
||||||
if(!found) {
|
if(!found) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conf->addIncludePath(s);
|
conf->addIncludePath(s);
|
||||||
|
|
||||||
s = conf->getenv("QC_WITH_LIBCURL_LIB");
|
s = conf->getenv("QC_WITH_LIBCURL_LIB");
|
||||||
if(!s.isEmpty()) {
|
if(!s.isEmpty()) {
|
||||||
if(!QFile::exists(s+QString("/libcurl.so")))
|
if(!conf->checkLibrary(s, "curl")) {
|
||||||
return false;
|
return false;
|
||||||
conf->addLib(QString("-L") + s);
|
}
|
||||||
|
conf->addLib(QString("-L") + s);
|
||||||
}else{
|
}else{
|
||||||
QStringList sl;
|
QStringList sl;
|
||||||
sl << "/usr/lib/";
|
sl << "/usr/lib/";
|
||||||
sl << "/usr/lib64/";
|
|
||||||
sl << "/usr/local/lib/";
|
sl << "/usr/local/lib/";
|
||||||
sl << "/usr/local/lib64/";
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
foreach(s, sl){
|
foreach(s, sl){
|
||||||
if(QFile::exists(s+QString("libcurl.so"))){
|
if(conf->checkLibrary(s, "curl")){
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -56,6 +55,7 @@ public:
|
|||||||
if(!found) return false;
|
if(!found) return false;
|
||||||
conf->addLib(QString("-L") + s);
|
conf->addLib(QString("-L") + s);
|
||||||
}
|
}
|
||||||
|
conf->addLib("-lcurl");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
-----BEGIN QCMOD-----
|
|
||||||
name: libmagick
|
|
||||||
arg: with-libmagick-inc=[path], Path to libmagick++ include files
|
|
||||||
arg: with-libmagick-lib=[path], Path to libmagick++ library files
|
|
||||||
-----END QCMOD-----
|
|
||||||
*/
|
|
||||||
#include <QProcess>
|
|
||||||
class qc_libmagick : public ConfObj
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
qc_libmagick(Conf *c) : ConfObj(c) {}
|
|
||||||
QString name() const { return "ImageMagick library (libmagick++)"; }
|
|
||||||
QString shortname() const { return "libmagick++"; }
|
|
||||||
QString checkString() const {
|
|
||||||
if(!conf->getenv("QC_DISABLE_libmagick").isEmpty())
|
|
||||||
return "";
|
|
||||||
return ConfObj::checkString();
|
|
||||||
}
|
|
||||||
bool exec(){
|
|
||||||
if(!conf->getenv("QC_DISABLE_libmagick").isEmpty())
|
|
||||||
return false;
|
|
||||||
QString s;
|
|
||||||
s = conf->getenv("QC_WITH_LIBMAGICK_INC");
|
|
||||||
if(!s.isEmpty()) {
|
|
||||||
if(!conf->checkHeader(s, "Magick++.h")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
QStringList sl;
|
|
||||||
sl << "/usr/include";
|
|
||||||
sl << "/usr/local/include";
|
|
||||||
bool found = false;
|
|
||||||
foreach(s, sl){
|
|
||||||
if(conf->checkHeader(s, "Magick++.h")){
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
conf->addIncludePath(s);
|
|
||||||
|
|
||||||
s = conf->getenv("QC_WITH_LIBMAGICK_LIB");
|
|
||||||
if(!s.isEmpty()) {
|
|
||||||
if(!conf->checkLibrary(s, "Magick++")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
QStringList sl;
|
|
||||||
sl << "/usr/lib/";
|
|
||||||
sl << "/usr/lib64/";
|
|
||||||
sl << "/usr/local/lib/";
|
|
||||||
sl << "/usr/local/lib64/";
|
|
||||||
bool found = false;
|
|
||||||
foreach(s, sl){
|
|
||||||
if(conf->checkLibrary(s, "Magick++")) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
conf->addLib(QString("-L") + s);
|
|
||||||
QProcess magickConfig;
|
|
||||||
QStringList params;
|
|
||||||
params << "--libs";
|
|
||||||
magickConfig.start("Magick++-config", params, QIODevice::ReadOnly);
|
|
||||||
magickConfig.waitForStarted();
|
|
||||||
magickConfig.waitForFinished();
|
|
||||||
QByteArray result = magickConfig.readAll();
|
|
||||||
result = result.replace("\n", "");
|
|
||||||
conf->addLib(result.data());
|
|
||||||
conf->addDefine("HAVE_MAGICK");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -3,21 +3,24 @@
|
|||||||
name: libtorrent
|
name: libtorrent
|
||||||
arg: with-libtorrent-inc=[path], Path to libtorrent include files
|
arg: with-libtorrent-inc=[path], Path to libtorrent include files
|
||||||
arg: with-libtorrent-lib=[path], Path to libtorrent library files
|
arg: with-libtorrent-lib=[path], Path to libtorrent library files
|
||||||
arg: with-libtorrent-static-lib=[path], Path to libtorrent .a file
|
|
||||||
-----END QCMOD-----
|
-----END QCMOD-----
|
||||||
*/
|
*/
|
||||||
class qc_libtorrent : public ConfObj
|
class qc_libtorrent : public ConfObj
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
qc_libtorrent(Conf *c) : ConfObj(c) {}
|
qc_libtorrent(Conf *c) : ConfObj(c) {}
|
||||||
QString name() const { return "libtorrent >= 0.13"; }
|
QString name() const { return "libtorrent >= 0.11 (>= 0.12 ADVISED)"; }
|
||||||
QString shortname() const { return "libtorrent"; }
|
QString shortname() const { return "libtorrent"; }
|
||||||
bool exec(){
|
bool exec(){
|
||||||
QString s;
|
QString s;
|
||||||
s = conf->getenv("QC_WITH_LIBTORRENT_INC");
|
s = conf->getenv("QC_WITH_LIBTORRENT_INC");
|
||||||
if(!s.isEmpty()) {
|
if(!s.isEmpty()) {
|
||||||
if(!conf->checkHeader(s, "libtorrent/lsd.hpp")) {
|
if(!conf->checkHeader(s, "libtorrent/kademlia/node.hpp")){
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
if(!conf->checkHeader(s, "libtorrent/extensions/ut_pex.hpp")) {
|
||||||
|
qWarning("Libtorrent >= v0.12 was not detected, PeX will be disabled.");
|
||||||
|
conf->addDefine("NO_PEX");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
QStringList sl;
|
QStringList sl;
|
||||||
@@ -25,24 +28,20 @@ public:
|
|||||||
sl << "/usr/local/include";
|
sl << "/usr/local/include";
|
||||||
bool found = false;
|
bool found = false;
|
||||||
foreach(s, sl){
|
foreach(s, sl){
|
||||||
if(conf->checkHeader(s, "libtorrent/lsd.hpp")){
|
if(conf->checkHeader(s, "libtorrent/kademlia/node.hpp")){
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!found) {
|
if(!found) return false;
|
||||||
return false;
|
if(!conf->checkHeader(s, "libtorrent/extensions/ut_pex.hpp")){
|
||||||
}
|
qWarning("Libtorrent >= v0.12 was not detected, PeX will be disabled.");
|
||||||
|
conf->addDefine("NO_PEX");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
conf->addIncludePath(s);
|
conf->addIncludePath(s);
|
||||||
conf->addIncludePath(s+QDir::separator()+"libtorrent");
|
conf->addIncludePath(s+QDir::separator()+"libtorrent");
|
||||||
|
|
||||||
s = conf->getenv("QC_WITH_LIBTORRENT_STATIC_LIB");
|
|
||||||
if(!s.isEmpty() && QFile::exists(s) && s.endsWith(".a")){
|
|
||||||
conf->addLib(s);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
s = conf->getenv("QC_WITH_LIBTORRENT_LIB");
|
s = conf->getenv("QC_WITH_LIBTORRENT_LIB");
|
||||||
if(!s.isEmpty()) {
|
if(!s.isEmpty()) {
|
||||||
if(!conf->checkLibrary(s, "torrent")) {
|
if(!conf->checkLibrary(s, "torrent")) {
|
||||||
@@ -52,9 +51,7 @@ public:
|
|||||||
}else{
|
}else{
|
||||||
QStringList sl;
|
QStringList sl;
|
||||||
sl << "/usr/lib/";
|
sl << "/usr/lib/";
|
||||||
sl << "/usr/lib64/";
|
|
||||||
sl << "/usr/local/lib/";
|
sl << "/usr/local/lib/";
|
||||||
sl << "/usr/local/lib64/";
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
foreach(s, sl){
|
foreach(s, sl){
|
||||||
if(conf->checkLibrary(s, "torrent")){
|
if(conf->checkLibrary(s, "torrent")){
|
||||||
@@ -65,6 +62,7 @@ public:
|
|||||||
if(!found) return false;
|
if(!found) return false;
|
||||||
conf->addLib(QString("-L") + s);
|
conf->addLib(QString("-L") + s);
|
||||||
}
|
}
|
||||||
|
//conf->addLib("-ltorrent");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
-----BEGIN QCMOD-----
|
|
||||||
name: libzzip
|
|
||||||
arg: with-libzzip-inc=[path], Path to libzzip++ include files
|
|
||||||
arg: with-libzzip-lib=[path], Path to libzzip++ library files
|
|
||||||
-----END QCMOD-----
|
|
||||||
*/
|
|
||||||
#include <QProcess>
|
|
||||||
class qc_libzzip : public ConfObj
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
qc_libzzip(Conf *c) : ConfObj(c) {}
|
|
||||||
QString name() const { return "Zzip library (libzzip)"; }
|
|
||||||
QString shortname() const { return "libzzip"; }
|
|
||||||
QString checkString() const {
|
|
||||||
if(!conf->getenv("QC_DISABLE_LIBZZIP").isEmpty())
|
|
||||||
return "";
|
|
||||||
return ConfObj::checkString();
|
|
||||||
}
|
|
||||||
bool exec(){
|
|
||||||
if(!conf->getenv("QC_DISABLE_LIBZZIP").isEmpty())
|
|
||||||
return false;
|
|
||||||
QString s;
|
|
||||||
s = conf->getenv("QC_WITH_LIBZZIP_INC");
|
|
||||||
if(!s.isEmpty()) {
|
|
||||||
if(!conf->checkHeader(s, "zzip/zzip.h")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
QStringList sl;
|
|
||||||
sl << "/usr/include";
|
|
||||||
sl << "/usr/local/include";
|
|
||||||
bool found = false;
|
|
||||||
foreach(s, sl){
|
|
||||||
if(conf->checkHeader(s, "zzip/zzip.h")){
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
conf->addIncludePath(s);
|
|
||||||
|
|
||||||
s = conf->getenv("QC_WITH_LIBZZIP_LIB");
|
|
||||||
if(!s.isEmpty()) {
|
|
||||||
if(!QFile::exists(s+QString("/libzzip.so"))){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
QStringList sl;
|
|
||||||
sl << "/usr/lib/";
|
|
||||||
sl << "/usr/lib64/";
|
|
||||||
sl << "/usr/local/lib/";
|
|
||||||
sl << "/usr/local/lib64/";
|
|
||||||
bool found = false;
|
|
||||||
foreach(s, sl){
|
|
||||||
if(QFile::exists(s+QString("libzzip.so"))){
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
conf->addLib(QString("-L") + s);
|
|
||||||
conf->addLib("-lzzip");
|
|
||||||
conf->addDefine("HAVE_ZZIP");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
19
qcm/python.qcm
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
-----BEGIN QCMOD-----
|
||||||
|
name: python
|
||||||
|
-----END QCMOD-----
|
||||||
|
*/
|
||||||
|
class qc_python : public ConfObj
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
qc_python(Conf *c) : ConfObj(c) {}
|
||||||
|
QString name() const { return "python >= 2.3"; }
|
||||||
|
QString shortname() const { return "python"; }
|
||||||
|
bool exec(){
|
||||||
|
int r = conf->doCommand("python testpython.py");
|
||||||
|
if(r == 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
16
qcm/qt4.qcm
@@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
-----BEGIN QCMOD-----
|
|
||||||
name: Qt >= 4.3
|
|
||||||
-----END QCMOD-----
|
|
||||||
*/
|
|
||||||
class qc_qt4 : public ConfObj
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
qc_qt4(Conf *c) : ConfObj(c) {}
|
|
||||||
QString name() const { return "Qt >= 4.3"; }
|
|
||||||
QString shortname() const { return "Qt 4.3"; }
|
|
||||||
bool exec()
|
|
||||||
{
|
|
||||||
return(QT_VERSION >= 0x040300);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
16
qcm/qt42.qcm
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
-----BEGIN QCMOD-----
|
||||||
|
name: Qt >= 4.2
|
||||||
|
-----END QCMOD-----
|
||||||
|
*/
|
||||||
|
class qc_qt42 : public ConfObj
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
qc_qt42(Conf *c) : ConfObj(c) {}
|
||||||
|
QString name() const { return "Qt >= 4.2"; }
|
||||||
|
QString shortname() const { return "qt42"; }
|
||||||
|
bool exec()
|
||||||
|
{
|
||||||
|
return(QT_VERSION >= 0x040200);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -22,11 +22,10 @@
|
|||||||
#ifndef DLLISTDELEGATE_H
|
#ifndef DLLISTDELEGATE_H
|
||||||
#define DLLISTDELEGATE_H
|
#define DLLISTDELEGATE_H
|
||||||
|
|
||||||
#include <QItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QStyleOptionProgressBarV2>
|
#include <QStyleOptionProgressBarV2>
|
||||||
#include <QStyleOptionViewItemV2>
|
|
||||||
#include <QProgressBar>
|
#include <QProgressBar>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
@@ -38,66 +37,128 @@
|
|||||||
#define DLSPEED 3
|
#define DLSPEED 3
|
||||||
#define UPSPEED 4
|
#define UPSPEED 4
|
||||||
#define SEEDSLEECH 5
|
#define SEEDSLEECH 5
|
||||||
#define RATIO 6
|
#define STATUS 6
|
||||||
#define ETA 7
|
#define ETA 7
|
||||||
#define HASH 8
|
#define HASH 8
|
||||||
|
|
||||||
class DLListDelegate: public QItemDelegate {
|
class DLListDelegate: public QAbstractItemDelegate {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DLListDelegate(QObject *parent) : QItemDelegate(parent){}
|
DLListDelegate(QObject *parent=0) : QAbstractItemDelegate(parent){}
|
||||||
|
|
||||||
~DLListDelegate(){}
|
~DLListDelegate(){}
|
||||||
|
|
||||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||||
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
QStyleOptionViewItem opt = option;
|
||||||
|
char tmp[MAX_CHAR_TMP];
|
||||||
|
// set text color
|
||||||
|
QVariant value = index.data(Qt::TextColorRole);
|
||||||
|
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
|
||||||
|
opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
|
||||||
|
}
|
||||||
|
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
||||||
|
? QPalette::Normal : QPalette::Disabled;
|
||||||
|
if (option.state & QStyle::State_Selected){
|
||||||
|
painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
|
||||||
|
}else{
|
||||||
|
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||||
|
}
|
||||||
|
// draw the background color
|
||||||
|
if(index.column() != PROGRESS){
|
||||||
|
if (option.showDecorationSelected && (option.state & QStyle::State_Selected)){
|
||||||
|
if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)){
|
||||||
|
cg = QPalette::Inactive;
|
||||||
|
}
|
||||||
|
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
|
||||||
|
}else{
|
||||||
|
value = index.data(Qt::BackgroundColorRole);
|
||||||
|
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
|
||||||
|
painter->fillRect(option.rect, qvariant_cast<QColor>(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
switch(index.column()){
|
switch(index.column()){
|
||||||
case SIZE:
|
case SIZE:
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
painter->drawText(option.rect, Qt::AlignCenter, misc::friendlyUnit(index.data().toLongLong()));
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
|
||||||
break;
|
break;
|
||||||
case ETA:
|
case ETA:
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
painter->drawText(option.rect, Qt::AlignCenter, misc::userFriendlyDuration(index.data().toLongLong()));
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::userFriendlyDuration(index.data().toLongLong()));
|
|
||||||
break;
|
break;
|
||||||
case UPSPEED:
|
case UPSPEED:
|
||||||
case DLSPEED:{
|
case DLSPEED:{
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
float speed = index.data().toDouble();
|
||||||
double speed = index.data().toDouble();
|
snprintf(tmp, MAX_CHAR_TMP, "%.1f", speed/1024.);
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString(QByteArray::number(speed/1024., 'f', 1))+QString::fromUtf8(" ")+tr("KiB/s"));
|
painter->drawText(option.rect, Qt::AlignCenter, QString(tmp)+" "+tr("KiB/s"));
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RATIO:{
|
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
|
||||||
double ratio = index.data().toDouble();
|
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString(QByteArray::number(ratio, 'f', 1)));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PROGRESS:{
|
case PROGRESS:{
|
||||||
QStyleOptionProgressBarV2 newopt;
|
QStyleOptionProgressBarV2 newopt;
|
||||||
double progress = index.data().toDouble()*100.;
|
float progress;
|
||||||
|
progress = index.data().toDouble()*100.;
|
||||||
|
snprintf(tmp, MAX_CHAR_TMP, "%.1f", progress);
|
||||||
newopt.rect = opt.rect;
|
newopt.rect = opt.rect;
|
||||||
newopt.text = QString(QByteArray::number(progress, 'f', 1))+QString::fromUtf8("%");
|
newopt.text = QString(tmp)+"%";
|
||||||
newopt.progress = (int)progress;
|
newopt.progress = (int)progress;
|
||||||
newopt.maximum = 100;
|
newopt.maximum = 100;
|
||||||
newopt.minimum = 0;
|
newopt.minimum = 0;
|
||||||
newopt.state |= QStyle::State_Enabled;
|
newopt.state |= QStyle::State_Enabled;
|
||||||
newopt.textVisible = true;
|
newopt.textVisible = false;
|
||||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt,
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt,
|
||||||
painter);
|
painter);
|
||||||
|
//We prefer to display text manually to control color/font/boldness
|
||||||
|
if (option.state & QStyle::State_Selected){
|
||||||
|
opt.palette.setColor(QPalette::Text, QColor("grey"));
|
||||||
|
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||||
|
}
|
||||||
|
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NAME:{
|
||||||
|
// decoration
|
||||||
|
value = index.data(Qt::DecorationRole);
|
||||||
|
QPixmap pixmap = qvariant_cast<QIcon>(value).pixmap(option.decorationSize, option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled, option.state & QStyle::State_Open ? QIcon::On : QIcon::Off);
|
||||||
|
QRect pixmapRect = (pixmap.isNull() ? QRect(0, 0, 0, 0): QRect(QPoint(0, 0), option.decorationSize));
|
||||||
|
if (pixmapRect.isValid()){
|
||||||
|
QPoint p = QStyle::alignedRect(option.direction, Qt::AlignLeft, pixmap.size(), option.rect).topLeft();
|
||||||
|
painter->drawPixmap(p, pixmap);
|
||||||
|
}
|
||||||
|
painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignLeft, index.data().toString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
QItemDelegate::paint(painter, option, index);
|
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const {
|
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||||
// No editor here
|
QVariant value = index.data(Qt::FontRole);
|
||||||
return 0;
|
QFont fnt = value.isValid() ? qvariant_cast<QFont>(value) : option.font;
|
||||||
|
QFontMetrics fontMetrics(fnt);
|
||||||
|
const QString text = index.data(Qt::DisplayRole).toString();
|
||||||
|
QRect textRect = QRect(0, 0, 0, fontMetrics.lineSpacing() * (text.count(QLatin1Char('\n')) + 1));
|
||||||
|
return textRect.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QWidget* createEditor(QWidget * parent, const QStyleOptionViewItem& /*option*/, const QModelIndex & index) const{
|
||||||
|
// if(index.column() == PROGRESS){
|
||||||
|
// QProgressBar *progressBar = new QProgressBar(parent);
|
||||||
|
// progressBar->setRange(0,100);
|
||||||
|
// progressBar->installEventFilter(const_cast<DLListDelegate*>(this));
|
||||||
|
// return progressBar;
|
||||||
|
// }
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
// void setEditorData(QWidget *editor, const QModelIndex &index) const{
|
||||||
|
// QProgressBar *progressBar = static_cast<QProgressBar*>(editor);
|
||||||
|
// float progress = index.data().toDouble();
|
||||||
|
// progressBar->setValue((int)(progress*100.));
|
||||||
|
// }
|
||||||
|
// void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex & index) const{
|
||||||
|
// if(index.column() == PROGRESS){
|
||||||
|
// editor->setGeometry(option.rect);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* Contact : chris@qbittorrent.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FINISHEDLISTDELEGATE_H
|
|
||||||
#define FINISHEDLISTDELEGATE_H
|
|
||||||
|
|
||||||
#include <QItemDelegate>
|
|
||||||
#include <QModelIndex>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QStyleOptionProgressBarV2>
|
|
||||||
#include <QStyleOptionViewItemV2>
|
|
||||||
#include <QProgressBar>
|
|
||||||
#include <QApplication>
|
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
// Defines for download list list columns
|
|
||||||
#define F_NAME 0
|
|
||||||
#define F_SIZE 1
|
|
||||||
#define F_UPSPEED 2
|
|
||||||
#define F_LEECH 3
|
|
||||||
#define F_RATIO 4
|
|
||||||
#define F_HASH 5
|
|
||||||
|
|
||||||
class FinishedListDelegate: public QItemDelegate {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
FinishedListDelegate(QObject *parent) : QItemDelegate(parent){}
|
|
||||||
|
|
||||||
~FinishedListDelegate(){}
|
|
||||||
|
|
||||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
|
||||||
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
|
||||||
switch(index.column()){
|
|
||||||
case F_SIZE:
|
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
|
||||||
break;
|
|
||||||
case F_UPSPEED:{
|
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
|
||||||
double speed = index.data().toDouble();
|
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString(QByteArray::number(speed/1024., 'f', 1))+QString::fromUtf8(" ")+tr("KiB/s"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case F_RATIO:{
|
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
|
||||||
double ratio = index.data().toDouble();
|
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString(QByteArray::number(ratio, 'f', 1)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
QItemDelegate::paint(painter, option, index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const {
|
|
||||||
// No editor here
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,594 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* Contact : chris@qbittorrent.org
|
|
||||||
*/
|
|
||||||
#include "FinishedTorrents.h"
|
|
||||||
#include "misc.h"
|
|
||||||
#include "properties_imp.h"
|
|
||||||
#include "bittorrent.h"
|
|
||||||
#include "allocationDlg.h"
|
|
||||||
#include "FinishedListDelegate.h"
|
|
||||||
#include "GUI.h"
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QHeaderView>
|
|
||||||
#include <QMenu>
|
|
||||||
|
|
||||||
FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : parent(parent), BTSession(BTSession), nbFinished(0){
|
|
||||||
setupUi(this);
|
|
||||||
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png")));
|
|
||||||
actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.png")));
|
|
||||||
connect(BTSession, SIGNAL(addedTorrent(QString, QTorrentHandle&, bool)), this, SLOT(torrentAdded(QString, QTorrentHandle&, bool)));
|
|
||||||
finishedListModel = new QStandardItemModel(0,6);
|
|
||||||
finishedListModel->setHeaderData(F_NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
|
||||||
finishedListModel->setHeaderData(F_SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
|
||||||
finishedListModel->setHeaderData(F_UPSPEED, Qt::Horizontal, tr("UP Speed", "i.e: Upload speed"));
|
|
||||||
finishedListModel->setHeaderData(F_LEECH, Qt::Horizontal, tr("Leechers", "i.e: full/partial sources"));
|
|
||||||
finishedListModel->setHeaderData(F_RATIO, Qt::Horizontal, tr("Ratio"));
|
|
||||||
finishedList->setModel(finishedListModel);
|
|
||||||
loadHiddenColumns();
|
|
||||||
// Hide hash column
|
|
||||||
finishedList->hideColumn(F_HASH);
|
|
||||||
// Load last columns width for download list
|
|
||||||
if(!loadColWidthFinishedList()){
|
|
||||||
finishedList->header()->resizeSection(0, 200);
|
|
||||||
}
|
|
||||||
// Make download list header clickable for sorting
|
|
||||||
finishedList->header()->setClickable(true);
|
|
||||||
finishedList->header()->setSortIndicatorShown(true);
|
|
||||||
connect(finishedList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortFinishedList(int)));
|
|
||||||
finishedListDelegate = new FinishedListDelegate(finishedList);
|
|
||||||
finishedList->setItemDelegate(finishedListDelegate);
|
|
||||||
connect(finishedList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFinishedListMenu(const QPoint&)));
|
|
||||||
finishedList->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
connect(finishedList->header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFinishedHoSMenu(const QPoint&)));
|
|
||||||
|
|
||||||
connect(finishedList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(notifyTorrentDoubleClicked(const QModelIndex&)));
|
|
||||||
actionDelete->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete.png")));
|
|
||||||
actionPreview_file->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/preview.png")));
|
|
||||||
actionDelete_Permanently->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete_perm.png")));
|
|
||||||
actionTorrent_Properties->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/properties.png")));
|
|
||||||
actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")));
|
|
||||||
connect(actionPause, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPause_triggered()));
|
|
||||||
connect(actionStart, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionStart_triggered()));
|
|
||||||
connect(actionDelete, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_triggered()));
|
|
||||||
connect(actionPreview_file, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPreview_file_triggered()));
|
|
||||||
connect(actionDelete_Permanently, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_Permanently_triggered()));
|
|
||||||
connect(actionOpen_destination_folder, SIGNAL(triggered()), (GUI*)parent, SLOT(openDestinationFolder()));
|
|
||||||
connect(actionBuy_it, SIGNAL(triggered()), (GUI*)parent, SLOT(goBuyPage()));
|
|
||||||
connect(actionTorrent_Properties, SIGNAL(triggered()), this, SLOT(propertiesSelection()));
|
|
||||||
|
|
||||||
connect(actionHOSColName, SIGNAL(triggered()), this, SLOT(hideOrShowColumnName()));
|
|
||||||
connect(actionHOSColSize, SIGNAL(triggered()), this, SLOT(hideOrShowColumnSize()));
|
|
||||||
connect(actionHOSColUpSpeed, SIGNAL(triggered()), this, SLOT(hideOrShowColumnUpSpeed()));
|
|
||||||
connect(actionHOSColLeechers, SIGNAL(triggered()), this, SLOT(hideOrShowColumnLeechers()));
|
|
||||||
connect(actionHOSColRatio, SIGNAL(triggered()), this, SLOT(hideOrShowColumnRatio()));
|
|
||||||
}
|
|
||||||
|
|
||||||
FinishedTorrents::~FinishedTorrents(){
|
|
||||||
saveColWidthFinishedList();
|
|
||||||
saveHiddenColumns();
|
|
||||||
delete finishedListDelegate;
|
|
||||||
delete finishedListModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::notifyTorrentDoubleClicked(const QModelIndex& index) {
|
|
||||||
unsigned int row = index.row();
|
|
||||||
QString hash = getHashFromRow(row);
|
|
||||||
emit torrentDoubleClicked(hash, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::addTorrent(QString hash){
|
|
||||||
if(!BTSession->isFinished(hash)){
|
|
||||||
BTSession->setFinishedTorrent(hash);
|
|
||||||
}
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
if(row != -1) return;
|
|
||||||
row = finishedListModel->rowCount();
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
|
||||||
// Adding torrent to download list
|
|
||||||
finishedListModel->insertRow(row);
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(h.name()));
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_SIZE), QVariant((qlonglong)h.actual_size()));
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)0.));
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_LEECH), QVariant("0"));
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_RATIO), QVariant(QString::fromUtf8(misc::toString(BTSession->getRealRatio(hash)).c_str())));
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_HASH), QVariant(hash));
|
|
||||||
if(h.is_paused()) {
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
|
|
||||||
setRowColor(row, "red");
|
|
||||||
}else{
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(QIcon(":/Icons/skin/seeding.png")), Qt::DecorationRole);
|
|
||||||
setRowColor(row, "orange");
|
|
||||||
}
|
|
||||||
// Update the number of finished torrents
|
|
||||||
++nbFinished;
|
|
||||||
emit finishedTorrentsNumberChanged(nbFinished);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::torrentAdded(QString, QTorrentHandle& h, bool) {
|
|
||||||
QString hash = h.hash();
|
|
||||||
if(BTSession->isFinished(hash)) {
|
|
||||||
addTorrent(hash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the color of a row in data model
|
|
||||||
void FinishedTorrents::setRowColor(int row, QString color){
|
|
||||||
unsigned int nbColumns = finishedListModel->columnCount()-1;
|
|
||||||
for(unsigned int i=0; i<nbColumns; ++i){
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, i), QVariant(QColor(color)), Qt::ForegroundRole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList FinishedTorrents::getSelectedTorrents(bool only_one) const{
|
|
||||||
QStringList res;
|
|
||||||
QModelIndex index;
|
|
||||||
QModelIndexList selectedIndexes = finishedList->selectionModel()->selectedIndexes();
|
|
||||||
foreach(index, selectedIndexes) {
|
|
||||||
if(index.column() == F_NAME) {
|
|
||||||
// Get the file hash
|
|
||||||
QString hash = finishedListModel->data(finishedListModel->index(index.row(), F_HASH)).toString();
|
|
||||||
res << hash;
|
|
||||||
if(only_one) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int FinishedTorrents::getNbTorrentsInList() const {
|
|
||||||
return nbFinished;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load columns width in a file that were saved previously
|
|
||||||
// (finished list)
|
|
||||||
bool FinishedTorrents::loadColWidthFinishedList(){
|
|
||||||
qDebug("Loading columns width for finished list");
|
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
|
||||||
QString line = settings.value("FinishedListColsWidth", QString()).toString();
|
|
||||||
if(line.isEmpty())
|
|
||||||
return false;
|
|
||||||
QStringList width_list = line.split(' ');
|
|
||||||
if(width_list.size() < finishedListModel->columnCount()-1)
|
|
||||||
return false;
|
|
||||||
unsigned int listSize = width_list.size();
|
|
||||||
for(unsigned int i=0; i<listSize; ++i){
|
|
||||||
finishedList->header()->resizeSection(i, width_list.at(i).toInt());
|
|
||||||
}
|
|
||||||
qDebug("Finished list columns width loaded");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save columns width in a file to remember them
|
|
||||||
// (finished list)
|
|
||||||
void FinishedTorrents::saveColWidthFinishedList() const{
|
|
||||||
qDebug("Saving columns width in finished list");
|
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
|
||||||
QStringList width_list;
|
|
||||||
QStringList new_width_list;
|
|
||||||
short nbColumns = finishedListModel->columnCount()-1;
|
|
||||||
|
|
||||||
QString line = settings.value("FinishedListColsWidth", QString()).toString();
|
|
||||||
if(!line.isEmpty()) {
|
|
||||||
width_list = line.split(' ');
|
|
||||||
}
|
|
||||||
for(short i=0; i<nbColumns; ++i){
|
|
||||||
if(finishedList->columnWidth(i)<1 && width_list.size() == finishedListModel->columnCount()-1 && width_list.at(i).toInt()>=1) {
|
|
||||||
// load the former width
|
|
||||||
new_width_list << width_list.at(i);
|
|
||||||
} else if(finishedList->columnWidth(i)>=1) {
|
|
||||||
// usual case, save the current width
|
|
||||||
new_width_list << QString::fromUtf8(misc::toString(finishedList->columnWidth(i)).c_str());
|
|
||||||
} else {
|
|
||||||
// default width
|
|
||||||
finishedList->resizeColumnToContents(i);
|
|
||||||
new_width_list << QString::fromUtf8(misc::toString(finishedList->columnWidth(i)).c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
settings.setValue("FinishedListColsWidth", new_width_list.join(" "));
|
|
||||||
qDebug("Finished list columns width saved");
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::on_actionSet_upload_limit_triggered(){
|
|
||||||
QModelIndexList selectedIndexes = finishedList->selectionModel()->selectedIndexes();
|
|
||||||
QModelIndex index;
|
|
||||||
QStringList hashes;
|
|
||||||
foreach(index, selectedIndexes){
|
|
||||||
if(index.column() == F_NAME){
|
|
||||||
// Get the file hash
|
|
||||||
hashes << finishedListModel->data(finishedListModel->index(index.row(), F_HASH)).toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
new BandwidthAllocationDialog(this, true, BTSession, hashes);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::updateFinishedList(){
|
|
||||||
QString hash;
|
|
||||||
QStringList finishedSHAs = BTSession->getFinishedTorrents();
|
|
||||||
foreach(hash, finishedSHAs){
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
|
||||||
if(!h.is_valid()){
|
|
||||||
qDebug("Problem: This torrent is not valid in finished list");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
if(row == -1){
|
|
||||||
qDebug("Cannot find torrent in finished list, adding it");
|
|
||||||
addTorrent(hash);
|
|
||||||
row = getRowFromHash(hash);
|
|
||||||
}
|
|
||||||
Q_ASSERT(row != -1);
|
|
||||||
if(h.is_paused()) continue;
|
|
||||||
if(BTSession->getTorrentsToPauseAfterChecking().indexOf(hash) != -1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(h.state() == torrent_status::downloading || (h.state() != torrent_status::checking_files && h.state() != torrent_status::queued_for_checking && h.progress() < 1.)) {
|
|
||||||
// What are you doing here? go back to download tab!
|
|
||||||
qDebug("Info: a torrent was moved from finished to download tab");
|
|
||||||
deleteTorrent(hash);
|
|
||||||
BTSession->setFinishedTorrent(hash);
|
|
||||||
emit torrentMovedFromFinishedList(hash);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(h.state() == torrent_status::checking_files){
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/time.png"))), Qt::DecorationRole);
|
|
||||||
setRowColor(row, QString::fromUtf8("grey"));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
setRowColor(row, QString::fromUtf8("orange"));
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))), Qt::DecorationRole);
|
|
||||||
if(!finishedList->isColumnHidden(F_UPSPEED)) {
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)h.upload_payload_rate()));
|
|
||||||
}
|
|
||||||
if(!finishedList->isColumnHidden(F_LEECH)) {
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_LEECH), misc::toQString(h.num_peers() - h.num_seeds(), true));
|
|
||||||
}
|
|
||||||
if(!finishedList->isColumnHidden(F_RATIO)) {
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_RATIO), QVariant(misc::toQString(BTSession->getRealRatio(hash))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int FinishedTorrents::getRowFromHash(QString hash) const{
|
|
||||||
unsigned int nbRows = finishedListModel->rowCount();
|
|
||||||
for(unsigned int i=0; i<nbRows; ++i){
|
|
||||||
if(finishedListModel->data(finishedListModel->index(i, F_HASH)) == hash){
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: does not actually pause the torrent in BT Session
|
|
||||||
void FinishedTorrents::pauseTorrent(QString hash) {
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
if(row == -1)
|
|
||||||
return;
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)0.0));
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_NAME), QIcon(QString::fromUtf8(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_LEECH), QVariant(QString::fromUtf8("0")));
|
|
||||||
setRowColor(row, QString::fromUtf8("red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::resumeTorrent(QString hash) {
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
Q_ASSERT(row != -1);
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))), Qt::DecorationRole);
|
|
||||||
setRowColor(row, QString::fromUtf8("orange"));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString FinishedTorrents::getHashFromRow(unsigned int row) const {
|
|
||||||
Q_ASSERT(row < (unsigned int)finishedListModel->rowCount());
|
|
||||||
return finishedListModel->data(finishedListModel->index(row, F_HASH)).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Will move it to download tab
|
|
||||||
void FinishedTorrents::deleteTorrent(QString hash){
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
if(row == -1){
|
|
||||||
qDebug("Torrent is not in finished list, nothing to delete");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
finishedListModel->removeRow(row);
|
|
||||||
--nbFinished;
|
|
||||||
emit finishedTorrentsNumberChanged(nbFinished);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show torrent properties dialog
|
|
||||||
void FinishedTorrents::showProperties(const QModelIndex &index){
|
|
||||||
showPropertiesFromHash(finishedListModel->data(finishedListModel->index(index.row(), F_HASH)).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::showPropertiesFromHash(QString hash){
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
|
||||||
properties *prop = new properties(this, BTSession, h);
|
|
||||||
connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSize(QString)));
|
|
||||||
connect(prop, SIGNAL(trackersChanged(QString)), BTSession, SLOT(saveTrackerFile(QString)));
|
|
||||||
prop->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::updateFileSize(QString hash){
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_SIZE), QVariant((qlonglong)h.actual_size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// display properties of selected items
|
|
||||||
void FinishedTorrents::propertiesSelection(){
|
|
||||||
QModelIndexList selectedIndexes = finishedList->selectionModel()->selectedIndexes();
|
|
||||||
QModelIndex index;
|
|
||||||
foreach(index, selectedIndexes){
|
|
||||||
if(index.column() == F_NAME){
|
|
||||||
showProperties(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){
|
|
||||||
QMenu myFinishedListMenu(this);
|
|
||||||
QModelIndex index;
|
|
||||||
// Enable/disable pause/start action given the DL state
|
|
||||||
QModelIndexList selectedIndexes = finishedList->selectionModel()->selectedIndexes();
|
|
||||||
bool has_pause = false, has_start = false, has_preview = false;
|
|
||||||
foreach(index, selectedIndexes) {
|
|
||||||
if(index.column() == F_NAME) {
|
|
||||||
// Get the file name
|
|
||||||
QString hash = finishedListModel->data(finishedListModel->index(index.row(), F_HASH)).toString();
|
|
||||||
// Get handle and pause the torrent
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
|
||||||
if(!h.is_valid()) continue;
|
|
||||||
if(h.is_paused()) {
|
|
||||||
if(!has_start) {
|
|
||||||
myFinishedListMenu.addAction(actionStart);
|
|
||||||
has_start = true;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if(!has_pause) {
|
|
||||||
myFinishedListMenu.addAction(actionPause);
|
|
||||||
has_pause = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(BTSession->isFilePreviewPossible(hash) && !has_preview) {
|
|
||||||
myFinishedListMenu.addAction(actionPreview_file);
|
|
||||||
has_preview = true;
|
|
||||||
}
|
|
||||||
if(has_pause && has_start && has_preview) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
myFinishedListMenu.addSeparator();
|
|
||||||
myFinishedListMenu.addAction(actionDelete);
|
|
||||||
myFinishedListMenu.addAction(actionDelete_Permanently);
|
|
||||||
myFinishedListMenu.addSeparator();
|
|
||||||
myFinishedListMenu.addAction(actionSet_upload_limit);
|
|
||||||
myFinishedListMenu.addSeparator();
|
|
||||||
myFinishedListMenu.addAction(actionOpen_destination_folder);
|
|
||||||
myFinishedListMenu.addAction(actionTorrent_Properties);
|
|
||||||
myFinishedListMenu.addSeparator();
|
|
||||||
myFinishedListMenu.addAction(actionBuy_it);
|
|
||||||
|
|
||||||
// Call menu
|
|
||||||
// XXX: why mapToGlobal() is not enough?
|
|
||||||
myFinishedListMenu.exec(mapToGlobal(pos)+QPoint(10,55));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Hiding Columns functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
// hide/show columns menu
|
|
||||||
void FinishedTorrents::displayFinishedHoSMenu(const QPoint& pos){
|
|
||||||
QMenu hideshowColumn(this);
|
|
||||||
hideshowColumn.setTitle(tr("Hide or Show Column"));
|
|
||||||
for(int i=0; i<=F_RATIO; i++) {
|
|
||||||
hideshowColumn.addAction(getActionHoSCol(i));
|
|
||||||
}
|
|
||||||
// Call menu
|
|
||||||
hideshowColumn.exec(mapToGlobal(pos)+QPoint(10,55));
|
|
||||||
}
|
|
||||||
|
|
||||||
// toggle hide/show a column
|
|
||||||
void FinishedTorrents::hideOrShowColumn(int index) {
|
|
||||||
unsigned int nbVisibleColumns = 0;
|
|
||||||
unsigned int nbCols = finishedListModel->columnCount();
|
|
||||||
// Count visible columns
|
|
||||||
for(unsigned int i=0; i<nbCols; ++i) {
|
|
||||||
if(!finishedList->isColumnHidden(i))
|
|
||||||
++nbVisibleColumns;
|
|
||||||
}
|
|
||||||
if(!finishedList->isColumnHidden(index)) {
|
|
||||||
// User wants to hide the column
|
|
||||||
// Is there at least one other visible column?
|
|
||||||
if(nbVisibleColumns <= 1) return;
|
|
||||||
// User can hide the column, do it.
|
|
||||||
finishedList->setColumnHidden(index, true);
|
|
||||||
getActionHoSCol(index)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png")));
|
|
||||||
--nbVisibleColumns;
|
|
||||||
} else {
|
|
||||||
// User want to display the column
|
|
||||||
finishedList->setColumnHidden(index, false);
|
|
||||||
getActionHoSCol(index)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
|
|
||||||
++nbVisibleColumns;
|
|
||||||
}
|
|
||||||
//resize all others non-hidden columns
|
|
||||||
for(unsigned int i=0; i<nbCols; ++i) {
|
|
||||||
if(!finishedList->isColumnHidden(i)) {
|
|
||||||
finishedList->setColumnWidth(i, (int)ceil(finishedList->columnWidth(i)+(finishedList->columnWidth(index)/nbVisibleColumns)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::hideOrShowColumnName() {
|
|
||||||
hideOrShowColumn(F_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::hideOrShowColumnSize() {
|
|
||||||
hideOrShowColumn(F_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::hideOrShowColumnUpSpeed() {
|
|
||||||
hideOrShowColumn(F_UPSPEED);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::hideOrShowColumnLeechers() {
|
|
||||||
hideOrShowColumn(F_LEECH);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::hideOrShowColumnRatio() {
|
|
||||||
hideOrShowColumn(F_RATIO);
|
|
||||||
}
|
|
||||||
|
|
||||||
// load the previous settings, and hide the columns
|
|
||||||
bool FinishedTorrents::loadHiddenColumns() {
|
|
||||||
bool loaded = false;
|
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
|
||||||
QString line = settings.value("FinishedListColsHoS", QString()).toString();
|
|
||||||
QStringList ishidden_list;
|
|
||||||
if(!line.isEmpty()) {
|
|
||||||
ishidden_list = line.split(' ');
|
|
||||||
if(ishidden_list.size() == finishedListModel->columnCount()-1) {
|
|
||||||
unsigned int listSize = ishidden_list.size();
|
|
||||||
for(unsigned int i=0; i<listSize; ++i){
|
|
||||||
finishedList->header()->resizeSection(i, ishidden_list.at(i).toInt());
|
|
||||||
}
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(int i=0; i<finishedListModel->columnCount()-1; i++) {
|
|
||||||
if(loaded && ishidden_list.at(i) == "0") {
|
|
||||||
finishedList->setColumnHidden(i, true);
|
|
||||||
getActionHoSCol(i)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png")));
|
|
||||||
} else {
|
|
||||||
getActionHoSCol(i)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return loaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// save the hidden columns in settings
|
|
||||||
void FinishedTorrents::saveHiddenColumns() {
|
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
|
||||||
QStringList ishidden_list;
|
|
||||||
short nbColumns = finishedListModel->columnCount()-1;
|
|
||||||
|
|
||||||
for(short i=0; i<nbColumns; ++i){
|
|
||||||
if(finishedList->isColumnHidden(i)) {
|
|
||||||
ishidden_list << QString::fromUtf8(misc::toString(0).c_str());
|
|
||||||
} else {
|
|
||||||
ishidden_list << QString::fromUtf8(misc::toString(1).c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
settings.setValue("FinishedListColsHoS", ishidden_list.join(" "));
|
|
||||||
}
|
|
||||||
|
|
||||||
// getter, return the action hide or show whose id is index
|
|
||||||
QAction* FinishedTorrents::getActionHoSCol(int index) {
|
|
||||||
switch(index) {
|
|
||||||
case F_NAME :
|
|
||||||
return actionHOSColName;
|
|
||||||
break;
|
|
||||||
case F_SIZE :
|
|
||||||
return actionHOSColSize;
|
|
||||||
break;
|
|
||||||
case F_UPSPEED :
|
|
||||||
return actionHOSColUpSpeed;
|
|
||||||
break;
|
|
||||||
case F_LEECH :
|
|
||||||
return actionHOSColLeechers;
|
|
||||||
break;
|
|
||||||
case F_RATIO :
|
|
||||||
return actionHOSColRatio;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sorting functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
void FinishedTorrents::sortFinishedList(int index){
|
|
||||||
static Qt::SortOrder sortOrder = Qt::AscendingOrder;
|
|
||||||
if(finishedList->header()->sortIndicatorSection() == index){
|
|
||||||
if(sortOrder == Qt::AscendingOrder){
|
|
||||||
sortOrder = Qt::DescendingOrder;
|
|
||||||
}else{
|
|
||||||
sortOrder = Qt::AscendingOrder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finishedList->header()->setSortIndicator(index, sortOrder);
|
|
||||||
switch(index){
|
|
||||||
case F_SIZE:
|
|
||||||
case F_UPSPEED:
|
|
||||||
sortFinishedListFloat(index, sortOrder);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sortFinishedListString(index, sortOrder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::sortFinishedListFloat(int index, Qt::SortOrder sortOrder){
|
|
||||||
QList<QPair<int, double> > lines;
|
|
||||||
// insertion sorting
|
|
||||||
unsigned int nbRows = finishedListModel->rowCount();
|
|
||||||
for(unsigned int i=0; i<nbRows; ++i){
|
|
||||||
misc::insertSort(lines, QPair<int,double>(i, finishedListModel->data(finishedListModel->index(i, index)).toDouble()), sortOrder);
|
|
||||||
}
|
|
||||||
// Insert items in new model, in correct order
|
|
||||||
unsigned int nbRows_old = lines.size();
|
|
||||||
for(unsigned int row=0; row<nbRows_old; ++row){
|
|
||||||
finishedListModel->insertRow(finishedListModel->rowCount());
|
|
||||||
unsigned int sourceRow = lines[row].first;
|
|
||||||
unsigned int nbColumns = finishedListModel->columnCount();
|
|
||||||
for(unsigned int col=0; col<nbColumns; ++col){
|
|
||||||
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col)));
|
|
||||||
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::DecorationRole), Qt::DecorationRole);
|
|
||||||
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::ForegroundRole), Qt::ForegroundRole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Remove old rows
|
|
||||||
finishedListModel->removeRows(0, nbRows_old);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::sortFinishedListString(int index, Qt::SortOrder sortOrder){
|
|
||||||
QList<QPair<int, QString> > lines;
|
|
||||||
// Insertion sorting
|
|
||||||
unsigned int nbRows = finishedListModel->rowCount();
|
|
||||||
for(unsigned int i=0; i<nbRows; ++i){
|
|
||||||
misc::insertSortString(lines, QPair<int, QString>(i, finishedListModel->data(finishedListModel->index(i, index)).toString()), sortOrder);
|
|
||||||
}
|
|
||||||
// Insert items in new model, in correct order
|
|
||||||
unsigned int nbRows_old = lines.size();
|
|
||||||
for(unsigned int row=0; row<nbRows_old; ++row){
|
|
||||||
finishedListModel->insertRow(finishedListModel->rowCount());
|
|
||||||
unsigned int sourceRow = lines[row].first;
|
|
||||||
unsigned int nbColumns = finishedListModel->columnCount();
|
|
||||||
for(unsigned int col=0; col<nbColumns; ++col){
|
|
||||||
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col)));
|
|
||||||
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::DecorationRole), Qt::DecorationRole);
|
|
||||||
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::ForegroundRole), Qt::ForegroundRole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Remove old rows
|
|
||||||
finishedListModel->removeRows(0, nbRows_old);
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* Contact : chris@qbittorrent.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SEEDING_H
|
|
||||||
#define SEEDING_H
|
|
||||||
|
|
||||||
#include "ui_seeding.h"
|
|
||||||
#include "qtorrenthandle.h"
|
|
||||||
|
|
||||||
class QStandardItemModel;
|
|
||||||
class bittorrent;
|
|
||||||
class FinishedListDelegate;
|
|
||||||
|
|
||||||
using namespace libtorrent;
|
|
||||||
|
|
||||||
class FinishedTorrents : public QWidget, public Ui::seeding {
|
|
||||||
Q_OBJECT
|
|
||||||
private:
|
|
||||||
QObject *parent;
|
|
||||||
bittorrent *BTSession;
|
|
||||||
FinishedListDelegate *finishedListDelegate;
|
|
||||||
QStandardItemModel *finishedListModel;
|
|
||||||
unsigned int nbFinished;
|
|
||||||
void hideOrShowColumn(int index);
|
|
||||||
bool loadHiddenColumns();
|
|
||||||
void saveHiddenColumns();
|
|
||||||
QAction* getActionHoSCol(int index);
|
|
||||||
|
|
||||||
public:
|
|
||||||
FinishedTorrents(QObject *parent, bittorrent *BTSession);
|
|
||||||
~FinishedTorrents();
|
|
||||||
// Methods
|
|
||||||
bool loadColWidthFinishedList();
|
|
||||||
int getRowFromHash(QString hash) const;
|
|
||||||
QStringList getSelectedTorrents(bool only_one=false) const;
|
|
||||||
unsigned int getNbTorrentsInList() const;
|
|
||||||
QString getHashFromRow(unsigned int row) const;
|
|
||||||
|
|
||||||
protected slots:
|
|
||||||
void showProperties(const QModelIndex &index);
|
|
||||||
void displayFinishedListMenu(const QPoint&);
|
|
||||||
void displayFinishedHoSMenu(const QPoint&);
|
|
||||||
void setRowColor(int row, QString color);
|
|
||||||
void saveColWidthFinishedList() const;
|
|
||||||
void sortFinishedList(int index);
|
|
||||||
void sortFinishedListFloat(int index, Qt::SortOrder sortOrder);
|
|
||||||
void sortFinishedListString(int index, Qt::SortOrder sortOrder);
|
|
||||||
void updateFileSize(QString hash);
|
|
||||||
void torrentAdded(QString path, QTorrentHandle& h, bool fastResume);
|
|
||||||
void on_actionSet_upload_limit_triggered();
|
|
||||||
void notifyTorrentDoubleClicked(const QModelIndex& index);
|
|
||||||
void hideOrShowColumnName();
|
|
||||||
void hideOrShowColumnSize();
|
|
||||||
void hideOrShowColumnUpSpeed();
|
|
||||||
void hideOrShowColumnLeechers();
|
|
||||||
void hideOrShowColumnRatio();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void addTorrent(QString hash);
|
|
||||||
void updateFinishedList();
|
|
||||||
void pauseTorrent(QString hash);
|
|
||||||
void resumeTorrent(QString hash);
|
|
||||||
void propertiesSelection();
|
|
||||||
void deleteTorrent(QString hash);
|
|
||||||
void showPropertiesFromHash(QString hash);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void torrentMovedFromFinishedList(QString);
|
|
||||||
void torrentDoubleClicked(QString hash, bool finished);
|
|
||||||
void finishedTorrentsNumberChanged(unsigned int);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
2554
src/GUI.cpp
221
src/GUI.h
@@ -22,141 +22,167 @@
|
|||||||
#ifndef GUI_H
|
#ifndef GUI_H
|
||||||
#define GUI_H
|
#define GUI_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QTcpServer>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
#include "ui_MainWindow.h"
|
#include <libtorrent/entry.hpp>
|
||||||
#include "qtorrenthandle.h"
|
#include <libtorrent/bencode.hpp>
|
||||||
|
#include <libtorrent/session.hpp>
|
||||||
|
#include <libtorrent/fingerprint.hpp>
|
||||||
|
#include <libtorrent/session_settings.hpp>
|
||||||
|
#include <libtorrent/identify_client.hpp>
|
||||||
|
#include <libtorrent/alert_types.hpp>
|
||||||
|
|
||||||
|
#include "ui_MainWindow.h"
|
||||||
|
#include "options_imp.h"
|
||||||
|
#include "about_imp.h"
|
||||||
|
#include "previewSelect.h"
|
||||||
|
#include "trackerLogin.h"
|
||||||
|
#include "bittorrent.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define TIME_TRAY_BALLOON 5000
|
||||||
|
|
||||||
class bittorrent;
|
|
||||||
class createtorrent;
|
class createtorrent;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class DownloadingTorrents;
|
class QCompleter;
|
||||||
class FinishedTorrents;
|
class DLListDelegate;
|
||||||
|
class SearchListDelegate;
|
||||||
|
class downloadThread;
|
||||||
class downloadFromURL;
|
class downloadFromURL;
|
||||||
class SearchEngine;
|
|
||||||
class QTcpServer;
|
|
||||||
class QTcpSocket;
|
class QTcpSocket;
|
||||||
class QCloseEvent;
|
class QCloseEvent;
|
||||||
class RSSImp;
|
|
||||||
class QShortcut;
|
using namespace libtorrent;
|
||||||
class about;
|
namespace fs = boost::filesystem;
|
||||||
class previewSelect;
|
|
||||||
class options_imp;
|
|
||||||
class QTabWidget;
|
|
||||||
class QLabel;
|
|
||||||
class QModelIndex;
|
|
||||||
class HttpServer;
|
|
||||||
|
|
||||||
class GUI : public QMainWindow, private Ui::MainWindow{
|
class GUI : public QMainWindow, private Ui::MainWindow{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Bittorrent
|
// Bittorrent
|
||||||
bittorrent *BTSession;
|
bittorrent BTSession;
|
||||||
QTimer *checkConnect;
|
QTimer *checkConnect;
|
||||||
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers;
|
QHash<QString, QStringList> trackerErrors;
|
||||||
|
QList<QPair<torrent_handle,std::string> > unauthenticated_trackers;
|
||||||
|
downloadFromURL *downloadFromURLDialog;
|
||||||
// GUI related
|
// GUI related
|
||||||
QTabWidget *tabs;
|
|
||||||
options_imp *options;
|
options_imp *options;
|
||||||
QSystemTrayIcon *myTrayIcon;
|
createtorrent *createWindow;
|
||||||
QTimer *systrayCreator;
|
|
||||||
QMenu *myTrayIconMenu;
|
|
||||||
DownloadingTorrents *downloadingTorrentTab;
|
|
||||||
FinishedTorrents *finishedTorrentTab;
|
|
||||||
QLabel *connecStatusLblIcon;
|
|
||||||
bool systrayIntegration;
|
|
||||||
bool displaySpeedInTitle;
|
|
||||||
bool force_exit;
|
|
||||||
unsigned int refreshInterval;
|
|
||||||
QTimer *refresher;
|
QTimer *refresher;
|
||||||
// Keyboard shortcuts
|
QSystemTrayIcon *myTrayIcon;
|
||||||
QShortcut *switchSearchShortcut;
|
QMenu *myTrayIconMenu;
|
||||||
QShortcut *switchSearchShortcut2;
|
about *aboutdlg;
|
||||||
QShortcut *switchDownShortcut;
|
QStandardItemModel *DLListModel;
|
||||||
QShortcut *switchUpShortcut;
|
DLListDelegate *DLDelegate;
|
||||||
QShortcut *switchRSSShortcut;
|
QStandardItemModel *SearchListModel;
|
||||||
// Search
|
SearchListDelegate *SearchDelegate;
|
||||||
SearchEngine *searchEngine;
|
unsigned int nbTorrents;
|
||||||
// RSS
|
QLabel *connecStatusLblIcon;
|
||||||
RSSImp *rssWidget;
|
bool force_exit;
|
||||||
// Web UI
|
// Preview
|
||||||
HttpServer *httpServer;
|
previewSelect *previewSelection;
|
||||||
// Misc
|
QProcess *previewProcess;
|
||||||
QTcpServer *tcpServer;
|
// Search related
|
||||||
|
QHash<QString, QString> searchResultsUrls;
|
||||||
|
QProcess *searchProcess;
|
||||||
|
bool search_stopped;
|
||||||
|
bool no_search_results;
|
||||||
|
QByteArray search_result_line_truncated;
|
||||||
|
unsigned long nb_search_results;
|
||||||
|
QTcpServer tcpServer;
|
||||||
QTcpSocket *clientConnection;
|
QTcpSocket *clientConnection;
|
||||||
|
QCompleter *searchCompleter;
|
||||||
|
QStringList searchHistory;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
// GUI related slots
|
// GUI related slots
|
||||||
void dropEvent(QDropEvent *event);
|
void dropEvent(QDropEvent *event);
|
||||||
void dragEnterEvent(QDragEnterEvent *event);
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
|
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
|
||||||
void on_actionAbout_triggered();
|
void showAbout();
|
||||||
void on_actionCreate_torrent_triggered();
|
void setInfoBar(const QString& info, const QString& color="black");
|
||||||
void on_actionWebsite_triggered() const;
|
void updateDlList(bool force=false);
|
||||||
void on_actionBugReport_triggered() const;
|
void showCreateWindow();
|
||||||
|
void clearLog();
|
||||||
|
void openqBTHomepage();
|
||||||
|
void openqBTBugTracker();
|
||||||
void readParamsOnSocket();
|
void readParamsOnSocket();
|
||||||
void acceptConnection();
|
void acceptConnection();
|
||||||
void togglePausedState(QString hash);
|
void saveCheckedSearchEngines(int) const;
|
||||||
void torrentDoubleClicked(QString hash, bool finished);
|
void saveColWidthDLList() const;
|
||||||
void on_actionPreview_file_triggered();
|
void saveColWidthSearchList() const;
|
||||||
void previewFile(QString filePath);
|
void loadCheckedSearchEngines();
|
||||||
|
bool loadColWidthDLList();
|
||||||
|
bool loadColWidthSearchList();
|
||||||
|
void sortDownloadList(int index);
|
||||||
|
void sortDownloadListFloat(int index, Qt::SortOrder sortOrder);
|
||||||
|
void sortDownloadListString(int index, Qt::SortOrder sortOrder);
|
||||||
|
void sortSearchList(int index);
|
||||||
|
void sortSearchListInt(int index, Qt::SortOrder sortOrder);
|
||||||
|
void sortSearchListString(int index, Qt::SortOrder sortOrder);
|
||||||
|
void displayDLListMenu(const QPoint& pos);
|
||||||
|
void selectGivenRow(const QModelIndex& index);
|
||||||
|
void togglePausedState(const QModelIndex& index);
|
||||||
|
void displayInfoBarMenu(const QPoint& pos);
|
||||||
|
void displayGUIMenu(const QPoint& pos);
|
||||||
|
void previewFileSelection();
|
||||||
|
void previewFile(const QString& filePath);
|
||||||
|
void cleanTempPreviewFile(int, QProcess::ExitStatus);
|
||||||
void balloonClicked();
|
void balloonClicked();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void on_actionExit_triggered();
|
void forceExit();
|
||||||
void createTrayIcon();
|
|
||||||
void updateUnfinishedTorrentNumber(unsigned int nb);
|
|
||||||
void updateFinishedTorrentNumber(unsigned int nb);
|
|
||||||
void fullDiskError(QTorrentHandle& h) const;
|
|
||||||
void handleDownloadFromUrlFailure(QString, QString) const;
|
|
||||||
void createSystrayDelayed();
|
|
||||||
// Keyboard shortcuts
|
|
||||||
void createKeyboardShortcuts();
|
|
||||||
void displayDownTab() const;
|
|
||||||
void displayUpTab() const;
|
|
||||||
void displaySearchTab() const;
|
|
||||||
void displayRSSTab() const;
|
|
||||||
// Torrent actions
|
// Torrent actions
|
||||||
void on_actionTorrent_Properties_triggered();
|
void showProperties(const QModelIndex &index);
|
||||||
void on_actionPause_triggered();
|
void propertiesSelection();
|
||||||
void on_actionPause_All_triggered();
|
void pauseSelection();
|
||||||
void on_actionStart_triggered();
|
void pauseAll();
|
||||||
void on_actionStart_All_triggered();
|
void startSelection();
|
||||||
void on_actionOpen_triggered();
|
void resumeAll();
|
||||||
void on_actionDelete_Permanently_triggered();
|
void askForTorrents();
|
||||||
void on_actionDelete_triggered();
|
void deletePermanently();
|
||||||
void on_actionSet_global_upload_limit_triggered();
|
void deleteSelection();
|
||||||
void on_actionSet_global_download_limit_triggered();
|
|
||||||
void on_actionDocumentation_triggered() const;
|
|
||||||
void checkConnectionStatus();
|
void checkConnectionStatus();
|
||||||
void configureSession(bool deleteOptions);
|
void configureSession(bool deleteOptions);
|
||||||
void processParams(const QStringList& params);
|
void processParams(const QStringList& params);
|
||||||
void addTorrent(QString path);
|
void addUnauthenticatedTracker(QPair<torrent_handle,std::string> tracker);
|
||||||
void addUnauthenticatedTracker(QPair<QTorrentHandle,QString> tracker);
|
|
||||||
void processScannedFiles(const QStringList& params);
|
void processScannedFiles(const QStringList& params);
|
||||||
void processDownloadedFiles(QString path, QString url);
|
void processDownloadedFiles(const QString& path, const QString& url);
|
||||||
void downloadFromURLList(const QStringList& urls);
|
void downloadFromURLList(const QStringList& urls);
|
||||||
void deleteTorrent(QString hash);
|
void displayDownloadingUrlInfos(const QString& url);
|
||||||
void deleteRatioTorrent(QString fileName);
|
// Search slots
|
||||||
void finishedTorrent(QTorrentHandle& h) const;
|
void on_search_button_clicked();
|
||||||
void torrentChecked(QString hash) const;
|
void on_stop_search_button_clicked();
|
||||||
void updateLists();
|
void on_clear_button_clicked();
|
||||||
bool initWebUi(QString username, QString password, int port);
|
void on_download_button_clicked();
|
||||||
void pauseTorrent(QString hash);
|
void on_update_nova_button_clicked();
|
||||||
|
void appendSearchResult(const QString& line);
|
||||||
|
void searchFinished(int exitcode,QProcess::ExitStatus);
|
||||||
|
void readSearchOutput();
|
||||||
|
void searchStarted();
|
||||||
|
void downloadSelectedItem(const QModelIndex& index);
|
||||||
|
void startSearchHistory();
|
||||||
|
void saveSearchHistory();
|
||||||
|
// Utils slots
|
||||||
|
void setRowColor(int row, const QString& color, bool inDLList=true);
|
||||||
// Options slots
|
// Options slots
|
||||||
void on_actionOptions_triggered();
|
void showOptions();
|
||||||
void OptionsSaved(QString info, bool deleteOptions);
|
void OptionsSaved(const QString& info, bool deleteOptions);
|
||||||
// HTTP slots
|
// HTTP slots
|
||||||
void on_actionDownload_from_URL_triggered();
|
void askForTorrentUrl();
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void trackerAuthenticationRequired(QTorrentHandle& h);
|
void torrentAdded(const QString& path, torrent_handle& h, bool fastResume);
|
||||||
void setTabText(int index, QString text) const;
|
void torrentDuplicate(const QString& path);
|
||||||
void openDestinationFolder() const;
|
void torrentCorrupted(const QString& path);
|
||||||
void goBuyPage() const;
|
void finishedTorrent(torrent_handle& h);
|
||||||
void updateRatio();
|
void fullDiskError(torrent_handle& h);
|
||||||
|
void portListeningFailure();
|
||||||
|
void trackerError(const QString& hash, const QString& time, const QString& msg);
|
||||||
|
void trackerAuthenticationRequired(torrent_handle& h);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *);
|
void closeEvent(QCloseEvent *);
|
||||||
@@ -167,8 +193,11 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
|
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
|
||||||
~GUI();
|
~GUI();
|
||||||
// Methods
|
// Methods
|
||||||
int getCurrentTabIndex() const;
|
int getRowFromHash(const QString& name) const;
|
||||||
QPoint screenCenter() const;
|
float getNovaVersion(const QString& novaPath) const;
|
||||||
|
QByteArray getNovaChangelog(const QString& novaPath) const;
|
||||||
|
void updateNova() const;
|
||||||
|
QPoint screenCenter();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1005 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 820 B |
|
Before Width: | Height: | Size: 821 B |
|
Before Width: | Height: | Size: 722 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 575 B |
|
Before Width: | Height: | Size: 704 B |
|
Before Width: | Height: | Size: 998 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 799 B |
BIN
src/Icons/flags/china_hong_kong.png
Normal file
|
After Width: | Height: | Size: 558 B |
|
Before Width: | Height: | Size: 172 B |
|
Before Width: | Height: | Size: 449 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 248 B |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 813 B |
|
Before Width: | Height: | Size: 532 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
@@ -1,23 +1,22 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Categories=Qt;Application;Network;P2P
|
Categories=Qt;Application;Network;P2P
|
||||||
Comment=V1.1.0
|
Comment=V0.9.2
|
||||||
|
Encoding=UTF-8
|
||||||
Exec=qbittorrent
|
Exec=qbittorrent
|
||||||
GenericName=Bittorrent client
|
GenericName=Bittorrent client
|
||||||
GenericName[bg]=Торент клиент
|
|
||||||
GenericName[de]=Bittorren Client
|
|
||||||
GenericName[el]=Τορεντ πελάτης
|
|
||||||
GenericName[es]=Cliente Bittorrent
|
|
||||||
GenericName[fr]=Client Bittorrent
|
GenericName[fr]=Client Bittorrent
|
||||||
GenericName[it]=Client Bittorrent
|
|
||||||
GenericName[ja]=Bittorrent クライアント
|
|
||||||
GenericName[ko]=비토렌트 클라이언트
|
|
||||||
GenericName[nl]=Bittorrent client
|
GenericName[nl]=Bittorrent client
|
||||||
GenericName[pl]=Klient Bittorrent
|
GenericName[es]=Cliente Bittorrent
|
||||||
GenericName[ru]=клиент Bittorrent
|
|
||||||
GenericName[sv]=Bittorrent-klient
|
GenericName[sv]=Bittorrent-klient
|
||||||
GenericName[tr]=Bittorrent istemcisi
|
GenericName[tr]=Bittorrent istemcisi
|
||||||
GenericName[uk]=Bittorrent-клієнт
|
GenericName[de]=Bittorren Client
|
||||||
|
GenericName[pl]=Klient Bittorrent
|
||||||
GenericName[zh]=Bittorrent之用户
|
GenericName[zh]=Bittorrent之用户
|
||||||
|
GenericName[ko]=비토렌트 클라이언트
|
||||||
|
GenericName[el]=Τορεντ πελάτης
|
||||||
|
GenericName[bg]=Торент клиент
|
||||||
|
GenericName[uk]=Bittorrent-клієнт
|
||||||
|
GenericName[ru]=клиент Bittorrent
|
||||||
Icon=qbittorrent
|
Icon=qbittorrent
|
||||||
MimeType=application/x-bittorrent
|
MimeType=application/x-bittorrent
|
||||||
Name=qBittorrent
|
Name=qBittorrent
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 948 B |
|
Before Width: | Height: | Size: 607 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 842 B After Width: | Height: | Size: 496 B |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 304 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 770 B |
|
Before Width: | Height: | Size: 337 B |
|
Before Width: | Height: | Size: 379 B |
BIN
src/Icons/splash.jpg
Normal file
|
After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 766 B |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 739 B |
|
Before Width: | Height: | Size: 856 B |
|
Before Width: | Height: | Size: 888 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 825 B |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 765 B |
|
Before Width: | Height: | Size: 787 B |
|
Before Width: | Height: | Size: 629 B |
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
#include <QItemDelegate>
|
#include <QItemDelegate>
|
||||||
#include <QStyleOptionProgressBarV2>
|
#include <QStyleOptionProgressBarV2>
|
||||||
#include <QStyleOptionViewItemV2>
|
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QProgressBar>
|
#include <QProgressBar>
|
||||||
@@ -36,43 +35,80 @@
|
|||||||
#define SIZE 1
|
#define SIZE 1
|
||||||
#define PROGRESS 2
|
#define PROGRESS 2
|
||||||
|
|
||||||
class PreviewListDelegate: public QItemDelegate {
|
class PreviewListDelegate: public QAbstractItemDelegate {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PreviewListDelegate(QObject *parent=0) : QItemDelegate(parent){}
|
PreviewListDelegate(QObject *parent=0) : QAbstractItemDelegate(parent){}
|
||||||
|
|
||||||
~PreviewListDelegate(){}
|
~PreviewListDelegate(){}
|
||||||
|
|
||||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||||
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
QItemDelegate delegate;
|
||||||
|
QStyleOptionViewItem opt = option;
|
||||||
|
QStyleOptionProgressBarV2 newopt;
|
||||||
|
char tmp[MAX_CHAR_TMP];
|
||||||
|
float progress;
|
||||||
|
// set text color
|
||||||
|
QVariant value = index.data(Qt::TextColorRole);
|
||||||
|
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
|
||||||
|
opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
|
||||||
|
}
|
||||||
|
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
||||||
|
? QPalette::Normal : QPalette::Disabled;
|
||||||
|
if (option.state & QStyle::State_Selected){
|
||||||
|
painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
|
||||||
|
}else{
|
||||||
|
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||||
|
}
|
||||||
|
// draw the background color
|
||||||
|
if(index.column() != PROGRESS){
|
||||||
|
if (option.showDecorationSelected && (option.state & QStyle::State_Selected)){
|
||||||
|
if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)){
|
||||||
|
cg = QPalette::Inactive;
|
||||||
|
}
|
||||||
|
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
|
||||||
|
}else{
|
||||||
|
value = index.data(Qt::BackgroundColorRole);
|
||||||
|
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
|
||||||
|
painter->fillRect(option.rect, qvariant_cast<QColor>(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
switch(index.column()){
|
switch(index.column()){
|
||||||
case SIZE:
|
case SIZE:
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
painter->drawText(option.rect, Qt::AlignCenter, misc::friendlyUnit(index.data().toLongLong()));
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
|
||||||
break;
|
break;
|
||||||
case PROGRESS:{
|
case NAME:
|
||||||
float progress = index.data().toDouble()*100.;
|
painter->drawText(option.rect, Qt::AlignLeft, index.data().toString());
|
||||||
QStyleOptionProgressBarV2 newopt;
|
break;
|
||||||
|
case PROGRESS:
|
||||||
|
progress = index.data().toDouble()*100.;
|
||||||
|
snprintf(tmp, MAX_CHAR_TMP, "%.1f", progress);
|
||||||
newopt.rect = opt.rect;
|
newopt.rect = opt.rect;
|
||||||
newopt.text = QString(QByteArray::number(progress, 'f', 1))+QString::fromUtf8("%");
|
newopt.text = QString(tmp)+"%";
|
||||||
newopt.progress = (int)progress;
|
newopt.progress = (int)progress;
|
||||||
newopt.maximum = 100;
|
newopt.maximum = 100;
|
||||||
newopt.minimum = 0;
|
newopt.minimum = 0;
|
||||||
newopt.state |= QStyle::State_Enabled;
|
newopt.state |= QStyle::State_Enabled;
|
||||||
newopt.textVisible = true;
|
newopt.textVisible = false;
|
||||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt,
|
||||||
|
painter);
|
||||||
|
//We prefer to display text manually to control color/font/boldness
|
||||||
|
if (option.state & QStyle::State_Selected){
|
||||||
|
opt.palette.setColor(QPalette::Text, QColor("grey"));
|
||||||
|
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||||
|
}
|
||||||
|
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
QItemDelegate::paint(painter, option, index);
|
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const {
|
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||||
// No editor here
|
QItemDelegate delegate;
|
||||||
return 0;
|
return delegate.sizeHint(option, index);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,8 @@
|
|||||||
#ifndef PROPLISTDELEGATE_H
|
#ifndef PROPLISTDELEGATE_H
|
||||||
#define PROPLISTDELEGATE_H
|
#define PROPLISTDELEGATE_H
|
||||||
|
|
||||||
#include <QItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
#include <QStyleOptionProgressBarV2>
|
#include <QStyleOptionProgressBarV2>
|
||||||
#include <QStyleOptionViewItemV2>
|
|
||||||
#include <QStyleOptionComboBox>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QProgressBar>
|
#include <QProgressBar>
|
||||||
@@ -37,112 +34,82 @@
|
|||||||
#define NAME 0
|
#define NAME 0
|
||||||
#define SIZE 1
|
#define SIZE 1
|
||||||
#define PROGRESS 2
|
#define PROGRESS 2
|
||||||
#define PRIORITY 3
|
#define SELECTED 3
|
||||||
#define INDEX 4
|
|
||||||
|
|
||||||
#define IGNORED 0
|
class PropListDelegate: public QAbstractItemDelegate {
|
||||||
#define NORMAL 1
|
|
||||||
#define HIGH 2
|
|
||||||
#define MAXIMUM 7
|
|
||||||
|
|
||||||
class PropListDelegate: public QItemDelegate {
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
|
||||||
bool* filteredFilesChanged;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PropListDelegate(QObject *parent=0, bool* filteredFilesChanged=0) : QItemDelegate(parent){
|
PropListDelegate(QObject *parent=0) : QAbstractItemDelegate(parent){}
|
||||||
this->filteredFilesChanged = filteredFilesChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
~PropListDelegate(){}
|
~PropListDelegate(){}
|
||||||
|
|
||||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||||
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
QStyleOptionViewItem opt = option;
|
||||||
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
|
char tmp[MAX_CHAR_TMP];
|
||||||
|
// set text color
|
||||||
|
QVariant value = index.data(Qt::TextColorRole);
|
||||||
|
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
|
||||||
|
opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
|
||||||
|
}
|
||||||
|
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
||||||
|
? QPalette::Normal : QPalette::Disabled;
|
||||||
|
if (option.state & QStyle::State_Selected){
|
||||||
|
painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
|
||||||
|
}else{
|
||||||
|
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||||
|
}
|
||||||
|
// draw the background color
|
||||||
|
if(index.column() != PROGRESS){
|
||||||
|
if (option.showDecorationSelected && (option.state & QStyle::State_Selected)){
|
||||||
|
if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)){
|
||||||
|
cg = QPalette::Inactive;
|
||||||
|
}
|
||||||
|
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
|
||||||
|
}else{
|
||||||
|
value = index.data(Qt::BackgroundColorRole);
|
||||||
|
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
|
||||||
|
painter->fillRect(option.rect, qvariant_cast<QColor>(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
switch(index.column()){
|
switch(index.column()){
|
||||||
case SIZE:
|
case SIZE:
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
painter->drawText(option.rect, Qt::AlignCenter, misc::friendlyUnit(index.data().toLongLong()));
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
break;
|
||||||
|
case NAME:
|
||||||
|
painter->drawText(option.rect, Qt::AlignLeft, index.data().toString());
|
||||||
break;
|
break;
|
||||||
case PROGRESS:{
|
case PROGRESS:{
|
||||||
QStyleOptionProgressBarV2 newopt;
|
QStyleOptionProgressBarV2 newopt;
|
||||||
float progress = index.data().toDouble()*100.;
|
float progress = index.data().toDouble()*100.;
|
||||||
|
snprintf(tmp, MAX_CHAR_TMP, "%.1f", progress);
|
||||||
newopt.rect = opt.rect;
|
newopt.rect = opt.rect;
|
||||||
newopt.text = QString(QByteArray::number(progress, 'f', 1))+QString::fromUtf8("%");
|
newopt.text = QString(tmp)+"%";
|
||||||
newopt.progress = (int)progress;
|
newopt.progress = (int)progress;
|
||||||
newopt.maximum = 100;
|
newopt.maximum = 100;
|
||||||
newopt.minimum = 0;
|
newopt.minimum = 0;
|
||||||
newopt.state |= QStyle::State_Enabled;
|
newopt.state |= QStyle::State_Enabled;
|
||||||
newopt.textVisible = true;
|
newopt.textVisible = false;
|
||||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt,
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PRIORITY:{
|
|
||||||
QStyleOptionComboBox newopt;
|
|
||||||
newopt.rect = opt.rect;
|
|
||||||
switch(index.data().toInt()){
|
|
||||||
case IGNORED:
|
|
||||||
newopt.currentText = tr("Ignored");
|
|
||||||
break;
|
|
||||||
case NORMAL:
|
|
||||||
newopt.currentText = tr("Normal", "Normal (priority)");
|
|
||||||
break;
|
|
||||||
case HIGH:
|
|
||||||
newopt.currentText = tr("High", "High (priority)");
|
|
||||||
break;
|
|
||||||
case MAXIMUM:
|
|
||||||
newopt.currentText = tr("Maximum", "Maximum (priority)");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
qDebug("Unhandled priority, setting NORMAL");
|
|
||||||
newopt.currentText = tr("Normal", "Normal (priority)");
|
|
||||||
}
|
|
||||||
newopt.state |= QStyle::State_Enabled;
|
|
||||||
QApplication::style()->drawComplexControl(QStyle::CC_ComboBox, &newopt,
|
|
||||||
painter);
|
painter);
|
||||||
opt.palette.setColor(QPalette::Text, QColor("black"));
|
//We prefer to display text manually to control color/font/boldness
|
||||||
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
if (option.state & QStyle::State_Selected){
|
||||||
painter->drawText(option.rect, Qt::AlignLeft, QString::fromUtf8(" ")+newopt.currentText);
|
opt.palette.setColor(QPalette::Text, QColor("grey"));
|
||||||
|
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||||
|
}
|
||||||
|
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
case SELECTED:
|
||||||
QItemDelegate::paint(painter, option, index);
|
if(index.data().toBool()){
|
||||||
}
|
painter->drawText(option.rect, Qt::AlignCenter, tr("True"));
|
||||||
}
|
}else{
|
||||||
|
painter->drawText(option.rect, Qt::AlignCenter, tr("False"));
|
||||||
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, const QModelIndex & index) const {
|
}
|
||||||
if(index.column() != PRIORITY) return 0;
|
|
||||||
QComboBox* editor = new QComboBox(parent);
|
|
||||||
editor->setFocusPolicy(Qt::StrongFocus);
|
|
||||||
editor->addItem(tr("Ignored"));
|
|
||||||
editor->addItem(tr("Normal", "Normal (priority)"));
|
|
||||||
editor->addItem(tr("High", "High (priority)"));
|
|
||||||
editor->addItem(tr("Maximum", "Maximum (priority)"));
|
|
||||||
return editor;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setEditorData(QWidget *editor, const QModelIndex &index) const {
|
|
||||||
unsigned short val = index.model()->data(index, Qt::DisplayRole).toInt();
|
|
||||||
QComboBox *combobox = static_cast<QComboBox*>(editor);
|
|
||||||
qDebug("Set Editor data: Prio is %d", val);
|
|
||||||
switch(val){
|
|
||||||
case IGNORED:
|
|
||||||
combobox->setCurrentIndex(0);
|
|
||||||
break;
|
|
||||||
case NORMAL:
|
|
||||||
combobox->setCurrentIndex(1);
|
|
||||||
break;
|
|
||||||
case HIGH:
|
|
||||||
combobox->setCurrentIndex(2);
|
|
||||||
break;
|
|
||||||
case MAXIMUM:
|
|
||||||
combobox->setCurrentIndex(3);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug("Unhandled priority, setting to NORMAL");
|
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
|
||||||
combobox->setCurrentIndex(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,73 +121,6 @@ class PropListDelegate: public QItemDelegate {
|
|||||||
QRect textRect = QRect(0, 0, 0, fontMetrics.lineSpacing() * (text.count(QLatin1Char('\n')) + 1));
|
QRect textRect = QRect(0, 0, 0, fontMetrics.lineSpacing() * (text.count(QLatin1Char('\n')) + 1));
|
||||||
return textRect.size();
|
return textRect.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
|
|
||||||
QComboBox *combobox = static_cast<QComboBox*>(editor);
|
|
||||||
int value = combobox->currentIndex();
|
|
||||||
qDebug("Setting combobox value in index: %d", value);
|
|
||||||
unsigned short old_val = index.model()->data(index, Qt::DisplayRole).toInt();
|
|
||||||
switch(value){
|
|
||||||
case 0:
|
|
||||||
if(old_val != IGNORED){
|
|
||||||
model->setData(index, QVariant(IGNORED));
|
|
||||||
if(filteredFilesChanged != 0)
|
|
||||||
*filteredFilesChanged = true;
|
|
||||||
} else {
|
|
||||||
// XXX: hack to force the model to send the itemChanged() signal
|
|
||||||
model->setData(index, QVariant(NORMAL));
|
|
||||||
model->setData(index, QVariant(IGNORED));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
// if(old_val != NORMAL){
|
|
||||||
// model->setData(index, QVariant(NORMAL));
|
|
||||||
// if(filteredFilesChanged != 0)
|
|
||||||
// *filteredFilesChanged = true;
|
|
||||||
// } else {
|
|
||||||
model->setData(index, QVariant(HIGH));
|
|
||||||
model->setData(index, QVariant(NORMAL));
|
|
||||||
if(filteredFilesChanged != 0)
|
|
||||||
*filteredFilesChanged = true;
|
|
||||||
// }
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if(old_val != HIGH){
|
|
||||||
model->setData(index, QVariant(HIGH));
|
|
||||||
if(filteredFilesChanged != 0)
|
|
||||||
*filteredFilesChanged = true;
|
|
||||||
} else {
|
|
||||||
model->setData(index, QVariant(NORMAL));
|
|
||||||
model->setData(index, QVariant(HIGH));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if(old_val != MAXIMUM){
|
|
||||||
model->setData(index, QVariant(MAXIMUM));
|
|
||||||
if(filteredFilesChanged != 0)
|
|
||||||
*filteredFilesChanged = true;
|
|
||||||
} else {
|
|
||||||
model->setData(index, QVariant(HIGH));
|
|
||||||
model->setData(index, QVariant(MAXIMUM));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if(old_val != NORMAL){
|
|
||||||
model->setData(index, QVariant(NORMAL));
|
|
||||||
if(filteredFilesChanged != 0)
|
|
||||||
*filteredFilesChanged = true;
|
|
||||||
} else {
|
|
||||||
model->setData(index, QVariant(HIGH));
|
|
||||||
model->setData(index, QVariant(NORMAL));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/* index */) const {
|
|
||||||
editor->setGeometry(option.rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,9 +22,8 @@
|
|||||||
#ifndef SEARCHLISTDELEGATE_H
|
#ifndef SEARCHLISTDELEGATE_H
|
||||||
#define SEARCHLISTDELEGATE_H
|
#define SEARCHLISTDELEGATE_H
|
||||||
|
|
||||||
#include <QItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
#include <QStyleOptionProgressBarV2>
|
#include <QStyleOptionProgressBarV2>
|
||||||
#include <QStyleOptionViewItemV2>
|
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QProgressBar>
|
#include <QProgressBar>
|
||||||
@@ -37,29 +36,59 @@
|
|||||||
#define LEECHERS 3
|
#define LEECHERS 3
|
||||||
#define ENGINE 4
|
#define ENGINE 4
|
||||||
|
|
||||||
class SearchListDelegate: public QItemDelegate {
|
class SearchListDelegate: public QAbstractItemDelegate {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SearchListDelegate(QObject *parent=0) : QItemDelegate(parent){}
|
SearchListDelegate(QObject *parent=0) : QAbstractItemDelegate(parent){}
|
||||||
|
|
||||||
~SearchListDelegate(){}
|
~SearchListDelegate(){}
|
||||||
|
|
||||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||||
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
QStyleOptionViewItem opt = option;
|
||||||
|
// set text color
|
||||||
|
QVariant value = index.data(Qt::TextColorRole);
|
||||||
|
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
|
||||||
|
opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
|
||||||
|
}
|
||||||
|
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
||||||
|
? QPalette::Normal : QPalette::Disabled;
|
||||||
|
if (option.state & QStyle::State_Selected){
|
||||||
|
painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
|
||||||
|
}else{
|
||||||
|
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||||
|
}
|
||||||
|
// draw the background color
|
||||||
|
if (option.showDecorationSelected && (option.state & QStyle::State_Selected)){
|
||||||
|
if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)){
|
||||||
|
cg = QPalette::Inactive;
|
||||||
|
}
|
||||||
|
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
|
||||||
|
}else{
|
||||||
|
value = index.data(Qt::BackgroundColorRole);
|
||||||
|
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
|
||||||
|
painter->fillRect(option.rect, qvariant_cast<QColor>(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
switch(index.column()){
|
switch(index.column()){
|
||||||
case SIZE:
|
case SIZE:
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
painter->drawText(option.rect, Qt::AlignCenter, misc::friendlyUnit(index.data().toLongLong()));
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
break;
|
||||||
|
case NAME:
|
||||||
|
painter->drawText(option.rect, Qt::AlignLeft, index.data().toString());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
QItemDelegate::paint(painter, option, index);
|
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const {
|
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||||
// No editor here
|
QVariant value = index.data(Qt::FontRole);
|
||||||
return 0;
|
QFont fnt = value.isValid() ? qvariant_cast<QFont>(value) : option.font;
|
||||||
|
QFontMetrics fontMetrics(fnt);
|
||||||
|
const QString text = index.data(Qt::DisplayRole).toString();
|
||||||
|
QRect textRect = QRect(0, 0, 0, fontMetrics.lineSpacing() * (text.count(QLatin1Char('\n')) + 1));
|
||||||
|
return textRect.size();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* Contact : chris@qbittorrent.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TRACKERSADDITION_H
|
|
||||||
#define TRACKERSADDITION_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QStringList>
|
|
||||||
#include "ui_trackersAdd.h"
|
|
||||||
|
|
||||||
class TrackersAddDlg : public QDialog, private Ui::TrackersAdditionDlg{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
TrackersAddDlg(QWidget *parent): QDialog(parent){
|
|
||||||
setupUi(this);
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
|
|
||||||
~TrackersAddDlg(){}
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void TrackersToAdd(QStringList trackers);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void on_buttonBox_accepted() {
|
|
||||||
QStringList trackers = trackers_list->toPlainText().trimmed().split("\n");
|
|
||||||
if(trackers.size()) {
|
|
||||||
emit TrackersToAdd(trackers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
519
src/about.ui
@@ -1,5 +1,7 @@
|
|||||||
<ui version="4.0" >
|
<ui version="4.0" >
|
||||||
<author>Christophe Dumez</author>
|
<author>Christophe Dumez</author>
|
||||||
|
<comment></comment>
|
||||||
|
<exportmacro></exportmacro>
|
||||||
<class>AboutDlg</class>
|
<class>AboutDlg</class>
|
||||||
<widget class="QDialog" name="AboutDlg" >
|
<widget class="QDialog" name="AboutDlg" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
@@ -10,38 +12,26 @@
|
|||||||
<height>320</height>
|
<height>320</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>504</width>
|
|
||||||
<height>320</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>504</width>
|
|
||||||
<height>320</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
<string>About qBittorrent</string>
|
<string>About qBittorrent</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="logo" >
|
<widget class="QLabel" name="logo" >
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
@@ -50,7 +40,9 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="lb_name" >
|
<widget class="QLabel" name="lb_name" >
|
||||||
<property name="sizePolicy" >
|
<property name="sizePolicy" >
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
<sizepolicy>
|
||||||
|
<hsizetype>7</hsizetype>
|
||||||
|
<vsizetype>5</vsizetype>
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@@ -63,19 +55,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -87,257 +66,289 @@
|
|||||||
<attribute name="title" >
|
<attribute name="title" >
|
||||||
<string>About</string>
|
<string>About</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<widget class="QLabel" name="mascot_lbl" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>380</x>
|
|
||||||
<y>50</y>
|
|
||||||
<width>94</width>
|
|
||||||
<height>162</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QLabel" name="lb_about" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>40</y>
|
|
||||||
<width>481</width>
|
|
||||||
<height>102</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>A bittorrent client using Qt4 and libtorrent, programmed in C++.<br>
|
|
||||||
<br>
|
|
||||||
Copyright © 2006 by Christophe Dumez<br>
|
|
||||||
<br> <u>Home Page:</u> <i>http://www.qbittorrent.org</i><br></string>
|
|
||||||
</property>
|
|
||||||
<property name="textFormat" >
|
|
||||||
<enum>Qt::RichText</enum>
|
|
||||||
</property>
|
|
||||||
<property name="alignment" >
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="tab3" >
|
|
||||||
<attribute name="title" >
|
|
||||||
<string>Author</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="te_authors" >
|
<widget class="QWidget" name="widget1" >
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType" >
|
<property name="sizeType" >
|
||||||
<enum>QSizePolicy::Preferred</enum>
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" >
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>20</height>
|
<height>40</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" >
|
<widget class="QLabel" name="lb_about" >
|
||||||
<property name="spacing" >
|
<property name="sizePolicy" >
|
||||||
<number>6</number>
|
<sizepolicy>
|
||||||
|
<hsizetype>7</hsizetype>
|
||||||
|
<vsizetype>7</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<property name="text" >
|
||||||
<widget class="QLabel" name="label_3" >
|
<string>A bittorrent client using Qt4 and libtorrent, programmed in C++.<br>
|
||||||
<property name="font" >
|
<br>
|
||||||
<font>
|
Copyright © 2006 by Christophe Dumez<br>
|
||||||
<family>Sans Serif</family>
|
<br> <u>Home Page:</u> <i>http://www.qbittorrent.org</i><br></string>
|
||||||
<pointsize>9</pointsize>
|
</property>
|
||||||
<weight>50</weight>
|
<property name="textFormat" >
|
||||||
<italic>false</italic>
|
<enum>Qt::RichText</enum>
|
||||||
<bold>false</bold>
|
</property>
|
||||||
<underline>true</underline>
|
<property name="alignment" >
|
||||||
<strikeout>false</strikeout>
|
<set>Qt::AlignCenter</set>
|
||||||
</font>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<property name="text" >
|
|
||||||
<string>Name:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_4" >
|
|
||||||
<property name="font" >
|
|
||||||
<font>
|
|
||||||
<family>Sans Serif</family>
|
|
||||||
<pointsize>9</pointsize>
|
|
||||||
<weight>50</weight>
|
|
||||||
<italic>false</italic>
|
|
||||||
<bold>false</bold>
|
|
||||||
<underline>true</underline>
|
|
||||||
<strikeout>false</strikeout>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Country:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lbl_birthday" >
|
|
||||||
<property name="font" >
|
|
||||||
<font>
|
|
||||||
<family>Sans Serif</family>
|
|
||||||
<pointsize>9</pointsize>
|
|
||||||
<weight>50</weight>
|
|
||||||
<italic>false</italic>
|
|
||||||
<bold>false</bold>
|
|
||||||
<underline>true</underline>
|
|
||||||
<strikeout>false</strikeout>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Birthday:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lbl_occupation" >
|
|
||||||
<property name="font" >
|
|
||||||
<font>
|
|
||||||
<family>Sans Serif</family>
|
|
||||||
<pointsize>9</pointsize>
|
|
||||||
<weight>50</weight>
|
|
||||||
<italic>false</italic>
|
|
||||||
<bold>false</bold>
|
|
||||||
<underline>true</underline>
|
|
||||||
<strikeout>false</strikeout>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Occupation:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_5" >
|
|
||||||
<property name="font" >
|
|
||||||
<font>
|
|
||||||
<family>Sans Serif</family>
|
|
||||||
<pointsize>9</pointsize>
|
|
||||||
<weight>50</weight>
|
|
||||||
<italic>false</italic>
|
|
||||||
<bold>false</bold>
|
|
||||||
<underline>true</underline>
|
|
||||||
<strikeout>false</strikeout>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>E-mail:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_8" >
|
|
||||||
<property name="font" >
|
|
||||||
<font>
|
|
||||||
<family>Sans Serif</family>
|
|
||||||
<pointsize>9</pointsize>
|
|
||||||
<weight>50</weight>
|
|
||||||
<italic>false</italic>
|
|
||||||
<bold>false</bold>
|
|
||||||
<underline>true</underline>
|
|
||||||
<strikeout>false</strikeout>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Home page:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType" >
|
<property name="sizeType" >
|
||||||
<enum>QSizePolicy::Preferred</enum>
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" >
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>20</height>
|
<height>40</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab3" >
|
||||||
|
<attribute name="title" >
|
||||||
|
<string>Author</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="te_authors" >
|
||||||
|
<layout class="QHBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" >
|
<widget class="QSplitter" name="splitter" >
|
||||||
<property name="spacing" >
|
<property name="orientation" >
|
||||||
<number>6</number>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<widget class="QWidget" name="widget" >
|
||||||
<widget class="QLabel" name="label_2" >
|
<layout class="QHBoxLayout" >
|
||||||
<property name="text" >
|
<property name="margin" >
|
||||||
<string>Christophe Dumez</string>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="spacing" >
|
||||||
</item>
|
<number>6</number>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_7" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>France</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<item>
|
||||||
</item>
|
<layout class="QVBoxLayout" >
|
||||||
<item>
|
<property name="margin" >
|
||||||
<widget class="QLabel" name="label_11" >
|
<number>0</number>
|
||||||
<property name="text" >
|
</property>
|
||||||
<string>03/05/1985</string>
|
<property name="spacing" >
|
||||||
</property>
|
<number>6</number>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
<item>
|
||||||
<item>
|
<widget class="QLabel" name="label_3" >
|
||||||
<widget class="QLabel" name="label_10" >
|
<property name="font" >
|
||||||
<property name="text" >
|
<font>
|
||||||
<string>Student in computer science</string>
|
<family>Sans Serif</family>
|
||||||
</property>
|
<pointsize>9</pointsize>
|
||||||
</widget>
|
<weight>50</weight>
|
||||||
</item>
|
<italic>false</italic>
|
||||||
<item>
|
<bold>false</bold>
|
||||||
<widget class="QLabel" name="label_6" >
|
<underline>true</underline>
|
||||||
<property name="text" >
|
<strikeout>false</strikeout>
|
||||||
<string>chris@qbittorrent.org</string>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="text" >
|
||||||
</item>
|
<string>Name:</string>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QLabel" name="label_9" >
|
</widget>
|
||||||
<property name="text" >
|
</item>
|
||||||
<string>http://www.dchris.eu</string>
|
<item>
|
||||||
</property>
|
<widget class="QLabel" name="label_4" >
|
||||||
</widget>
|
<property name="font" >
|
||||||
</item>
|
<font>
|
||||||
</layout>
|
<family>Sans Serif</family>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
<weight>50</weight>
|
||||||
|
<italic>false</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
<underline>true</underline>
|
||||||
|
<strikeout>false</strikeout>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Country:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lbl_birthday" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<family>Sans Serif</family>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
<weight>50</weight>
|
||||||
|
<italic>false</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
<underline>true</underline>
|
||||||
|
<strikeout>false</strikeout>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Birthday:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lbl_occupation" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<family>Sans Serif</family>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
<weight>50</weight>
|
||||||
|
<italic>false</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
<underline>true</underline>
|
||||||
|
<strikeout>false</strikeout>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Occupation:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<family>Sans Serif</family>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
<weight>50</weight>
|
||||||
|
<italic>false</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
<underline>true</underline>
|
||||||
|
<strikeout>false</strikeout>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>E-mail:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_8" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<family>Sans Serif</family>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
<weight>50</weight>
|
||||||
|
<italic>false</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
<underline>true</underline>
|
||||||
|
<strikeout>false</strikeout>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Home page:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Christophe Dumez</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_7" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>France</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_11" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>03/05/1985</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_10" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Student in computer science</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_6" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>chris@qbittorrent.org</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_9" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>http://www.dchris.eu</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer>
|
<spacer>
|
||||||
@@ -359,9 +370,12 @@ Copyright © 2006 by Christophe Dumez<br>
|
|||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab4" >
|
<widget class="QWidget" name="tab4" >
|
||||||
<attribute name="title" >
|
<attribute name="title" >
|
||||||
<string>Thanks to</string>
|
<string>Thanks To</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -375,6 +389,9 @@ Copyright © 2006 by Christophe Dumez<br>
|
|||||||
<string>Translation</string>
|
<string>Translation</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -392,6 +409,9 @@ Copyright © 2006 by Christophe Dumez<br>
|
|||||||
<string>License</string>
|
<string>License</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -405,6 +425,7 @@ Copyright © 2006 by Christophe Dumez<br>
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11" />
|
<layoutdefault spacing="6" margin="11" />
|
||||||
|
<pixmapfunction></pixmapfunction>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -23,64 +23,51 @@
|
|||||||
#define ABOUT_H
|
#define ABOUT_H
|
||||||
|
|
||||||
#include "ui_about.h"
|
#include "ui_about.h"
|
||||||
#include <QScrollBar>
|
|
||||||
|
|
||||||
class about : public QDialog, private Ui::AboutDlg{
|
class about : public QDialog, private Ui::AboutDlg{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~about() {
|
about(QWidget *parent = 0): QDialog(parent){
|
||||||
qDebug("Deleting about dlg");
|
|
||||||
}
|
|
||||||
|
|
||||||
about(QWidget *parent): QDialog(parent){
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
// Set icons
|
// Set icons
|
||||||
logo->setPixmap(QPixmap(QString::fromUtf8(":/Icons/qbittorrent22.png")));
|
logo->setPixmap(QPixmap(QString::fromUtf8(":/Icons/qbittorrent32.png")));
|
||||||
mascot_lbl->setPixmap(QPixmap(QString::fromUtf8(":/Icons/mascot.png")));
|
|
||||||
//Title
|
//Title
|
||||||
lb_name->setText(QString::fromUtf8("<b><h1>")+tr("qBittorrent")+QString::fromUtf8(" "VERSION"</h1></b>"));
|
lb_name->setText("<b><h1>"+tr("qBittorrent")+" "VERSION"</h1></b>");
|
||||||
// Thanks
|
// Thanks
|
||||||
te_thanks->append(QString::fromUtf8("<a name='top'></a>"));
|
te_thanks->append("<ul><li>I would like to thank sourceforge.net for hosting qBittorrent project.</li>");
|
||||||
te_thanks->append(QString::fromUtf8("<ul><li>I would like to thank sourceforge.net for hosting qBittorrent project.</li>"));
|
te_thanks->append("<li>I also want to thank Jeffery Fernandez (jeffery@qbittorrent.org), project consultant, webdevelopper and RPM packager, for his help.</li>");
|
||||||
te_thanks->append(QString::fromUtf8("<li>I am happy that Arnaud Demaizière is contributing to the project as a developer. His help is greatly appreciated</li>"));
|
te_thanks->append("<li>I am gratefull to Peter Koeleman (peter@qbittorrent.org) and Johnny Mast (rave@qbittorrent.org) who helped me port qBittorrent to Windows.</li>");
|
||||||
te_thanks->append(QString::fromUtf8("<li>I also want to thank Jeffery Fernandez (jeffery@qbittorrent.org), project consultant, RPM packager, for his help and support.</li>"));
|
te_thanks->append("<li>Thanks a lot to our graphist Mateusz Toboła (tobejodok@qbittorrent.org) for his great work.</li></ul>");
|
||||||
te_thanks->append(QString::fromUtf8("<li>I am grateful to Peter Koeleman (peter@qbittorrent.org) who is helping port qBittorrent to Windows.</li>"));
|
|
||||||
te_thanks->append(QString::fromUtf8("<li>Thanks a lot to our graphist Mateusz Toboła (tobejodok@qbittorrent.org) for his great work.</li></ul><br><br>"));
|
|
||||||
te_thanks->scrollToAnchor(QString::fromUtf8("top"));
|
|
||||||
// Translation
|
// Translation
|
||||||
te_translation->append(QString::fromUtf8("<a name='top'></a>"));
|
te_translation->append(tr("I would like to thank the following people who volunteered to translate qBittorrent:")+"<br>");
|
||||||
te_translation->append(tr("I would like to thank the following people who volunteered to translate qBittorrent:")+QString::fromUtf8("<br>"));
|
|
||||||
te_translation->append(QString::fromUtf8(
|
te_translation->append(QString::fromUtf8(
|
||||||
"<i>- <u>Brazilian:</u> Nick Marinho (nickmarinho@gmail.com)<br>\
|
"<i>- <u>Bulgarian:</u> Tsvetan & Boiko Bankov (emerge_life@users.sourceforge.net)<br>\
|
||||||
- <u>Bulgarian:</u> Tsvetan & Boiko Bankov (emerge_life@users.sourceforge.net)<br>\
|
|
||||||
- <u>Catalan:</u> Gekko Dam Beer (gekko04@users.sourceforge.net)<br>\
|
- <u>Catalan:</u> Gekko Dam Beer (gekko04@users.sourceforge.net)<br>\
|
||||||
- <u>Chinese (Simplified):</u> Guo Yue (guoyue0418@hotmail.com)<br>\
|
- <u>Chinese (Simplified):</u> Guo Yue (guoyue0418@hotmail.com)<br>\
|
||||||
|
- <u>Chinese (Traditional):</u> Jeff Chen (jeff.cn.chen@gmail.com)<br>\
|
||||||
- <u>Danish:</u> Mathias Nielsen (comoneo@gmail.com)<br>\
|
- <u>Danish:</u> Mathias Nielsen (comoneo@gmail.com)<br>\
|
||||||
- <u>Dutch:</u> Joost Schipper (heavyjoost@users.sourceforge.net)<br>\
|
- <u>Dutch:</u> Luke Niesink (luke@lukeniesink.net)<br>\
|
||||||
- <u>Finnish:</u> Niklas Laxström (nikerabbit@users.sourceforge.net)<br>\
|
- <u>Finnish:</u> Niklas Laxström (nikerabbit@users.sourceforge.net)<br>\
|
||||||
- <u>German:</u> Niels Hoffmann (zentralmaschine@users.sourceforge.net)<br>\
|
- <u>German:</u> Niels Hoffmann (zentralmaschine@users.sourceforge.net)<br>\
|
||||||
- <u>Greek:</u> Tsvetan Bankov (emerge_life@users.sourceforge.net)<br>\
|
- <u>Greek:</u> Tsvetan Bankov (emerge_life@users.sourceforge.net)<br>\
|
||||||
- <u>Hungarian:</u> Majoros Péter (majoros.j.p@t-online.hu)<br>\
|
- <u>Italian:</u> Ferraro Luciano (luciano.ferraro@gmail.com)<br>\
|
||||||
- <u>Italian:</u> Mirko Ferrari (mirkoferrari@gmail.com) and Ferraro Luciano (luciano.ferraro@gmail.com)<br>\
|
|
||||||
- <u>Japanese:</u> Nardog (nardog@e2umail.com)<br>\
|
- <u>Japanese:</u> Nardog (nardog@e2umail.com)<br>\
|
||||||
- <u>Korean:</u> Jin Woo Sin (jin828sin@users.sourceforge.net)<br>\
|
- <u>Korean:</u> Jin Woo Sin (jin828sin@users.sourceforge.net)<br>\
|
||||||
- <u>Norwegian:</u> Lars-Erik Labori (hamil@users.sourceforge.net)<br>\
|
- <u>Norwegian:</u> Lars-Erik Labori (hamil@users.sourceforge.net)<br>\
|
||||||
- <u>Polish:</u> Jarek Smieja (ajep9691@wp.pl)<br>\
|
- <u>Polish:</u> Adam Babol (a-b@users.sourceforge.net)<br>\
|
||||||
- <u>Portuguese:</u> Nick Marinho (nickmarinho@gmail.com)<br>\
|
- <u>Portuguese:</u> Nick Marinho (nickmarinho@gmail.com)<br>\
|
||||||
- <u>Romanian:</u> Obada Denis (obadadenis@users.sourceforge.net)<br>\
|
- <u>Romanian:</u> Obada Denis (obadadenis@users.sourceforge.net)<br>\
|
||||||
- <u>Russian:</u> Nick Khazov (m2k3d0n at users.sourceforge.net)<br>\
|
- <u>Russian:</u> Nick Khazov (m2k3d0n at users.sourceforge.net)<br>\
|
||||||
- <u>Slovak:</u> helix84<br>\
|
- <u>Slovak:</u> helix84<br>\
|
||||||
- <u>Spanish:</u> Vicente Raul Plata Fonseca (silverxnt@users.sourceforge.net)<br>\
|
- <u>Spanish:</u> Vicente Raul Plata Fonseca (silverxnt@users.sourceforge.net)<br>\
|
||||||
- <u>Swedish:</u> Daniel Nylander (po@danielnylander.se)<br>\
|
- <u>Swedish:</u> Daniel Nylander (po@danielnylander.se)<br>\
|
||||||
- <u>Turkish:</u> Erdem Bingöl (erdem84@gmail.com)<br>\
|
- <u>Turkish:</u> Erdem Bingöl (erdem84@gmail.com)<br>\
|
||||||
- <u>Ukrainian:</u> Andrey Shpachenko (masterfix@users.sourceforge.net)<br><br>"));
|
- <u>Ukrainian:</u> Andrey Shpachenko (masterfix@users.sourceforge.net)<br><br>"));
|
||||||
te_translation->append(tr("Please contact me if you would like to translate qBittorrent into your own language."));
|
te_translation->append(tr("Please contact me if you would like to translate qBittorrent into your own language."));
|
||||||
te_translation->scrollToAnchor(QString::fromUtf8("top"));
|
|
||||||
// License
|
// License
|
||||||
te_license->append(QString::fromUtf8("<a name='top'></a>"));
|
te_license->append("<center><b>GNU GENERAL PUBLIC LICENSE</b></center><br>\
|
||||||
te_license->append(QString::fromUtf8("<center><b>GNU GENERAL PUBLIC LICENSE</b></center><br>\
|
|
||||||
<center>Version 2, June 1991</center><br>\
|
<center>Version 2, June 1991</center><br>\
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.<br>\
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.<br>\
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA<br>\
|
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA<br>\
|
||||||
@@ -413,8 +400,7 @@ class about : public QDialog, private Ui::AboutDlg{
|
|||||||
proprietary programs. If your program is a subroutine library, you may<br>\
|
proprietary programs. If your program is a subroutine library, you may<br>\
|
||||||
consider it more useful to permit linking proprietary applications with the<br>\
|
consider it more useful to permit linking proprietary applications with the<br>\
|
||||||
library. If this is what you want to do, use the GNU Library General<br>\
|
library. If this is what you want to do, use the GNU Library General<br>\
|
||||||
Public License instead of this License.<br>"));
|
Public License instead of this License.<br>");
|
||||||
te_license->scrollToAnchor(QString::fromUtf8("top"));
|
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,29 +5,20 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>511</width>
|
<width>440</width>
|
||||||
<height>441</height>
|
<height>389</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
<string>Torrent addition dialog</string>
|
<string>Torrent addition dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin" >
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="fileNameLbl" >
|
<widget class="QLabel" name="fileNameLbl" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
@@ -57,21 +48,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="savePathTxt" />
|
<widget class="QLineEdit" name="savePathTxt" />
|
||||||
</item>
|
</item>
|
||||||
@@ -98,16 +80,31 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="torrentContentList" >
|
<widget class="QTreeWidget" name="torrentContentList" >
|
||||||
<property name="contextMenuPolicy" >
|
<property name="contextMenuPolicy" >
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="editTriggers" >
|
|
||||||
<set>QAbstractItemView::AllEditTriggers</set>
|
|
||||||
</property>
|
|
||||||
<property name="selectionMode" >
|
<property name="selectionMode" >
|
||||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="indentation" >
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<column>
|
||||||
|
<property name="text" >
|
||||||
|
<string>File name</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text" >
|
||||||
|
<string>File size</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Selected</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -126,21 +123,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
@@ -184,24 +172,20 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
<action name="actionIgnored" >
|
<action name="actionSelect" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Ignored</string>
|
<string>Select</string>
|
||||||
|
</property>
|
||||||
|
<property name="iconText" >
|
||||||
|
<string>Select</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Select</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionNormal" >
|
<action name="actionUnselect" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Normal</string>
|
<string>Unselect</string>
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionHigh" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>High</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionMaximum" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Maximum</string>
|
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -1,179 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* Contact : chris@qbittorrent.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BANDWIDTH_ALLOCATION_H
|
|
||||||
#define BANDWIDTH_ALLOCATION_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QList>
|
|
||||||
#include <QSettings>
|
|
||||||
#include "ui_bandwidth_limit.h"
|
|
||||||
#include "misc.h"
|
|
||||||
#include "bittorrent.h"
|
|
||||||
|
|
||||||
using namespace libtorrent;
|
|
||||||
|
|
||||||
class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
BandwidthAllocationDialog(QWidget *parent, bool uploadMode, bittorrent *BTSession, QStringList hashes): QDialog(parent), uploadMode(uploadMode), hashes(hashes){
|
|
||||||
setupUi(this);
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
qDebug("Bandwidth allocation dialog creation");
|
|
||||||
this->BTSession = BTSession;
|
|
||||||
if(hashes.size() == 0)
|
|
||||||
global = true;
|
|
||||||
else
|
|
||||||
global = false;
|
|
||||||
if(uploadMode)
|
|
||||||
lblTitle->setText(tr("Upload limit:"));
|
|
||||||
else
|
|
||||||
lblTitle->setText(tr("Download limit:"));
|
|
||||||
connect(bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateBandwidthLabel(int)));
|
|
||||||
if(!global){
|
|
||||||
unsigned int nbTorrents = hashes.size();
|
|
||||||
if(!nbTorrents) close();
|
|
||||||
int val = 0;
|
|
||||||
int max = -1;
|
|
||||||
if(nbTorrents == 1){
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hashes.at(0));
|
|
||||||
if(uploadMode){
|
|
||||||
if(h.upload_limit() > 0)
|
|
||||||
val = (int)(h.upload_limit() / 1024.);
|
|
||||||
if(BTSession->getSession()->upload_rate_limit() > 0)
|
|
||||||
max = (int)(BTSession->getSession()->upload_rate_limit() / 1024.);
|
|
||||||
}else{
|
|
||||||
if(h.download_limit() > 0)
|
|
||||||
val = (int)(h.download_limit() / 1024.);
|
|
||||||
if(BTSession->getSession()->download_rate_limit() > 0){
|
|
||||||
qDebug("there is a global download rate limit at: %d kb/s", (int)(BTSession->getSession()->download_rate_limit() / 1024.));
|
|
||||||
max = (int)(BTSession->getSession()->download_rate_limit() / 1024.);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(max != -1)
|
|
||||||
bandwidthSlider->setMaximum(max);
|
|
||||||
qDebug("Bandwidth limit: %d", val);
|
|
||||||
if(val > bandwidthSlider->maximum())
|
|
||||||
val = bandwidthSlider->maximum();
|
|
||||||
else if(val < bandwidthSlider->minimum())
|
|
||||||
val = 0;
|
|
||||||
bandwidthSlider->setValue(val);
|
|
||||||
if(val == 0) {
|
|
||||||
limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)"));
|
|
||||||
kb_lbl->setText(QString::fromUtf8(""));
|
|
||||||
} else {
|
|
||||||
limit_lbl->setText(misc::toQString(val));
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
qDebug("More than one torrent selected, no initilization");
|
|
||||||
bandwidthSlider->setValue(0);
|
|
||||||
limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)"));
|
|
||||||
kb_lbl->setText(QString::fromUtf8(""));
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
// Global limit
|
|
||||||
int val = 0;
|
|
||||||
session *s = BTSession->getSession();
|
|
||||||
if(uploadMode){
|
|
||||||
if(s->upload_rate_limit() > 0)
|
|
||||||
val = (int)(s->upload_rate_limit()/1024.);
|
|
||||||
}else{
|
|
||||||
if(s->download_rate_limit() > 0)
|
|
||||||
val = (int)(s->download_rate_limit()/1024.);
|
|
||||||
}
|
|
||||||
if(val == 0){
|
|
||||||
bandwidthSlider->setValue(0);
|
|
||||||
limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)"));
|
|
||||||
kb_lbl->setText(QString::fromUtf8(""));
|
|
||||||
}else{
|
|
||||||
bandwidthSlider->setValue(val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(setBandwidth()));
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
|
|
||||||
~BandwidthAllocationDialog(){
|
|
||||||
qDebug("Deleting bandwidth allocation dialog");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected slots:
|
|
||||||
void updateBandwidthLabel(int val){
|
|
||||||
if(val == 0){
|
|
||||||
limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)"));
|
|
||||||
kb_lbl->setText(QString::fromUtf8(""));
|
|
||||||
}else{
|
|
||||||
limit_lbl->setText(misc::toQString(val));
|
|
||||||
kb_lbl->setText(tr("KiB/s"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBandwidth(){
|
|
||||||
qDebug("setBandwidth called");
|
|
||||||
int val = bandwidthSlider->value();
|
|
||||||
if(!global){
|
|
||||||
QString hash;
|
|
||||||
if(uploadMode) {
|
|
||||||
foreach(hash, hashes) {
|
|
||||||
if(!val)
|
|
||||||
BTSession->setUploadLimit(hash, -1);
|
|
||||||
else
|
|
||||||
BTSession->setUploadLimit(hash, val*1024);
|
|
||||||
qDebug("Setting upload limit");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
foreach(hash, hashes) {
|
|
||||||
if(!val)
|
|
||||||
BTSession->setDownloadLimit(hash, -1);
|
|
||||||
else
|
|
||||||
BTSession->setDownloadLimit(hash, val*1024);
|
|
||||||
qDebug("Setting download limit");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
|
||||||
session *s = BTSession->getSession();
|
|
||||||
if(uploadMode){
|
|
||||||
if(!val)
|
|
||||||
s->set_upload_rate_limit(-1);
|
|
||||||
else
|
|
||||||
s->set_upload_rate_limit(val*1024);
|
|
||||||
settings.setValue(QString::fromUtf8("Preferences/Connection/GlobalUPLimit"), val);
|
|
||||||
}else{
|
|
||||||
if(!val)
|
|
||||||
s->set_download_rate_limit(-1);
|
|
||||||
else
|
|
||||||
s->set_download_rate_limit(val*1024);
|
|
||||||
settings.setValue(QString::fromUtf8("Preferences/Connection/GlobalDLLimit"), val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool uploadMode;
|
|
||||||
bool global;
|
|
||||||
bittorrent *BTSession;
|
|
||||||
QStringList hashes;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,264 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* Contact : chris@qbittorrent.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARBORESCENCE_H
|
|
||||||
#define ARBORESCENCE_H
|
|
||||||
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QDir>
|
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
class torrent_file {
|
|
||||||
private:
|
|
||||||
torrent_file *parent;
|
|
||||||
bool is_dir;
|
|
||||||
QString rel_path;
|
|
||||||
QList<torrent_file*> children;
|
|
||||||
size_type size;
|
|
||||||
float progress;
|
|
||||||
int priority;
|
|
||||||
int index; // Index in torrent_info
|
|
||||||
|
|
||||||
public:
|
|
||||||
torrent_file(torrent_file *parent, QString path, bool dir, size_type size=0, int index=-1, float progress=0., int priority=1): parent(parent), is_dir(dir), size(size), progress(progress), priority(priority), index(index){
|
|
||||||
qDebug("created a file with index %d", index);
|
|
||||||
rel_path = QDir::cleanPath(path);
|
|
||||||
if(parent) {
|
|
||||||
parent->updateProgress();
|
|
||||||
parent->updatePriority(priority);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~torrent_file() {
|
|
||||||
qDeleteAll(children);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString path() const {
|
|
||||||
return rel_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString name() const {
|
|
||||||
return rel_path.split(QDir::separator()).last();
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateProgress() {
|
|
||||||
Q_ASSERT(is_dir);
|
|
||||||
if(children.isEmpty()) {
|
|
||||||
progress = 0.;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
float wanted = 0.;
|
|
||||||
float done = 0.;
|
|
||||||
torrent_file *child;
|
|
||||||
foreach(child, children) {
|
|
||||||
wanted += child->getSize();
|
|
||||||
done += child->getSize()*child->getProgress();
|
|
||||||
}
|
|
||||||
progress = done / wanted;
|
|
||||||
Q_ASSERT(progress >= 0.);
|
|
||||||
Q_ASSERT(progress <= 1.);
|
|
||||||
}
|
|
||||||
|
|
||||||
void updatePriority(int prio) {
|
|
||||||
Q_ASSERT(is_dir);
|
|
||||||
torrent_file *child;
|
|
||||||
foreach(child, children) {
|
|
||||||
if(child->getPriority() != prio) return;
|
|
||||||
}
|
|
||||||
priority = prio;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getPriority() const {
|
|
||||||
return priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_type getSize() const {
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
float getProgress() const {
|
|
||||||
return progress;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getIndex() const {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isDir() const {
|
|
||||||
return is_dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasChildren() const {
|
|
||||||
return (!children.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<torrent_file*> getChildren() const {
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
|
|
||||||
torrent_file* getChild(QString fileName) const {
|
|
||||||
Q_ASSERT(is_dir);
|
|
||||||
torrent_file* f;
|
|
||||||
foreach(f, children) {
|
|
||||||
if(f->name() == fileName) return f;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addBytes(size_type b) {
|
|
||||||
size += b;
|
|
||||||
if(parent)
|
|
||||||
parent->addBytes(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
torrent_file* addChild(QString fileName, bool dir, size_type size=0, int index = -1, float progress=0., int priority=1) {
|
|
||||||
Q_ASSERT(is_dir);
|
|
||||||
qDebug("Adding a new child of size: %ld", (long)size);
|
|
||||||
torrent_file *f = new torrent_file(this, QDir::cleanPath(rel_path+QDir::separator()+fileName), dir, size, index, progress, priority);
|
|
||||||
children << f;
|
|
||||||
if(size) {
|
|
||||||
addBytes(size);
|
|
||||||
}
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool removeFromFS(QString saveDir) {
|
|
||||||
QString full_path = saveDir + QDir::separator() + rel_path;
|
|
||||||
if(!QFile::exists(full_path)) {
|
|
||||||
qDebug("%s does not exist, no need to remove it", full_path.toUtf8().data());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool success = true;
|
|
||||||
torrent_file *f;
|
|
||||||
qDebug("We have %d children", children.size());
|
|
||||||
foreach(f, children) {
|
|
||||||
bool s = f->removeFromFS(saveDir);
|
|
||||||
success = s && success;
|
|
||||||
}
|
|
||||||
if(is_dir) {
|
|
||||||
qDebug("trying to remove directory: %s", full_path.toUtf8().data());
|
|
||||||
QDir dir(full_path);
|
|
||||||
dir.rmdir(full_path);
|
|
||||||
} else {
|
|
||||||
qDebug("trying to remove file: %s", full_path.toUtf8().data());
|
|
||||||
bool s = QFile::remove(full_path);
|
|
||||||
success = s && success;
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class arborescence {
|
|
||||||
private:
|
|
||||||
torrent_file *root;
|
|
||||||
|
|
||||||
public:
|
|
||||||
arborescence(torrent_info t) {
|
|
||||||
torrent_info::file_iterator fi = t.begin_files();
|
|
||||||
if(t.num_files() > 1) {
|
|
||||||
root = new torrent_file(0, misc::toQString(t.name()), true);
|
|
||||||
} else {
|
|
||||||
// XXX: Will crash if there is no file in torrent
|
|
||||||
root = new torrent_file(0, misc::toQString(t.name()), false, fi->size, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int i = 0;
|
|
||||||
while(fi != t.end_files()) {
|
|
||||||
QString path = QDir::cleanPath(misc::toQString(fi->path.string()));
|
|
||||||
addFile(path, fi->size, i);
|
|
||||||
fi++;
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
qDebug("real size: %ld, tree size: %ld", (long)t.total_size(), (long)root->getSize());
|
|
||||||
Q_ASSERT(root->getSize() == t.total_size());
|
|
||||||
}
|
|
||||||
|
|
||||||
arborescence(torrent_info t, std::vector<float> fp, int *prioritiesTab) {
|
|
||||||
torrent_info::file_iterator fi = t.begin_files();
|
|
||||||
if(t.num_files() > 1) {
|
|
||||||
qDebug("More than one file in the torrent, setting a folder as root");
|
|
||||||
root = new torrent_file(0, misc::toQString(t.name()), true);
|
|
||||||
} else {
|
|
||||||
// XXX: Will crash if there is no file in torrent
|
|
||||||
qDebug("one file in the torrent, setting it as root with index 0");
|
|
||||||
root = new torrent_file(0, misc::toQString(t.name()), false, fi->size, 0, fp[0], prioritiesTab[0]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int i = 0;
|
|
||||||
while(fi != t.end_files()) {
|
|
||||||
QString path = QDir::cleanPath(misc::toQString(fi->path.string()));
|
|
||||||
addFile(path, fi->size, i, fp[i], prioritiesTab[i]);
|
|
||||||
fi++;
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
qDebug("real size: %ld, tree size: %ld", (long)t.total_size(), (long)root->getSize());
|
|
||||||
Q_ASSERT(root->getSize() == t.total_size());
|
|
||||||
}
|
|
||||||
|
|
||||||
~arborescence() {
|
|
||||||
delete root;
|
|
||||||
}
|
|
||||||
|
|
||||||
torrent_file* getRoot() const {
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool removeFromFS(QString saveDir) {
|
|
||||||
if(!QFile::exists(saveDir+QDir::separator()+root->path())) return true;
|
|
||||||
bool success = root->removeFromFS(saveDir);
|
|
||||||
QDir root_dir(root->path());
|
|
||||||
root_dir.rmdir(saveDir+QDir::separator()+root->path());
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void addFile(QString path, size_type file_size, int index, float progress=0., int priority=1) {
|
|
||||||
Q_ASSERT(root->isDir());
|
|
||||||
path = QDir::cleanPath(path);
|
|
||||||
Q_ASSERT(path.startsWith(root->path()));
|
|
||||||
QString relative_path = path.remove(0, root->path().size());
|
|
||||||
if(relative_path.at(0) ==QDir::separator())
|
|
||||||
relative_path.remove(0, 1);
|
|
||||||
QStringList fileNames = relative_path.split(QDir::separator());
|
|
||||||
QString fileName;
|
|
||||||
torrent_file *dad = root;
|
|
||||||
unsigned int nb_i = 0;
|
|
||||||
unsigned int size = fileNames.size();
|
|
||||||
foreach(fileName, fileNames) {
|
|
||||||
++nb_i;
|
|
||||||
if(fileName == ".") continue;
|
|
||||||
torrent_file* child = dad->getChild(fileName);
|
|
||||||
if(!child) {
|
|
||||||
if(nb_i != size) {
|
|
||||||
// Folder
|
|
||||||
child = dad->addChild(fileName, true);
|
|
||||||
} else {
|
|
||||||
// File
|
|
||||||
child = dad->addChild(fileName, false, file_size, index, progress, priority);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dad = child;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
<ui version="4.0" >
|
|
||||||
<class>bandwidth_dlg</class>
|
|
||||||
<widget class="QDialog" name="bandwidth_dlg" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>222</width>
|
|
||||||
<height>129</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle" >
|
|
||||||
<string>Bandwidth allocation</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" >
|
|
||||||
<property name="margin" >
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="spacing" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<property name="margin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="spacing" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lblTitle" >
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="limit_lbl" >
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="kb_lbl" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>KiB/s</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSlider" name="bandwidthSlider" >
|
|
||||||
<property name="minimum" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum" >
|
|
||||||
<number>1000</number>
|
|
||||||
</property>
|
|
||||||
<property name="sliderPosition" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons" >
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>bandwidth_dlg</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel" >
|
|
||||||
<x>212</x>
|
|
||||||
<y>83</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel" >
|
|
||||||
<x>221</x>
|
|
||||||
<y>98</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
||||||
1459
src/bittorrent.cpp
176
src/bittorrent.h
@@ -21,167 +21,129 @@
|
|||||||
#ifndef __BITTORRENT_H__
|
#ifndef __BITTORRENT_H__
|
||||||
#define __BITTORRENT_H__
|
#define __BITTORRENT_H__
|
||||||
|
|
||||||
#include <QHash>
|
#include <QTimer>
|
||||||
#include <QList>
|
|
||||||
#include <QPair>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QDateTime>
|
|
||||||
|
|
||||||
|
#include <libtorrent/entry.hpp>
|
||||||
|
#include <libtorrent/bencode.hpp>
|
||||||
#include <libtorrent/session.hpp>
|
#include <libtorrent/session.hpp>
|
||||||
|
#include <libtorrent/fingerprint.hpp>
|
||||||
|
#include <libtorrent/session_settings.hpp>
|
||||||
|
#include <libtorrent/identify_client.hpp>
|
||||||
|
#include <libtorrent/alert_types.hpp>
|
||||||
#include <libtorrent/ip_filter.hpp>
|
#include <libtorrent/ip_filter.hpp>
|
||||||
#include "qtorrenthandle.h"
|
|
||||||
|
#ifndef NO_PEX
|
||||||
|
#include <libtorrent/extensions/metadata_transfer.hpp>
|
||||||
|
#include <libtorrent/extensions/ut_pex.hpp>
|
||||||
|
#endif
|
||||||
|
#ifdef NO_PEX
|
||||||
|
#include <QHash>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <boost/format.hpp>
|
||||||
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
#include <boost/filesystem/exception.hpp>
|
||||||
|
|
||||||
|
#include "deleteThread.h"
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
class downloadThread;
|
class downloadThread;
|
||||||
class deleteThread;
|
|
||||||
class QTimer;
|
|
||||||
class FilterParserThread;
|
|
||||||
|
|
||||||
class bittorrent : public QObject{
|
class bittorrent : public QObject{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
session *s;
|
session *s;
|
||||||
|
bool DHTEnabled;
|
||||||
QString scan_dir;
|
QString scan_dir;
|
||||||
QTimer *timerScan;
|
QTimer *timerScan;
|
||||||
QTimer *timerAlerts;
|
QTimer *timerAlerts;
|
||||||
QTimer *fastResumeSaver;
|
|
||||||
QTimer *BigRatioTimer;
|
|
||||||
bool DHTEnabled;
|
|
||||||
downloadThread *downloader;
|
downloadThread *downloader;
|
||||||
|
QStringList supported_preview_extensions;
|
||||||
QString defaultSavePath;
|
QString defaultSavePath;
|
||||||
QStringList torrentsToPauseAfterChecking;
|
#ifdef NO_PEX
|
||||||
QHash<QString, QDateTime> TorrentsStartTime;
|
QHash<QString, torrent_handle> torrent_list;
|
||||||
QHash<QString, size_type> TorrentsStartData;
|
#endif
|
||||||
QHash<QString, QPair<size_type,size_type> > ratioData;
|
|
||||||
QHash<QString, QHash<QString, QString> > trackersErrors;
|
|
||||||
deleteThread *deleter;
|
|
||||||
QStringList finishedTorrents;
|
|
||||||
QStringList unfinishedTorrents;
|
|
||||||
bool preAllocateAll;
|
|
||||||
bool addInPause;
|
|
||||||
int maxConnecsPerTorrent;
|
|
||||||
int maxUploadsPerTorrent;
|
|
||||||
float max_ratio;
|
|
||||||
bool UPnPEnabled;
|
|
||||||
bool NATPMPEnabled;
|
|
||||||
bool LSDEnabled;
|
|
||||||
FilterParserThread *filterParser;
|
|
||||||
QString filterPath;
|
|
||||||
int folderScanInterval; // in seconds
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString getSavePath(QString hash);
|
QString getSavePath(const QString& hash);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor / Destructor
|
// Constructor / Destructor
|
||||||
bittorrent();
|
bittorrent();
|
||||||
~bittorrent();
|
~bittorrent();
|
||||||
QTorrentHandle getTorrentHandle(QString hash) const;
|
torrent_handle getTorrentHandle(const QString& hash) const;
|
||||||
bool isPaused(QString hash) const;
|
#ifndef NO_PEX
|
||||||
bool isFilePreviewPossible(QString fileHash) const;
|
std::vector<torrent_handle> getTorrentHandles() const;
|
||||||
|
#endif
|
||||||
|
#ifdef NO_PEX
|
||||||
|
QList<torrent_handle> getTorrentHandles() const;
|
||||||
|
#endif
|
||||||
|
bool isPaused(const QString& hash) const;
|
||||||
|
bool hasFilteredFiles(const QString& fileHash) const;
|
||||||
|
bool isFilePreviewPossible(const QString& fileHash) const;
|
||||||
bool isDHTEnabled() const;
|
bool isDHTEnabled() const;
|
||||||
float getPayloadDownloadRate() const;
|
float getPayloadDownloadRate() const;
|
||||||
float getPayloadUploadRate() const;
|
float getPayloadUploadRate() const;
|
||||||
|
QList<torrent_handle> getFinishedTorrentHandles() const;
|
||||||
session_status getSessionStatus() const;
|
session_status getSessionStatus() const;
|
||||||
int getListenPort() const;
|
int getListenPort() const;
|
||||||
QStringList getTorrentsToPauseAfterChecking() const;
|
|
||||||
qlonglong getETA(QString hash) const;
|
|
||||||
float getRealRatio(QString hash) const;
|
|
||||||
session* getSession() const;
|
|
||||||
QHash<QString, QString> getTrackersErrors(QString hash) const;
|
|
||||||
QStringList getFinishedTorrents() const;
|
|
||||||
QStringList getUnfinishedTorrents() const;
|
|
||||||
bool isFinished(QString hash) const;
|
|
||||||
bool has_filtered_files(QString hash) const;
|
|
||||||
unsigned int getFinishedPausedTorrentsNb() const;
|
|
||||||
unsigned int getUnfinishedPausedTorrentsNb() const;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false);
|
void addTorrent(const QString& path, bool fromScanDir = false, const QString& from_url = QString());
|
||||||
void downloadFromUrl(QString url);
|
void downloadFromUrl(const QString& url);
|
||||||
void downloadFromURLList(const QStringList& url_list);
|
void downloadFromURLList(const QStringList& url_list);
|
||||||
void deleteTorrent(QString hash, bool permanent = false);
|
void deleteTorrent(const QString& hash, bool permanent = false);
|
||||||
bool pauseTorrent(QString hash);
|
void pauseTorrent(const QString& hash);
|
||||||
bool resumeTorrent(QString hash);
|
|
||||||
void pauseAllTorrents();
|
void pauseAllTorrents();
|
||||||
void resumeAllTorrents();
|
void resumeAllTorrents();
|
||||||
|
void resumeTorrent(const QString& hash);
|
||||||
|
void enableDHT();
|
||||||
|
void disableDHT();
|
||||||
void saveDHTEntry();
|
void saveDHTEntry();
|
||||||
void preAllocateAllFiles(bool b);
|
void saveFastResumeData();
|
||||||
void saveFastResumeAndRatioData();
|
void enableDirectoryScanning(const QString& scan_dir);
|
||||||
void saveFastResumeAndRatioData(QString hash);
|
|
||||||
void enableDirectoryScanning(QString scan_dir);
|
|
||||||
void disableDirectoryScanning();
|
void disableDirectoryScanning();
|
||||||
|
#ifndef NO_PEX
|
||||||
void enablePeerExchange();
|
void enablePeerExchange();
|
||||||
void enableIPFilter(QString filter);
|
#endif
|
||||||
|
void enableIPFilter(ip_filter filter);
|
||||||
void disableIPFilter();
|
void disableIPFilter();
|
||||||
|
void reloadTorrent(const torrent_handle &h, bool compact_mode = true);
|
||||||
void resumeUnfinishedTorrents();
|
void resumeUnfinishedTorrents();
|
||||||
void saveTorrentSpeedLimits(QString hash);
|
|
||||||
void loadTorrentSpeedLimits(QString hash);
|
|
||||||
void saveDownloadUploadForTorrent(QString hash);
|
|
||||||
void loadDownloadUploadForTorrent(QString hash);
|
|
||||||
void handleDownloadFailure(QString url, QString reason);
|
|
||||||
void loadWebSeeds(QString fileHash);
|
|
||||||
// Session configuration - Setters
|
// Session configuration - Setters
|
||||||
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
|
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
|
||||||
void setMaxConnections(int maxConnec);
|
void setMaxConnections(int maxConnec);
|
||||||
void setMaxConnectionsPerTorrent(int max);
|
void setDownloadRateLimit(int rate);
|
||||||
void setMaxUploadsPerTorrent(int max);
|
void setUploadRateLimit(int rate);
|
||||||
void setDownloadRateLimit(long rate);
|
|
||||||
void setUploadRateLimit(long rate);
|
|
||||||
void setGlobalRatio(float ratio);
|
void setGlobalRatio(float ratio);
|
||||||
void setDeleteRatio(float ratio);
|
|
||||||
void setDHTPort(int dht_port);
|
void setDHTPort(int dht_port);
|
||||||
void setProxySettings(proxy_settings proxySettings, bool trackers=true, bool peers=true, bool web_seeds=true, bool dht=true);
|
|
||||||
void setSessionSettings(session_settings sessionSettings);
|
void setSessionSettings(session_settings sessionSettings);
|
||||||
void startTorrentsInPause(bool b);
|
void setDefaultSavePath(const QString& savepath);
|
||||||
void setDefaultSavePath(QString savepath);
|
|
||||||
void applyEncryptionSettings(pe_settings se);
|
|
||||||
void loadFilesPriorities(QTorrentHandle& h);
|
|
||||||
void setDownloadLimit(QString hash, long val);
|
|
||||||
void setUploadLimit(QString hash, long val);
|
|
||||||
void setUnfinishedTorrent(QString hash);
|
|
||||||
void setFinishedTorrent(QString hash);
|
|
||||||
void enableUPnP(bool b);
|
|
||||||
void enableNATPMP(bool b);
|
|
||||||
void enableLSD(bool b);
|
|
||||||
bool enableDHT(bool b);
|
|
||||||
void reloadTorrent(const QTorrentHandle &h, bool full_alloc);
|
|
||||||
void setTimerScanInterval(int secs);
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
void cleanDeleter(deleteThread* deleter);
|
||||||
|
void loadFilteredFiles(torrent_handle& h);
|
||||||
void scanDirectory();
|
void scanDirectory();
|
||||||
void readAlerts();
|
void readAlerts();
|
||||||
void processDownloadedFile(QString, QString);
|
void processDownloadedFile(const QString&, const QString&, int, const QString&);
|
||||||
bool loadTrackerFile(QString hash);
|
void resumeUnfinished();
|
||||||
void saveTrackerFile(QString hash);
|
|
||||||
void deleteBigRatios();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void invalidTorrent(QString path);
|
void invalidTorrent(const QString& path);
|
||||||
void duplicateTorrent(QString path);
|
void duplicateTorrent(const QString& path);
|
||||||
void addedTorrent(QString path, QTorrentHandle& h, bool fastResume);
|
void addedTorrent(const QString& path, torrent_handle& h, bool fastResume);
|
||||||
void deletedTorrent(QString hash);
|
void finishedTorrent(torrent_handle& h);
|
||||||
void pausedTorrent(QString hash);
|
void fullDiskError(torrent_handle& h);
|
||||||
void resumedTorrent(QString hash);
|
void trackerError(const QString& hash, const QString& time, const QString& msg);
|
||||||
void finishedTorrent(QTorrentHandle& h);
|
|
||||||
void fullDiskError(QTorrentHandle& h);
|
|
||||||
void trackerError(QString hash, QString time, QString msg);
|
|
||||||
void portListeningFailure();
|
void portListeningFailure();
|
||||||
void trackerAuthenticationRequired(QTorrentHandle& h);
|
void trackerAuthenticationRequired(torrent_handle& h);
|
||||||
|
void downloadFromUrlFailure(const QString& url, const QString& error);
|
||||||
void scanDirFoundTorrents(const QStringList& pathList);
|
void scanDirFoundTorrents(const QStringList& pathList);
|
||||||
void newDownloadedTorrent(QString path, QString url);
|
void newDownloadedTorrent(const QString& path, const QString& url);
|
||||||
void aboutToDownloadFromUrl(QString url);
|
void aboutToDownloadFromUrl(const QString& url);
|
||||||
void updateFileSize(QString hash);
|
|
||||||
void peerBlocked(QString);
|
|
||||||
void downloadFromUrlFailure(QString url, QString reason);
|
|
||||||
void fastResumeDataRejected(QString name);
|
|
||||||
void urlSeedProblem(QString url, QString msg);
|
|
||||||
void torrentFinishedChecking(QString hash);
|
|
||||||
void torrent_ratio_deleted(QString fileName);
|
|
||||||
void UPnPError(QString msg);
|
|
||||||
void UPnPSuccess(QString msg);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
LANG_FOLDER = "lang/"
|
|
||||||
PO_FOLDER = 'po_files'
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
po_files = os.listdir(os.path.join(LANG_FOLDER, PO_FOLDER))
|
|
||||||
po_files = [x for x in po_files if os.path.splitext(x)[-1] == ".po"]
|
|
||||||
for file in po_files:
|
|
||||||
# First clean up the ts file
|
|
||||||
ts_file = os.path.join(LANG_FOLDER, os.path.splitext(file)[0]+'.ts')
|
|
||||||
po_file = os.path.join(LANG_FOLDER, PO_FOLDER, file)
|
|
||||||
if os.path.exists(ts_file):
|
|
||||||
os.remove(ts_file)
|
|
||||||
# Convert to PO
|
|
||||||
print "Converting %s..." % (po_file,)
|
|
||||||
os.system("po2ts %s -o %s" % (po_file, ts_file))
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
LANG_FOLDER = 'lang/'
|
|
||||||
PO_FOLDER = 'po_files'
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
ts_files = os.listdir(LANG_FOLDER)
|
|
||||||
ts_files = [x for x in ts_files if os.path.splitext(x)[-1] == ".ts"]
|
|
||||||
for file in ts_files:
|
|
||||||
# First clean up the po file
|
|
||||||
po_file = os.path.join(LANG_FOLDER, PO_FOLDER, os.path.splitext(file)[0]+'.po')
|
|
||||||
ts_file = os.path.join(LANG_FOLDER, file)
|
|
||||||
if os.path.exists(po_file):
|
|
||||||
os.remove(po_file)
|
|
||||||
# create po folder if it doesn't exist
|
|
||||||
if not os.path.exists(os.path.join(LANG_FOLDER, PO_FOLDER)):
|
|
||||||
os.mkdir(os.path.join(LANG_FOLDER, PO_FOLDER))
|
|
||||||
# Convert to PO
|
|
||||||
print "Converting %s..." % (ts_file,)
|
|
||||||
os.system("ts2po %s -o %s" % (ts_file, po_file))
|
|
||||||
# Making an archive
|
|
||||||
os.system("tar czf %s %s" % (os.path.join(LANG_FOLDER, PO_FOLDER)+'.tar.gz', os.path.join(LANG_FOLDER, PO_FOLDER)))
|
|
||||||
@@ -1,18 +1,27 @@
|
|||||||
<ui version="4.0" >
|
<ui version="4.0" >
|
||||||
|
<author></author>
|
||||||
|
<comment></comment>
|
||||||
|
<exportmacro></exportmacro>
|
||||||
<class>createTorrentDialog</class>
|
<class>createTorrentDialog</class>
|
||||||
<widget class="QDialog" name="createTorrentDialog" >
|
<widget class="QDialog" name="createTorrentDialog" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>592</width>
|
<width>560</width>
|
||||||
<height>655</height>
|
<height>307</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
<string>Torrent Creation Tool</string>
|
<string>Torrent Creation Tool</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="createTorrent_title" >
|
<widget class="QLabel" name="createTorrent_title" >
|
||||||
<property name="minimumSize" >
|
<property name="minimumSize" >
|
||||||
@@ -39,7 +48,7 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Torrent file creation</string>
|
<string>Create Torrent file</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment" >
|
<property name="alignment" >
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
@@ -47,51 +56,55 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="lbl_input" >
|
<layout class="QHBoxLayout" >
|
||||||
<property name="text" >
|
<property name="margin" >
|
||||||
<string>File or folder to add to the torrent:</string>
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="textInputPath" />
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addFile_button" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Add a file</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="icons.qrc" >:/Icons/add_file.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addFolder_button" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Add a folder</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="icons.qrc" >:/Icons/add_folder.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="lbl_announce_url" >
|
<widget class="QLabel" name="lbl_destination" >
|
||||||
<property name="minimumSize" >
|
<property name="maximumSize" >
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>16777215</width>
|
||||||
<height>102</height>
|
<height>26</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string><center>Destination torrent file:</center></string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" >
|
||||||
|
<cstring>txt_destination</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lbl_input" >
|
||||||
|
<property name="maximumSize" >
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string><center>Input file or directory:</center></string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" >
|
||||||
|
<cstring>txt_input</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lbl_announce_url" >
|
||||||
<property name="maximumSize" >
|
<property name="maximumSize" >
|
||||||
<size>
|
<size>
|
||||||
<width>16777215</width>
|
<width>16777215</width>
|
||||||
@@ -99,42 +112,17 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Announce urls (trackers):</string>
|
<string><center>Announce url:<br>(One per line)</center></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy" >
|
||||||
<cstring></cstring>
|
<cstring></cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="urlSeeds_lbl" >
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>101</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Web seeds urls (optional):</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="lbl_comment" >
|
<widget class="QLabel" name="lbl_comment" >
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>102</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>102</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Comment (optional):</string>
|
<string><center>Comment:</center></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy" >
|
||||||
<cstring>txt_comment</cstring>
|
<cstring>txt_comment</cstring>
|
||||||
@@ -145,244 +133,64 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="trackers_list" >
|
<widget class="QLineEdit" name="txt_destination" />
|
||||||
<property name="selectionMode" >
|
|
||||||
<enum>QAbstractItemView::MultiSelection</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" >
|
<widget class="QToolButton" name="browse_destination" >
|
||||||
<property name="spacing" >
|
<property name="text" >
|
||||||
<number>6</number>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin" >
|
</widget>
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>16</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addTracker_button" >
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="icons.qrc" >:/Icons/skin/add.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="removeTracker_button" >
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="icons.qrc" >:/Icons/skin/remove.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>16</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="URLSeeds_list" >
|
<widget class="QLineEdit" name="txt_input" />
|
||||||
<property name="selectionMode" >
|
</item>
|
||||||
<enum>QAbstractItemView::MultiSelection</enum>
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkDirectory" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Directory</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" >
|
<widget class="QToolButton" name="browse_input" >
|
||||||
<property name="spacing" >
|
<property name="text" >
|
||||||
<number>6</number>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin" >
|
</widget>
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>16</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addURLSeed_button" >
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="icons.qrc" >:/Icons/skin/add.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="removeURLSeed_button" >
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="icons.qrc" >:/Icons/skin/remove.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>16</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTextEdit" name="txt_announce" />
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="txt_comment" >
|
<widget class="QTextEdit" name="txt_comment" >
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>421</width>
|
|
||||||
<height>102</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="acceptRichText" >
|
<property name="acceptRichText" >
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@@ -394,120 +202,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
<item>
|
<property name="margin" >
|
||||||
<widget class="QLabel" name="txtPieceSize" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Piece size:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="comboPieceSize" >
|
|
||||||
<property name="currentIndex" >
|
|
||||||
<number>3</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>32 KiB</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>64 KiB</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>128 KiB</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>256 KiB</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>512 KiB</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>1 MiB</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>2 MiB</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>4 MiB</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="check_private" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Private (won't be distributed on DHT network if enabled)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="checkStartSeeding" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Start seeding after creation</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="progressLbl" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Progress:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QProgressBar" name="progressBar" >
|
|
||||||
<property name="value" >
|
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
@@ -524,7 +224,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="createButton" >
|
<widget class="QPushButton" name="createButton" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Create and save...</string>
|
<string>Create</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -552,9 +252,8 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<pixmapfunction></pixmapfunction>
|
||||||
<include location="icons.qrc" />
|
<resources/>
|
||||||
</resources>
|
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>cancelButton</sender>
|
<sender>cancelButton</sender>
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QInputDialog>
|
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
@@ -33,10 +32,12 @@
|
|||||||
#include <libtorrent/file.hpp>
|
#include <libtorrent/file.hpp>
|
||||||
#include <libtorrent/storage.hpp>
|
#include <libtorrent/storage.hpp>
|
||||||
#include <libtorrent/hasher.hpp>
|
#include <libtorrent/hasher.hpp>
|
||||||
|
|
||||||
|
#ifndef NO_PEX
|
||||||
#include <libtorrent/file_pool.hpp>
|
#include <libtorrent/file_pool.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "createtorrent_imp.h"
|
#include "createtorrent_imp.h"
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
@@ -44,225 +45,101 @@ using namespace boost::filesystem;
|
|||||||
createtorrent::createtorrent(QWidget *parent): QDialog(parent){
|
createtorrent::createtorrent(QWidget *parent): QDialog(parent){
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
creatorThread = new torrentCreatorThread();
|
|
||||||
connect(creatorThread, SIGNAL(creationSuccess(QString)), this, SLOT(handleCreationSucess(QString)));
|
|
||||||
connect(creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
|
|
||||||
connect(creatorThread, SIGNAL(updateProgress(int)), this, SLOT(updateProgressBar(int)));
|
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
createtorrent::~createtorrent() {
|
void createtorrent::on_browse_destination_clicked(){
|
||||||
delete creatorThread;
|
QString destination = QFileDialog::getSaveFileName(this, tr("Select destination torrent file"), QDir::homePath(), tr("Torrent Files")+" (*.torrent)");
|
||||||
}
|
if(!destination.isEmpty()){
|
||||||
|
txt_destination->setText(destination);
|
||||||
void createtorrent::on_addFolder_button_clicked(){
|
|
||||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Select a folder to add to the torrent"), QDir::homePath(), QFileDialog::ShowDirsOnly);
|
|
||||||
if(!dir.isEmpty())
|
|
||||||
textInputPath->setText(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
void createtorrent::on_addFile_button_clicked(){
|
|
||||||
QString file = QFileDialog::getOpenFileName(this, tr("Select a file to add to the torrent"), QDir::homePath(), QString(), 0, QFileDialog::ShowDirsOnly);
|
|
||||||
if(!file.isEmpty())
|
|
||||||
textInputPath->setText(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
void createtorrent::on_removeTracker_button_clicked() {
|
|
||||||
QModelIndexList selectedIndexes = trackers_list->selectionModel()->selectedIndexes();
|
|
||||||
for(int i=selectedIndexes.size()-1; i>=0; --i){
|
|
||||||
QListWidgetItem *item = trackers_list->takeItem(selectedIndexes.at(i).row());
|
|
||||||
delete item;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int createtorrent::getPieceSize() const {
|
void createtorrent::on_browse_input_clicked(){
|
||||||
switch(comboPieceSize->currentIndex()) {
|
// Can't use QFileDialog static functions for this because
|
||||||
case 0:
|
// user can select a file or a directory
|
||||||
return 32*1024;
|
QFileDialog *fd = new QFileDialog(this, tr("Select input directory or file"), QDir::homePath());
|
||||||
case 1:
|
if(checkDirectory->isChecked()){
|
||||||
return 64*1024;
|
fd->setFileMode(QFileDialog::DirectoryOnly);
|
||||||
case 2:
|
}else{
|
||||||
return 128*1024;
|
fd->setFileMode(QFileDialog::ExistingFile);
|
||||||
case 3:
|
|
||||||
return 256*1024;
|
|
||||||
case 4:
|
|
||||||
return 512*1024;
|
|
||||||
case 5:
|
|
||||||
return 1024*1024;
|
|
||||||
case 6:
|
|
||||||
return 2048*1024;
|
|
||||||
default:
|
|
||||||
return 256*1024;
|
|
||||||
}
|
}
|
||||||
}
|
QStringList fileNames;
|
||||||
|
if (fd->exec()){
|
||||||
void createtorrent::on_addTracker_button_clicked() {
|
fileNames = fd->selectedFiles();
|
||||||
bool ok;
|
txt_input->setText(fileNames.first());
|
||||||
QString URL = QInputDialog::getText(this, tr("Please type an announce URL"),
|
|
||||||
tr("Announce URL:", "Tracker URL"), QLineEdit::Normal,
|
|
||||||
"http://", &ok);
|
|
||||||
if(ok){
|
|
||||||
if(trackers_list->findItems(URL, Qt::MatchFixedString).size() == 0)
|
|
||||||
trackers_list->addItem(URL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void createtorrent::on_removeURLSeed_button_clicked(){
|
|
||||||
QModelIndexList selectedIndexes = URLSeeds_list->selectionModel()->selectedIndexes();
|
|
||||||
for(int i=selectedIndexes.size()-1; i>=0; --i){
|
|
||||||
QListWidgetItem *item = URLSeeds_list->takeItem(selectedIndexes.at(i).row());
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void createtorrent::on_addURLSeed_button_clicked(){
|
|
||||||
bool ok;
|
|
||||||
QString URL = QInputDialog::getText(this, tr("Please type a web seed url"),
|
|
||||||
tr("Web seed URL:"), QLineEdit::Normal,
|
|
||||||
"http://", &ok);
|
|
||||||
if(ok){
|
|
||||||
if(URLSeeds_list->findItems(URL, Qt::MatchFixedString).size() == 0)
|
|
||||||
URLSeeds_list->addItem(URL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subfunction to add files to a torrent_info structure
|
// Subfunction to add files to a torrent_info structure
|
||||||
// Written by Arvid Norberg (libtorrent Author)
|
// Written by Arvid Norberg (libtorrent Author)
|
||||||
void add_files(torrent_info& t, path const& p, path const& l){
|
void add_files(torrent_info& t, path const& p, path const& l){
|
||||||
qDebug("p: %s, l: %s, l.leaf(): %s", p.string().c_str(), l.string().c_str(), l.leaf().c_str());
|
|
||||||
path f(p / l);
|
path f(p / l);
|
||||||
if (is_directory(f)){
|
if (is_directory(f)){
|
||||||
for (directory_iterator i(f), end; i != end; ++i)
|
for (directory_iterator i(f), end; i != end; ++i)
|
||||||
add_files(t, p, l / i->leaf());
|
add_files(t, p, l / i->leaf());
|
||||||
}else{
|
}else{
|
||||||
qDebug("Adding %s", l.string().c_str());
|
|
||||||
t.add_file(l, file_size(f));
|
t.add_file(l, file_size(f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList createtorrent::allItems(QListWidget *list){
|
|
||||||
QStringList res;
|
|
||||||
unsigned int nbItems = list->count();
|
|
||||||
for(unsigned int i=0; i< nbItems; ++i){
|
|
||||||
res << list->item(i)->text();
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main function that create a .torrent file
|
// Main function that create a .torrent file
|
||||||
void createtorrent::on_createButton_clicked(){
|
void createtorrent::on_createButton_clicked(){
|
||||||
QString input = textInputPath->text().trimmed();
|
QString destination = txt_destination->text();
|
||||||
if (input.endsWith(QDir::separator()))
|
if(destination.isEmpty()){
|
||||||
input.chop(1);
|
QMessageBox::critical(0, tr("No destination path set"), tr("Please type a destination path first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QString input = txt_input->text();
|
||||||
if(input.isEmpty()){
|
if(input.isEmpty()){
|
||||||
QMessageBox::critical(0, tr("No input path set"), tr("Please type an input path first"));
|
QMessageBox::critical(0, tr("No input path set"), tr("Please type an input path first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QStringList trackers = allItems(trackers_list);
|
if(!QFile::exists(input)){
|
||||||
if(!trackers.size()){
|
QMessageBox::critical(0, tr("Input path does not exist"), tr("Please type a valid input path first"));
|
||||||
QMessageBox::critical(0, tr("No tracker path set"), tr("Please set at least one tracker"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString destination = QFileDialog::getSaveFileName(this, tr("Select destination torrent file"), QDir::homePath(), tr("Torrent Files")+QString::fromUtf8(" (*.torrent)"));
|
char const* creator_str = "qBittorrent";
|
||||||
if(!destination.isEmpty()) {
|
int piece_size = 256 * 1024;
|
||||||
if(!destination.endsWith(QString::fromUtf8(".torrent")))
|
|
||||||
destination += QString::fromUtf8(".torrent");
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QStringList url_seeds = allItems(URLSeeds_list);
|
|
||||||
QString comment = txt_comment->toPlainText();
|
|
||||||
creatorThread->create(input, destination, trackers, url_seeds, comment, check_private->isChecked(), getPieceSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
void createtorrent::handleCreationFailure(QString msg) {
|
|
||||||
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent creation was unsuccessful, reason: %1").arg(msg));
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void createtorrent::handleCreationSuccess(QString path, const char* branch_path, QString hash) {
|
|
||||||
if(checkStartSeeding->isChecked()) {
|
|
||||||
// Create save path file
|
|
||||||
QFile savepath_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".savepath"));
|
|
||||||
savepath_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
|
||||||
savepath_file.write(branch_path);
|
|
||||||
savepath_file.close();
|
|
||||||
emit torrent_to_seed(path);
|
|
||||||
}
|
|
||||||
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+path);
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void createtorrent::updateProgressBar(int progress) {
|
|
||||||
progressBar->setValue(progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Torrent Creator Thread
|
|
||||||
//
|
|
||||||
|
|
||||||
void torrentCreatorThread::create(QString _input_path, QString _save_path, QStringList _trackers, QStringList _url_seeds, QString _comment, bool _is_private, int _piece_size) {
|
|
||||||
input_path = _input_path;
|
|
||||||
save_path = _save_path;
|
|
||||||
trackers = _trackers;
|
|
||||||
url_seeds = _url_seeds;
|
|
||||||
comment = _comment;
|
|
||||||
is_private = _is_private;
|
|
||||||
piece_size = _piece_size;
|
|
||||||
abort = false;
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void torrentCreatorThread::run() {
|
|
||||||
emit updateProgress(0);
|
|
||||||
char const* creator_str = "qBittorrent "VERSION;
|
|
||||||
try {
|
try {
|
||||||
boost::intrusive_ptr<torrent_info> t(new torrent_info);
|
torrent_info t;
|
||||||
ofstream out(complete(path((const char*)save_path.toUtf8())), std::ios_base::binary);
|
path full_path = complete(path((const char*)input.toUtf8()));
|
||||||
// Adding files to the torrent
|
ofstream out(complete(path((const char*)destination.toUtf8())), std::ios_base::binary);
|
||||||
path full_path = complete(path(input_path.toUtf8().data()));
|
|
||||||
add_files(*t, full_path.branch_path(), full_path.leaf());
|
add_files(t, full_path.branch_path(), full_path.leaf());
|
||||||
if(abort) return;
|
t.set_piece_size(piece_size);
|
||||||
// Set piece size
|
#ifndef NO_PEX
|
||||||
t->set_piece_size(piece_size);
|
|
||||||
// Add url seeds
|
|
||||||
QString seed;
|
|
||||||
foreach(seed, url_seeds){
|
|
||||||
t->add_url_seed(seed.toUtf8().data());
|
|
||||||
}
|
|
||||||
for(int i=0; i<trackers.size(); ++i){
|
|
||||||
t->add_tracker(trackers.at(i).toUtf8().data());
|
|
||||||
}
|
|
||||||
if(abort) return;
|
|
||||||
// calculate the hash for all pieces
|
|
||||||
file_pool fp;
|
file_pool fp;
|
||||||
boost::scoped_ptr<storage_interface> st(default_storage_constructor(t, full_path.branch_path(), fp));
|
storage st(t, full_path.branch_path(), fp);
|
||||||
int num = t->num_pieces();
|
#endif
|
||||||
|
#ifdef NO_PEX
|
||||||
|
storage st(t, full_path.branch_path());
|
||||||
|
#endif
|
||||||
|
QStringList trackers = txt_announce->toPlainText().split('\n');
|
||||||
|
for(int i=0; i<trackers.size(); ++i){
|
||||||
|
t.add_tracker((const char*)trackers.at(i).toUtf8());
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate the hash for all pieces
|
||||||
|
int num = t.num_pieces();
|
||||||
std::vector<char> buf(piece_size);
|
std::vector<char> buf(piece_size);
|
||||||
for (int i = 0; i < num; ++i) {
|
for (int i = 0; i < num; ++i)
|
||||||
st->read(&buf[0], i, 0, t->piece_size(i));
|
{
|
||||||
hasher h(&buf[0], t->piece_size(i));
|
st.read(&buf[0], i, 0, t.piece_size(i));
|
||||||
t->set_hash(i, h.final());
|
hasher h(&buf[0], t.piece_size(i));
|
||||||
emit updateProgress((int)(i*100./(float)num));
|
t.set_hash(i, h.final());
|
||||||
if(abort) return;
|
|
||||||
}
|
}
|
||||||
// Set qBittorrent as creator and add user comment to
|
// Set qBittorrent as creator and add user comment to
|
||||||
// torrent_info structure
|
// torrent_info structure
|
||||||
t->set_creator(creator_str);
|
t.set_creator(creator_str);
|
||||||
t->set_comment((const char*)comment.toUtf8());
|
t.set_comment((const char*)txt_comment->toPlainText().toUtf8());
|
||||||
// Is private ?
|
|
||||||
if(is_private){
|
|
||||||
t->set_priv(true);
|
|
||||||
}
|
|
||||||
if(abort) return;
|
|
||||||
// create the torrent and print it to out
|
// create the torrent and print it to out
|
||||||
entry e = t->create_torrent();
|
entry e = t.create_torrent();
|
||||||
libtorrent::bencode(std::ostream_iterator<char>(out), e);
|
libtorrent::bencode(std::ostream_iterator<char>(out), e);
|
||||||
out.flush();
|
|
||||||
emit updateProgress(100);
|
|
||||||
emit creationSuccess(save_path, full_path.branch_path().string().c_str(), misc::toQString(t->info_hash()));
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e){
|
catch (std::exception& e){
|
||||||
emit creationFailure(QString::fromUtf8(e.what()));
|
std::cerr << e.what() << "\n";
|
||||||
}
|
}
|
||||||
|
hide();
|
||||||
|
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+destination);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,65 +22,19 @@
|
|||||||
#ifndef CREATE_TORRENT_IMP_H
|
#ifndef CREATE_TORRENT_IMP_H
|
||||||
#define CREATE_TORRENT_IMP_H
|
#define CREATE_TORRENT_IMP_H
|
||||||
|
|
||||||
#include <QThread>
|
#include <QDialog>
|
||||||
|
|
||||||
#include "ui_createtorrent.h"
|
#include "ui_createtorrent.h"
|
||||||
|
|
||||||
class torrentCreatorThread : public QThread {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
QString input_path;
|
|
||||||
QString save_path;
|
|
||||||
QStringList trackers;
|
|
||||||
QStringList url_seeds;
|
|
||||||
QString comment;
|
|
||||||
bool is_private;
|
|
||||||
int piece_size;
|
|
||||||
bool abort;
|
|
||||||
|
|
||||||
public:
|
|
||||||
torrentCreatorThread() {}
|
|
||||||
~torrentCreatorThread() {
|
|
||||||
abort = true;
|
|
||||||
wait();
|
|
||||||
}
|
|
||||||
void create(QString _input_path, QString _save_path, QStringList _trackers, QStringList _url_seeds, QString _comment, bool _is_private, int _piece_size);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void run();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void creationFailure(QString msg);
|
|
||||||
void creationSuccess(QString path, const char* branch_path, QString hash);
|
|
||||||
void updateProgress(int progress);
|
|
||||||
};
|
|
||||||
|
|
||||||
class createtorrent : public QDialog, private Ui::createTorrentDialog{
|
class createtorrent : public QDialog, private Ui::createTorrentDialog{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
|
||||||
torrentCreatorThread *creatorThread;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
createtorrent(QWidget *parent = 0);
|
createtorrent(QWidget *parent = 0);
|
||||||
~createtorrent();
|
|
||||||
QStringList allItems(QListWidget *list);
|
|
||||||
int getPieceSize() const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void torrent_to_seed(QString path);
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
void on_browse_destination_clicked();
|
||||||
|
void on_browse_input_clicked();
|
||||||
void on_createButton_clicked();
|
void on_createButton_clicked();
|
||||||
void on_addFile_button_clicked();
|
|
||||||
void on_addFolder_button_clicked();
|
|
||||||
void on_addTracker_button_clicked();
|
|
||||||
void on_removeTracker_button_clicked();
|
|
||||||
void on_addURLSeed_button_clicked();
|
|
||||||
void on_removeURLSeed_button_clicked();
|
|
||||||
void handleCreationFailure(QString msg);
|
|
||||||
void handleCreationSuccess(QString path, const char* branch_path, QString hash);
|
|
||||||
void updateProgressBar(int progress);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,102 +23,31 @@
|
|||||||
#define DELETETHREAD_H
|
#define DELETETHREAD_H
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QMutex>
|
|
||||||
#include <QWaitCondition>
|
|
||||||
#include <QMutexLocker>
|
|
||||||
#include <QPair>
|
|
||||||
|
|
||||||
#include "arborescence.h"
|
#include "misc.h"
|
||||||
|
|
||||||
class subDeleteThread : public QThread {
|
|
||||||
Q_OBJECT
|
|
||||||
private:
|
|
||||||
QString save_path;
|
|
||||||
arborescence *arb;
|
|
||||||
bool abort;
|
|
||||||
|
|
||||||
public:
|
|
||||||
subDeleteThread(QObject *parent, QString saveDir, arborescence *arb) : QThread(parent), save_path(saveDir), arb(arb), abort(false){}
|
|
||||||
|
|
||||||
~subDeleteThread(){
|
|
||||||
abort = true;
|
|
||||||
wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
|
||||||
// For subthreads
|
|
||||||
void deletionSuccessST(subDeleteThread* st);
|
|
||||||
void deletionFailureST(subDeleteThread* st);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void run(){
|
|
||||||
if(arb->removeFromFS(save_path))
|
|
||||||
emit deletionSuccessST(this);
|
|
||||||
else
|
|
||||||
emit deletionFailureST(this);
|
|
||||||
delete arb;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class deleteThread : public QThread {
|
class deleteThread : public QThread {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QPair<QString, arborescence*> > torrents_list;
|
QString path;
|
||||||
QMutex mutex;
|
|
||||||
QWaitCondition condition;
|
|
||||||
bool abort;
|
|
||||||
QList<subDeleteThread*> subThreads;
|
|
||||||
|
|
||||||
public:
|
public :
|
||||||
deleteThread(QObject* parent) : QThread(parent), abort(false){}
|
deleteThread(QString _path): path(_path){
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
|
||||||
~deleteThread(){
|
~deleteThread(){
|
||||||
mutex.lock();
|
|
||||||
abort = true;
|
|
||||||
condition.wakeOne();
|
|
||||||
mutex.unlock();
|
|
||||||
qDeleteAll(subThreads);
|
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteTorrent(QString saveDir, arborescence *arb){
|
signals:
|
||||||
qDebug("deleteThread called");
|
void deletionFinished(deleteThread*) const;
|
||||||
QMutexLocker locker(&mutex);
|
|
||||||
torrents_list << QPair<QString, arborescence*>(saveDir, arb);
|
|
||||||
if(!isRunning()){
|
|
||||||
start();
|
|
||||||
}else{
|
|
||||||
condition.wakeOne();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
void run(){
|
void run(){
|
||||||
forever{
|
misc::removePath(path);
|
||||||
if(abort)
|
emit deletionFinished(this);
|
||||||
return;
|
|
||||||
mutex.lock();
|
|
||||||
if(torrents_list.size() != 0){
|
|
||||||
QPair<QString, arborescence *> torrent = torrents_list.takeFirst();
|
|
||||||
mutex.unlock();
|
|
||||||
subDeleteThread *st = new subDeleteThread(0, torrent.first, torrent.second);
|
|
||||||
subThreads << st;
|
|
||||||
connect(st, SIGNAL(deletionSuccessST(subDeleteThread*)), this, SLOT(deleteSubThread(subDeleteThread*)));
|
|
||||||
connect(st, SIGNAL(deletionFailureST(subDeleteThread*)), this, SLOT(deleteSubThread(subDeleteThread*)));
|
|
||||||
st->start();
|
|
||||||
}else{
|
|
||||||
condition.wait(&mutex);
|
|
||||||
mutex.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected slots:
|
|
||||||
void deleteSubThread(subDeleteThread* st){
|
|
||||||
int index = subThreads.indexOf(st);
|
|
||||||
Q_ASSERT(index != -1);
|
|
||||||
subThreads.removeAt(index);
|
|
||||||
delete st;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
249
src/download.ui
@@ -1,249 +0,0 @@
|
|||||||
<ui version="4.0" >
|
|
||||||
<class>downloading</class>
|
|
||||||
<widget class="QWidget" name="downloading" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>811</width>
|
|
||||||
<height>453</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle" >
|
|
||||||
<string>Search</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" >
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" >
|
|
||||||
<property name="spacing" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="margin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeView" name="downloadList" >
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="contextMenuPolicy" >
|
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
|
||||||
</property>
|
|
||||||
<property name="autoScroll" >
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="selectionMode" >
|
|
||||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
|
||||||
</property>
|
|
||||||
<property name="indentation" >
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="itemsExpandable" >
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTabWidget" name="tabBottom" >
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>142</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="tabPosition" >
|
|
||||||
<enum>QTabWidget::West</enum>
|
|
||||||
</property>
|
|
||||||
<property name="currentIndex" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="log_tab" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>765</width>
|
|
||||||
<height>138</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<attribute name="title" >
|
|
||||||
<string>Log</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QVBoxLayout" >
|
|
||||||
<property name="spacing" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="margin" >
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QTextBrowser" name="infoBar" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>120</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="contextMenuPolicy" >
|
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="filter_tab" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>765</width>
|
|
||||||
<height>138</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<attribute name="title" >
|
|
||||||
<string>IP filter</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QVBoxLayout" >
|
|
||||||
<property name="spacing" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="margin" >
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QTextBrowser" name="textBlockedUsers" >
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>123</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
<action name="actionStart" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Start</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionPause" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Pause</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionDelete" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Delete</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionClearLog" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Clear</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionPreview_file" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Preview file</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionSet_upload_limit" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Set upload limit</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionSet_download_limit" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Set download limit</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionDelete_Permanently" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Delete Permanently</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionTorrent_Properties" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Torrent Properties</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionOpen_destination_folder" >
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="icons.qrc" >
|
|
||||||
<normaloff>:/Icons/folder.png</normaloff>:/Icons/folder.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Open destination folder</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionHOSColName" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Name</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionHOSColSize" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Size</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionHOSColProgress" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Progress</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionHOSColDownSpeed" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>DLSpeed</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionHOSColUpSpeed" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>UpSpeed</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionHOSColSeedersLeechers" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Seeds/Leechs</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionHOSColRatio" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Ratio</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionHOSColEta" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>ETA</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionBuy_it" >
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="icons.qrc" >
|
|
||||||
<normaloff>:/Icons/money.png</normaloff>:/Icons/money.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Buy it</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<zorder>tabBottom</zorder>
|
|
||||||
<zorder></zorder>
|
|
||||||
</widget>
|
|
||||||
<resources>
|
|
||||||
<include location="icons.qrc" />
|
|
||||||
</resources>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@@ -37,6 +37,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
|
|||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
icon_lbl->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/url.png")));
|
icon_lbl->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/url.png")));
|
||||||
|
connect(this, SIGNAL(urlsReadyToBeDownloaded(const QStringList&)), parent, SLOT(downloadFromURLList(const QStringList&)));
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
|
|||||||
public slots:
|
public slots:
|
||||||
void on_downloadButton_clicked(){
|
void on_downloadButton_clicked(){
|
||||||
QString urls = textUrls->toPlainText();
|
QString urls = textUrls->toPlainText();
|
||||||
QStringList url_list = urls.split(QString::fromUtf8("\n"));
|
QStringList url_list = urls.split("\n");
|
||||||
QString url;
|
QString url;
|
||||||
QStringList url_list_cleaned;
|
QStringList url_list_cleaned;
|
||||||
foreach(url, url_list){
|
foreach(url, url_list){
|
||||||
@@ -64,7 +65,6 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emit urlsReadyToBeDownloaded(url_list_cleaned);
|
emit urlsReadyToBeDownloaded(url_list_cleaned);
|
||||||
qDebug("Emitted urlsReadytobedownloaded signal");
|
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,207 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* Contact : chris@qbittorrent.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "downloadThread.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// http://curl.rtin.bz/libcurl/c/libcurl-errors.html
|
|
||||||
QString subDownloadThread::errorCodeToString(CURLcode status) {
|
|
||||||
switch(status){
|
|
||||||
case CURLE_FTP_CANT_GET_HOST:
|
|
||||||
case CURLE_COULDNT_RESOLVE_HOST:
|
|
||||||
return tr("Host is unreachable");
|
|
||||||
case CURLE_READ_ERROR:
|
|
||||||
case CURLE_FILE_COULDNT_READ_FILE:
|
|
||||||
return tr("File was not found (404)");
|
|
||||||
case CURLE_FTP_ACCESS_DENIED:
|
|
||||||
case CURLE_LOGIN_DENIED:
|
|
||||||
case CURLE_FTP_USER_PASSWORD_INCORRECT:
|
|
||||||
return tr("Connection was denied");
|
|
||||||
case CURLE_URL_MALFORMAT:
|
|
||||||
return tr("Url is invalid");
|
|
||||||
case CURLE_COULDNT_RESOLVE_PROXY:
|
|
||||||
return tr("Could not resolve proxy");
|
|
||||||
//case 5:
|
|
||||||
// return tr("Connection forbidden (403)");
|
|
||||||
//case 6:
|
|
||||||
// return tr("Connection was not authorized (401)");
|
|
||||||
//case 7:
|
|
||||||
// return tr("Content has moved (301)");
|
|
||||||
case CURLE_COULDNT_CONNECT:
|
|
||||||
return tr("Connection failure");
|
|
||||||
case CURLE_OPERATION_TIMEOUTED:
|
|
||||||
return tr("Connection was timed out");
|
|
||||||
case CURLE_INTERFACE_FAILED:
|
|
||||||
return tr("Incorrect network interface");
|
|
||||||
default:
|
|
||||||
return tr("Unknown error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
subDownloadThread::subDownloadThread(QObject *parent, QString url) : QThread(parent), url(url), abort(false){}
|
|
||||||
|
|
||||||
subDownloadThread::~subDownloadThread(){
|
|
||||||
abort = true;
|
|
||||||
wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
void subDownloadThread::run(){
|
|
||||||
// XXX: Trick to get a unique filename
|
|
||||||
QString filePath;
|
|
||||||
QTemporaryFile *tmpfile = new QTemporaryFile();
|
|
||||||
if (tmpfile->open()) {
|
|
||||||
filePath = tmpfile->fileName();
|
|
||||||
}
|
|
||||||
delete tmpfile;
|
|
||||||
FILE *f = fopen(filePath.toUtf8().data(), "wb");
|
|
||||||
if(!f) {
|
|
||||||
std::cerr << "couldn't open destination file" << "\n";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CURL *curl;
|
|
||||||
CURLcode res;
|
|
||||||
curl = curl_easy_init();
|
|
||||||
if(curl) {
|
|
||||||
std::string c_url = url.toUtf8().data();
|
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, c_url.c_str());
|
|
||||||
// SSL support
|
|
||||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
|
|
||||||
// PROXY SUPPORT
|
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
|
||||||
int intValue = settings.value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt();
|
|
||||||
if(intValue > 0) {
|
|
||||||
// Proxy enabled
|
|
||||||
QString IP = settings.value(QString::fromUtf8("Preferences/Connection/Proxy/IP"), "0.0.0.0").toString();
|
|
||||||
QString port = settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Port"), 8080).toString();
|
|
||||||
qDebug("Using proxy: %s", (IP+QString(":")+port).toUtf8().data());
|
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYPORT, (IP+QString(":")+port).toUtf8().data());
|
|
||||||
// Default proxy type is HTTP, we must change if it is SOCKS5
|
|
||||||
if(intValue%2==0) {
|
|
||||||
qDebug("Proxy is SOCKS5, not HTTP");
|
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
|
||||||
}
|
|
||||||
// Authentication?
|
|
||||||
if(intValue > 2) {
|
|
||||||
qDebug("Proxy requires authentication, authenticating");
|
|
||||||
QString username = settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Username"), QString()).toString();
|
|
||||||
QString password = settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Password"), QString()).toString();
|
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, (username+QString(":")+password).toUtf8().data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// We have to define CURLOPT_WRITEFUNCTION or it will crash on windows
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, f);
|
|
||||||
// Verbose
|
|
||||||
//curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
|
||||||
// No progress info (we don't use it)
|
|
||||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
|
|
||||||
// Redirections
|
|
||||||
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, -1);
|
|
||||||
qDebug("Downloading %s", url.toUtf8().data());
|
|
||||||
res = curl_easy_perform(curl);
|
|
||||||
/* always cleanup */
|
|
||||||
curl_easy_cleanup(curl);
|
|
||||||
fclose(f);
|
|
||||||
if(res) {
|
|
||||||
emit downloadFailureST(this, url, errorCodeToString(res));
|
|
||||||
} else {
|
|
||||||
emit downloadFinishedST(this, url, filePath);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
std::cerr << "Could not initialize CURL" << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Download Thread **/
|
|
||||||
|
|
||||||
downloadThread::downloadThread(QObject* parent) : QThread(parent), abort(false){}
|
|
||||||
|
|
||||||
downloadThread::~downloadThread(){
|
|
||||||
mutex.lock();
|
|
||||||
abort = true;
|
|
||||||
condition.wakeOne();
|
|
||||||
mutex.unlock();
|
|
||||||
qDeleteAll(subThreads);
|
|
||||||
wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
void downloadThread::downloadUrl(QString url){
|
|
||||||
QMutexLocker locker(&mutex);
|
|
||||||
if(downloading_list.contains(url)) return;
|
|
||||||
url_list << url;
|
|
||||||
downloading_list << url;
|
|
||||||
if(!isRunning()){
|
|
||||||
start();
|
|
||||||
}else{
|
|
||||||
condition.wakeOne();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void downloadThread::run(){
|
|
||||||
forever{
|
|
||||||
if(abort)
|
|
||||||
return;
|
|
||||||
mutex.lock();
|
|
||||||
if(url_list.size() != 0){
|
|
||||||
QString url = url_list.takeFirst();
|
|
||||||
mutex.unlock();
|
|
||||||
subDownloadThread *st = new subDownloadThread(0, url);
|
|
||||||
subThreads << st;
|
|
||||||
connect(st, SIGNAL(downloadFinishedST(subDownloadThread*, QString, QString)), this, SLOT(propagateDownloadedFile(subDownloadThread*, QString, QString)));
|
|
||||||
connect(st, SIGNAL(downloadFailureST(subDownloadThread*, QString, QString)), this, SLOT(propagateDownloadFailure(subDownloadThread*, QString, QString)));
|
|
||||||
st->start();
|
|
||||||
}else{
|
|
||||||
condition.wait(&mutex);
|
|
||||||
mutex.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void downloadThread::propagateDownloadedFile(subDownloadThread* st, QString url, QString path){
|
|
||||||
int index = subThreads.indexOf(st);
|
|
||||||
Q_ASSERT(index != -1);
|
|
||||||
subThreads.removeAt(index);
|
|
||||||
delete st;
|
|
||||||
emit downloadFinished(url, path);
|
|
||||||
mutex.lock();
|
|
||||||
index = downloading_list.indexOf(url);
|
|
||||||
Q_ASSERT(index != -1);
|
|
||||||
downloading_list.removeAt(index);
|
|
||||||
mutex.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void downloadThread::propagateDownloadFailure(subDownloadThread* st, QString url, QString reason){
|
|
||||||
int index = subThreads.indexOf(st);
|
|
||||||
Q_ASSERT(index != -1);
|
|
||||||
subThreads.removeAt(index);
|
|
||||||
delete st;
|
|
||||||
emit downloadFailure(url, reason);
|
|
||||||
mutex.lock();
|
|
||||||
index = downloading_list.indexOf(url);
|
|
||||||
Q_ASSERT(index != -1);
|
|
||||||
downloading_list.removeAt(index);
|
|
||||||
mutex.unlock();
|
|
||||||
}
|
|
||||||
@@ -28,58 +28,144 @@
|
|||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <QWaitCondition>
|
#include <QWaitCondition>
|
||||||
#include <QStringList>
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
class subDownloadThread : public QThread {
|
#include "misc.h"
|
||||||
Q_OBJECT
|
|
||||||
private:
|
|
||||||
QString url;
|
|
||||||
bool abort;
|
|
||||||
|
|
||||||
public:
|
|
||||||
subDownloadThread(QObject *parent, QString url);
|
|
||||||
~subDownloadThread();
|
|
||||||
QString errorCodeToString(CURLcode status);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
// For subthreads
|
|
||||||
void downloadFinishedST(subDownloadThread* st, QString url, QString file_path);
|
|
||||||
void downloadFailureST(subDownloadThread* st, QString url, QString reason);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void run();
|
|
||||||
};
|
|
||||||
|
|
||||||
class downloadThread : public QThread {
|
class downloadThread : public QThread {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList url_list;
|
QStringList url_list;
|
||||||
QStringList downloading_list;
|
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
QWaitCondition condition;
|
QWaitCondition condition;
|
||||||
bool abort;
|
bool abort;
|
||||||
QList<subDownloadThread*> subThreads;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void downloadFinished(QString url, QString file_path);
|
void downloadFinished(const QString& url, const QString& file_path, int return_code, const QString& errorBuffer);
|
||||||
void downloadFailure(QString url, QString reason);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
downloadThread(QObject* parent);
|
downloadThread(QObject* parent) : QThread(parent){
|
||||||
|
mutex.lock();
|
||||||
|
abort = false;
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
~downloadThread();
|
~downloadThread(){
|
||||||
|
mutex.lock();
|
||||||
|
abort = true;
|
||||||
|
condition.wakeOne();
|
||||||
|
mutex.unlock();
|
||||||
|
wait();
|
||||||
|
}
|
||||||
|
|
||||||
void downloadUrl(QString url);
|
void downloadUrl(const QString& url){
|
||||||
void setProxy(QString IP, int port, QString username, QString password);
|
QMutexLocker locker(&mutex);
|
||||||
|
qDebug("In Download thread function, mutex locked");
|
||||||
|
url_list << url;
|
||||||
|
qDebug("In Download thread function, mutex unlocked (url added)");
|
||||||
|
if(!isRunning()){
|
||||||
|
qDebug("In Download thread function, Launching thread (was stopped)");
|
||||||
|
start();
|
||||||
|
}else{
|
||||||
|
condition.wakeOne();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void run();
|
void run(){
|
||||||
|
forever{
|
||||||
protected slots:
|
if(abort)
|
||||||
void propagateDownloadedFile(subDownloadThread* st, QString url, QString path);
|
return;
|
||||||
void propagateDownloadFailure(subDownloadThread* st, QString url, QString reason);
|
mutex.lock();
|
||||||
|
qDebug("In Download thread RUN, mutex locked");
|
||||||
|
if(url_list.size() != 0){
|
||||||
|
QString url = url_list.takeFirst();
|
||||||
|
mutex.unlock();
|
||||||
|
qDebug("In Download thread RUN, mutex unlocked (got url)");
|
||||||
|
CURL *curl;
|
||||||
|
QString filePath;
|
||||||
|
int return_code, response;
|
||||||
|
// XXX: Trick to get a unique filename
|
||||||
|
QTemporaryFile *tmpfile = new QTemporaryFile;
|
||||||
|
if (tmpfile->open()) {
|
||||||
|
filePath = tmpfile->fileName();
|
||||||
|
}
|
||||||
|
delete tmpfile;
|
||||||
|
if(abort)
|
||||||
|
return;
|
||||||
|
FILE *file = fopen((const char*)filePath.toUtf8(), "w");
|
||||||
|
if(!file){
|
||||||
|
std::cerr << "Error: could not open temporary file...\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Initilization required by libcurl
|
||||||
|
curl = curl_easy_init();
|
||||||
|
if(!curl){
|
||||||
|
std::cerr << "Error: Failed to init curl...\n";
|
||||||
|
fclose(file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Set url to download
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, url.toLocal8Bit().constData());
|
||||||
|
qDebug("Url: %s", url.toLocal8Bit().constData());
|
||||||
|
// Define our callback to get called when there's data to be written
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, misc::my_fwrite);
|
||||||
|
// Set destination file
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
|
||||||
|
// Some SSL mambo jambo
|
||||||
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||||
|
// Disable progress meter
|
||||||
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
|
||||||
|
// Any kind of authentication
|
||||||
|
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
||||||
|
//curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||||
|
// Auto referrer
|
||||||
|
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1);
|
||||||
|
// Follow redirections
|
||||||
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
|
||||||
|
// Enable cookies
|
||||||
|
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
|
||||||
|
// We want error message:
|
||||||
|
char errorBuffer[CURL_ERROR_SIZE];
|
||||||
|
errorBuffer[0]=0; /* prevent junk from being output */
|
||||||
|
return_code = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
|
||||||
|
if(return_code){
|
||||||
|
std::cerr << "Error: failed to set error buffer in curl\n";
|
||||||
|
fclose(file);
|
||||||
|
QFile::remove(filePath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unsigned short retries = 0;
|
||||||
|
bool to_many_users = false;
|
||||||
|
do{
|
||||||
|
// Perform Download
|
||||||
|
return_code = curl_easy_perform(curl);
|
||||||
|
// We want HTTP response code
|
||||||
|
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
|
||||||
|
qDebug("HTTP response code: %d", response);
|
||||||
|
if(response/100 == 5){
|
||||||
|
to_many_users = true;
|
||||||
|
++retries;
|
||||||
|
SleeperThread::msleep(1000);
|
||||||
|
}
|
||||||
|
}while(to_many_users && retries < 10);
|
||||||
|
// Cleanup
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
// Close tmp file
|
||||||
|
fclose(file);
|
||||||
|
emit downloadFinished(url, filePath, return_code, QString(errorBuffer));
|
||||||
|
qDebug("In Download thread RUN, signal emitted, ErrorBuffer: %s", errorBuffer);
|
||||||
|
}else{
|
||||||
|
qDebug("In Download thread RUN, mutex still locked (no urls) -> sleeping");
|
||||||
|
condition.wait(&mutex);
|
||||||
|
mutex.unlock();
|
||||||
|
qDebug("In Download thread RUN, woke up, mutex unlocked");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,886 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* Contact : chris@qbittorrent.org
|
|
||||||
*/
|
|
||||||
#include "downloadingTorrents.h"
|
|
||||||
#include "misc.h"
|
|
||||||
#include "properties_imp.h"
|
|
||||||
#include "bittorrent.h"
|
|
||||||
#include "allocationDlg.h"
|
|
||||||
#include "DLListDelegate.h"
|
|
||||||
#include "GUI.h"
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QHeaderView>
|
|
||||||
#include <QTime>
|
|
||||||
#include <QMenu>
|
|
||||||
|
|
||||||
DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession) : parent(parent), BTSession(BTSession), delayedSorting(false), nbTorrents(0) {
|
|
||||||
setupUi(this);
|
|
||||||
// Setting icons
|
|
||||||
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png")));
|
|
||||||
actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.png")));
|
|
||||||
actionDelete->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete.png")));
|
|
||||||
actionClearLog->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete.png")));
|
|
||||||
actionPreview_file->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/preview.png")));
|
|
||||||
actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")));
|
|
||||||
actionSet_download_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png")));
|
|
||||||
actionDelete_Permanently->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete_perm.png")));
|
|
||||||
actionTorrent_Properties->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/properties.png")));
|
|
||||||
// tabBottom->setTabIcon(0, QIcon(QString::fromUtf8(":/Icons/log.png")));
|
|
||||||
// tabBottom->setTabIcon(1, QIcon(QString::fromUtf8(":/Icons/filter.png")));
|
|
||||||
|
|
||||||
// Set Download list model
|
|
||||||
DLListModel = new QStandardItemModel(0,9);
|
|
||||||
DLListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
|
||||||
DLListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
|
||||||
DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress", "i.e: % downloaded"));
|
|
||||||
DLListModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("DL Speed", "i.e: Download speed"));
|
|
||||||
DLListModel->setHeaderData(UPSPEED, Qt::Horizontal, tr("UP Speed", "i.e: Upload speed"));
|
|
||||||
DLListModel->setHeaderData(SEEDSLEECH, Qt::Horizontal, tr("Seeds/Leechs", "i.e: full/partial sources"));
|
|
||||||
DLListModel->setHeaderData(RATIO, Qt::Horizontal, tr("Ratio"));
|
|
||||||
DLListModel->setHeaderData(ETA, Qt::Horizontal, tr("ETA", "i.e: Estimated Time of Arrival / Time left"));
|
|
||||||
downloadList->setModel(DLListModel);
|
|
||||||
DLDelegate = new DLListDelegate(downloadList);
|
|
||||||
downloadList->setItemDelegate(DLDelegate);
|
|
||||||
// Hide hash column
|
|
||||||
downloadList->hideColumn(HASH);
|
|
||||||
loadHiddenColumns();
|
|
||||||
|
|
||||||
connect(BTSession, SIGNAL(addedTorrent(QString, QTorrentHandle&, bool)), this, SLOT(torrentAdded(QString, QTorrentHandle&, bool)));
|
|
||||||
connect(BTSession, SIGNAL(duplicateTorrent(QString)), this, SLOT(torrentDuplicate(QString)));
|
|
||||||
connect(BTSession, SIGNAL(invalidTorrent(QString)), this, SLOT(torrentCorrupted(QString)));
|
|
||||||
connect(BTSession, SIGNAL(portListeningFailure()), this, SLOT(portListeningFailure()));
|
|
||||||
connect(BTSession, SIGNAL(peerBlocked(QString)), this, SLOT(addLogPeerBlocked(const QString)));
|
|
||||||
connect(BTSession, SIGNAL(fastResumeDataRejected(QString)), this, SLOT(addFastResumeRejectedAlert(QString)));
|
|
||||||
connect(BTSession, SIGNAL(aboutToDownloadFromUrl(QString)), this, SLOT(displayDownloadingUrlInfos(QString)));
|
|
||||||
connect(BTSession, SIGNAL(urlSeedProblem(QString, QString)), this, SLOT(addUrlSeedError(QString, QString)));
|
|
||||||
connect(BTSession, SIGNAL(UPnPError(QString)), this, SLOT(displayUPnPError(QString)));
|
|
||||||
connect(BTSession, SIGNAL(UPnPSuccess(QString)), this, SLOT(displayUPnPSuccess(QString)));
|
|
||||||
|
|
||||||
// Load last columns width for download list
|
|
||||||
if(!loadColWidthDLList()) {
|
|
||||||
downloadList->header()->resizeSection(0, 200);
|
|
||||||
}
|
|
||||||
// Make download list header clickable for sorting
|
|
||||||
downloadList->header()->setClickable(true);
|
|
||||||
downloadList->header()->setSortIndicatorShown(true);
|
|
||||||
// Connecting Actions to slots
|
|
||||||
connect(downloadList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(notifyTorrentDoubleClicked(const QModelIndex&)));
|
|
||||||
connect(downloadList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortDownloadList(int)));
|
|
||||||
connect(downloadList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLListMenu(const QPoint&)));
|
|
||||||
downloadList->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
connect(downloadList->header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&)));
|
|
||||||
connect(infoBar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoBarMenu(const QPoint&)));
|
|
||||||
// Actions
|
|
||||||
connect(actionPause, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPause_triggered()));
|
|
||||||
connect(actionStart, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionStart_triggered()));
|
|
||||||
connect(actionDelete, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_triggered()));
|
|
||||||
connect(actionPreview_file, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPreview_file_triggered()));
|
|
||||||
connect(actionDelete_Permanently, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_Permanently_triggered()));
|
|
||||||
connect(actionOpen_destination_folder, SIGNAL(triggered()), (GUI*)parent, SLOT(openDestinationFolder()));
|
|
||||||
connect(actionTorrent_Properties, SIGNAL(triggered()), this, SLOT(propertiesSelection()));
|
|
||||||
connect(actionBuy_it, SIGNAL(triggered()), (GUI*)parent, SLOT(goBuyPage()));
|
|
||||||
|
|
||||||
connect(actionHOSColName, SIGNAL(triggered()), this, SLOT(hideOrShowColumnName()));
|
|
||||||
connect(actionHOSColSize, SIGNAL(triggered()), this, SLOT(hideOrShowColumnSize()));
|
|
||||||
connect(actionHOSColProgress, SIGNAL(triggered()), this, SLOT(hideOrShowColumnProgress()));
|
|
||||||
connect(actionHOSColDownSpeed, SIGNAL(triggered()), this, SLOT(hideOrShowColumnDownSpeed()));
|
|
||||||
connect(actionHOSColUpSpeed, SIGNAL(triggered()), this, SLOT(hideOrShowColumnUpSpeed()));
|
|
||||||
connect(actionHOSColSeedersLeechers, SIGNAL(triggered()), this, SLOT(hideOrShowColumnSeedersLeechers()));
|
|
||||||
connect(actionHOSColRatio, SIGNAL(triggered()), this, SLOT(hideOrShowColumnRatio()));
|
|
||||||
connect(actionHOSColEta, SIGNAL(triggered()), this, SLOT(hideOrShowColumnEta()));
|
|
||||||
|
|
||||||
// Set info Bar infos
|
|
||||||
setInfoBar(tr("qBittorrent %1 started.", "e.g: qBittorrent v0.x started.").arg(QString::fromUtf8(""VERSION)));
|
|
||||||
qDebug("Download tab built");
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadingTorrents::~DownloadingTorrents() {
|
|
||||||
saveColWidthDLList();
|
|
||||||
saveHiddenColumns();
|
|
||||||
delete DLDelegate;
|
|
||||||
delete DLListModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DownloadingTorrents::notifyTorrentDoubleClicked(const QModelIndex& index) {
|
|
||||||
unsigned int row = index.row();
|
|
||||||
QString hash = getHashFromRow(row);
|
|
||||||
emit torrentDoubleClicked(hash, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::addLogPeerBlocked(QString ip) {
|
|
||||||
static unsigned int nbLines = 0;
|
|
||||||
++nbLines;
|
|
||||||
if(nbLines > 200) {
|
|
||||||
textBlockedUsers->clear();
|
|
||||||
nbLines = 1;
|
|
||||||
}
|
|
||||||
textBlockedUsers->append(QString::fromUtf8("<font color='grey'>")+ QTime::currentTime().toString(QString::fromUtf8("hh:mm:ss")) + QString::fromUtf8("</font> - ")+tr("<font color='red'>%1</font> <i>was blocked</i>", "x.y.z.w was blocked").arg(ip));
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int DownloadingTorrents::getNbTorrentsInList() const {
|
|
||||||
return nbTorrents;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: do not actually pause the torrent in BT session
|
|
||||||
void DownloadingTorrents::pauseTorrent(QString hash) {
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
if(row == -1)
|
|
||||||
return;
|
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0));
|
|
||||||
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0));
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QIcon(QString::fromUtf8(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
|
||||||
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString::fromUtf8("0/0")));
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
|
||||||
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
|
|
||||||
setRowColor(row, QString::fromUtf8("red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DownloadingTorrents::getHashFromRow(unsigned int row) const {
|
|
||||||
Q_ASSERT(row < (unsigned int)DLListModel->rowCount());
|
|
||||||
return DLListModel->data(DLListModel->index(row, HASH)).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::setBottomTabEnabled(unsigned int index, bool b){
|
|
||||||
if(index and !b)
|
|
||||||
tabBottom->setCurrentIndex(0);
|
|
||||||
tabBottom->setTabEnabled(index, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show torrent properties dialog
|
|
||||||
void DownloadingTorrents::showProperties(const QModelIndex &index) {
|
|
||||||
showPropertiesFromHash(DLListModel->data(DLListModel->index(index.row(), HASH)).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::showPropertiesFromHash(QString hash) {
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
|
||||||
properties *prop = new properties(this, BTSession, h);
|
|
||||||
connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSizeAndProgress(QString)));
|
|
||||||
connect(prop, SIGNAL(trackersChanged(QString)), BTSession, SLOT(saveTrackerFile(QString)));
|
|
||||||
prop->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::resumeTorrent(QString hash){
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
Q_ASSERT(row != -1);
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/connecting.png"))), Qt::DecorationRole);
|
|
||||||
setRowColor(row, QString::fromUtf8("grey"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove a torrent from the download list but NOT from the BT Session
|
|
||||||
void DownloadingTorrents::deleteTorrent(QString hash) {
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
if(row == -1){
|
|
||||||
qDebug("torrent is not in download list, nothing to delete");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DLListModel->removeRow(row);
|
|
||||||
--nbTorrents;
|
|
||||||
emit unfinishedTorrentsNumberChanged(nbTorrents);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::displayUPnPError(QString msg) {
|
|
||||||
setInfoBar(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(msg), QColor("red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::displayUPnPSuccess(QString msg) {
|
|
||||||
DownloadingTorrents::setInfoBar(tr("UPnP/NAT-PMP: Port mapping successful, message: %1").arg(msg), QColor("blue"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update Info Bar information
|
|
||||||
void DownloadingTorrents::setInfoBar(QString info, QColor color) {
|
|
||||||
static unsigned int nbLines = 0;
|
|
||||||
++nbLines;
|
|
||||||
// Check log size, clear it if too big
|
|
||||||
if(nbLines > 200) {
|
|
||||||
infoBar->clear();
|
|
||||||
nbLines = 1;
|
|
||||||
}
|
|
||||||
infoBar->append(QString::fromUtf8("<font color='grey'>")+ QTime::currentTime().toString(QString::fromUtf8("hh:mm:ss")) + QString::fromUtf8("</font> - <font color='") + color.name() +QString::fromUtf8("'><i>") + info + QString::fromUtf8("</i></font>"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::addFastResumeRejectedAlert(QString name) {
|
|
||||||
setInfoBar(tr("Fast resume data was rejected for torrent %1, checking again...").arg(name), QString::fromUtf8("red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::addUrlSeedError(QString url, QString msg) {
|
|
||||||
setInfoBar(tr("Url seed lookup failed for url: %1, message: %2").arg(url).arg(msg), QString::fromUtf8("red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::on_actionSet_download_limit_triggered() {
|
|
||||||
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
|
||||||
QModelIndex index;
|
|
||||||
QStringList hashes;
|
|
||||||
foreach(index, selectedIndexes) {
|
|
||||||
if(index.column() == NAME) {
|
|
||||||
// Get the file hash
|
|
||||||
hashes << DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Q_ASSERT(hashes.size() > 0);
|
|
||||||
new BandwidthAllocationDialog(this, false, BTSession, hashes);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::on_actionSet_upload_limit_triggered() {
|
|
||||||
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
|
||||||
QModelIndex index;
|
|
||||||
QStringList hashes;
|
|
||||||
foreach(index, selectedIndexes) {
|
|
||||||
if(index.column() == NAME) {
|
|
||||||
// Get the file hash
|
|
||||||
hashes << DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Q_ASSERT(hashes.size() > 0);
|
|
||||||
new BandwidthAllocationDialog(this, true, BTSession, hashes);
|
|
||||||
}
|
|
||||||
|
|
||||||
// display properties of selected items
|
|
||||||
void DownloadingTorrents::propertiesSelection(){
|
|
||||||
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
|
||||||
QModelIndex index;
|
|
||||||
foreach(index, selectedIndexes){
|
|
||||||
if(index.column() == NAME){
|
|
||||||
showProperties(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::displayDLListMenu(const QPoint& pos) {
|
|
||||||
QMenu myDLLlistMenu(this);
|
|
||||||
QModelIndex index;
|
|
||||||
// Enable/disable pause/start action given the DL state
|
|
||||||
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
|
||||||
bool has_pause = false, has_start = false, has_preview = false;
|
|
||||||
foreach(index, selectedIndexes) {
|
|
||||||
if(index.column() == NAME) {
|
|
||||||
// Get the file name
|
|
||||||
QString hash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
|
|
||||||
// Get handle and pause the torrent
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
|
||||||
if(!h.is_valid()) continue;
|
|
||||||
if(h.is_paused()) {
|
|
||||||
if(!has_start) {
|
|
||||||
myDLLlistMenu.addAction(actionStart);
|
|
||||||
has_start = true;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if(!has_pause) {
|
|
||||||
myDLLlistMenu.addAction(actionPause);
|
|
||||||
has_pause = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(BTSession->isFilePreviewPossible(hash) && !has_preview) {
|
|
||||||
myDLLlistMenu.addAction(actionPreview_file);
|
|
||||||
has_preview = true;
|
|
||||||
}
|
|
||||||
if(has_pause && has_start && has_preview) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
myDLLlistMenu.addSeparator();
|
|
||||||
myDLLlistMenu.addAction(actionDelete);
|
|
||||||
myDLLlistMenu.addAction(actionDelete_Permanently);
|
|
||||||
myDLLlistMenu.addSeparator();
|
|
||||||
myDLLlistMenu.addAction(actionSet_download_limit);
|
|
||||||
myDLLlistMenu.addAction(actionSet_upload_limit);
|
|
||||||
myDLLlistMenu.addSeparator();
|
|
||||||
myDLLlistMenu.addAction(actionOpen_destination_folder);
|
|
||||||
myDLLlistMenu.addAction(actionTorrent_Properties);
|
|
||||||
myDLLlistMenu.addSeparator();
|
|
||||||
myDLLlistMenu.addAction(actionBuy_it);
|
|
||||||
// Call menu
|
|
||||||
// XXX: why mapToGlobal() is not enough?
|
|
||||||
myDLLlistMenu.exec(mapToGlobal(pos)+QPoint(10,60));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Hiding Columns functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
// hide/show columns menu
|
|
||||||
void DownloadingTorrents::displayDLHoSMenu(const QPoint& pos){
|
|
||||||
QMenu hideshowColumn(this);
|
|
||||||
hideshowColumn.setTitle(tr("Hide or Show Column"));
|
|
||||||
for(int i=0; i<=ETA; i++) {
|
|
||||||
hideshowColumn.addAction(getActionHoSCol(i));
|
|
||||||
}
|
|
||||||
// Call menu
|
|
||||||
hideshowColumn.exec(mapToGlobal(pos)+QPoint(10,55));
|
|
||||||
}
|
|
||||||
|
|
||||||
// toggle hide/show a column
|
|
||||||
void DownloadingTorrents::hideOrShowColumn(int index) {
|
|
||||||
unsigned int nbVisibleColumns = 0;
|
|
||||||
unsigned int nbCols = DLListModel->columnCount();
|
|
||||||
// Count visible columns
|
|
||||||
for(unsigned int i=0; i<nbCols; ++i) {
|
|
||||||
if(!downloadList->isColumnHidden(i))
|
|
||||||
++nbVisibleColumns;
|
|
||||||
}
|
|
||||||
if(!downloadList->isColumnHidden(index)) {
|
|
||||||
// User wants to hide the column
|
|
||||||
// Is there at least one other visible column?
|
|
||||||
if(nbVisibleColumns <= 1) return;
|
|
||||||
// User can hide the column, do it.
|
|
||||||
downloadList->setColumnHidden(index, true);
|
|
||||||
getActionHoSCol(index)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png")));
|
|
||||||
--nbVisibleColumns;
|
|
||||||
} else {
|
|
||||||
// User want to display the column
|
|
||||||
downloadList->setColumnHidden(index, false);
|
|
||||||
getActionHoSCol(index)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
|
|
||||||
++nbVisibleColumns;
|
|
||||||
}
|
|
||||||
//resize all others non-hidden columns
|
|
||||||
for(unsigned int i=0; i<nbCols; ++i) {
|
|
||||||
if(!downloadList->isColumnHidden(i)) {
|
|
||||||
downloadList->setColumnWidth(i, (int)ceil(downloadList->columnWidth(i)+(downloadList->columnWidth(index)/nbVisibleColumns)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// save the hidden columns in settings
|
|
||||||
void DownloadingTorrents::saveHiddenColumns() {
|
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
|
||||||
QStringList ishidden_list;
|
|
||||||
short nbColumns = DLListModel->columnCount()-1;
|
|
||||||
|
|
||||||
for(short i=0; i<nbColumns; ++i){
|
|
||||||
if(downloadList->isColumnHidden(i)) {
|
|
||||||
ishidden_list << QString::fromUtf8(misc::toString(0).c_str());
|
|
||||||
} else {
|
|
||||||
ishidden_list << QString::fromUtf8(misc::toString(1).c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
settings.setValue("DownloadListColsHoS", ishidden_list.join(" "));
|
|
||||||
}
|
|
||||||
|
|
||||||
// load the previous settings, and hide the columns
|
|
||||||
bool DownloadingTorrents::loadHiddenColumns() {
|
|
||||||
bool loaded = false;
|
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
|
||||||
QString line = settings.value("DownloadListColsHoS", QString()).toString();
|
|
||||||
QStringList ishidden_list;
|
|
||||||
if(!line.isEmpty()) {
|
|
||||||
ishidden_list = line.split(' ');
|
|
||||||
if(ishidden_list.size() == DLListModel->columnCount()-1) {
|
|
||||||
unsigned int listSize = ishidden_list.size();
|
|
||||||
for(unsigned int i=0; i<listSize; ++i){
|
|
||||||
downloadList->header()->resizeSection(i, ishidden_list.at(i).toInt());
|
|
||||||
}
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(int i=0; i<DLListModel->columnCount()-1; i++) {
|
|
||||||
if(loaded && ishidden_list.at(i) == "0") {
|
|
||||||
downloadList->setColumnHidden(i, true);
|
|
||||||
getActionHoSCol(i)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png")));
|
|
||||||
} else {
|
|
||||||
getActionHoSCol(i)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return loaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::hideOrShowColumnName() {
|
|
||||||
hideOrShowColumn(NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::hideOrShowColumnSize() {
|
|
||||||
hideOrShowColumn(SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::hideOrShowColumnProgress() {
|
|
||||||
hideOrShowColumn(PROGRESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::hideOrShowColumnDownSpeed() {
|
|
||||||
hideOrShowColumn(DLSPEED);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::hideOrShowColumnUpSpeed() {
|
|
||||||
hideOrShowColumn(UPSPEED);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::hideOrShowColumnSeedersLeechers() {
|
|
||||||
hideOrShowColumn(SEEDSLEECH);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::hideOrShowColumnRatio() {
|
|
||||||
hideOrShowColumn(RATIO);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::hideOrShowColumnEta() {
|
|
||||||
hideOrShowColumn(ETA);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DownloadingTorrents::on_actionClearLog_triggered() {
|
|
||||||
infoBar->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// getter, return the action hide or show whose id is index
|
|
||||||
QAction* DownloadingTorrents::getActionHoSCol(int index) {
|
|
||||||
switch(index) {
|
|
||||||
case NAME :
|
|
||||||
return actionHOSColName;
|
|
||||||
break;
|
|
||||||
case SIZE :
|
|
||||||
return actionHOSColSize;
|
|
||||||
break;
|
|
||||||
case PROGRESS :
|
|
||||||
return actionHOSColProgress;
|
|
||||||
break;
|
|
||||||
case DLSPEED :
|
|
||||||
return actionHOSColDownSpeed;
|
|
||||||
break;
|
|
||||||
case UPSPEED :
|
|
||||||
return actionHOSColUpSpeed;
|
|
||||||
break;
|
|
||||||
case SEEDSLEECH :
|
|
||||||
return actionHOSColSeedersLeechers;
|
|
||||||
break;
|
|
||||||
case RATIO :
|
|
||||||
return actionHOSColRatio;
|
|
||||||
break;
|
|
||||||
case ETA :
|
|
||||||
return actionHOSColEta;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList DownloadingTorrents::getSelectedTorrents(bool only_one) const{
|
|
||||||
QStringList res;
|
|
||||||
QModelIndex index;
|
|
||||||
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
|
||||||
foreach(index, selectedIndexes) {
|
|
||||||
if(index.column() == NAME) {
|
|
||||||
// Get the file hash
|
|
||||||
QString hash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
|
|
||||||
res << hash;
|
|
||||||
if(only_one) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::displayInfoBarMenu(const QPoint& pos) {
|
|
||||||
// Log Menu
|
|
||||||
QMenu myLogMenu(this);
|
|
||||||
myLogMenu.addAction(actionClearLog);
|
|
||||||
// XXX: Why mapToGlobal() is not enough?
|
|
||||||
myLogMenu.exec(mapToGlobal(pos)+QPoint(44,305));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::sortProgressColumnDelayed() {
|
|
||||||
if(delayedSorting) {
|
|
||||||
sortDownloadListFloat(PROGRESS, delayedSortingOrder);
|
|
||||||
qDebug("Delayed sorting of progress column");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get information from torrent handles and
|
|
||||||
// update download list accordingly
|
|
||||||
void DownloadingTorrents::updateDlList() {
|
|
||||||
// browse handles
|
|
||||||
QStringList unfinishedTorrents = BTSession->getUnfinishedTorrents();
|
|
||||||
QString hash;
|
|
||||||
foreach(hash, unfinishedTorrents) {
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
|
||||||
if(!h.is_valid()){
|
|
||||||
qDebug("We have an invalid handle for: %s", qPrintable(hash));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
try{
|
|
||||||
QString hash = h.hash();
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
if(row == -1) {
|
|
||||||
qDebug("Info: Could not find filename in download list, adding it...");
|
|
||||||
addTorrent(hash);
|
|
||||||
row = getRowFromHash(hash);
|
|
||||||
}
|
|
||||||
Q_ASSERT(row != -1);
|
|
||||||
// No need to update a paused torrent
|
|
||||||
if(h.is_paused()) continue;
|
|
||||||
if(BTSession->getTorrentsToPauseAfterChecking().indexOf(hash) != -1) {
|
|
||||||
if(!downloadList->isColumnHidden(PROGRESS)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Parse download state
|
|
||||||
// Setting download state
|
|
||||||
switch(h.state()) {
|
|
||||||
case torrent_status::finished:
|
|
||||||
case torrent_status::seeding:
|
|
||||||
qDebug("A torrent that was in download tab just finished, moving it to finished tab");
|
|
||||||
BTSession->setUnfinishedTorrent(hash);
|
|
||||||
emit torrentFinished(hash);
|
|
||||||
deleteTorrent(hash);
|
|
||||||
continue;
|
|
||||||
case torrent_status::checking_files:
|
|
||||||
case torrent_status::queued_for_checking:
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/time.png"))), Qt::DecorationRole);
|
|
||||||
setRowColor(row, QString::fromUtf8("grey"));
|
|
||||||
if(!downloadList->isColumnHidden(PROGRESS)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case torrent_status::connecting_to_tracker:
|
|
||||||
if(h.download_payload_rate() > 0) {
|
|
||||||
// Display "Downloading" status when connecting if download speed > 0
|
|
||||||
if(!downloadList->isColumnHidden(ETA)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)BTSession->getETA(hash)));
|
|
||||||
}
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png"))), Qt::DecorationRole);
|
|
||||||
setRowColor(row, QString::fromUtf8("green"));
|
|
||||||
}else{
|
|
||||||
if(!downloadList->isColumnHidden(ETA)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
|
||||||
}
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/connecting.png"))), Qt::DecorationRole);
|
|
||||||
setRowColor(row, QString::fromUtf8("grey"));
|
|
||||||
}
|
|
||||||
if(!downloadList->isColumnHidden(PROGRESS)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
|
|
||||||
}
|
|
||||||
if(!downloadList->isColumnHidden(DLSPEED)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)h.download_payload_rate()));
|
|
||||||
}
|
|
||||||
if(!downloadList->isColumnHidden(UPSPEED)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)h.upload_payload_rate()));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case torrent_status::downloading:
|
|
||||||
case torrent_status::downloading_metadata:
|
|
||||||
if(h.download_payload_rate() > 0) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png"))), Qt::DecorationRole);
|
|
||||||
if(!downloadList->isColumnHidden(ETA)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)BTSession->getETA(hash)));
|
|
||||||
}
|
|
||||||
setRowColor(row, QString::fromUtf8("green"));
|
|
||||||
}else{
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/stalled.png"))), Qt::DecorationRole);
|
|
||||||
if(!downloadList->isColumnHidden(ETA)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
|
||||||
}
|
|
||||||
setRowColor(row, QApplication::palette().color(QPalette::WindowText));
|
|
||||||
}
|
|
||||||
if(!downloadList->isColumnHidden(PROGRESS)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
|
|
||||||
}
|
|
||||||
if(!downloadList->isColumnHidden(DLSPEED)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)h.download_payload_rate()));
|
|
||||||
}
|
|
||||||
if(!downloadList->isColumnHidden(UPSPEED)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)h.upload_payload_rate()));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if(!downloadList->isColumnHidden(ETA)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!downloadList->isColumnHidden(SEEDSLEECH)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(misc::toQString(h.num_seeds(), true)+QString::fromUtf8("/")+misc::toQString(h.num_peers() - h.num_seeds(), true)));
|
|
||||||
}
|
|
||||||
if(!downloadList->isColumnHidden(RATIO)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, RATIO), QVariant(misc::toQString(BTSession->getRealRatio(hash))));
|
|
||||||
}
|
|
||||||
}catch(invalid_handle e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::addTorrent(QString hash) {
|
|
||||||
if(BTSession->isFinished(hash)){
|
|
||||||
BTSession->setUnfinishedTorrent(hash);
|
|
||||||
}
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
if(row != -1) return;
|
|
||||||
row = DLListModel->rowCount();
|
|
||||||
// Adding torrent to download list
|
|
||||||
DLListModel->insertRow(row);
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(h.name()));
|
|
||||||
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)h.actual_size()));
|
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.));
|
|
||||||
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.));
|
|
||||||
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString::fromUtf8("0/0")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
|
||||||
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
|
|
||||||
// Pause torrent if it was paused last time
|
|
||||||
if(BTSession->isPaused(hash)) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/paused.png"))), Qt::DecorationRole);
|
|
||||||
setRowColor(row, QString::fromUtf8("red"));
|
|
||||||
}else{
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/connecting.png"))), Qt::DecorationRole);
|
|
||||||
setRowColor(row, QString::fromUtf8("grey"));
|
|
||||||
}
|
|
||||||
++nbTorrents;
|
|
||||||
emit unfinishedTorrentsNumberChanged(nbTorrents);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::sortDownloadListFloat(int index, Qt::SortOrder sortOrder) {
|
|
||||||
QList<QPair<int, double> > lines;
|
|
||||||
// insertion sorting
|
|
||||||
unsigned int nbRows = DLListModel->rowCount();
|
|
||||||
for(unsigned int i=0; i<nbRows; ++i) {
|
|
||||||
misc::insertSort(lines, QPair<int,double>(i, DLListModel->data(DLListModel->index(i, index)).toDouble()), sortOrder);
|
|
||||||
}
|
|
||||||
// Insert items in new model, in correct order
|
|
||||||
unsigned int nbRows_old = lines.size();
|
|
||||||
for(unsigned int row=0; row<nbRows_old; ++row) {
|
|
||||||
DLListModel->insertRow(DLListModel->rowCount());
|
|
||||||
unsigned int sourceRow = lines[row].first;
|
|
||||||
unsigned int nbColumns = DLListModel->columnCount();
|
|
||||||
for(unsigned int col=0; col<nbColumns; ++col) {
|
|
||||||
DLListModel->setData(DLListModel->index(nbRows_old+row, col), DLListModel->data(DLListModel->index(sourceRow, col)));
|
|
||||||
DLListModel->setData(DLListModel->index(nbRows_old+row, col), DLListModel->data(DLListModel->index(sourceRow, col), Qt::DecorationRole), Qt::DecorationRole);
|
|
||||||
DLListModel->setData(DLListModel->index(nbRows_old+row, col), DLListModel->data(DLListModel->index(sourceRow, col), Qt::ForegroundRole), Qt::ForegroundRole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Remove old rows
|
|
||||||
DLListModel->removeRows(0, nbRows_old);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::sortDownloadListString(int index, Qt::SortOrder sortOrder) {
|
|
||||||
QList<QPair<int, QString> > lines;
|
|
||||||
// Insertion sorting
|
|
||||||
unsigned int nbRows = DLListModel->rowCount();
|
|
||||||
for(unsigned int i=0; i<nbRows; ++i) {
|
|
||||||
misc::insertSortString(lines, QPair<int, QString>(i, DLListModel->data(DLListModel->index(i, index)).toString()), sortOrder);
|
|
||||||
}
|
|
||||||
// Insert items in new model, in correct order
|
|
||||||
unsigned int nbRows_old = lines.size();
|
|
||||||
for(unsigned int row=0; row<nbRows_old; ++row) {
|
|
||||||
DLListModel->insertRow(DLListModel->rowCount());
|
|
||||||
unsigned int sourceRow = lines[row].first;
|
|
||||||
unsigned int nbColumns = DLListModel->columnCount();
|
|
||||||
for(unsigned int col=0; col<nbColumns; ++col) {
|
|
||||||
DLListModel->setData(DLListModel->index(nbRows_old+row, col), DLListModel->data(DLListModel->index(sourceRow, col)));
|
|
||||||
DLListModel->setData(DLListModel->index(nbRows_old+row, col), DLListModel->data(DLListModel->index(sourceRow, col), Qt::DecorationRole), Qt::DecorationRole);
|
|
||||||
DLListModel->setData(DLListModel->index(nbRows_old+row, col), DLListModel->data(DLListModel->index(sourceRow, col), Qt::ForegroundRole), Qt::ForegroundRole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Remove old rows
|
|
||||||
DLListModel->removeRows(0, nbRows_old);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::sortDownloadList(int index, Qt::SortOrder startSortOrder, bool fromLoadColWidth) {
|
|
||||||
qDebug("Called sort download list");
|
|
||||||
static Qt::SortOrder sortOrder = startSortOrder;
|
|
||||||
if(!fromLoadColWidth && downloadList->header()->sortIndicatorSection() == index) {
|
|
||||||
if(sortOrder == Qt::AscendingOrder) {
|
|
||||||
sortOrder = Qt::DescendingOrder;
|
|
||||||
}else{
|
|
||||||
sortOrder = Qt::AscendingOrder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString sortOrderLetter;
|
|
||||||
if(sortOrder == Qt::AscendingOrder)
|
|
||||||
sortOrderLetter = QString::fromUtf8("a");
|
|
||||||
else
|
|
||||||
sortOrderLetter = QString::fromUtf8("d");
|
|
||||||
if(fromLoadColWidth) {
|
|
||||||
// XXX: Why is this needed?
|
|
||||||
if(sortOrder == Qt::DescendingOrder)
|
|
||||||
downloadList->header()->setSortIndicator(index, Qt::AscendingOrder);
|
|
||||||
else
|
|
||||||
downloadList->header()->setSortIndicator(index, Qt::DescendingOrder);
|
|
||||||
} else {
|
|
||||||
downloadList->header()->setSortIndicator(index, sortOrder);
|
|
||||||
}
|
|
||||||
switch(index) {
|
|
||||||
case SIZE:
|
|
||||||
case ETA:
|
|
||||||
case UPSPEED:
|
|
||||||
case DLSPEED:
|
|
||||||
sortDownloadListFloat(index, sortOrder);
|
|
||||||
break;
|
|
||||||
case PROGRESS:
|
|
||||||
if(fromLoadColWidth) {
|
|
||||||
// Progress sorting must be delayed until files are checked (on startup)
|
|
||||||
delayedSorting = true;
|
|
||||||
qDebug("Delayed sorting of the progress column");
|
|
||||||
delayedSortingOrder = sortOrder;
|
|
||||||
}else{
|
|
||||||
sortDownloadListFloat(index, sortOrder);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sortDownloadListString(index, sortOrder);
|
|
||||||
}
|
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
|
||||||
settings.setValue(QString::fromUtf8("DownloadListSortedCol"), misc::toQString(index)+sortOrderLetter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save columns width in a file to remember them
|
|
||||||
// (download list)
|
|
||||||
void DownloadingTorrents::saveColWidthDLList() const{
|
|
||||||
qDebug("Saving columns width in download list");
|
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
|
||||||
QStringList width_list;
|
|
||||||
QStringList new_width_list;
|
|
||||||
short nbColumns = DLListModel->columnCount()-1;
|
|
||||||
QString line = settings.value("DownloadListColsWidth", QString()).toString();
|
|
||||||
if(!line.isEmpty()) {
|
|
||||||
width_list = line.split(' ');
|
|
||||||
}
|
|
||||||
for(short i=0; i<nbColumns; ++i){
|
|
||||||
if(downloadList->columnWidth(i)<1 && width_list.size() == DLListModel->columnCount()-1 && width_list.at(i).toInt()>=1) {
|
|
||||||
// load the former width
|
|
||||||
new_width_list << width_list.at(i);
|
|
||||||
} else if(downloadList->columnWidth(i)>=1) {
|
|
||||||
// usual case, save the current width
|
|
||||||
new_width_list << QString::fromUtf8(misc::toString(downloadList->columnWidth(i)).c_str());
|
|
||||||
} else {
|
|
||||||
// default width
|
|
||||||
downloadList->resizeColumnToContents(i);
|
|
||||||
new_width_list << QString::fromUtf8(misc::toString(downloadList->columnWidth(i)).c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
settings.setValue(QString::fromUtf8("DownloadListColsWidth"), new_width_list.join(QString::fromUtf8(" ")));
|
|
||||||
qDebug("Download list columns width saved");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load columns width in a file that were saved previously
|
|
||||||
// (download list)
|
|
||||||
bool DownloadingTorrents::loadColWidthDLList() {
|
|
||||||
qDebug("Loading columns width for download list");
|
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
|
||||||
QString line = settings.value(QString::fromUtf8("DownloadListColsWidth"), QString()).toString();
|
|
||||||
if(line.isEmpty())
|
|
||||||
return false;
|
|
||||||
QStringList width_list = line.split(QString::fromUtf8(" "));
|
|
||||||
if(width_list.size() != DLListModel->columnCount()-1) {
|
|
||||||
qDebug("Corrupted values for download list columns sizes");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
unsigned int listSize = width_list.size();
|
|
||||||
for(unsigned int i=0; i<listSize; ++i) {
|
|
||||||
downloadList->header()->resizeSection(i, width_list.at(i).toInt());
|
|
||||||
}
|
|
||||||
// Loading last sorted column
|
|
||||||
QString sortedCol = settings.value(QString::fromUtf8("DownloadListSortedCol"), QString()).toString();
|
|
||||||
if(!sortedCol.isEmpty()) {
|
|
||||||
Qt::SortOrder sortOrder;
|
|
||||||
if(sortedCol.endsWith(QString::fromUtf8("d")))
|
|
||||||
sortOrder = Qt::DescendingOrder;
|
|
||||||
else
|
|
||||||
sortOrder = Qt::AscendingOrder;
|
|
||||||
sortedCol = sortedCol.left(sortedCol.size()-1);
|
|
||||||
int index = sortedCol.toInt();
|
|
||||||
sortDownloadList(index, sortOrder, true);
|
|
||||||
}
|
|
||||||
qDebug("Download list columns width loaded");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when a torrent is added
|
|
||||||
void DownloadingTorrents::torrentAdded(QString path, QTorrentHandle& h, bool fastResume) {
|
|
||||||
QString hash = h.hash();
|
|
||||||
if(BTSession->isFinished(hash)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int row = DLListModel->rowCount();
|
|
||||||
// Adding torrent to download list
|
|
||||||
DLListModel->insertRow(row);
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(h.name()));
|
|
||||||
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)h.actual_size()));
|
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.));
|
|
||||||
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.));
|
|
||||||
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString::fromUtf8("0/0")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, RATIO), QVariant(misc::toQString(BTSession->getRealRatio(hash))));
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
|
||||||
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
|
|
||||||
// Pause torrent if it was paused last time
|
|
||||||
// Not using isPaused function because torrents are paused after checking now
|
|
||||||
if(QFile::exists(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".paused"))) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/paused.png"))), Qt::DecorationRole);
|
|
||||||
setRowColor(row, QString::fromUtf8("red"));
|
|
||||||
}else{
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/connecting.png"))), Qt::DecorationRole);
|
|
||||||
setRowColor(row, QString::fromUtf8("grey"));
|
|
||||||
}
|
|
||||||
if(!fastResume) {
|
|
||||||
setInfoBar(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(path));
|
|
||||||
}else{
|
|
||||||
setInfoBar(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(path));
|
|
||||||
}
|
|
||||||
++nbTorrents;
|
|
||||||
emit unfinishedTorrentsNumberChanged(nbTorrents);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when trying to add a duplicate torrent
|
|
||||||
void DownloadingTorrents::torrentDuplicate(QString path) {
|
|
||||||
setInfoBar(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::torrentCorrupted(QString path) {
|
|
||||||
setInfoBar(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(path), QString::fromUtf8("red"));
|
|
||||||
setInfoBar(tr("This file is either corrupted or this isn't a torrent."),QString::fromUtf8("red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::updateFileSizeAndProgress(QString hash) {
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
Q_ASSERT(row != -1);
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
|
||||||
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)h.actual_size()));
|
|
||||||
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when we couldn't listen on any port
|
|
||||||
// in the given range.
|
|
||||||
void DownloadingTorrents::portListeningFailure() {
|
|
||||||
setInfoBar(tr("Couldn't listen on any of the given ports."), QString::fromUtf8("red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the color of a row in data model
|
|
||||||
void DownloadingTorrents::setRowColor(int row, QColor color) {
|
|
||||||
unsigned int nbColumns = DLListModel->columnCount()-1;
|
|
||||||
for(unsigned int i=0; i<nbColumns; ++i) {
|
|
||||||
DLListModel->setData(DLListModel->index(row, i), QVariant(color), Qt::ForegroundRole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the row of in data model
|
|
||||||
// corresponding to the given the hash
|
|
||||||
int DownloadingTorrents::getRowFromHash(QString hash) const{
|
|
||||||
unsigned int nbRows = DLListModel->rowCount();
|
|
||||||
for(unsigned int i=0; i<nbRows; ++i) {
|
|
||||||
if(DLListModel->data(DLListModel->index(i, HASH)) == hash) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadingTorrents::displayDownloadingUrlInfos(QString url) {
|
|
||||||
setInfoBar(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(url), QPalette::WindowText);
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* Contact : chris@qbittorrent.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef DOWNLOADINGTORRENTS_H
|
|
||||||
#define DOWNLOADINGTORRENTS_H
|
|
||||||
|
|
||||||
#include "ui_download.h"
|
|
||||||
#include "qtorrenthandle.h"
|
|
||||||
|
|
||||||
class QStandardItemModel;
|
|
||||||
class bittorrent;
|
|
||||||
class DLListDelegate;
|
|
||||||
|
|
||||||
using namespace libtorrent;
|
|
||||||
|
|
||||||
class DownloadingTorrents : public QWidget, public Ui::downloading{
|
|
||||||
Q_OBJECT
|
|
||||||
private:
|
|
||||||
QObject *parent;
|
|
||||||
bittorrent *BTSession;
|
|
||||||
DLListDelegate *DLDelegate;
|
|
||||||
QStandardItemModel *DLListModel;
|
|
||||||
bool delayedSorting;
|
|
||||||
unsigned int nbTorrents;
|
|
||||||
Qt::SortOrder delayedSortingOrder;
|
|
||||||
void hideOrShowColumn(int index);
|
|
||||||
bool loadHiddenColumns();
|
|
||||||
void saveHiddenColumns();
|
|
||||||
QAction* getActionHoSCol(int index);
|
|
||||||
|
|
||||||
public:
|
|
||||||
DownloadingTorrents(QObject *parent, bittorrent *BTSession);
|
|
||||||
~DownloadingTorrents();
|
|
||||||
// Methods
|
|
||||||
bool loadColWidthDLList();
|
|
||||||
int getRowFromHash(QString hash) const;
|
|
||||||
QString getHashFromRow(unsigned int row) const;
|
|
||||||
QStringList getSelectedTorrents(bool only_one=false) const;
|
|
||||||
unsigned int getNbTorrentsInList() const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void unfinishedTorrentsNumberChanged(unsigned int);
|
|
||||||
void torrentDoubleClicked(QString hash, bool finished);
|
|
||||||
void torrentFinished(QString hash);
|
|
||||||
|
|
||||||
protected slots:
|
|
||||||
void addLogPeerBlocked(QString);
|
|
||||||
void addFastResumeRejectedAlert(QString);
|
|
||||||
void addUrlSeedError(QString url, QString msg);
|
|
||||||
void on_actionSet_download_limit_triggered();
|
|
||||||
void notifyTorrentDoubleClicked(const QModelIndex& index);
|
|
||||||
void on_actionSet_upload_limit_triggered();
|
|
||||||
void displayDLListMenu(const QPoint& pos);
|
|
||||||
void displayDLHoSMenu(const QPoint&);
|
|
||||||
void on_actionClearLog_triggered();
|
|
||||||
void displayInfoBarMenu(const QPoint& pos);
|
|
||||||
void addTorrent(QString hash);
|
|
||||||
void sortDownloadList(int index, Qt::SortOrder startSortOrder=Qt::AscendingOrder, bool fromLoadColWidth=false);
|
|
||||||
void sortDownloadListFloat(int index, Qt::SortOrder sortOrder);
|
|
||||||
void sortDownloadListString(int index, Qt::SortOrder sortOrder);
|
|
||||||
void saveColWidthDLList() const;
|
|
||||||
void torrentAdded(QString path, QTorrentHandle& h, bool fastResume);
|
|
||||||
void torrentDuplicate(QString path);
|
|
||||||
void torrentCorrupted(QString path);
|
|
||||||
void portListeningFailure();
|
|
||||||
void setRowColor(int row, QColor color);
|
|
||||||
void displayDownloadingUrlInfos(QString url);
|
|
||||||
void showProperties(const QModelIndex &index);
|
|
||||||
void hideOrShowColumnName();
|
|
||||||
void hideOrShowColumnSize();
|
|
||||||
void hideOrShowColumnProgress();
|
|
||||||
void hideOrShowColumnDownSpeed();
|
|
||||||
void hideOrShowColumnUpSpeed();
|
|
||||||
void hideOrShowColumnSeedersLeechers();
|
|
||||||
void hideOrShowColumnRatio();
|
|
||||||
void hideOrShowColumnEta();
|
|
||||||
void displayUPnPError(QString msg);
|
|
||||||
void displayUPnPSuccess(QString msg);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void updateDlList();
|
|
||||||
void setInfoBar(QString info, QColor color=QApplication::palette().color(QPalette::WindowText));
|
|
||||||
void pauseTorrent(QString hash);
|
|
||||||
void resumeTorrent(QString hash);
|
|
||||||
void deleteTorrent(QString hash);
|
|
||||||
void setBottomTabEnabled(unsigned int index, bool b);
|
|
||||||
void propertiesSelection();
|
|
||||||
void sortProgressColumnDelayed();
|
|
||||||
void updateFileSizeAndProgress(QString hash);
|
|
||||||
void showPropertiesFromHash(QString hash);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
<ui version="4.0" >
|
|
||||||
<class>engineSelect</class>
|
|
||||||
<widget class="QDialog" name="engineSelect" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>541</width>
|
|
||||||
<height>254</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="acceptDrops" >
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle" >
|
|
||||||
<string>Search plugins</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" >
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lbl_engines" >
|
|
||||||
<property name="font" >
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
<underline>true</underline>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Installed search engines:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeWidget" name="pluginsTree" >
|
|
||||||
<property name="contextMenuPolicy" >
|
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
|
||||||
</property>
|
|
||||||
<property name="selectionMode" >
|
|
||||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
|
||||||
</property>
|
|
||||||
<property name="uniformRowHeights" >
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="itemsExpandable" >
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<column>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Name</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Url</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Enabled</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="getNewEngine_lbl" >
|
|
||||||
<property name="font" >
|
|
||||||
<font>
|
|
||||||
<italic>true</italic>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>You can get new search engine plugins here: <a href="http:plugins.qbittorrent.org">http://plugins.qbittorrent.org</a></string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="installButton" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Install a new one</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="updateButton" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Check for updates</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="closeButton" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Close</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
<action name="actionEnable" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Enable</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionDisable" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Disable</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionUninstall" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Uninstall</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@@ -1,703 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* Contact : chris@qbittorrent.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "engineSelectDlg.h"
|
|
||||||
#include "downloadThread.h"
|
|
||||||
#include "misc.h"
|
|
||||||
#include "pluginSource.h"
|
|
||||||
#include <QProcess>
|
|
||||||
#include <QHeaderView>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QMenu>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QDropEvent>
|
|
||||||
#include <QInputDialog>
|
|
||||||
|
|
||||||
#ifdef HAVE_MAGICK
|
|
||||||
#include <Magick++.h>
|
|
||||||
using namespace Magick;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_ZZIP
|
|
||||||
#include <zzip/zzip.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ENGINE_NAME 0
|
|
||||||
#define ENGINE_URL 1
|
|
||||||
#define ENGINE_STATE 2
|
|
||||||
#define ENGINE_ID 3
|
|
||||||
|
|
||||||
engineSelectDlg::engineSelectDlg(QWidget *parent) : QDialog(parent) {
|
|
||||||
setupUi(this);
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
pluginsTree->header()->resizeSection(0, 170);
|
|
||||||
pluginsTree->header()->resizeSection(1, 220);
|
|
||||||
pluginsTree->hideColumn(ENGINE_ID);
|
|
||||||
actionEnable->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
|
|
||||||
actionDisable->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png")));
|
|
||||||
actionUninstall->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/remove.png")));
|
|
||||||
connect(actionEnable, SIGNAL(triggered()), this, SLOT(enableSelection()));
|
|
||||||
connect(actionDisable, SIGNAL(triggered()), this, SLOT(disableSelection()));
|
|
||||||
connect(pluginsTree, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayContextMenu(const QPoint&)));
|
|
||||||
downloader = new downloadThread(this);
|
|
||||||
connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
|
|
||||||
connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString)));
|
|
||||||
loadSupportedSearchEngines(true);
|
|
||||||
connect(pluginsTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(toggleEngineState(QTreeWidgetItem*, int)));
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
|
|
||||||
engineSelectDlg::~engineSelectDlg() {
|
|
||||||
qDebug("Destroying engineSelectDlg");
|
|
||||||
saveSettings();
|
|
||||||
emit enginesChanged();
|
|
||||||
qDebug("Before deleting downloader");
|
|
||||||
delete downloader;
|
|
||||||
qDebug("Engine plugins dialog destroyed");
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::dropEvent(QDropEvent *event) {
|
|
||||||
event->acceptProposedAction();
|
|
||||||
QStringList files=event->mimeData()->text().split(QString::fromUtf8("\n"));
|
|
||||||
QString file;
|
|
||||||
foreach(file, files) {
|
|
||||||
qDebug("dropped %s", file.toUtf8().data());
|
|
||||||
file = file.replace("file://", "");
|
|
||||||
if(file.startsWith("http://", Qt::CaseInsensitive) || file.startsWith("https://", Qt::CaseInsensitive) || file.startsWith("ftp://", Qt::CaseInsensitive)) {
|
|
||||||
downloader->downloadUrl(file);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(file.endsWith(".py", Qt::CaseInsensitive)) {
|
|
||||||
QString plugin_name = file.split(QDir::separator()).last();
|
|
||||||
plugin_name.replace(".py", "");
|
|
||||||
installPlugin(file, plugin_name);
|
|
||||||
}
|
|
||||||
#ifdef HAVE_ZZIP
|
|
||||||
if(file.endsWith(".zip", Qt::CaseInsensitive)) {
|
|
||||||
installZipPlugin(file);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode if we accept drag 'n drop or not
|
|
||||||
void engineSelectDlg::dragEnterEvent(QDragEnterEvent *event) {
|
|
||||||
QString mime;
|
|
||||||
foreach(mime, event->mimeData()->formats()){
|
|
||||||
qDebug("mimeData: %s", mime.toUtf8().data());
|
|
||||||
}
|
|
||||||
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) {
|
|
||||||
event->acceptProposedAction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::saveSettings() {
|
|
||||||
qDebug("Saving engines settings");
|
|
||||||
QStringList known_engines;
|
|
||||||
QVariantList known_enginesEnabled;
|
|
||||||
QString engine;
|
|
||||||
foreach(engine, installed_engines.keys()) {
|
|
||||||
known_engines << engine;
|
|
||||||
known_enginesEnabled << QVariant(installed_engines.value(engine, true));
|
|
||||||
qDebug("Engine %s has state: %d", engine.toUtf8().data(), installed_engines.value(engine, true));
|
|
||||||
}
|
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
|
||||||
settings.setValue(QString::fromUtf8("SearchEngines/knownEngines"), known_engines);
|
|
||||||
settings.setValue(QString::fromUtf8("SearchEngines/knownEnginesEnabled"), known_enginesEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::on_updateButton_clicked() {
|
|
||||||
// Download version file from primary server
|
|
||||||
downloader->downloadUrl("http://www.dchris.eu/search_engine/versions.txt");
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::toggleEngineState(QTreeWidgetItem *item, int) {
|
|
||||||
int index = pluginsTree->indexOfTopLevelItem(item);
|
|
||||||
QString id = item->text(ENGINE_ID);
|
|
||||||
bool new_val = !installed_engines.value(id, true);
|
|
||||||
installed_engines[id] = new_val;
|
|
||||||
QString enabledTxt;
|
|
||||||
if(new_val){
|
|
||||||
enabledTxt = tr("True");
|
|
||||||
setRowColor(index, "green");
|
|
||||||
}else{
|
|
||||||
enabledTxt = tr("False");
|
|
||||||
setRowColor(index, "red");
|
|
||||||
}
|
|
||||||
item->setText(ENGINE_STATE, enabledTxt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::displayContextMenu(const QPoint& pos) {
|
|
||||||
QMenu myContextMenu(this);
|
|
||||||
QModelIndex index;
|
|
||||||
// Enable/disable pause/start action given the DL state
|
|
||||||
QList<QTreeWidgetItem *> items = pluginsTree->selectedItems();
|
|
||||||
bool has_enable = false, has_disable = false;
|
|
||||||
QTreeWidgetItem *item;
|
|
||||||
foreach(item, items) {
|
|
||||||
QString id = item->text(ENGINE_ID);
|
|
||||||
if(installed_engines.value(id, true) and !has_disable) {
|
|
||||||
myContextMenu.addAction(actionDisable);
|
|
||||||
has_disable = true;
|
|
||||||
}
|
|
||||||
if(!installed_engines.value(id, true) and !has_enable) {
|
|
||||||
myContextMenu.addAction(actionEnable);
|
|
||||||
has_enable = true;
|
|
||||||
}
|
|
||||||
if(has_enable && has_disable) break;
|
|
||||||
}
|
|
||||||
myContextMenu.addSeparator();
|
|
||||||
myContextMenu.addAction(actionUninstall);
|
|
||||||
myContextMenu.exec(mapToGlobal(pos)+QPoint(12, 58));
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::on_closeButton_clicked() {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::on_actionUninstall_triggered() {
|
|
||||||
QList<QTreeWidgetItem *> items = pluginsTree->selectedItems();
|
|
||||||
QTreeWidgetItem *item;
|
|
||||||
bool change = false;
|
|
||||||
bool error = false;
|
|
||||||
foreach(item, items) {
|
|
||||||
int index = pluginsTree->indexOfTopLevelItem(item);
|
|
||||||
Q_ASSERT(index != -1);
|
|
||||||
QString id = item->text(ENGINE_ID);
|
|
||||||
if(QFile::exists(":/search_engine/engines/"+id+".py")) {
|
|
||||||
error = true;
|
|
||||||
// Disable it instead
|
|
||||||
installed_engines.insert(id, false);
|
|
||||||
item->setText(ENGINE_STATE, tr("False"));
|
|
||||||
setRowColor(index, "red");
|
|
||||||
continue;
|
|
||||||
}else {
|
|
||||||
// Proceed with uninstall
|
|
||||||
// remove it from hard drive
|
|
||||||
QDir enginesFolder(misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines");
|
|
||||||
QStringList filters;
|
|
||||||
filters << id+".*";
|
|
||||||
QStringList files = enginesFolder.entryList(filters, QDir::Files, QDir::Unsorted);
|
|
||||||
QString file;
|
|
||||||
foreach(file, files) {
|
|
||||||
enginesFolder.remove(file);
|
|
||||||
}
|
|
||||||
// Remove it from lists
|
|
||||||
installed_engines.remove(id);
|
|
||||||
delete item;
|
|
||||||
change = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(error)
|
|
||||||
QMessageBox::warning(0, tr("Uninstall warning"), tr("Some plugins could not be uninstalled because they are included in qBittorrent.\n Only the ones you added yourself can be uninstalled.\nHowever, those plugins were disabled."));
|
|
||||||
else
|
|
||||||
QMessageBox::information(0, tr("Uninstall success"), tr("All selected plugins were uninstalled successfully"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::enableSelection() {
|
|
||||||
QList<QTreeWidgetItem *> items = pluginsTree->selectedItems();
|
|
||||||
QTreeWidgetItem *item;
|
|
||||||
foreach(item, items) {
|
|
||||||
int index = pluginsTree->indexOfTopLevelItem(item);
|
|
||||||
Q_ASSERT(index != -1);
|
|
||||||
QString id = item->text(ENGINE_ID);
|
|
||||||
installed_engines.insert(id, true);
|
|
||||||
item->setText(ENGINE_STATE, tr("True"));
|
|
||||||
setRowColor(index, "green");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::disableSelection() {
|
|
||||||
QList<QTreeWidgetItem *> items = pluginsTree->selectedItems();
|
|
||||||
QTreeWidgetItem *item;
|
|
||||||
foreach(item, items) {
|
|
||||||
int index = pluginsTree->indexOfTopLevelItem(item);
|
|
||||||
Q_ASSERT(index != -1);
|
|
||||||
QString id = item->text(ENGINE_ID);
|
|
||||||
installed_engines.insert(id, false);
|
|
||||||
item->setText(ENGINE_STATE, tr("False"));
|
|
||||||
setRowColor(index, "red");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the color of a row in data model
|
|
||||||
void engineSelectDlg::setRowColor(int row, QString color){
|
|
||||||
QTreeWidgetItem *item = pluginsTree->topLevelItem(row);
|
|
||||||
for(int i=0; i<pluginsTree->columnCount()-1; ++i){
|
|
||||||
item->setData(i, Qt::ForegroundRole, QVariant(QColor(color)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool engineSelectDlg::checkInstalled(QString plugin_name) const {
|
|
||||||
QProcess nova;
|
|
||||||
QStringList params;
|
|
||||||
params << misc::qBittorrentPath()+"search_engine"+QDir::separator()+"nova2.py";
|
|
||||||
params << "--supported_engines";
|
|
||||||
nova.start("python", params, QIODevice::ReadOnly);
|
|
||||||
nova.waitForStarted();
|
|
||||||
nova.waitForFinished();
|
|
||||||
QByteArray result = nova.readAll();
|
|
||||||
result = result.replace("\r", "");
|
|
||||||
result = result.replace("\n", "");
|
|
||||||
QList<QByteArray> plugins_list = result.split(',');
|
|
||||||
return plugins_list.contains(plugin_name.toUtf8());
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::loadSupportedSearchEngines(bool first) {
|
|
||||||
// Some clean up first
|
|
||||||
pluginsTree->clear();
|
|
||||||
QHash<QString, bool> old_engines;
|
|
||||||
if(first) {
|
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
|
||||||
QStringList known_engines = settings.value(QString::fromUtf8("SearchEngines/knownEngines"), QStringList()).toStringList();
|
|
||||||
QVariantList enabled = settings.value(QString::fromUtf8("SearchEngines/knownEnginesEnabled"), QList<QVariant>()).toList();
|
|
||||||
Q_ASSERT(known_engines.size() == enabled.size());
|
|
||||||
unsigned int nbKnownEngines = known_engines.size();
|
|
||||||
for(unsigned int i=0; i<nbKnownEngines; ++i) {
|
|
||||||
old_engines[known_engines.at(i)] = enabled.at(i).toBool();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
old_engines = installed_engines;
|
|
||||||
}
|
|
||||||
installed_engines.clear();
|
|
||||||
QStringList params;
|
|
||||||
// Ask nova core for the supported search engines
|
|
||||||
QProcess nova;
|
|
||||||
params << misc::qBittorrentPath()+"search_engine"+QDir::separator()+"nova2.py";
|
|
||||||
params << "--supported_engines";
|
|
||||||
nova.start("python", params, QIODevice::ReadOnly);
|
|
||||||
nova.waitForStarted();
|
|
||||||
nova.waitForFinished();
|
|
||||||
QByteArray result = nova.readAll();
|
|
||||||
result = result.replace("\r", "");
|
|
||||||
result = result.replace("\n", "");
|
|
||||||
qDebug("read: %s", result.data());
|
|
||||||
QByteArray e;
|
|
||||||
QStringList supported_engines_ids;
|
|
||||||
foreach(e, result.split(',')) {
|
|
||||||
QString en = QString(e);
|
|
||||||
supported_engines_ids << en;
|
|
||||||
installed_engines[en] = old_engines.value(en, true);
|
|
||||||
}
|
|
||||||
params.clear();
|
|
||||||
params << misc::qBittorrentPath()+"search_engine"+QDir::separator()+"nova2.py";
|
|
||||||
params << "--supported_engines_infos";
|
|
||||||
nova.start("python", params, QIODevice::ReadOnly);
|
|
||||||
nova.waitForStarted();
|
|
||||||
nova.waitForFinished();
|
|
||||||
result = nova.readAll();
|
|
||||||
result = result.replace("\r", "");
|
|
||||||
result = result.replace("\n", "");
|
|
||||||
qDebug("read: %s", result.data());
|
|
||||||
unsigned int i = 0;
|
|
||||||
foreach(e, result.split(',')) {
|
|
||||||
QString id = supported_engines_ids.at(i);
|
|
||||||
QString nameUrlCouple(e);
|
|
||||||
QStringList line = nameUrlCouple.split('|');
|
|
||||||
if(line.size() != 2) continue;
|
|
||||||
QString enabledTxt;
|
|
||||||
if(installed_engines.value(id, true)) {
|
|
||||||
enabledTxt = tr("True");
|
|
||||||
} else {
|
|
||||||
enabledTxt = tr("False");
|
|
||||||
}
|
|
||||||
line << enabledTxt;
|
|
||||||
line << id;
|
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem(pluginsTree, line);
|
|
||||||
QString iconPath = misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator()+id+".png";
|
|
||||||
if(QFile::exists(iconPath)) {
|
|
||||||
// Good, we already have the icon
|
|
||||||
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
|
||||||
} else {
|
|
||||||
// Icon is missing, we must download it
|
|
||||||
downloader->downloadUrl(line.at(1)+"/favicon.ico");
|
|
||||||
}
|
|
||||||
if(installed_engines.value(id, true))
|
|
||||||
setRowColor(i, "green");
|
|
||||||
else
|
|
||||||
setRowColor(i, "red");
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QTreeWidgetItem*> engineSelectDlg::findItemsWithUrl(QString url){
|
|
||||||
QList<QTreeWidgetItem*> res;
|
|
||||||
for(int i=0; i<pluginsTree->topLevelItemCount(); ++i) {
|
|
||||||
QTreeWidgetItem *item = pluginsTree->topLevelItem(i);
|
|
||||||
if(url.startsWith(item->text(ENGINE_URL), Qt::CaseInsensitive))
|
|
||||||
res << item;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id){
|
|
||||||
QList<QTreeWidgetItem*> res;
|
|
||||||
for(int i=0; i<pluginsTree->topLevelItemCount(); ++i) {
|
|
||||||
QTreeWidgetItem *item = pluginsTree->topLevelItem(i);
|
|
||||||
if(id == item->text(ENGINE_ID))
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool engineSelectDlg::isUpdateNeeded(QString plugin_name, float new_version) const {
|
|
||||||
float old_version = misc::getPluginVersion(misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py");
|
|
||||||
qDebug("IsUpdate needed? tobeinstalled: %.2f, alreadyinstalled: %.2f", new_version, old_version);
|
|
||||||
return (new_version > old_version);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_ZZIP
|
|
||||||
void engineSelectDlg::installZipPlugin(QString path) {
|
|
||||||
QStringList plugins;
|
|
||||||
QStringList favicons;
|
|
||||||
ZZIP_DIR* dir = zzip_dir_open(path.toUtf8().data(), 0);
|
|
||||||
if(!dir) {
|
|
||||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("Search engine plugin archive could not be read."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ZZIP_DIRENT dirent;
|
|
||||||
while(zzip_dir_read(dir, &dirent)) {
|
|
||||||
/* show info for first file */
|
|
||||||
QString name(dirent.d_name);
|
|
||||||
if(name.endsWith(".py", Qt::CaseInsensitive)) {
|
|
||||||
plugins << name;
|
|
||||||
} else {
|
|
||||||
if(name.endsWith(".png", Qt::CaseInsensitive)) {
|
|
||||||
favicons << name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString plugin;
|
|
||||||
std::cout << dirent.d_name << std::endl;
|
|
||||||
ZZIP_FILE* fp = zzip_file_open(dir, dirent.d_name, 0);
|
|
||||||
if (fp) {
|
|
||||||
char buf[10];
|
|
||||||
zzip_ssize_t len = zzip_file_read(fp, buf, 10);
|
|
||||||
if (len) {
|
|
||||||
/* show head of README */
|
|
||||||
std::cout << buf;
|
|
||||||
}
|
|
||||||
zzip_file_close(fp);
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
|
||||||
foreach(plugin, plugins) {
|
|
||||||
QString plugin_name = plugin.split(QDir::separator()).last();
|
|
||||||
plugin_name.chop(3); // Remove .py extension
|
|
||||||
qDebug("Detected plugin %s in archive", plugin_name.toUtf8().data());
|
|
||||||
ZZIP_FILE* fp = zzip_file_open(dir, plugin.toUtf8().data(), 0);
|
|
||||||
if(fp) {
|
|
||||||
QTemporaryFile *tmpfile = new QTemporaryFile();
|
|
||||||
QString tmpPath;
|
|
||||||
// Write file
|
|
||||||
if(tmpfile->open()) {
|
|
||||||
tmpPath = tmpfile->fileName();
|
|
||||||
char buf[255];
|
|
||||||
zzip_ssize_t len = zzip_file_read(fp, buf, 255);
|
|
||||||
while(len) {
|
|
||||||
tmpfile->write(buf, len);
|
|
||||||
len = zzip_file_read(fp, buf, 255);
|
|
||||||
}
|
|
||||||
zzip_file_close(fp);
|
|
||||||
tmpfile->close();
|
|
||||||
} else {
|
|
||||||
qDebug("Could not open tmp file");
|
|
||||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
|
||||||
delete tmpfile;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Install plugin
|
|
||||||
installPlugin(tmpPath, plugin_name);
|
|
||||||
qDebug("installPlugin() finished");
|
|
||||||
delete tmpfile;
|
|
||||||
qDebug("Deleted tmpfile");
|
|
||||||
} else {
|
|
||||||
qDebug("Cannot read file in archive");
|
|
||||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString favicon;
|
|
||||||
foreach(favicon, favicons) {
|
|
||||||
qDebug("Detected favicon %s in archive", favicon.toUtf8().data());
|
|
||||||
// Ok we have a favicon here
|
|
||||||
QString plugin_name = favicon.split(QDir::separator()).last();
|
|
||||||
plugin_name.chop(4); // Remove .png extension
|
|
||||||
if(!QFile::exists(misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py"))
|
|
||||||
continue;
|
|
||||||
// Check if we already have a favicon for this plugin
|
|
||||||
QString iconPath = misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator()+plugin_name+".png";
|
|
||||||
if(QFile::exists(iconPath)) continue;
|
|
||||||
ZZIP_FILE* fp = zzip_file_open(dir, favicon.toUtf8().data(), 0);
|
|
||||||
if(fp) {
|
|
||||||
QFile dest_icon(iconPath);
|
|
||||||
// Write icon
|
|
||||||
if(dest_icon.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
||||||
char buf[255];
|
|
||||||
zzip_ssize_t len = zzip_file_read(fp, buf, 255);
|
|
||||||
while(len) {
|
|
||||||
dest_icon.write(buf, len);
|
|
||||||
len = zzip_file_read(fp, buf, 255);
|
|
||||||
}
|
|
||||||
zzip_file_close(fp);
|
|
||||||
dest_icon.close();
|
|
||||||
// Update icon in list
|
|
||||||
QTreeWidgetItem *item = findItemWithID(plugin_name);
|
|
||||||
Q_ASSERT(item);
|
|
||||||
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zzip_dir_close(dir);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
|
|
||||||
qDebug("Asked to install plugin at %s", path.toUtf8().data());
|
|
||||||
float new_version = misc::getPluginVersion(path);
|
|
||||||
qDebug("Version to be installed: %.2f", new_version);
|
|
||||||
if(!isUpdateNeeded(plugin_name, new_version)) {
|
|
||||||
qDebug("Apparently update it not needed, we have a more recent version");
|
|
||||||
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("A more recent version of %1 search engine plugin is already installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Process with install
|
|
||||||
QString dest_path = misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py";
|
|
||||||
bool update = false;
|
|
||||||
if(QFile::exists(dest_path)) {
|
|
||||||
// Backup in case install fails
|
|
||||||
QFile::copy(dest_path, dest_path+".bak");
|
|
||||||
QFile::remove(dest_path);
|
|
||||||
update = true;
|
|
||||||
}
|
|
||||||
// Copy the plugin
|
|
||||||
QFile::copy(path, dest_path);
|
|
||||||
// Check if this was correctly installed
|
|
||||||
if(!checkInstalled(plugin_name)) {
|
|
||||||
if(update) {
|
|
||||||
// Remove broken file
|
|
||||||
QFile::remove(dest_path);
|
|
||||||
// restore backup
|
|
||||||
QFile::copy(dest_path+".bak", dest_path);
|
|
||||||
QFile::remove(dest_path+".bak");
|
|
||||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be updated, keeping old version.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
// Remove broken file
|
|
||||||
QFile::remove(dest_path);
|
|
||||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Install was successful, remove backup
|
|
||||||
if(update) {
|
|
||||||
QFile::remove(dest_path+".bak");
|
|
||||||
}
|
|
||||||
// Refresh plugin list
|
|
||||||
loadSupportedSearchEngines();
|
|
||||||
if(update) {
|
|
||||||
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::on_installButton_clicked() {
|
|
||||||
pluginSourceDlg *dlg = new pluginSourceDlg(this);
|
|
||||||
connect(dlg, SIGNAL(askForLocalFile()), this, SLOT(askForLocalPlugin()));
|
|
||||||
connect(dlg, SIGNAL(askForUrl()), this, SLOT(askForPluginUrl()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::askForPluginUrl() {
|
|
||||||
bool ok;
|
|
||||||
QString url = QInputDialog::getText(this, tr("New search engine plugin URL"),
|
|
||||||
tr("URL:"), QLineEdit::Normal,
|
|
||||||
"http://", &ok);
|
|
||||||
if (ok && !url.isEmpty())
|
|
||||||
downloader->downloadUrl(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::askForLocalPlugin() {
|
|
||||||
QStringList pathsList = QFileDialog::getOpenFileNames(0,
|
|
||||||
tr("Select search plugins"), QDir::homePath(),
|
|
||||||
#ifdef HAVE_ZZIP
|
|
||||||
tr("qBittorrent search plugins")+QString::fromUtf8(" (*.py *.zip)"));
|
|
||||||
#else
|
|
||||||
tr("qBittorrent search plugins")+QString::fromUtf8(" (*.py)"));
|
|
||||||
#endif
|
|
||||||
QString path;
|
|
||||||
foreach(path, pathsList) {
|
|
||||||
if(path.endsWith(".py", Qt::CaseInsensitive)) {
|
|
||||||
QString plugin_name = path.split(QDir::separator()).last();
|
|
||||||
plugin_name.replace(".py", "", Qt::CaseInsensitive);
|
|
||||||
installPlugin(path, plugin_name);
|
|
||||||
}
|
|
||||||
#ifdef HAVE_ZZIP
|
|
||||||
else {
|
|
||||||
if(path.endsWith(".zip", Qt::CaseInsensitive)) {
|
|
||||||
installZipPlugin(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool engineSelectDlg::parseVersionsFile(QString versions_file, QString updateServer) {
|
|
||||||
qDebug("Checking if update is needed");
|
|
||||||
bool file_correct = false;
|
|
||||||
QFile versions(versions_file);
|
|
||||||
if(!versions.open(QIODevice::ReadOnly | QIODevice::Text)){
|
|
||||||
qDebug("* Error: Could not read versions.txt file");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool updated = false;
|
|
||||||
while(!versions.atEnd()) {
|
|
||||||
QByteArray line = versions.readLine();
|
|
||||||
line.replace("\n", "");
|
|
||||||
line = line.trimmed();
|
|
||||||
if(line.isEmpty()) continue;
|
|
||||||
if(line.startsWith("#")) continue;
|
|
||||||
QList<QByteArray> list = line.split(' ');
|
|
||||||
if(list.size() != 2) continue;
|
|
||||||
QString plugin_name = QString(list.first());
|
|
||||||
if(!plugin_name.endsWith(":")) continue;
|
|
||||||
plugin_name.chop(1); // remove trailing ':'
|
|
||||||
bool ok;
|
|
||||||
float version = list.last().toFloat(&ok);
|
|
||||||
qDebug("read line %s: %.2f", plugin_name.toUtf8().data(), version);
|
|
||||||
if(!ok) continue;
|
|
||||||
file_correct = true;
|
|
||||||
if(isUpdateNeeded(plugin_name, version)) {
|
|
||||||
qDebug("Plugin: %s is outdated", plugin_name.toUtf8().data());
|
|
||||||
// Downloading update
|
|
||||||
downloader->downloadUrl(updateServer+plugin_name+".pyqBT"); // Actually this is really a .py
|
|
||||||
downloader->downloadUrl(updateServer+plugin_name+".png");
|
|
||||||
updated = true;
|
|
||||||
}else {
|
|
||||||
qDebug("Plugin: %s is up to date", plugin_name.toUtf8().data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Close file
|
|
||||||
versions.close();
|
|
||||||
// Clean up tmp file
|
|
||||||
QFile::remove(versions_file);
|
|
||||||
if(file_correct && !updated) {
|
|
||||||
QMessageBox::information(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("All your plugins are already up to date."));
|
|
||||||
}
|
|
||||||
return file_correct;
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
|
||||||
qDebug("engineSelectDlg received %s", url.toUtf8().data());
|
|
||||||
if(url.endsWith("favicon.ico", Qt::CaseInsensitive)){
|
|
||||||
// Icon downloaded
|
|
||||||
QImage fileIcon;
|
|
||||||
#ifdef HAVE_MAGICK
|
|
||||||
try{
|
|
||||||
QFile::copy(filePath, filePath+".ico");
|
|
||||||
Image image(QDir::cleanPath(filePath+".ico").toUtf8().data());
|
|
||||||
// Convert to PNG since we can't read ICO format
|
|
||||||
image.magick("PNG");
|
|
||||||
// Resize to 16x16px
|
|
||||||
image.sample(Geometry(16, 16));
|
|
||||||
image.write(filePath.toUtf8().data());
|
|
||||||
QFile::remove(filePath+".ico");
|
|
||||||
}catch(Magick::Exception &error_){
|
|
||||||
qDebug("favicon conversion to PNG failure: %s", error_.what());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if(fileIcon.load(filePath)) {
|
|
||||||
QList<QTreeWidgetItem*> items = findItemsWithUrl(url);
|
|
||||||
QTreeWidgetItem *item;
|
|
||||||
foreach(item, items){
|
|
||||||
QString id = item->text(ENGINE_ID);
|
|
||||||
QString iconPath = misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator()+id+".png";
|
|
||||||
QFile::copy(filePath, iconPath);
|
|
||||||
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Delete tmp file
|
|
||||||
QFile::remove(filePath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(url == "http://www.dchris.eu/search_engine/versions.txt") {
|
|
||||||
if(!parseVersionsFile(filePath, "http://www.dchris.eu/search_engine/")) {
|
|
||||||
qDebug("Primary update server failed, try secondary");
|
|
||||||
downloader->downloadUrl("http://hydr0g3n.free.fr/search_engine/versions.txt");
|
|
||||||
}
|
|
||||||
QFile::remove(filePath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(url == "http://hydr0g3n.free.fr/search_engine/versions.txt") {
|
|
||||||
if(!parseVersionsFile(filePath, "http://hydr0g3n.free.fr/search_engine/")) {
|
|
||||||
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, update server is temporarily unavailable."));
|
|
||||||
}
|
|
||||||
QFile::remove(filePath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(url.endsWith(".pyqBT", Qt::CaseInsensitive) || url.endsWith(".py", Qt::CaseInsensitive)) {
|
|
||||||
QString plugin_name = url.split('/').last();
|
|
||||||
plugin_name.replace(".pyqBT", "");
|
|
||||||
plugin_name.replace(".py", "");
|
|
||||||
installPlugin(filePath, plugin_name);
|
|
||||||
QFile::remove(filePath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#ifdef HAVE_ZZIP
|
|
||||||
if(url.endsWith(".zip", Qt::CaseInsensitive)) {
|
|
||||||
installZipPlugin(filePath);
|
|
||||||
QFile::remove(filePath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
|
|
||||||
if(url.endsWith("favicon.ico", Qt::CaseInsensitive)){
|
|
||||||
qDebug("Could not download favicon: %s, reason: %s", url.toUtf8().data(), reason.toUtf8().data());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(url == "http://www.dchris.eu/search_engine/versions.txt") {
|
|
||||||
// Primary update server failed, try secondary
|
|
||||||
qDebug("Primary update server failed, try secondary");
|
|
||||||
downloader->downloadUrl("http://hydr0g3n.free.fr/search_engine/versions.txt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(url == "http://hydr0g3n.free.fr/search_engine/versions.txt") {
|
|
||||||
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, update server is temporarily unavailable."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(url.endsWith(".pyqBT", Qt::CaseInsensitive) || url.endsWith(".py", Qt::CaseInsensitive)) {
|
|
||||||
// a plugin update download has been failed
|
|
||||||
QString plugin_name = url.split('/').last();
|
|
||||||
plugin_name.replace(".pyqBT", "", Qt::CaseInsensitive);
|
|
||||||
plugin_name.replace(".py", "", Qt::CaseInsensitive);
|
|
||||||
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin install failed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
|
||||||
}
|
|
||||||
#ifdef HAVE_ZZIP
|
|
||||||
if(url.endsWith(".zip", Qt::CaseInsensitive)) {
|
|
||||||
QString plugin_name = url.split('/').last();
|
|
||||||
plugin_name.replace(".zip", "", Qt::CaseInsensitive);
|
|
||||||
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin install failed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* Contact : chris@qbittorrent.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ENGINE_SELECT_DLG_H
|
|
||||||
#define ENGINE_SELECT_DLG_H
|
|
||||||
|
|
||||||
#include "ui_engineSelect.h"
|
|
||||||
|
|
||||||
class downloadThread;
|
|
||||||
class QDropEvent;
|
|
||||||
|
|
||||||
class engineSelectDlg : public QDialog, public Ui::engineSelect{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Search related
|
|
||||||
QHash<QString, bool> installed_engines;
|
|
||||||
downloadThread *downloader;
|
|
||||||
|
|
||||||
public:
|
|
||||||
engineSelectDlg(QWidget *parent);
|
|
||||||
~engineSelectDlg();
|
|
||||||
QList<QTreeWidgetItem*> findItemsWithUrl(QString url);
|
|
||||||
QTreeWidgetItem* findItemWithID(QString id);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool parseVersionsFile(QString versions_file, QString updateServer);
|
|
||||||
bool isUpdateNeeded(QString plugin_name, float new_version) const;
|
|
||||||
bool checkInstalled(QString plugin_name) const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void enginesChanged();
|
|
||||||
|
|
||||||
protected slots:
|
|
||||||
void saveSettings();
|
|
||||||
void on_closeButton_clicked();
|
|
||||||
void loadSupportedSearchEngines(bool first=false);
|
|
||||||
void toggleEngineState(QTreeWidgetItem*, int);
|
|
||||||
void setRowColor(int row, QString color);
|
|
||||||
void processDownloadedFile(QString url, QString filePath);
|
|
||||||
void handleDownloadFailure(QString url, QString reason);
|
|
||||||
void displayContextMenu(const QPoint& pos);
|
|
||||||
void enableSelection();
|
|
||||||
void disableSelection();
|
|
||||||
void on_actionUninstall_triggered();
|
|
||||||
void on_updateButton_clicked();
|
|
||||||
void on_installButton_clicked();
|
|
||||||
void dropEvent(QDropEvent *event);
|
|
||||||
void dragEnterEvent(QDragEnterEvent *event);
|
|
||||||
void installPlugin(QString plugin_path, QString plugin_name);
|
|
||||||
void askForLocalPlugin();
|
|
||||||
void askForPluginUrl();
|
|
||||||
#ifdef HAVE_ZZIP
|
|
||||||
void installZipPlugin(QString path);
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,186 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 by Ishan Arora
|
|
||||||
* ishanarora@gmail.com
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "eventmanager.h"
|
|
||||||
#include "json.h"
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
EventManager::EventManager(QObject *parent)
|
|
||||||
: QObject(parent)
|
|
||||||
{
|
|
||||||
revision = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventManager::update(QVariantMap event)
|
|
||||||
{
|
|
||||||
revision++;
|
|
||||||
events << QPair<ulong, QVariantMap>(revision, event);
|
|
||||||
emit updated();
|
|
||||||
qDebug("Added the following event");
|
|
||||||
qDebug() << event;
|
|
||||||
/* QLinkedList<QPair<ulong, QVariantMap> >::iterator i;
|
|
||||||
for (i = events.begin(); i != events.end(); i++)
|
|
||||||
qDebug() << *i;*/
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant EventManager::querySince(ulong r) const
|
|
||||||
{
|
|
||||||
QVariantList list;
|
|
||||||
QLinkedListIterator<QPair<ulong, QVariantMap> > i(events);
|
|
||||||
i.toBack();
|
|
||||||
while (i.hasPrevious())
|
|
||||||
{
|
|
||||||
QPair<ulong, QVariantMap> pair = i.previous();
|
|
||||||
if (pair.first <= r)
|
|
||||||
break;
|
|
||||||
list.prepend(QVariant(pair.second));
|
|
||||||
}
|
|
||||||
QVariantMap map;
|
|
||||||
map["events"] = QVariant(list);
|
|
||||||
map["revision"] = QVariant((qulonglong) revision);
|
|
||||||
return QVariant(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EventManager::isUpdated(ulong r) const
|
|
||||||
{
|
|
||||||
return (r < revision);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventManager::addedTorrent(QString, QTorrentHandle& h)
|
|
||||||
{
|
|
||||||
QVariantMap event;
|
|
||||||
event["type"] = QVariant("add");
|
|
||||||
event["hash"] = QVariant(h.hash());
|
|
||||||
event["name"] = QVariant(h.name());
|
|
||||||
update(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventManager::deletedTorrent(QString hash)
|
|
||||||
{
|
|
||||||
QVariantMap event;
|
|
||||||
event["type"] = QVariant("delete");
|
|
||||||
event["hash"] = QVariant(hash);
|
|
||||||
QLinkedList<QPair<ulong, QVariantMap> >::iterator i = events.end();
|
|
||||||
bool loop = true;
|
|
||||||
while (loop && i != events.begin()) {
|
|
||||||
--i;
|
|
||||||
QVariantMap oldevent = i->second;
|
|
||||||
if(oldevent["hash"] == QVariant(hash))
|
|
||||||
{
|
|
||||||
if(oldevent["type"] == QVariant("add"))
|
|
||||||
loop = false;
|
|
||||||
i = events.erase(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
update(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventManager::modifiedTorrent(QTorrentHandle h)
|
|
||||||
{
|
|
||||||
QString hash = h.hash();
|
|
||||||
QVariantMap event;
|
|
||||||
QVariant v;
|
|
||||||
|
|
||||||
if(h.is_paused())
|
|
||||||
v = QVariant("paused");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch(h.state())
|
|
||||||
{
|
|
||||||
case torrent_status::finished:
|
|
||||||
case torrent_status::seeding:
|
|
||||||
v = QVariant("seeding");
|
|
||||||
break;
|
|
||||||
case torrent_status::checking_files:
|
|
||||||
case torrent_status::queued_for_checking:
|
|
||||||
v = QVariant("checking");
|
|
||||||
break;
|
|
||||||
case torrent_status::connecting_to_tracker:
|
|
||||||
if(h.download_payload_rate() > 0)
|
|
||||||
v = QVariant("downloading");
|
|
||||||
else
|
|
||||||
v = QVariant("connecting");
|
|
||||||
break;
|
|
||||||
case torrent_status::downloading:
|
|
||||||
case torrent_status::downloading_metadata:
|
|
||||||
if(h.download_payload_rate() > 0)
|
|
||||||
v = QVariant("downloading");
|
|
||||||
else
|
|
||||||
v = QVariant("stalled");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
v = QVariant();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(modify(hash, "state", v))
|
|
||||||
event["state"] = v;
|
|
||||||
|
|
||||||
v = QVariant((qlonglong)h.actual_size());
|
|
||||||
if(modify(hash, "size", v))
|
|
||||||
event["size"] = v;
|
|
||||||
|
|
||||||
v = QVariant(h.progress());
|
|
||||||
if(modify(hash, "progress", v))
|
|
||||||
event["progress"] = v;
|
|
||||||
|
|
||||||
v = QVariant(h.download_payload_rate());
|
|
||||||
if(modify(hash, "dlspeed", v))
|
|
||||||
event["dlspeed"] = v;
|
|
||||||
|
|
||||||
v = QVariant(h.upload_payload_rate());
|
|
||||||
if(modify(hash, "upspeed", v))
|
|
||||||
event["upspeed"] = v;
|
|
||||||
|
|
||||||
if(event.size() > 0)
|
|
||||||
{
|
|
||||||
event["type"] = QVariant("modify");
|
|
||||||
event["hash"] = QVariant(hash);
|
|
||||||
update(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EventManager::modify(QString hash, QString key, QVariant value)
|
|
||||||
{
|
|
||||||
QLinkedList<QPair<ulong, QVariantMap> >::iterator i = events.end();
|
|
||||||
while (i != events.begin()) {
|
|
||||||
--i;
|
|
||||||
QVariantMap event = i->second;
|
|
||||||
if(event["hash"] == QVariant(hash))
|
|
||||||
{
|
|
||||||
if(event["type"] == QVariant("add"))
|
|
||||||
return true;
|
|
||||||
if(event.contains(key))
|
|
||||||
{
|
|
||||||
if(event[key] == value)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(event.size() <= 3)
|
|
||||||
i = events.erase(i);
|
|
||||||
else
|
|
||||||
i->second.remove(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 by Ishan Arora
|
|
||||||
* ishanarora@gmail.com
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef EVENTMANAGER_H
|
|
||||||
#define EVENTMANAGER_H
|
|
||||||
|
|
||||||
#include "qtorrenthandle.h"
|
|
||||||
#include <QLinkedList>
|
|
||||||
#include <QPair>
|
|
||||||
#include <QVariant>
|
|
||||||
|
|
||||||
class EventManager : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
private:
|
|
||||||
ulong revision;
|
|
||||||
QLinkedList<QPair <ulong, QVariantMap> > events;
|
|
||||||
bool modify(QString hash, QString key, QVariant value);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void update(QVariantMap event);
|
|
||||||
|
|
||||||
public:
|
|
||||||
EventManager(QObject *parent = 0);
|
|
||||||
QVariant querySince(ulong r) const;
|
|
||||||
bool isUpdated(ulong r) const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void updated();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void addedTorrent(QString path, QTorrentHandle& h);
|
|
||||||
void deletedTorrent(QString hash);
|
|
||||||
void modifiedTorrent(QTorrentHandle h);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,383 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* Contact : chris@qbittorrent.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FILTERPARSERTHREAD_H
|
|
||||||
#define FILTERPARSERTHREAD_H
|
|
||||||
|
|
||||||
#include <QThread>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QDataStream>
|
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
#include <libtorrent/session.hpp>
|
|
||||||
#include <libtorrent/ip_filter.hpp>
|
|
||||||
|
|
||||||
using namespace libtorrent;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
// P2B Stuff
|
|
||||||
#include <string.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
// End of P2B stuff
|
|
||||||
|
|
||||||
class FilterParserThread : public QThread {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
private:
|
|
||||||
session *s;
|
|
||||||
ip_filter filter;
|
|
||||||
bool abort;
|
|
||||||
QString filePath;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void run(){
|
|
||||||
qDebug("Processing filter file");
|
|
||||||
if(filePath.endsWith(".dat", Qt::CaseInsensitive)) {
|
|
||||||
// eMule DAT file
|
|
||||||
parseDATFilterFile(filePath);
|
|
||||||
} else {
|
|
||||||
if(filePath.endsWith(".p2p", Qt::CaseInsensitive)) {
|
|
||||||
// PeerGuardian p2p file
|
|
||||||
parseP2PFilterFile(filePath);
|
|
||||||
} else {
|
|
||||||
if(filePath.endsWith(".p2p", Qt::CaseInsensitive)) {
|
|
||||||
// PeerGuardian p2p file
|
|
||||||
parseP2BFilterFile(filePath);
|
|
||||||
} else {
|
|
||||||
// Default: eMule DAT format
|
|
||||||
parseDATFilterFile(filePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s->set_ip_filter(filter);
|
|
||||||
qDebug("IP Filter thread: finished parsing, filter applied");
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
FilterParserThread(QObject* parent, session *s) : QThread(parent), s(s), abort(false) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
~FilterParserThread(){
|
|
||||||
abort = true;
|
|
||||||
wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parser for eMule ip filter in DAT format
|
|
||||||
void parseDATFilterFile(QString filePath) {
|
|
||||||
const QRegExp is_ipv6(QString::fromUtf8("^[0-9a-f]{4}(:[0-9a-f]{4}){7}$"), Qt::CaseInsensitive, QRegExp::RegExp);
|
|
||||||
const QRegExp is_ipv4(QString::fromUtf8("^(([0-1]?[0-9]?[0-9])|(2[0-4][0-9])|(25[0-5]))(\\.(([0-1]?[0-9]?[0-9])|(2[0-4][0-9])|(25[0-5]))){3}$"), Qt::CaseInsensitive, QRegExp::RegExp);
|
|
||||||
QString strStartIP, strEndIP;
|
|
||||||
bool IPv4 = true;
|
|
||||||
QFile file(filePath);
|
|
||||||
if (file.exists()){
|
|
||||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
|
||||||
QMessageBox::critical(0, tr("I/O Error", "Input/Output Error"), tr("Couldn't open %1 in read mode.").arg(filePath));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
unsigned int nbLine = 0;
|
|
||||||
while (!file.atEnd() && !abort) {
|
|
||||||
++nbLine;
|
|
||||||
QByteArray line = file.readLine();
|
|
||||||
// Ignoring empty lines
|
|
||||||
line = line.trimmed();
|
|
||||||
if(line.isEmpty()) continue;
|
|
||||||
// Ignoring commented lines
|
|
||||||
if(line.startsWith('#') || line.startsWith("//")) continue;
|
|
||||||
// Line is not commented
|
|
||||||
QList<QByteArray> partsList = line.split(',');
|
|
||||||
unsigned int nbElem = partsList.size();
|
|
||||||
// IP Range can be splitted by a dash or a comma...
|
|
||||||
// Check if there is a dash in first part
|
|
||||||
QByteArray firstPart = partsList.at(0);
|
|
||||||
int nbAccess = 0;
|
|
||||||
if(firstPart.contains('-')) {
|
|
||||||
// Range is splitted by a dash
|
|
||||||
QList<QByteArray> IPs = firstPart.split('-');
|
|
||||||
if(IPs.size() != 2) {
|
|
||||||
qDebug("Ipfilter.dat: line %d is malformed.", nbLine);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
strStartIP = IPs.at(0).trimmed();
|
|
||||||
strEndIP = IPs.at(1).trimmed();
|
|
||||||
// Check if IPs are correct
|
|
||||||
if(strStartIP.contains(is_ipv4) && strEndIP.contains(is_ipv4)) {
|
|
||||||
IPv4 = true;
|
|
||||||
} else {
|
|
||||||
if(strStartIP.contains(is_ipv6) && strEndIP.contains(is_ipv6)) {
|
|
||||||
IPv4 = false;
|
|
||||||
} else {
|
|
||||||
// Could not determine IP format
|
|
||||||
qDebug("Ipfilter.dat: line %d is malformed.", nbLine);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check if there is an access value (apparently not mandatory)
|
|
||||||
if(nbElem > 1) {
|
|
||||||
// There is possibly one
|
|
||||||
bool ok;
|
|
||||||
nbAccess = partsList.at(1).trimmed().toInt(&ok);
|
|
||||||
if(!ok){
|
|
||||||
nbAccess = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Range is probably splitted by a comma
|
|
||||||
unsigned int nbElem = partsList.size();
|
|
||||||
if(nbElem > 1) {
|
|
||||||
strStartIP = firstPart.trimmed();
|
|
||||||
strEndIP = partsList.at(1).trimmed();
|
|
||||||
// Check if IPs are correct
|
|
||||||
if(strStartIP.contains(is_ipv4) && strEndIP.contains(is_ipv4)) {
|
|
||||||
IPv4 = true;
|
|
||||||
} else {
|
|
||||||
if(strStartIP.contains(is_ipv6) && strEndIP.contains(is_ipv6)) {
|
|
||||||
IPv4 = false;
|
|
||||||
} else {
|
|
||||||
// Could not determine IP format
|
|
||||||
qDebug("Ipfilter.dat: line %d is malformed.", nbLine);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check if there is an access value (apparently not mandatory)
|
|
||||||
if(nbElem > 2) {
|
|
||||||
// There is possibly one
|
|
||||||
bool ok;
|
|
||||||
nbAccess = partsList.at(2).trimmed().toInt(&ok);
|
|
||||||
if(!ok){
|
|
||||||
nbAccess = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(nbAccess > 127) {
|
|
||||||
// Ignoring this rule because access value is too high
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Now Add to the filter
|
|
||||||
QStringList IP;
|
|
||||||
if(IPv4) {
|
|
||||||
//IPv4 addresses
|
|
||||||
IP = strStartIP.split('.');
|
|
||||||
address_v4 start((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
|
||||||
IP = strEndIP.split('.');
|
|
||||||
address_v4 last((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
|
||||||
// Apply to bittorrent session
|
|
||||||
filter.add_rule(start, last, ip_filter::blocked);
|
|
||||||
} else {
|
|
||||||
// IPv6, ex : 1fff:0000:0a88:85a3:0000:0000:ac1f:8001
|
|
||||||
IP = strStartIP.split(':');
|
|
||||||
address_v6 start = address_v6::from_string(strStartIP.remove(':', 0).toUtf8().data());
|
|
||||||
IP = strEndIP.split(':');
|
|
||||||
address_v6 last = address_v6::from_string(strEndIP.remove(':', 0).toUtf8().data());
|
|
||||||
// Apply to bittorrent session
|
|
||||||
filter.add_rule(start, last, ip_filter::blocked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parser for PeerGuardian ip filter in p2p format
|
|
||||||
void parseP2PFilterFile(QString filePath) {
|
|
||||||
const QRegExp is_ipv4(QString::fromUtf8("^(([0-1]?[0-9]?[0-9])|(2[0-4][0-9])|(25[0-5]))(\\.(([0-1]?[0-9]?[0-9])|(2[0-4][0-9])|(25[0-5]))){3}$"), Qt::CaseInsensitive, QRegExp::RegExp);
|
|
||||||
QFile file(filePath);
|
|
||||||
QStringList IP;
|
|
||||||
if (file.exists()){
|
|
||||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
|
||||||
QMessageBox::critical(0, tr("I/O Error", "Input/Output Error"), tr("Couldn't open %1 in read mode.").arg(filePath));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
unsigned int nbLine = 0;
|
|
||||||
while (!file.atEnd() && !abort) {
|
|
||||||
++nbLine;
|
|
||||||
QByteArray line = file.readLine();
|
|
||||||
// Ignoring empty lines
|
|
||||||
line = line.trimmed();
|
|
||||||
if(line.isEmpty()) continue;
|
|
||||||
// Ignoring commented lines
|
|
||||||
if(line.startsWith('#') || line.startsWith("//")) continue;
|
|
||||||
// Line is not commented
|
|
||||||
QList<QByteArray> partsList = line.split(':');
|
|
||||||
if(partsList.size() < 2){
|
|
||||||
qDebug("p2p file: line %d is malformed.", nbLine);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Get IP range
|
|
||||||
QList<QByteArray> IPs = partsList.last().split('-');
|
|
||||||
if(IPs.size() != 2) {
|
|
||||||
qDebug("p2p file: line %d is malformed.", nbLine);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
QString strStartIP = IPs.at(0).trimmed();
|
|
||||||
QString strEndIP = IPs.at(1).trimmed();
|
|
||||||
// Check IPs format (IPv4 only)
|
|
||||||
if(strStartIP.contains(is_ipv4) && strEndIP.contains(is_ipv4)) {
|
|
||||||
// IPv4
|
|
||||||
IP = strStartIP.split('.');
|
|
||||||
address_v4 start((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
|
||||||
IP = strEndIP.split('.');
|
|
||||||
address_v4 last((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
|
||||||
// Apply to bittorrent session
|
|
||||||
filter.add_rule(start, last, ip_filter::blocked);
|
|
||||||
} else {
|
|
||||||
qDebug("p2p file: line %d is malformed.", nbLine);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int getlineInStream(QDataStream& stream, string& name, char delim) {
|
|
||||||
char c;
|
|
||||||
int total_read = 0;
|
|
||||||
do {
|
|
||||||
int read = stream.readRawData(&c, 1);
|
|
||||||
total_read += read;
|
|
||||||
if(read > 0) {
|
|
||||||
if(c != delim) {
|
|
||||||
name += c;
|
|
||||||
} else {
|
|
||||||
// Delim found
|
|
||||||
return total_read;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while(read > 0);
|
|
||||||
return total_read;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parser for PeerGuardian ip filter in p2p format
|
|
||||||
void parseP2BFilterFile(QString filePath) {
|
|
||||||
QFile file(filePath);
|
|
||||||
if (file.exists()){
|
|
||||||
if(!file.open(QIODevice::ReadOnly)){
|
|
||||||
QMessageBox::critical(0, tr("I/O Error", "Input/Output Error"), tr("Couldn't open %1 in read mode.").arg(filePath));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QDataStream stream(&file);
|
|
||||||
// Read header
|
|
||||||
char buf[7];
|
|
||||||
unsigned char version;
|
|
||||||
if(
|
|
||||||
!stream.readRawData(buf, sizeof(buf)) ||
|
|
||||||
memcmp(buf, "\xFF\xFF\xFF\xFFP2B", 7) ||
|
|
||||||
!stream.readRawData((char*)&version, sizeof(version))
|
|
||||||
) {
|
|
||||||
QMessageBox::critical(0, tr("I/O Error", "Input/Output Error"), tr("%1 is not a valid PeerGuardian P2B file.").arg(filePath));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(version==1 || version==2) {
|
|
||||||
qDebug ("p2b version 1 or 2");
|
|
||||||
unsigned int start, end;
|
|
||||||
|
|
||||||
string name;
|
|
||||||
while(getlineInStream(stream, name, '\0') && !abort) {
|
|
||||||
if(
|
|
||||||
!stream.readRawData((char*)&start, sizeof(start)) ||
|
|
||||||
!stream.readRawData((char*)&end, sizeof(end))
|
|
||||||
) {
|
|
||||||
QMessageBox::critical(0, tr("I/O Error", "Input/Output Error"), tr("%1 is not a valid PeerGuardian P2B file.").arg(filePath));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Network byte order to Host byte order
|
|
||||||
// asio address_v4 contructor expects it
|
|
||||||
// that way
|
|
||||||
address_v4 first(ntohl(start));
|
|
||||||
address_v4 last(ntohl(end));
|
|
||||||
// Apply to bittorrent session
|
|
||||||
filter.add_rule(first, last, ip_filter::blocked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(version==3) {
|
|
||||||
qDebug ("p2b version 3");
|
|
||||||
unsigned int namecount;
|
|
||||||
if(!stream.readRawData((char*)&namecount, sizeof(namecount))) {
|
|
||||||
QMessageBox::critical(0, tr("I/O Error", "Input/Output Error"), tr("%1 is not a valid PeerGuardian P2B file.").arg(filePath));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
namecount=ntohl(namecount);
|
|
||||||
// Reading names although, we don't really care about them
|
|
||||||
for(unsigned int i=0; i<namecount; i++) {
|
|
||||||
string name;
|
|
||||||
if(!getlineInStream(stream, name, '\0')) {
|
|
||||||
QMessageBox::critical(0, tr("I/O Error", "Input/Output Error"), tr("%1 is not a valid PeerGuardian P2B file.").arg(filePath));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(abort) return;
|
|
||||||
}
|
|
||||||
// Reading the ranges
|
|
||||||
unsigned int rangecount;
|
|
||||||
if(!stream.readRawData((char*)&rangecount, sizeof(rangecount))) {
|
|
||||||
QMessageBox::critical(0, tr("I/O Error", "Input/Output Error"), tr("%1 is not a valid PeerGuardian P2B file.").arg(filePath));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
rangecount=ntohl(rangecount);
|
|
||||||
|
|
||||||
unsigned int name, start, end;
|
|
||||||
|
|
||||||
for(unsigned int i=0; i<rangecount; i++) {
|
|
||||||
if(
|
|
||||||
!stream.readRawData((char*)&name, sizeof(name)) ||
|
|
||||||
!stream.readRawData((char*)&start, sizeof(start)) ||
|
|
||||||
!stream.readRawData((char*)&end, sizeof(end))
|
|
||||||
) {
|
|
||||||
QMessageBox::critical(0, tr("I/O Error", "Input/Output Error"), tr("%1 is not a valid PeerGuardian P2B file.").arg(filePath));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Network byte order to Host byte order
|
|
||||||
// asio address_v4 contructor expects it
|
|
||||||
// that way
|
|
||||||
address_v4 first(ntohl(start));
|
|
||||||
address_v4 last(ntohl(end));
|
|
||||||
// Apply to bittorrent session
|
|
||||||
filter.add_rule(first, last, ip_filter::blocked);
|
|
||||||
if(abort) return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
QMessageBox::critical(0, tr("I/O Error", "Input/Output Error"), tr("%1 is not a valid PeerGuardian P2B file.").arg(filePath));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process ip filter file
|
|
||||||
// Supported formats:
|
|
||||||
// * 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){
|
|
||||||
if(isRunning()) {
|
|
||||||
// Already parsing a filter, abort first
|
|
||||||
abort = true;
|
|
||||||
wait();
|
|
||||||
}
|
|
||||||
abort = false;
|
|
||||||
filePath = _filePath;
|
|
||||||
// Run it
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 by Ishan Arora
|
|
||||||
* ishanarora@gmail.com
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "httpconnection.h"
|
|
||||||
#include "httpserver.h"
|
|
||||||
#include "eventmanager.h"
|
|
||||||
#include "json.h"
|
|
||||||
#include <QTcpSocket>
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QHttpRequestHeader>
|
|
||||||
#include <QHttpResponseHeader>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
HttpConnection::HttpConnection(QTcpSocket *socket, HttpServer *parent)
|
|
||||||
: QObject(parent), socket(socket), parent(parent)
|
|
||||||
{
|
|
||||||
socket->setParent(this);
|
|
||||||
connect(socket, SIGNAL(readyRead()), this, SLOT(read()));
|
|
||||||
connect(socket, SIGNAL(disconnected()), this, SLOT(deleteLater()));
|
|
||||||
}
|
|
||||||
|
|
||||||
HttpConnection::~HttpConnection()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void HttpConnection::read()
|
|
||||||
{
|
|
||||||
QString input = socket->readAll();
|
|
||||||
qDebug(" -------");
|
|
||||||
qDebug("|REQUEST|");
|
|
||||||
qDebug(" -------");
|
|
||||||
qDebug(input.toAscii().constData());
|
|
||||||
parser.write(input);
|
|
||||||
if(parser.isError())
|
|
||||||
{
|
|
||||||
generator.setStatusLine(400, "Bad Request");
|
|
||||||
write();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (parser.isParsable())
|
|
||||||
respond();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HttpConnection::write()
|
|
||||||
{
|
|
||||||
QByteArray output = generator.toByteArray();
|
|
||||||
qDebug(" --------");
|
|
||||||
qDebug("|RESPONSE|");
|
|
||||||
qDebug(" --------");
|
|
||||||
qDebug()<<output;
|
|
||||||
socket->write(output);
|
|
||||||
socket->disconnectFromHost();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HttpConnection::respond()
|
|
||||||
{
|
|
||||||
QStringList auth = parser.value("Authorization").split(" ", QString::SkipEmptyParts);
|
|
||||||
if (auth.size() != 2 || QString::compare(auth[0], "Basic", Qt::CaseInsensitive) != 0 || !parent->isAuthorized(auth[1].toUtf8()))
|
|
||||||
{
|
|
||||||
generator.setStatusLine(401, "Unauthorized");
|
|
||||||
generator.setValue("WWW-Authenticate", "Basic realm=\"you know what\"");
|
|
||||||
write();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QString url = parser.url();
|
|
||||||
QStringList list = url.split('/', QString::SkipEmptyParts);
|
|
||||||
if (list.contains(".") || list.contains(".."))
|
|
||||||
{
|
|
||||||
respondNotFound();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (list.size() == 0)
|
|
||||||
list.append("index.html");
|
|
||||||
if (list.size() == 2)
|
|
||||||
{
|
|
||||||
if (list[0] == "json")
|
|
||||||
{
|
|
||||||
if (list[1] == "events")
|
|
||||||
{
|
|
||||||
EventManager* manager = parent->eventManager();
|
|
||||||
uint r = parser.get("r").toUInt();
|
|
||||||
if(manager->isUpdated(r))
|
|
||||||
respondJson();
|
|
||||||
else
|
|
||||||
connect(manager, SIGNAL(updated()), this, SLOT(respondJson()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (list[0] == "command")
|
|
||||||
{
|
|
||||||
QString command = list[1];
|
|
||||||
respondCommand(command);
|
|
||||||
generator.setStatusLine(200, "OK");
|
|
||||||
write();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (list[0] == "images")
|
|
||||||
list[0] = "Icons";
|
|
||||||
else
|
|
||||||
list.prepend("webui");
|
|
||||||
url = ":/" + list.join("/");
|
|
||||||
QFile file(url);
|
|
||||||
if(!file.open(QIODevice::ReadOnly))
|
|
||||||
{
|
|
||||||
respondNotFound();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QString ext = list.last();
|
|
||||||
int index = ext.lastIndexOf('.') + 1;
|
|
||||||
if (index > 0)
|
|
||||||
ext.remove(0, index);
|
|
||||||
else
|
|
||||||
ext.clear();
|
|
||||||
QByteArray data = file.readAll();
|
|
||||||
generator.setStatusLine(200, "OK");
|
|
||||||
generator.setContentTypeByExt(ext);
|
|
||||||
generator.setMessage(data);
|
|
||||||
write();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HttpConnection::respondNotFound()
|
|
||||||
{
|
|
||||||
generator.setStatusLine(404, "File not found");
|
|
||||||
write();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HttpConnection::respondJson()
|
|
||||||
{
|
|
||||||
EventManager* manager = parent->eventManager();
|
|
||||||
QString temp = parser.get("r");
|
|
||||||
uint r = parser.get("r").toUInt();
|
|
||||||
QVariant data = manager->querySince(r);
|
|
||||||
QString string = toJson(data);
|
|
||||||
generator.setStatusLine(200, "OK");
|
|
||||||
generator.setContentTypeByExt("js");
|
|
||||||
generator.setMessage(string);
|
|
||||||
write();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HttpConnection::respondCommand(QString command)
|
|
||||||
{
|
|
||||||
if(command == "download")
|
|
||||||
{
|
|
||||||
QString urls = parser.post("urls");
|
|
||||||
QStringList list = urls.split('\n');
|
|
||||||
QStringList url_list_cleaned;
|
|
||||||
foreach(QString url, list){
|
|
||||||
url = url.trimmed();
|
|
||||||
if(!url.isEmpty()){
|
|
||||||
if(url_list_cleaned.indexOf(QRegExp(url, Qt::CaseInsensitive, QRegExp::FixedString)) < 0){
|
|
||||||
url_list_cleaned << url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit urlsReadyToBeDownloaded(url_list_cleaned);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(command == "resumeall")
|
|
||||||
{
|
|
||||||
emit resumeAllTorrents();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(command == "pauseall")
|
|
||||||
{
|
|
||||||
emit pauseAllTorrents();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(command == "resume")
|
|
||||||
{
|
|
||||||
emit resumeTorrent(parser.post("hash"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(command == "pause")
|
|
||||||
{
|
|
||||||
emit pauseTorrent(parser.post("hash"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(command == "delete")
|
|
||||||
{
|
|
||||||
emit deleteTorrent(parser.post("hash"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||