Browse Source

Moved search code into a subfolder

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
7ec842929a
  1. 4
      src/GUI.cpp
  2. 4
      src/GUI.h
  3. 4
      src/misc.cpp
  4. 20
      src/properties/properties.pri
  5. 12
      src/rss/rss.pri
  6. 23
      src/search.qrc
  7. 0
      src/searchengine/engineselect.ui
  8. 4
      src/searchengine/engineselectdlg.cpp
  9. 0
      src/searchengine/engineselectdlg.h
  10. 0
      src/searchengine/nova/__init__.py
  11. 0
      src/searchengine/nova/engines/__init__.py
  12. 0
      src/searchengine/nova/engines/btjunkie.png
  13. 0
      src/searchengine/nova/engines/btjunkie.py
  14. 0
      src/searchengine/nova/engines/isohunt.png
  15. 0
      src/searchengine/nova/engines/isohunt.py
  16. 0
      src/searchengine/nova/engines/mininova.png
  17. 0
      src/searchengine/nova/engines/mininova.py
  18. 0
      src/searchengine/nova/engines/piratebay.png
  19. 0
      src/searchengine/nova/engines/piratebay.py
  20. 0
      src/searchengine/nova/engines/torrentdownloads.png
  21. 0
      src/searchengine/nova/engines/torrentdownloads.py
  22. 0
      src/searchengine/nova/engines/torrentreactor.png
  23. 0
      src/searchengine/nova/engines/torrentreactor.py
  24. 0
      src/searchengine/nova/engines/versions.txt
  25. 0
      src/searchengine/nova/engines/vertor.png
  26. 0
      src/searchengine/nova/engines/vertor.py
  27. 0
      src/searchengine/nova/helpers.py
  28. 0
      src/searchengine/nova/nova2.py
  29. 0
      src/searchengine/nova/nova2dl.py
  30. 0
      src/searchengine/nova/novaprinter.py
  31. 0
      src/searchengine/nova/socks.py
  32. 0
      src/searchengine/pluginsource.h
  33. 23
      src/searchengine/search.qrc
  34. 0
      src/searchengine/search.ui
  35. 22
      src/searchengine/searchengine.cpp
  36. 0
      src/searchengine/searchengine.h
  37. 17
      src/searchengine/searchengine.pri
  38. 0
      src/searchengine/searchlistdelegate.h
  39. 0
      src/searchengine/searchtab.cpp
  40. 0
      src/searchengine/searchtab.h
  41. 0
      src/searchengine/supportedengines.h
  42. 27
      src/src.pro
  43. 32
      src/torrentcreatordlg.cpp
  44. 6
      src/torrentcreatordlg.h

4
src/GUI.cpp

@ -47,7 +47,7 @@
#include "GUI.h" #include "GUI.h"
#include "transferlistwidget.h" #include "transferlistwidget.h"
#include "misc.h" #include "misc.h"
#include "createtorrent_imp.h" #include "torrentcreatordlg.h"
#include "downloadfromurldlg.h" #include "downloadfromurldlg.h"
#include "torrentadditiondlg.h" #include "torrentadditiondlg.h"
#include "searchengine.h" #include "searchengine.h"
@ -721,7 +721,7 @@ void GUI::on_actionCreate_torrent_triggered() {
if(createTorrentDlg) { if(createTorrentDlg) {
createTorrentDlg->setFocus(); createTorrentDlg->setFocus();
} else { } else {
createTorrentDlg = new createtorrent(this); createTorrentDlg = new TorrentCreatorDlg(this);
connect(createTorrentDlg, SIGNAL(torrent_to_seed(QString)), this, SLOT(addTorrent(QString))); connect(createTorrentDlg, SIGNAL(torrent_to_seed(QString)), this, SLOT(addTorrent(QString)));
} }
} }

4
src/GUI.h

@ -54,7 +54,7 @@ class PropertiesWidget;
class StatusBar; class StatusBar;
class consoleDlg; class consoleDlg;
class about; class about;
class createtorrent; class TorrentCreatorDlg;
class downloadFromURL; class downloadFromURL;
class HidableTabWidget; class HidableTabWidget;
class LineEdit; class LineEdit;
@ -149,7 +149,7 @@ private:
QPointer<options_imp> options; QPointer<options_imp> options;
QPointer<consoleDlg> console; QPointer<consoleDlg> console;
QPointer<about> aboutDlg; QPointer<about> aboutDlg;
QPointer<createtorrent> createTorrentDlg; QPointer<TorrentCreatorDlg> createTorrentDlg;
QPointer<downloadFromURL> downloadFromURLDialog; QPointer<downloadFromURL> downloadFromURLDialog;
QPointer<QSystemTrayIcon> systrayIcon; QPointer<QSystemTrayIcon> systrayIcon;
QPointer<QTimer> systrayCreator; QPointer<QTimer> systrayCreator;

4
src/misc.cpp

@ -415,7 +415,7 @@ void misc::moveToXDGFolders() {
copyDir(old_BTBackupPath, BTBackupLocation()); copyDir(old_BTBackupPath, BTBackupLocation());
} }
// Copy search engine folder // Copy search engine folder
const QString old_searchPath = old_qBtPath.absoluteFilePath("search_engine"); const QString old_searchPath = old_qBtPath.absoluteFilePath("nova");
if(QDir(old_searchPath).exists()) { if(QDir(old_searchPath).exists()) {
copyDir(old_searchPath, searchEngineLocation()); copyDir(old_searchPath, searchEngineLocation());
} }
@ -471,7 +471,7 @@ QPoint misc::screenCenter(QWidget *win) {
QString misc::searchEngineLocation() { QString misc::searchEngineLocation() {
const QString location = QDir::cleanPath(QDesktopServicesDataLocation() const QString location = QDir::cleanPath(QDesktopServicesDataLocation()
+ QDir::separator() + "search_engine"); + QDir::separator() + "nova");
QDir locationDir(location); QDir locationDir(location);
if(!locationDir.exists()) if(!locationDir.exists())
locationDir.mkpath(locationDir.absolutePath()); locationDir.mkpath(locationDir.absolutePath());

20
src/properties/properties.pri

@ -1,9 +1,8 @@
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
!contains(DEFINES, DISABLE_GUI) { FORMS += $$PWD/propertieswidget.ui
FORMS += $$PWD/propertieswidget.ui
HEADERS += $$PWD/propertieswidget.h \ HEADERS += $$PWD/propertieswidget.h \
$$PWD/peerlistwidget.h \ $$PWD/peerlistwidget.h \
$$PWD/proplistdelegate.h \ $$PWD/proplistdelegate.h \
$$PWD/trackerlist.h \ $$PWD/trackerlist.h \
@ -11,16 +10,11 @@ INCLUDEPATH += $$PWD
$$PWD/peerlistdelegate.h \ $$PWD/peerlistdelegate.h \
$$PWD/peeraddition.h \ $$PWD/peeraddition.h \
$$PWD/trackersadditiondlg.h \ $$PWD/trackersadditiondlg.h \
$$PWD/pieceavailabilitybar.h $$PWD/pieceavailabilitybar.h \
$$PWD/proptabbar.h
SOURCES += $$PWD/propertieswidget.cpp \ SOURCES += $$PWD/propertieswidget.cpp \
$$PWD/peerlistwidget.cpp \ $$PWD/peerlistwidget.cpp \
$$PWD/trackerlist.cpp $$PWD/trackerlist.cpp \
$$PWD/proptabbar.cpp
}
HEADERS += \
properties/proptabbar.h
SOURCES += \
properties/proptabbar.cpp

12
src/rss/rss.pri

@ -1,8 +1,6 @@
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
!contains(DEFINES, DISABLE_GUI) { HEADERS += $$PWD/rss_imp.h \
HEADERS += $$PWD/rss_imp.h \
$$PWD/rsssettings.h \ $$PWD/rsssettings.h \
$$PWD/feeddownloader.h \ $$PWD/feeddownloader.h \
$$PWD/feedlistwidget.h \ $$PWD/feedlistwidget.h \
@ -12,8 +10,8 @@ INCLUDEPATH += $$PWD
$$PWD/rssfile.h \ $$PWD/rssfile.h \
$$PWD/rssarticle.h \ $$PWD/rssarticle.h \
$$PWD/rssfilters.h $$PWD/rssfilters.h
SOURCES += $$PWD/rss_imp.cpp \ SOURCES += $$PWD/rss_imp.cpp \
$$PWD/rsssettings.cpp \ $$PWD/rsssettings.cpp \
$$PWD/feedlistwidget.cpp \ $$PWD/feedlistwidget.cpp \
$$PWD/rssmanager.cpp \ $$PWD/rssmanager.cpp \
@ -23,7 +21,7 @@ INCLUDEPATH += $$PWD
$$PWD/feeddownloader.cpp \ $$PWD/feeddownloader.cpp \
$$PWD/rssfilters.cpp $$PWD/rssfilters.cpp
FORMS += $$PWD/ui/rss.ui \ FORMS += $$PWD/ui/rss.ui \
$$PWD/ui/feeddownloader.ui \ $$PWD/ui/feeddownloader.ui \
$$PWD/ui/rsssettings.ui $$PWD/ui/rsssettings.ui
}

23
src/search.qrc

@ -1,23 +0,0 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>search_engine/nova2.py</file>
<file>search_engine/novaprinter.py</file>
<file>search_engine/socks.py</file>
<file>search_engine/nova2dl.py</file>
<file>search_engine/helpers.py</file>
<file>search_engine/engines/vertor.png</file>
<file>search_engine/engines/mininova.png</file>
<file>search_engine/engines/mininova.py</file>
<file>search_engine/engines/torrentdownloads.png</file>
<file>search_engine/engines/isohunt.png</file>
<file>search_engine/engines/torrentreactor.py</file>
<file>search_engine/engines/btjunkie.png</file>
<file>search_engine/engines/piratebay.py</file>
<file>search_engine/engines/torrentdownloads.py</file>
<file>search_engine/engines/torrentreactor.png</file>
<file>search_engine/engines/isohunt.py</file>
<file>search_engine/engines/btjunkie.py</file>
<file>search_engine/engines/piratebay.png</file>
<file>search_engine/engines/vertor.py</file>
</qresource>
</RCC>

0
src/ui/engineselect.ui → src/searchengine/engineselect.ui

4
src/engineselectdlg.cpp → src/searchengine/engineselectdlg.cpp

@ -44,7 +44,7 @@
#include <QTemporaryFile> #include <QTemporaryFile>
enum EngineColumns {ENGINE_NAME, ENGINE_URL, ENGINE_STATE, ENGINE_ID}; enum EngineColumns {ENGINE_NAME, ENGINE_URL, ENGINE_STATE, ENGINE_ID};
#define UPDATE_URL "http://qbittorrent.svn.sourceforge.net/viewvc/qbittorrent/trunk/src/search_engine/engines/" #define UPDATE_URL "http://qbittorrent.svn.sourceforge.net/viewvc/qbittorrent/trunk/src/nova/engines/"
engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_engines) : QDialog(parent), supported_engines(supported_engines) { engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_engines) : QDialog(parent), supported_engines(supported_engines) {
setupUi(this); setupUi(this);
@ -164,7 +164,7 @@ void engineSelectDlg::on_actionUninstall_triggered() {
int index = pluginsTree->indexOfTopLevelItem(item); int index = pluginsTree->indexOfTopLevelItem(item);
Q_ASSERT(index != -1); Q_ASSERT(index != -1);
QString id = item->text(ENGINE_ID); QString id = item->text(ENGINE_ID);
if(QFile::exists(":/search_engine/engines/"+id+".py")) { if(QFile::exists(":/nova/engines/"+id+".py")) {
error = true; error = true;
// Disable it instead // Disable it instead
supported_engines->value(id)->setEnabled(false); supported_engines->value(id)->setEnabled(false);

0
src/engineselectdlg.h → src/searchengine/engineselectdlg.h

0
src/search_engine/__init__.py → src/searchengine/nova/__init__.py

0
src/search_engine/engines/__init__.py → src/searchengine/nova/engines/__init__.py

0
src/search_engine/engines/btjunkie.png → src/searchengine/nova/engines/btjunkie.png

Before

Width:  |  Height:  |  Size: 622 B

After

Width:  |  Height:  |  Size: 622 B

0
src/search_engine/engines/btjunkie.py → src/searchengine/nova/engines/btjunkie.py

0
src/search_engine/engines/isohunt.png → src/searchengine/nova/engines/isohunt.png

Before

Width:  |  Height:  |  Size: 633 B

After

Width:  |  Height:  |  Size: 633 B

0
src/search_engine/engines/isohunt.py → src/searchengine/nova/engines/isohunt.py

0
src/search_engine/engines/mininova.png → src/searchengine/nova/engines/mininova.png

Before

Width:  |  Height:  |  Size: 365 B

After

Width:  |  Height:  |  Size: 365 B

0
src/search_engine/engines/mininova.py → src/searchengine/nova/engines/mininova.py

0
src/search_engine/engines/piratebay.png → src/searchengine/nova/engines/piratebay.png

Before

Width:  |  Height:  |  Size: 609 B

After

Width:  |  Height:  |  Size: 609 B

0
src/search_engine/engines/piratebay.py → src/searchengine/nova/engines/piratebay.py

0
src/search_engine/engines/torrentdownloads.png → src/searchengine/nova/engines/torrentdownloads.png

Before

Width:  |  Height:  |  Size: 423 B

After

Width:  |  Height:  |  Size: 423 B

0
src/search_engine/engines/torrentdownloads.py → src/searchengine/nova/engines/torrentdownloads.py

0
src/search_engine/engines/torrentreactor.png → src/searchengine/nova/engines/torrentreactor.png

Before

Width:  |  Height:  |  Size: 529 B

After

Width:  |  Height:  |  Size: 529 B

0
src/search_engine/engines/torrentreactor.py → src/searchengine/nova/engines/torrentreactor.py

0
src/search_engine/engines/versions.txt → src/searchengine/nova/engines/versions.txt

0
src/search_engine/engines/vertor.png → src/searchengine/nova/engines/vertor.png

Before

Width:  |  Height:  |  Size: 643 B

After

Width:  |  Height:  |  Size: 643 B

0
src/search_engine/engines/vertor.py → src/searchengine/nova/engines/vertor.py

0
src/search_engine/helpers.py → src/searchengine/nova/helpers.py

0
src/search_engine/nova2.py → src/searchengine/nova/nova2.py

0
src/search_engine/nova2dl.py → src/searchengine/nova/nova2dl.py

0
src/search_engine/novaprinter.py → src/searchengine/nova/novaprinter.py

0
src/search_engine/socks.py → src/searchengine/nova/socks.py

0
src/pluginsource.h → src/searchengine/pluginsource.h

23
src/searchengine/search.qrc

@ -0,0 +1,23 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>nova/nova2.py</file>
<file>nova/novaprinter.py</file>
<file>nova/socks.py</file>
<file>nova/nova2dl.py</file>
<file>nova/helpers.py</file>
<file>nova/engines/vertor.png</file>
<file>nova/engines/mininova.png</file>
<file>nova/engines/mininova.py</file>
<file>nova/engines/torrentdownloads.png</file>
<file>nova/engines/isohunt.png</file>
<file>nova/engines/torrentreactor.py</file>
<file>nova/engines/btjunkie.png</file>
<file>nova/engines/piratebay.py</file>
<file>nova/engines/torrentdownloads.py</file>
<file>nova/engines/torrentreactor.png</file>
<file>nova/engines/isohunt.py</file>
<file>nova/engines/btjunkie.py</file>
<file>nova/engines/piratebay.png</file>
<file>nova/engines/vertor.py</file>
</qresource>
</RCC>

0
src/ui/search.ui → src/searchengine/search.ui

22
src/searchengine.cpp → src/searchengine/searchengine.cpp

@ -470,7 +470,7 @@ void SearchEngine::downloadFinished(int exitcode, QProcess::ExitStatus) {
// Update nova.py search plugin if necessary // Update nova.py search plugin if necessary
void SearchEngine::updateNova() { void SearchEngine::updateNova() {
qDebug("Updating nova"); qDebug("Updating nova");
// create search_engine directory if necessary // create nova directory if necessary
QDir search_dir(misc::searchEngineLocation()); QDir search_dir(misc::searchEngineLocation());
QFile package_file(search_dir.absoluteFilePath("__init__.py")); QFile package_file(search_dir.absoluteFilePath("__init__.py"));
package_file.open(QIODevice::WriteOnly | QIODevice::Text); package_file.open(QIODevice::WriteOnly | QIODevice::Text);
@ -483,47 +483,47 @@ void SearchEngine::updateNova() {
package_file2.close(); package_file2.close();
// Copy search plugin files (if necessary) // Copy search plugin files (if necessary)
QString filePath = search_dir.absoluteFilePath("nova2.py"); QString filePath = search_dir.absoluteFilePath("nova2.py");
if(getPluginVersion(":/search_engine/nova2.py") > getPluginVersion(filePath)) { if(getPluginVersion(":/nova/nova2.py") > getPluginVersion(filePath)) {
if(QFile::exists(filePath)) { if(QFile::exists(filePath)) {
misc::safeRemove(filePath); misc::safeRemove(filePath);
misc::safeRemove(filePath+"c"); misc::safeRemove(filePath+"c");
} }
QFile::copy(":/search_engine/nova2.py", filePath); QFile::copy(":/nova/nova2.py", filePath);
} }
filePath = search_dir.absoluteFilePath("nova2dl.py"); filePath = search_dir.absoluteFilePath("nova2dl.py");
if(getPluginVersion(":/search_engine/nova2dl.py") > getPluginVersion(filePath)) { if(getPluginVersion(":/nova/nova2dl.py") > getPluginVersion(filePath)) {
if(QFile::exists(filePath)){ if(QFile::exists(filePath)){
misc::safeRemove(filePath); misc::safeRemove(filePath);
misc::safeRemove(filePath+"c"); misc::safeRemove(filePath+"c");
} }
QFile::copy(":/search_engine/nova2dl.py", filePath); QFile::copy(":/nova/nova2dl.py", filePath);
} }
filePath = search_dir.absoluteFilePath("novaprinter.py"); filePath = search_dir.absoluteFilePath("novaprinter.py");
if(getPluginVersion(":/search_engine/novaprinter.py") > getPluginVersion(filePath)) { if(getPluginVersion(":/nova/novaprinter.py") > getPluginVersion(filePath)) {
if(QFile::exists(filePath)){ if(QFile::exists(filePath)){
misc::safeRemove(filePath); misc::safeRemove(filePath);
misc::safeRemove(filePath+"c"); misc::safeRemove(filePath+"c");
} }
QFile::copy(":/search_engine/novaprinter.py", filePath); QFile::copy(":/nova/novaprinter.py", filePath);
} }
filePath = search_dir.absoluteFilePath("helpers.py"); filePath = search_dir.absoluteFilePath("helpers.py");
if(getPluginVersion(":/search_engine/helpers.py") > getPluginVersion(filePath)) { if(getPluginVersion(":/nova/helpers.py") > getPluginVersion(filePath)) {
if(QFile::exists(filePath)){ if(QFile::exists(filePath)){
misc::safeRemove(filePath); misc::safeRemove(filePath);
misc::safeRemove(filePath+"c"); misc::safeRemove(filePath+"c");
} }
QFile::copy(":/search_engine/helpers.py", filePath); QFile::copy(":/nova/helpers.py", filePath);
} }
filePath = search_dir.absoluteFilePath("socks.py"); filePath = search_dir.absoluteFilePath("socks.py");
if(!QFile::exists(filePath)) { if(!QFile::exists(filePath)) {
QFile::copy(":/search_engine/socks.py", filePath); QFile::copy(":/nova/socks.py", filePath);
} }
QDir destDir(QDir(misc::searchEngineLocation()).absoluteFilePath("engines")); QDir destDir(QDir(misc::searchEngineLocation()).absoluteFilePath("engines"));
QDir shipped_subDir(":/search_engine/engines/"); QDir shipped_subDir(":/nova/engines/");
QStringList files = shipped_subDir.entryList(); QStringList files = shipped_subDir.entryList();
foreach(const QString &file, files){ foreach(const QString &file, files){
QString shipped_file = shipped_subDir.absoluteFilePath(file); QString shipped_file = shipped_subDir.absoluteFilePath(file);

0
src/searchengine.h → src/searchengine/searchengine.h

17
src/searchengine/searchengine.pri

@ -0,0 +1,17 @@
INCLUDEPATH += $$PWD
FORMS += $$PWD/search.ui \
$$PWD/engineselect.ui
HEADERS += $$PWD/searchengine.h \
$$PWD/searchtab.h \
$$PWD/engineselectdlg.h \
$$PWD/pluginsource.h \
$$PWD/searchlistdelegate.h \
$$PWD/supportedengines.h
SOURCES += $$PWD/searchengine.cpp \
$$PWD/searchtab.cpp \
$$PWD/engineselectdlg.cpp
RESOURCES += $$PWD/search.qrc

0
src/searchlistdelegate.h → src/searchengine/searchlistdelegate.h

0
src/searchtab.cpp → src/searchengine/searchtab.cpp

0
src/searchtab.h → src/searchengine/searchtab.h

0
src/supportedengines.h → src/searchengine/supportedengines.h

27
src/src.pro

@ -222,7 +222,6 @@ os2 {
# Resource files # Resource files
RESOURCES += icons.qrc \ RESOURCES += icons.qrc \
lang.qrc \ lang.qrc \
search.qrc \
about.qrc about.qrc
# Add GeoIP resource file if the GeoIP database # Add GeoIP resource file if the GeoIP database
@ -282,13 +281,13 @@ HEADERS += misc.h \
preferences.h \ preferences.h \
scannedfoldersmodel.h \ scannedfoldersmodel.h \
qinisettings.h \ qinisettings.h \
smtp.h smtp.h \
torrentcreatordlg.h
contains(DEFINES, DISABLE_GUI) { contains(DEFINES, DISABLE_GUI) {
HEADERS += headlessloader.h HEADERS += headlessloader.h
} else { } else {
HEADERS += GUI.h \ HEADERS += GUI.h \
supportedengines.h \
transferlistwidget.h \ transferlistwidget.h \
transferlistdelegate.h \ transferlistdelegate.h \
transferlistfilterswidget.h \ transferlistfilterswidget.h \
@ -297,17 +296,11 @@ contains(DEFINES, DISABLE_GUI) {
deletionconfirmationdlg.h \ deletionconfirmationdlg.h \
statusbar.h \ statusbar.h \
reverseresolution.h \ reverseresolution.h \
searchtab.h \
console_imp.h \ console_imp.h \
ico.h \ ico.h \
engineselectdlg.h \
pluginsource.h \
searchEngine.h \
speedlimitdlg.h \ speedlimitdlg.h \
options_imp.h \ options_imp.h \
about_imp.h \ about_imp.h \
createtorrent_imp.h \
searchlistdelegate.h \
previewselect.h \ previewselect.h \
previewlistdelegate.h \ previewlistdelegate.h \
downloadfromurldlg.h \ downloadfromurldlg.h \
@ -345,9 +338,12 @@ contains(DEFINES, USE_SYSTEM_QTSINGLEAPPLICATION) {
include(qtlibtorrent/qtlibtorrent.pri) include(qtlibtorrent/qtlibtorrent.pri)
include(webui/webui.pri) include(webui/webui.pri)
include(rss/rss.pri)
include(tracker/tracker.pri) include(tracker/tracker.pri)
include(properties/properties.pri) !contains(DEFINES, DISABLE_GUI) {
include(properties/properties.pri)
include(searchengine/searchengine.pri)
include(rss/rss.pri)
}
!contains(DEFINES, DISABLE_GUI) { !contains(DEFINES, DISABLE_GUI) {
FORMS += ui/mainwindow.ui \ FORMS += ui/mainwindow.ui \
@ -358,9 +354,7 @@ include(properties/properties.pri)
ui/login.ui \ ui/login.ui \
ui/downloadfromurldlg.ui \ ui/downloadfromurldlg.ui \
ui/torrentadditiondlg.ui \ ui/torrentadditiondlg.ui \
ui/search.ui \
ui/bandwidth_limit.ui \ ui/bandwidth_limit.ui \
ui/engineselect.ui \
ui/pluginsource.ui \ ui/pluginsource.ui \
ui/trackersadditiondlg.ui \ ui/trackersadditiondlg.ui \
ui/console.ui \ ui/console.ui \
@ -373,15 +367,12 @@ SOURCES += main.cpp \
downloadthread.cpp \ downloadthread.cpp \
scannedfoldersmodel.cpp \ scannedfoldersmodel.cpp \
misc.cpp \ misc.cpp \
smtp.cpp smtp.cpp \
torrentcreatordlg.cpp
!contains(DEFINES, DISABLE_GUI) { !contains(DEFINES, DISABLE_GUI) {
SOURCES += GUI.cpp \ SOURCES += GUI.cpp \
options_imp.cpp \ options_imp.cpp \
createtorrent_imp.cpp \
searchengine.cpp \
engineselectdlg.cpp \
searchtab.cpp \
ico.cpp \ ico.cpp \
transferlistwidget.cpp \ transferlistwidget.cpp \
cookiesdlg.cpp \ cookiesdlg.cpp \

32
src/createtorrent_imp.cpp → src/torrentcreatordlg.cpp

@ -48,7 +48,7 @@
#include <libtorrent/create_torrent.hpp> #include <libtorrent/create_torrent.hpp>
#include "torrentpersistentdata.h" #include "torrentpersistentdata.h"
#include "createtorrent_imp.h" #include "torrentcreatordlg.h"
#include "misc.h" #include "misc.h"
#include "qinisettings.h" #include "qinisettings.h"
@ -64,7 +64,7 @@ bool file_filter(boost::filesystem::path const& filename)
return true; return true;
} }
createtorrent::createtorrent(QWidget *parent): QDialog(parent){ TorrentCreatorDlg::TorrentCreatorDlg(QWidget *parent): QDialog(parent){
setupUi(this); setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
setModal(true); setModal(true);
@ -76,11 +76,11 @@ createtorrent::createtorrent(QWidget *parent): QDialog(parent){
show(); show();
} }
createtorrent::~createtorrent() { TorrentCreatorDlg::~TorrentCreatorDlg() {
delete creatorThread; delete creatorThread;
} }
void createtorrent::on_addFolder_button_clicked(){ void TorrentCreatorDlg::on_addFolder_button_clicked(){
QIniSettings settings("qBittorrent", "qBittorrent"); QIniSettings settings("qBittorrent", "qBittorrent");
QString last_path = settings.value("CreateTorrent/last_add_path", QDir::homePath()).toString(); QString last_path = settings.value("CreateTorrent/last_add_path", QDir::homePath()).toString();
QString dir = QFileDialog::getExistingDirectory(this, tr("Select a folder to add to the torrent"), last_path, QFileDialog::ShowDirsOnly); QString dir = QFileDialog::getExistingDirectory(this, tr("Select a folder to add to the torrent"), last_path, QFileDialog::ShowDirsOnly);
@ -93,7 +93,7 @@ void createtorrent::on_addFolder_button_clicked(){
} }
} }
void createtorrent::on_addFile_button_clicked(){ void TorrentCreatorDlg::on_addFile_button_clicked(){
QIniSettings settings("qBittorrent", "qBittorrent"); QIniSettings settings("qBittorrent", "qBittorrent");
QString last_path = settings.value("CreateTorrent/last_add_path", QDir::homePath()).toString(); QString last_path = settings.value("CreateTorrent/last_add_path", QDir::homePath()).toString();
QString file = QFileDialog::getOpenFileName(this, tr("Select a file to add to the torrent"), last_path); QString file = QFileDialog::getOpenFileName(this, tr("Select a file to add to the torrent"), last_path);
@ -106,7 +106,7 @@ void createtorrent::on_addFile_button_clicked(){
} }
} }
void createtorrent::on_removeTracker_button_clicked() { void TorrentCreatorDlg::on_removeTracker_button_clicked() {
QModelIndexList selectedIndexes = trackers_list->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = trackers_list->selectionModel()->selectedIndexes();
for(int i=selectedIndexes.size()-1; i>=0; --i){ for(int i=selectedIndexes.size()-1; i>=0; --i){
QListWidgetItem *item = trackers_list->takeItem(selectedIndexes.at(i).row()); QListWidgetItem *item = trackers_list->takeItem(selectedIndexes.at(i).row());
@ -114,7 +114,7 @@ void createtorrent::on_removeTracker_button_clicked() {
} }
} }
int createtorrent::getPieceSize() const { int TorrentCreatorDlg::getPieceSize() const {
switch(comboPieceSize->currentIndex()) { switch(comboPieceSize->currentIndex()) {
case 0: case 0:
return 32*1024; return 32*1024;
@ -135,7 +135,7 @@ int createtorrent::getPieceSize() const {
} }
} }
void createtorrent::on_addTracker_button_clicked() { void TorrentCreatorDlg::on_addTracker_button_clicked() {
bool ok; bool ok;
QString URL = QInputDialog::getText(this, tr("Please type an announce URL"), QString URL = QInputDialog::getText(this, tr("Please type an announce URL"),
tr("Announce URL:", "Tracker URL"), QLineEdit::Normal, tr("Announce URL:", "Tracker URL"), QLineEdit::Normal,
@ -146,7 +146,7 @@ void createtorrent::on_addTracker_button_clicked() {
} }
} }
void createtorrent::on_removeURLSeed_button_clicked(){ void TorrentCreatorDlg::on_removeURLSeed_button_clicked(){
QModelIndexList selectedIndexes = URLSeeds_list->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = URLSeeds_list->selectionModel()->selectedIndexes();
for(int i=selectedIndexes.size()-1; i>=0; --i){ for(int i=selectedIndexes.size()-1; i>=0; --i){
QListWidgetItem *item = URLSeeds_list->takeItem(selectedIndexes.at(i).row()); QListWidgetItem *item = URLSeeds_list->takeItem(selectedIndexes.at(i).row());
@ -154,7 +154,7 @@ void createtorrent::on_removeURLSeed_button_clicked(){
} }
} }
void createtorrent::on_addURLSeed_button_clicked(){ void TorrentCreatorDlg::on_addURLSeed_button_clicked(){
bool ok; bool ok;
QString URL = QInputDialog::getText(this, tr("Please type a web seed url"), QString URL = QInputDialog::getText(this, tr("Please type a web seed url"),
tr("Web seed URL:"), QLineEdit::Normal, tr("Web seed URL:"), QLineEdit::Normal,
@ -165,7 +165,7 @@ void createtorrent::on_addURLSeed_button_clicked(){
} }
} }
QStringList createtorrent::allItems(QListWidget *list){ QStringList TorrentCreatorDlg::allItems(QListWidget *list){
QStringList res; QStringList res;
unsigned int nbItems = list->count(); unsigned int nbItems = list->count();
for(unsigned int i=0; i< nbItems; ++i){ for(unsigned int i=0; i< nbItems; ++i){
@ -175,7 +175,7 @@ QStringList createtorrent::allItems(QListWidget *list){
} }
// Main function that create a .torrent file // Main function that create a .torrent file
void createtorrent::on_createButton_clicked(){ void TorrentCreatorDlg::on_createButton_clicked(){
QString input = textInputPath->text().trimmed(); QString input = textInputPath->text().trimmed();
if (input.endsWith(QDir::separator())) if (input.endsWith(QDir::separator()))
input.chop(1); input.chop(1);
@ -206,7 +206,7 @@ void createtorrent::on_createButton_clicked(){
creatorThread->create(input, destination, trackers, url_seeds, comment, check_private->isChecked(), getPieceSize()); creatorThread->create(input, destination, trackers, url_seeds, comment, check_private->isChecked(), getPieceSize());
} }
void createtorrent::handleCreationFailure(QString msg) { void TorrentCreatorDlg::handleCreationFailure(QString msg) {
// Enable dialog // Enable dialog
setEnabled(true); setEnabled(true);
// Remove busy cursor // Remove busy cursor
@ -214,7 +214,7 @@ void createtorrent::handleCreationFailure(QString msg) {
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent creation was unsuccessful, reason: %1").arg(msg)); QMessageBox::information(0, tr("Torrent creation"), tr("Torrent creation was unsuccessful, reason: %1").arg(msg));
} }
void createtorrent::handleCreationSuccess(QString path, QString branch_path) { void TorrentCreatorDlg::handleCreationSuccess(QString path, QString branch_path) {
// Enable Dialog // Enable Dialog
setEnabled(true); setEnabled(true);
// Remove busy cursor // Remove busy cursor
@ -246,7 +246,7 @@ void createtorrent::handleCreationSuccess(QString path, QString branch_path) {
close(); close();
} }
void createtorrent::on_cancelButton_clicked() { void TorrentCreatorDlg::on_cancelButton_clicked() {
// End torrent creation thread // End torrent creation thread
if(creatorThread->isRunning()) { if(creatorThread->isRunning()) {
creatorThread->abortCreation(); creatorThread->abortCreation();
@ -258,7 +258,7 @@ void createtorrent::on_cancelButton_clicked() {
reject(); reject();
} }
void createtorrent::updateProgressBar(int progress) { void TorrentCreatorDlg::updateProgressBar(int progress) {
progressBar->setValue(progress); progressBar->setValue(progress);
} }

6
src/createtorrent_imp.h → src/torrentcreatordlg.h

@ -71,15 +71,15 @@ class torrentCreatorThread : public QThread {
void updateProgress(int progress); void updateProgress(int progress);
}; };
class createtorrent : public QDialog, private Ui::createTorrentDialog{ class TorrentCreatorDlg : public QDialog, private Ui::createTorrentDialog{
Q_OBJECT Q_OBJECT
private: private:
torrentCreatorThread *creatorThread; torrentCreatorThread *creatorThread;
public: public:
createtorrent(QWidget *parent = 0); TorrentCreatorDlg(QWidget *parent = 0);
~createtorrent(); ~TorrentCreatorDlg();
QStringList allItems(QListWidget *list); QStringList allItems(QListWidget *list);
int getPieceSize() const; int getPieceSize() const;
Loading…
Cancel
Save