mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-05 11:24:15 +00:00
Coding style clean up
This commit is contained in:
parent
00b4ad6ec8
commit
f3448125c3
@ -45,7 +45,7 @@ class about : public QDialog, private Ui::AboutDlg{
|
|||||||
qDebug("Deleting about dlg");
|
qDebug("Deleting about dlg");
|
||||||
}
|
}
|
||||||
|
|
||||||
about(QWidget *parent): QDialog(parent){
|
about(QWidget *parent): QDialog(parent) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
// Set icons
|
// Set icons
|
||||||
|
@ -43,7 +43,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
downloadFromURL(QWidget *parent): QDialog(parent){
|
downloadFromURL(QWidget *parent): QDialog(parent) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
setModal(true);
|
setModal(true);
|
||||||
@ -55,26 +55,26 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~downloadFromURL(){}
|
~downloadFromURL() {}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void urlsReadyToBeDownloaded(const QStringList& torrent_urls);
|
void urlsReadyToBeDownloaded(const QStringList& torrent_urls);
|
||||||
|
|
||||||
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(QString::fromUtf8("\n"));
|
||||||
QString url;
|
QString url;
|
||||||
QStringList url_list_cleaned;
|
QStringList url_list_cleaned;
|
||||||
foreach (url, url_list){
|
foreach (url, url_list) {
|
||||||
url = url.trimmed();
|
url = url.trimmed();
|
||||||
if (!url.isEmpty()){
|
if (!url.isEmpty()) {
|
||||||
if (url_list_cleaned.indexOf(QRegExp(url, Qt::CaseInsensitive, QRegExp::FixedString)) < 0){
|
if (url_list_cleaned.indexOf(QRegExp(url, Qt::CaseInsensitive, QRegExp::FixedString)) < 0) {
|
||||||
url_list_cleaned << url;
|
url_list_cleaned << url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!url_list_cleaned.size()){
|
if (!url_list_cleaned.size()) {
|
||||||
QMessageBox::critical(0, tr("No URL entered"), tr("Please type at least one URL."));
|
QMessageBox::critical(0, tr("No URL entered"), tr("Please type at least one URL."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_cancelButton_clicked(){
|
void on_cancelButton_clicked() {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -133,7 +133,7 @@ void DownloadThread::downloadTorrentUrl(const QString &url) {
|
|||||||
connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(checkDownloadSize(qint64,qint64)));
|
connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(checkDownloadSize(qint64,qint64)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkReply* DownloadThread::downloadUrl(const QString &url){
|
QNetworkReply* DownloadThread::downloadUrl(const QString &url) {
|
||||||
// Update proxy settings
|
// Update proxy settings
|
||||||
applyProxySettings();
|
applyProxySettings();
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
@ -208,7 +208,7 @@ void DownloadThread::applyProxySettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString DownloadThread::errorCodeToString(QNetworkReply::NetworkError status) {
|
QString DownloadThread::errorCodeToString(QNetworkReply::NetworkError status) {
|
||||||
switch(status){
|
switch(status) {
|
||||||
case QNetworkReply::HostNotFoundError:
|
case QNetworkReply::HostNotFoundError:
|
||||||
return tr("The remote host name was not found (invalid hostname)");
|
return tr("The remote host name was not found (invalid hostname)");
|
||||||
case QNetworkReply::OperationCanceledError:
|
case QNetworkReply::OperationCanceledError:
|
||||||
|
14
src/main.cpp
14
src/main.cpp
@ -154,7 +154,7 @@ void sigabrtHandler(int) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Main
|
// Main
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]) {
|
||||||
// Create Application
|
// Create Application
|
||||||
QString uid = misc::getUserIDString();
|
QString uid = misc::getUserIDString();
|
||||||
#ifdef DISABLE_GUI
|
#ifdef DISABLE_GUI
|
||||||
@ -192,19 +192,19 @@ int main(int argc, char *argv[]){
|
|||||||
QString locale = pref.getLocale();
|
QString locale = pref.getLocale();
|
||||||
QTranslator qtTranslator;
|
QTranslator qtTranslator;
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
if (locale.isEmpty()){
|
if (locale.isEmpty()) {
|
||||||
locale = QLocale::system().name();
|
locale = QLocale::system().name();
|
||||||
pref.setLocale(locale);
|
pref.setLocale(locale);
|
||||||
}
|
}
|
||||||
if (qtTranslator.load(
|
if (qtTranslator.load(
|
||||||
QString::fromUtf8("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)
|
QString::fromUtf8("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)
|
||||||
)){
|
)) {
|
||||||
qDebug("Qt %s locale recognized, using translation.", qPrintable(locale));
|
qDebug("Qt %s locale recognized, using translation.", qPrintable(locale));
|
||||||
}else{
|
}else{
|
||||||
qDebug("Qt %s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
qDebug("Qt %s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
||||||
}
|
}
|
||||||
app.installTranslator(&qtTranslator);
|
app.installTranslator(&qtTranslator);
|
||||||
if (translator.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
|
if (translator.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
|
||||||
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
||||||
}else{
|
}else{
|
||||||
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
||||||
@ -221,12 +221,12 @@ int main(int argc, char *argv[]){
|
|||||||
app.setApplicationName(QString::fromUtf8("qBittorrent"));
|
app.setApplicationName(QString::fromUtf8("qBittorrent"));
|
||||||
|
|
||||||
// Check for executable parameters
|
// Check for executable parameters
|
||||||
if (argc > 1){
|
if (argc > 1) {
|
||||||
if (QString::fromLocal8Bit(argv[1]) == QString::fromUtf8("--version")){
|
if (QString::fromLocal8Bit(argv[1]) == QString::fromUtf8("--version")) {
|
||||||
std::cout << "qBittorrent " << VERSION << '\n';
|
std::cout << "qBittorrent " << VERSION << '\n';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (QString::fromLocal8Bit(argv[1]) == QString::fromUtf8("--help")){
|
if (QString::fromLocal8Bit(argv[1]) == QString::fromUtf8("--help")) {
|
||||||
UsageDisplay::displayUsage(argv[0]);
|
UsageDisplay::displayUsage(argv[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -584,7 +584,7 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(const QTorrentHandle &h
|
|||||||
QString torrent_name;
|
QString torrent_name;
|
||||||
try {
|
try {
|
||||||
torrent_name = h.name();
|
torrent_name = h.name();
|
||||||
} catch(invalid_handle&){
|
} catch(invalid_handle&) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QMessageBox confirmBox(QMessageBox::Question, tr("Recursive download confirmation"), tr("The torrent %1 contains torrent files, do you want to proceed with their download?").arg(torrent_name));
|
QMessageBox confirmBox(QMessageBox::Question, tr("Recursive download confirmation"), tr("The torrent %1 contains torrent files, do you want to proceed with their download?").arg(torrent_name));
|
||||||
@ -897,7 +897,7 @@ void MainWindow::dropEvent(QDropEvent *event) {
|
|||||||
|
|
||||||
// Decode if we accept drag 'n drop or not
|
// Decode if we accept drag 'n drop or not
|
||||||
void MainWindow::dragEnterEvent(QDragEnterEvent *event) {
|
void MainWindow::dragEnterEvent(QDragEnterEvent *event) {
|
||||||
foreach (const QString &mime, event->mimeData()->formats()){
|
foreach (const QString &mime, event->mimeData()->formats()) {
|
||||||
qDebug("mimeData: %s", mime.toLocal8Bit().data());
|
qDebug("mimeData: %s", mime.toLocal8Bit().data());
|
||||||
}
|
}
|
||||||
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) {
|
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) {
|
||||||
|
@ -622,7 +622,7 @@ QString misc::friendlyUnit(qreal val) {
|
|||||||
return QString::number(val, 'f', 1) + " " + tr(units[i].source, units[i].comment);
|
return QString::number(val, 'f', 1) + " " + tr(units[i].source, units[i].comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool misc::isPreviewable(QString extension){
|
bool misc::isPreviewable(QString extension) {
|
||||||
if (extension.isEmpty()) return false;
|
if (extension.isEmpty()) return false;
|
||||||
extension = extension.toUpper();
|
extension = extension.toUpper();
|
||||||
if (extension == "AVI") return true;
|
if (extension == "AVI") return true;
|
||||||
@ -911,7 +911,7 @@ QString misc::parseHtmlLinks(const QString &raw_text)
|
|||||||
")"
|
")"
|
||||||
"|"
|
"|"
|
||||||
"(" // case 2b no scheme, no TLD, must have at least 2 aphanum strings plus uncommon TLD string --> del.icio.us
|
"(" // case 2b no scheme, no TLD, must have at least 2 aphanum strings plus uncommon TLD string --> del.icio.us
|
||||||
"([a-zA-Z0-9_-]+\\.){2,}" //2 or more domainpart. --> del.icio.
|
"([a-zA-Z0-9_-]+\\.) {2,}" //2 or more domainpart. --> del.icio.
|
||||||
"[a-zA-Z]{2,}" //one ab (2 char or longer) --> us
|
"[a-zA-Z]{2,}" //one ab (2 char or longer) --> us
|
||||||
"([a-zA-Z0-9\\?%=&/_\\.:#;-]*)" // everything to 1st non-URI char, maybe nothing in case of del.icio.us/path
|
"([a-zA-Z0-9\\?%=&/_\\.:#;-]*)" // everything to 1st non-URI char, maybe nothing in case of del.icio.us/path
|
||||||
")"
|
")"
|
||||||
|
@ -81,8 +81,8 @@ options_imp::options_imp(QWidget *parent):
|
|||||||
hsplitter->setCollapsible(1, false);
|
hsplitter->setCollapsible(1, false);
|
||||||
// Get apply button in button box
|
// Get apply button in button box
|
||||||
QList<QAbstractButton *> buttons = buttonBox->buttons();
|
QList<QAbstractButton *> buttons = buttonBox->buttons();
|
||||||
foreach (QAbstractButton *button, buttons){
|
foreach (QAbstractButton *button, buttons) {
|
||||||
if (buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole){
|
if (buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) {
|
||||||
applyButton = button;
|
applyButton = button;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ options_imp::options_imp(QWidget *parent):
|
|||||||
// Load options
|
// Load options
|
||||||
loadOptions();
|
loadOptions();
|
||||||
// Disable systray integration if it is not supported by the system
|
// Disable systray integration if it is not supported by the system
|
||||||
if (!QSystemTrayIcon::isSystemTrayAvailable()){
|
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
checkShowSystray->setChecked(false);
|
checkShowSystray->setChecked(false);
|
||||||
checkShowSystray->setEnabled(false);
|
checkShowSystray->setEnabled(false);
|
||||||
}
|
}
|
||||||
@ -279,7 +279,7 @@ void options_imp::initializeLanguageCombo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Main destructor
|
// Main destructor
|
||||||
options_imp::~options_imp(){
|
options_imp::~options_imp() {
|
||||||
qDebug("-> destructing Options");
|
qDebug("-> destructing Options");
|
||||||
foreach (const QString &path, addedScanDirs)
|
foreach (const QString &path, addedScanDirs)
|
||||||
ScanFoldersModel::instance()->removePath(path);
|
ScanFoldersModel::instance()->removePath(path);
|
||||||
@ -343,14 +343,14 @@ QSize options_imp::sizeFittingScreen() const {
|
|||||||
return size();
|
return size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::saveOptions(){
|
void options_imp::saveOptions() {
|
||||||
applyButton->setEnabled(false);
|
applyButton->setEnabled(false);
|
||||||
Preferences pref;
|
Preferences pref;
|
||||||
// Load the translation
|
// Load the translation
|
||||||
QString locale = getLocale();
|
QString locale = getLocale();
|
||||||
if (pref.getLocale() != locale) {
|
if (pref.getLocale() != locale) {
|
||||||
QTranslator *translator = new QTranslator;
|
QTranslator *translator = new QTranslator;
|
||||||
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
|
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
|
||||||
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
||||||
}else{
|
}else{
|
||||||
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
||||||
@ -454,7 +454,7 @@ void options_imp::saveOptions(){
|
|||||||
// Misc preferences
|
// Misc preferences
|
||||||
// * IPFilter
|
// * IPFilter
|
||||||
pref.setFilteringEnabled(isFilteringEnabled());
|
pref.setFilteringEnabled(isFilteringEnabled());
|
||||||
if (isFilteringEnabled()){
|
if (isFilteringEnabled()) {
|
||||||
QString filter_path = textFilterPath->text();
|
QString filter_path = textFilterPath->text();
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||||
filter_path.replace("\\", "/");
|
filter_path.replace("\\", "/");
|
||||||
@ -508,12 +508,12 @@ int options_imp::getProxyType() const{
|
|||||||
return Proxy::SOCKS4;
|
return Proxy::SOCKS4;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (isProxyAuthEnabled()){
|
if (isProxyAuthEnabled()) {
|
||||||
return Proxy::SOCKS5_PW;
|
return Proxy::SOCKS5_PW;
|
||||||
}
|
}
|
||||||
return Proxy::SOCKS5;
|
return Proxy::SOCKS5;
|
||||||
case 3:
|
case 3:
|
||||||
if (isProxyAuthEnabled()){
|
if (isProxyAuthEnabled()) {
|
||||||
return Proxy::HTTP_PW;
|
return Proxy::HTTP_PW;
|
||||||
}
|
}
|
||||||
return Proxy::HTTP;
|
return Proxy::HTTP;
|
||||||
@ -522,7 +522,7 @@ int options_imp::getProxyType() const{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::loadOptions(){
|
void options_imp::loadOptions() {
|
||||||
int intValue;
|
int intValue;
|
||||||
qreal floatValue;
|
qreal floatValue;
|
||||||
QString strValue;
|
QString strValue;
|
||||||
@ -812,10 +812,10 @@ bool options_imp::isUPnPEnabled() const{
|
|||||||
// [download,upload]
|
// [download,upload]
|
||||||
QPair<int,int> options_imp::getGlobalBandwidthLimits() const{
|
QPair<int,int> options_imp::getGlobalBandwidthLimits() const{
|
||||||
int DL = -1, UP = -1;
|
int DL = -1, UP = -1;
|
||||||
if (checkDownloadLimit->isChecked()){
|
if (checkDownloadLimit->isChecked()) {
|
||||||
DL = spinDownloadLimit->value();
|
DL = spinDownloadLimit->value();
|
||||||
}
|
}
|
||||||
if (checkUploadLimit->isChecked()){
|
if (checkUploadLimit->isChecked()) {
|
||||||
UP = spinUploadLimit->value();
|
UP = spinUploadLimit->value();
|
||||||
}
|
}
|
||||||
return qMakePair(DL, UP);
|
return qMakePair(DL, UP);
|
||||||
@ -837,7 +837,7 @@ int options_imp::getDHTPort() const {
|
|||||||
|
|
||||||
// Return Share ratio
|
// Return Share ratio
|
||||||
qreal options_imp::getMaxRatio() const{
|
qreal options_imp::getMaxRatio() const{
|
||||||
if (checkMaxRatio->isChecked()){
|
if (checkMaxRatio->isChecked()) {
|
||||||
return spinMaxRatio->value();
|
return spinMaxRatio->value();
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -845,7 +845,7 @@ qreal options_imp::getMaxRatio() const{
|
|||||||
|
|
||||||
// Return Save Path
|
// Return Save Path
|
||||||
QString options_imp::getSavePath() const{
|
QString options_imp::getSavePath() const{
|
||||||
if (textSavePath->text().trimmed().isEmpty()){
|
if (textSavePath->text().trimmed().isEmpty()) {
|
||||||
QString save_path = Preferences().getSavePath();
|
QString save_path = Preferences().getSavePath();
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||||
save_path.replace("/", "\\");
|
save_path.replace("/", "\\");
|
||||||
@ -865,7 +865,7 @@ bool options_imp::isTempPathEnabled() const {
|
|||||||
|
|
||||||
// Return max connections number
|
// Return max connections number
|
||||||
int options_imp::getMaxConnecs() const{
|
int options_imp::getMaxConnecs() const{
|
||||||
if (!checkMaxConnecs->isChecked()){
|
if (!checkMaxConnecs->isChecked()) {
|
||||||
return -1;
|
return -1;
|
||||||
}else{
|
}else{
|
||||||
return spinMaxConnec->value();
|
return spinMaxConnec->value();
|
||||||
@ -873,7 +873,7 @@ int options_imp::getMaxConnecs() const{
|
|||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getMaxConnecsPerTorrent() const{
|
int options_imp::getMaxConnecsPerTorrent() const{
|
||||||
if (!checkMaxConnecsPerTorrent->isChecked()){
|
if (!checkMaxConnecsPerTorrent->isChecked()) {
|
||||||
return -1;
|
return -1;
|
||||||
}else{
|
}else{
|
||||||
return spinMaxConnecPerTorrent->value();
|
return spinMaxConnecPerTorrent->value();
|
||||||
@ -881,15 +881,15 @@ int options_imp::getMaxConnecsPerTorrent() const{
|
|||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getMaxUploadsPerTorrent() const{
|
int options_imp::getMaxUploadsPerTorrent() const{
|
||||||
if (!checkMaxUploadsPerTorrent->isChecked()){
|
if (!checkMaxUploadsPerTorrent->isChecked()) {
|
||||||
return -1;
|
return -1;
|
||||||
}else{
|
}else{
|
||||||
return spinMaxUploadsPerTorrent->value();
|
return spinMaxUploadsPerTorrent->value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_buttonBox_accepted(){
|
void options_imp::on_buttonBox_accepted() {
|
||||||
if (applyButton->isEnabled()){
|
if (applyButton->isEnabled()) {
|
||||||
saveOptions();
|
saveOptions();
|
||||||
applyButton->setEnabled(false);
|
applyButton->setEnabled(false);
|
||||||
this->hide();
|
this->hide();
|
||||||
@ -900,18 +900,18 @@ void options_imp::on_buttonBox_accepted(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::applySettings(QAbstractButton* button) {
|
void options_imp::applySettings(QAbstractButton* button) {
|
||||||
if (button == applyButton){
|
if (button == applyButton) {
|
||||||
saveOptions();
|
saveOptions();
|
||||||
emit status_changed();
|
emit status_changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::closeEvent(QCloseEvent *e){
|
void options_imp::closeEvent(QCloseEvent *e) {
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
e->accept();
|
e->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_buttonBox_rejected(){
|
void options_imp::on_buttonBox_rejected() {
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
@ -920,12 +920,12 @@ bool options_imp::useAdditionDialog() const{
|
|||||||
return checkAdditionDialog->isChecked();
|
return checkAdditionDialog->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableApplyButton(){
|
void options_imp::enableApplyButton() {
|
||||||
applyButton->setEnabled(true);
|
applyButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableProxy(int index){
|
void options_imp::enableProxy(int index) {
|
||||||
if (index){
|
if (index) {
|
||||||
//enable
|
//enable
|
||||||
lblProxyIP->setEnabled(true);
|
lblProxyIP->setEnabled(true);
|
||||||
textProxyIP->setEnabled(true);
|
textProxyIP->setEnabled(true);
|
||||||
@ -1084,7 +1084,7 @@ void options_imp::on_browseExportDirButton_clicked() {
|
|||||||
} else {
|
} else {
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), QDir::homePath());
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), QDir::homePath());
|
||||||
}
|
}
|
||||||
if (!dir.isNull()){
|
if (!dir.isNull()) {
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||||
dir.replace("/", "\\");
|
dir.replace("/", "\\");
|
||||||
#endif
|
#endif
|
||||||
@ -1101,7 +1101,7 @@ void options_imp::on_browseFilterButton_clicked() {
|
|||||||
} else {
|
} else {
|
||||||
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an ip filter file"), QDir::homePath(), tr("Filters")+QString(" (*.dat *.p2p *.p2b)"));
|
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an ip filter file"), QDir::homePath(), tr("Filters")+QString(" (*.dat *.p2p *.p2b)"));
|
||||||
}
|
}
|
||||||
if (!ipfilter.isNull()){
|
if (!ipfilter.isNull()) {
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||||
ipfilter.replace("/", "\\");
|
ipfilter.replace("/", "\\");
|
||||||
#endif
|
#endif
|
||||||
@ -1110,7 +1110,7 @@ void options_imp::on_browseFilterButton_clicked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display dialog to choose save dir
|
// Display dialog to choose save dir
|
||||||
void options_imp::on_browseSaveDirButton_clicked(){
|
void options_imp::on_browseSaveDirButton_clicked() {
|
||||||
const QString save_path = misc::expandPath(textSavePath->text());
|
const QString save_path = misc::expandPath(textSavePath->text());
|
||||||
QDir saveDir(save_path);
|
QDir saveDir(save_path);
|
||||||
QString dir;
|
QString dir;
|
||||||
@ -1119,7 +1119,7 @@ void options_imp::on_browseSaveDirButton_clicked(){
|
|||||||
} else {
|
} else {
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||||
}
|
}
|
||||||
if (!dir.isNull()){
|
if (!dir.isNull()) {
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||||
dir.replace("/", "\\");
|
dir.replace("/", "\\");
|
||||||
#endif
|
#endif
|
||||||
@ -1127,7 +1127,7 @@ void options_imp::on_browseSaveDirButton_clicked(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_browseTempDirButton_clicked(){
|
void options_imp::on_browseTempDirButton_clicked() {
|
||||||
const QString temp_path = misc::expandPath(textTempPath->text());
|
const QString temp_path = misc::expandPath(textTempPath->text());
|
||||||
QDir tempDir(temp_path);
|
QDir tempDir(temp_path);
|
||||||
QString dir;
|
QString dir;
|
||||||
@ -1136,7 +1136,7 @@ void options_imp::on_browseTempDirButton_clicked(){
|
|||||||
} else {
|
} else {
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||||
}
|
}
|
||||||
if (!dir.isNull()){
|
if (!dir.isNull()) {
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||||
dir.replace("/", "\\");
|
dir.replace("/", "\\");
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,15 +45,15 @@ class PreviewListDelegate: public QItemDelegate {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PreviewListDelegate(QObject *parent=0) : QItemDelegate(parent){}
|
PreviewListDelegate(QObject *parent=0) : QItemDelegate(parent) {}
|
||||||
|
|
||||||
~PreviewListDelegate(){}
|
~PreviewListDelegate() {}
|
||||||
|
|
||||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||||
painter->save();
|
painter->save();
|
||||||
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
||||||
|
|
||||||
switch(index.column()){
|
switch(index.column()) {
|
||||||
case PreviewSelect::SIZE:
|
case PreviewSelect::SIZE:
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include "previewlistdelegate.h"
|
#include "previewlistdelegate.h"
|
||||||
#include "previewselect.h"
|
#include "previewselect.h"
|
||||||
|
|
||||||
PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent), h(h){
|
PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent), h(h) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
// Preview list
|
// Preview list
|
||||||
@ -56,7 +56,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent)
|
|||||||
std::vector<libtorrent::size_type> fp;
|
std::vector<libtorrent::size_type> fp;
|
||||||
h.file_progress(fp);
|
h.file_progress(fp);
|
||||||
unsigned int nbFiles = h.num_files();
|
unsigned int nbFiles = h.num_files();
|
||||||
for (unsigned int i=0; i<nbFiles; ++i){
|
for (unsigned int i=0; i<nbFiles; ++i) {
|
||||||
QString fileName = h.filename_at(i);
|
QString fileName = h.filename_at(i);
|
||||||
QString extension = fileName.split(QString::fromUtf8(".")).last().toUpper();
|
QString extension = fileName.split(QString::fromUtf8(".")).last().toUpper();
|
||||||
if (misc::isPreviewable(extension)) {
|
if (misc::isPreviewable(extension)) {
|
||||||
@ -71,12 +71,12 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent)
|
|||||||
previewList->selectionModel()->select(previewListModel->index(0, NAME), QItemSelectionModel::Select);
|
previewList->selectionModel()->select(previewListModel->index(0, NAME), QItemSelectionModel::Select);
|
||||||
previewList->selectionModel()->select(previewListModel->index(0, SIZE), QItemSelectionModel::Select);
|
previewList->selectionModel()->select(previewListModel->index(0, SIZE), QItemSelectionModel::Select);
|
||||||
previewList->selectionModel()->select(previewListModel->index(0, PROGRESS), QItemSelectionModel::Select);
|
previewList->selectionModel()->select(previewListModel->index(0, PROGRESS), QItemSelectionModel::Select);
|
||||||
if (!previewListModel->rowCount()){
|
if (!previewListModel->rowCount()) {
|
||||||
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString)));
|
connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString)));
|
||||||
if (previewListModel->rowCount() == 1){
|
if (previewListModel->rowCount() == 1) {
|
||||||
qDebug("Torrent file only contains one file, no need to display selection dialog before preview");
|
qDebug("Torrent file only contains one file, no need to display selection dialog before preview");
|
||||||
// Only one file : no choice
|
// Only one file : no choice
|
||||||
on_previewButton_clicked();
|
on_previewButton_clicked();
|
||||||
@ -86,13 +86,13 @@ PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PreviewSelect::~PreviewSelect(){
|
PreviewSelect::~PreviewSelect() {
|
||||||
delete previewListModel;
|
delete previewListModel;
|
||||||
delete listDelegate;
|
delete listDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PreviewSelect::on_previewButton_clicked(){
|
void PreviewSelect::on_previewButton_clicked() {
|
||||||
QModelIndex index;
|
QModelIndex index;
|
||||||
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(NAME);
|
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(NAME);
|
||||||
if (selectedIndexes.size() == 0) return;
|
if (selectedIndexes.size() == 0) return;
|
||||||
@ -100,10 +100,10 @@ void PreviewSelect::on_previewButton_clicked(){
|
|||||||
h.flush_cache();
|
h.flush_cache();
|
||||||
|
|
||||||
QString path;
|
QString path;
|
||||||
foreach (index, selectedIndexes){
|
foreach (index, selectedIndexes) {
|
||||||
path = h.absolute_files_path().at(indexes.at(index.row()));
|
path = h.absolute_files_path().at(indexes.at(index.row()));
|
||||||
// File
|
// File
|
||||||
if (QFile::exists(path)){
|
if (QFile::exists(path)) {
|
||||||
emit readyToPreviewFile(path);
|
emit readyToPreviewFile(path);
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
||||||
@ -116,6 +116,6 @@ void PreviewSelect::on_previewButton_clicked(){
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewSelect::on_cancelButton_clicked(){
|
void PreviewSelect::on_cancelButton_clicked() {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public:
|
|||||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(validateInput()));
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(validateInput()));
|
||||||
}
|
}
|
||||||
|
|
||||||
~PeerAdditionDlg(){}
|
~PeerAdditionDlg() {}
|
||||||
|
|
||||||
QString getIP() const {
|
QString getIP() const {
|
||||||
QHostAddress ip(lineIP->text());
|
QHostAddress ip(lineIP->text());
|
||||||
|
@ -43,14 +43,14 @@ public:
|
|||||||
TOT_DOWN, TOT_UP, IP_HIDDEN, COL_COUNT};
|
TOT_DOWN, TOT_UP, IP_HIDDEN, COL_COUNT};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PeerListDelegate(QObject *parent) : QItemDelegate(parent){}
|
PeerListDelegate(QObject *parent) : QItemDelegate(parent) {}
|
||||||
|
|
||||||
~PeerListDelegate(){}
|
~PeerListDelegate() {}
|
||||||
|
|
||||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||||
painter->save();
|
painter->save();
|
||||||
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
||||||
switch(index.column()){
|
switch(index.column()) {
|
||||||
case TOT_DOWN:
|
case TOT_DOWN:
|
||||||
case TOT_UP:
|
case TOT_UP:
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
|
@ -400,12 +400,12 @@ void PropertiesWidget::loadDynamicData() {
|
|||||||
} catch(invalid_handle e) {}
|
} catch(invalid_handle e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::loadUrlSeeds(){
|
void PropertiesWidget::loadUrlSeeds() {
|
||||||
listWebSeeds->clear();
|
listWebSeeds->clear();
|
||||||
qDebug("Loading URL seeds");
|
qDebug("Loading URL seeds");
|
||||||
const QStringList hc_seeds = h.url_seeds();
|
const QStringList hc_seeds = h.url_seeds();
|
||||||
// Add url seeds
|
// Add url seeds
|
||||||
foreach (const QString &hc_seed, hc_seeds){
|
foreach (const QString &hc_seed, hc_seeds) {
|
||||||
qDebug("Loading URL seed: %s", qPrintable(hc_seed));
|
qDebug("Loading URL seed: %s", qPrintable(hc_seed));
|
||||||
new QListWidgetItem(hc_seed, listWebSeeds);
|
new QListWidgetItem(hc_seed, listWebSeeds);
|
||||||
}
|
}
|
||||||
@ -450,7 +450,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::displayFilesListMenu(const QPoint&){
|
void PropertiesWidget::displayFilesListMenu(const QPoint&) {
|
||||||
QMenu myFilesLlistMenu;
|
QMenu myFilesLlistMenu;
|
||||||
QModelIndexList selectedRows = filesList->selectionModel()->selectedRows(0);
|
QModelIndexList selectedRows = filesList->selectionModel()->selectedRows(0);
|
||||||
QAction *actRename = 0;
|
QAction *actRename = 0;
|
||||||
@ -616,7 +616,7 @@ void PropertiesWidget::renameSelectedFile() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::askWebSeed(){
|
void PropertiesWidget::askWebSeed() {
|
||||||
bool ok;
|
bool ok;
|
||||||
// Ask user for a new url seed
|
// Ask user for a new url seed
|
||||||
const QString url_seed = QInputDialog::getText(this, tr("New url seed", "New HTTP source"),
|
const QString url_seed = QInputDialog::getText(this, tr("New url seed", "New HTTP source"),
|
||||||
@ -635,15 +635,15 @@ void PropertiesWidget::askWebSeed(){
|
|||||||
loadUrlSeeds();
|
loadUrlSeeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::deleteSelectedUrlSeeds(){
|
void PropertiesWidget::deleteSelectedUrlSeeds() {
|
||||||
const QList<QListWidgetItem *> selectedItems = listWebSeeds->selectedItems();
|
const QList<QListWidgetItem *> selectedItems = listWebSeeds->selectedItems();
|
||||||
bool change = false;
|
bool change = false;
|
||||||
foreach (const QListWidgetItem *item, selectedItems){
|
foreach (const QListWidgetItem *item, selectedItems) {
|
||||||
QString url_seed = item->text();
|
QString url_seed = item->text();
|
||||||
h.remove_url_seed(url_seed);
|
h.remove_url_seed(url_seed);
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
if (change){
|
if (change) {
|
||||||
// Refresh list
|
// Refresh list
|
||||||
loadUrlSeeds();
|
loadUrlSeeds();
|
||||||
}
|
}
|
||||||
@ -674,7 +674,7 @@ void PropertiesWidget::on_changeSavePathButton_clicked() {
|
|||||||
new_path = QFileDialog::getExistingDirectory(this, tr("Choose save path"), saveDir.absolutePath(),
|
new_path = QFileDialog::getExistingDirectory(this, tr("Choose save path"), saveDir.absolutePath(),
|
||||||
QFileDialog::DontConfirmOverwrite|QFileDialog::ShowDirsOnly|QFileDialog::HideNameFilterDetails);
|
QFileDialog::DontConfirmOverwrite|QFileDialog::ShowDirsOnly|QFileDialog::HideNameFilterDetails);
|
||||||
}
|
}
|
||||||
if (!new_path.isEmpty()){
|
if (!new_path.isEmpty()) {
|
||||||
// Check if savePath exists
|
// Check if savePath exists
|
||||||
QString save_path_dir = new_path.replace("\\", "/");
|
QString save_path_dir = new_path.replace("\\", "/");
|
||||||
QString new_file_name;
|
QString new_file_name;
|
||||||
|
@ -60,15 +60,15 @@ signals:
|
|||||||
void filteredFilesChanged() const;
|
void filteredFilesChanged() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PropListDelegate(PropertiesWidget* properties=0, QObject *parent=0) : QItemDelegate(parent), properties(properties){
|
PropListDelegate(PropertiesWidget* properties=0, QObject *parent=0) : QItemDelegate(parent), properties(properties) {
|
||||||
}
|
}
|
||||||
|
|
||||||
~PropListDelegate(){}
|
~PropListDelegate() {}
|
||||||
|
|
||||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||||
painter->save();
|
painter->save();
|
||||||
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
||||||
switch(index.column()){
|
switch(index.column()) {
|
||||||
case PCSIZE:
|
case PCSIZE:
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
||||||
|
@ -108,7 +108,7 @@ void TrackerList::moveSelectionUp() {
|
|||||||
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
|
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
|
||||||
if (selected_items.isEmpty()) return;
|
if (selected_items.isEmpty()) return;
|
||||||
bool change = false;
|
bool change = false;
|
||||||
foreach (QTreeWidgetItem *item, selected_items){
|
foreach (QTreeWidgetItem *item, selected_items) {
|
||||||
int index = indexOfTopLevelItem(item);
|
int index = indexOfTopLevelItem(item);
|
||||||
if (index > NB_STICKY_ITEM) {
|
if (index > NB_STICKY_ITEM) {
|
||||||
insertTopLevelItem(index-1, takeTopLevelItem(index));
|
insertTopLevelItem(index-1, takeTopLevelItem(index));
|
||||||
@ -273,7 +273,7 @@ void TrackerList::loadTrackers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ask the user for new trackers and add them to the torrent
|
// Ask the user for new trackers and add them to the torrent
|
||||||
void TrackerList::askForTrackers(){
|
void TrackerList::askForTrackers() {
|
||||||
QTorrentHandle h = properties->getCurrentTorrent();
|
QTorrentHandle h = properties->getCurrentTorrent();
|
||||||
if (!h.is_valid()) return;
|
if (!h.is_valid()) return;
|
||||||
QStringList trackers = TrackersAdditionDlg::askForTrackers(h);
|
QStringList trackers = TrackersAdditionDlg::askForTrackers(h);
|
||||||
@ -291,7 +291,7 @@ void TrackerList::askForTrackers(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackerList::deleteSelectedTrackers(){
|
void TrackerList::deleteSelectedTrackers() {
|
||||||
QTorrentHandle h = properties->getCurrentTorrent();
|
QTorrentHandle h = properties->getCurrentTorrent();
|
||||||
if (!h.is_valid()) {
|
if (!h.is_valid()) {
|
||||||
clear();
|
clear();
|
||||||
@ -300,7 +300,7 @@ void TrackerList::deleteSelectedTrackers(){
|
|||||||
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
|
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
|
||||||
if (selected_items.isEmpty()) return;
|
if (selected_items.isEmpty()) return;
|
||||||
QStringList urls_to_remove;
|
QStringList urls_to_remove;
|
||||||
foreach (QTreeWidgetItem *item, selected_items){
|
foreach (QTreeWidgetItem *item, selected_items) {
|
||||||
QString tracker_url = item->data(COL_URL, Qt::DisplayRole).toString();
|
QString tracker_url = item->data(COL_URL, Qt::DisplayRole).toString();
|
||||||
urls_to_remove << tracker_url;
|
urls_to_remove << tracker_url;
|
||||||
tracker_items.remove(tracker_url);
|
tracker_items.remove(tracker_url);
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
list_url->setCursorPosition(0);
|
list_url->setCursorPosition(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
~TrackersAdditionDlg(){}
|
~TrackersAdditionDlg() {}
|
||||||
|
|
||||||
QStringList newTrackers() const {
|
QStringList newTrackers() const {
|
||||||
return trackers_list->toPlainText().trimmed().split("\n");
|
return trackers_list->toPlainText().trimmed().split("\n");
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~FilterParserThread(){
|
~FilterParserThread() {
|
||||||
abort = true;
|
abort = true;
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
@ -68,8 +68,8 @@ public:
|
|||||||
int parseDATFilterFile(QString filePath) {
|
int parseDATFilterFile(QString filePath) {
|
||||||
int ruleCount = 0;
|
int ruleCount = 0;
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
if (file.exists()){
|
if (file.exists()) {
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
std::cerr << "I/O Error: Could not open ip filer file in read mode." << std::endl;
|
std::cerr << "I/O Error: Could not open ip filer file in read mode." << std::endl;
|
||||||
return ruleCount;
|
return ruleCount;
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ public:
|
|||||||
try {
|
try {
|
||||||
filter.add_rule(startAddr, endAddr, libtorrent::ip_filter::blocked);
|
filter.add_rule(startAddr, endAddr, libtorrent::ip_filter::blocked);
|
||||||
++ruleCount;
|
++ruleCount;
|
||||||
}catch(exception){
|
}catch(exception) {
|
||||||
qDebug("Bad line in filter file, avoided crash...");
|
qDebug("Bad line in filter file, avoided crash...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,8 +154,8 @@ public:
|
|||||||
int parseP2PFilterFile(QString filePath) {
|
int parseP2PFilterFile(QString filePath) {
|
||||||
int ruleCount = 0;
|
int ruleCount = 0;
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
if (file.exists()){
|
if (file.exists()) {
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
std::cerr << "I/O Error: Could not open ip filer file in read mode." << std::endl;
|
std::cerr << "I/O Error: Could not open ip filer file in read mode." << std::endl;
|
||||||
return ruleCount;
|
return ruleCount;
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ public:
|
|||||||
if (line.startsWith('#') || line.startsWith("//")) continue;
|
if (line.startsWith('#') || line.startsWith("//")) continue;
|
||||||
// Line is splitted by :
|
// Line is splitted by :
|
||||||
QList<QByteArray> partsList = line.split(':');
|
QList<QByteArray> partsList = line.split(':');
|
||||||
if (partsList.size() < 2){
|
if (partsList.size() < 2) {
|
||||||
qDebug("p2p file: line %d is malformed.", nbLine);
|
qDebug("p2p file: line %d is malformed.", nbLine);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -246,8 +246,8 @@ public:
|
|||||||
int parseP2BFilterFile(QString filePath) {
|
int parseP2BFilterFile(QString filePath) {
|
||||||
int ruleCount = 0;
|
int ruleCount = 0;
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
if (file.exists()){
|
if (file.exists()) {
|
||||||
if (!file.open(QIODevice::ReadOnly)){
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
std::cerr << "I/O Error: Could not open ip filer file in read mode." << std::endl;
|
std::cerr << "I/O Error: Could not open ip filer file in read mode." << std::endl;
|
||||||
return ruleCount;
|
return ruleCount;
|
||||||
}
|
}
|
||||||
@ -351,7 +351,7 @@ public:
|
|||||||
// * eMule IP list (DAT): http://wiki.phoenixlabs.org/wiki/DAT_Format
|
// * eMule IP list (DAT): http://wiki.phoenixlabs.org/wiki/DAT_Format
|
||||||
// * PeerGuardian Text (P2P): http://wiki.phoenixlabs.org/wiki/P2P_Format
|
// * PeerGuardian Text (P2P): http://wiki.phoenixlabs.org/wiki/P2P_Format
|
||||||
// * PeerGuardian Binary (P2B): http://wiki.phoenixlabs.org/wiki/P2B_Format
|
// * PeerGuardian Binary (P2B): http://wiki.phoenixlabs.org/wiki/P2B_Format
|
||||||
void processFilterFile(QString _filePath){
|
void processFilterFile(QString _filePath) {
|
||||||
// First, import current filter
|
// First, import current filter
|
||||||
filter = s->get_ip_filter();
|
filter = s->get_ip_filter();
|
||||||
if (isRunning()) {
|
if (isRunning()) {
|
||||||
@ -392,7 +392,7 @@ protected:
|
|||||||
return ip.toString();
|
return ip.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(){
|
void run() {
|
||||||
qDebug("Processing filter file");
|
qDebug("Processing filter file");
|
||||||
int ruleCount = 0;
|
int ruleCount = 0;
|
||||||
if (filePath.endsWith(".p2p", Qt::CaseInsensitive)) {
|
if (filePath.endsWith(".p2p", Qt::CaseInsensitive)) {
|
||||||
@ -412,7 +412,7 @@ protected:
|
|||||||
try {
|
try {
|
||||||
s->set_ip_filter(filter);
|
s->set_ip_filter(filter);
|
||||||
emit IPFilterParsed(ruleCount);
|
emit IPFilterParsed(ruleCount);
|
||||||
} catch(std::exception&){
|
} catch(std::exception&) {
|
||||||
emit IPFilterError();
|
emit IPFilterError();
|
||||||
}
|
}
|
||||||
qDebug("IP Filter thread: finished parsing, filter applied");
|
qDebug("IP Filter thread: finished parsing, filter applied");
|
||||||
|
@ -922,7 +922,7 @@ QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed) {
|
|||||||
// Adding torrent to Bittorrent session
|
// Adding torrent to Bittorrent session
|
||||||
try {
|
try {
|
||||||
h = QTorrentHandle(add_magnet_uri(*s, magnet_uri.toStdString(), p));
|
h = QTorrentHandle(add_magnet_uri(*s, magnet_uri.toStdString(), p));
|
||||||
}catch(std::exception e){
|
}catch(std::exception e) {
|
||||||
qDebug("Error: %s", e.what());
|
qDebug("Error: %s", e.what());
|
||||||
}
|
}
|
||||||
// Check if it worked
|
// Check if it worked
|
||||||
@ -1114,7 +1114,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
|
|||||||
// Adding torrent to Bittorrent session
|
// Adding torrent to Bittorrent session
|
||||||
try {
|
try {
|
||||||
h = QTorrentHandle(s->add_torrent(p));
|
h = QTorrentHandle(s->add_torrent(p));
|
||||||
}catch(std::exception e){
|
}catch(std::exception e) {
|
||||||
qDebug("Error: %s", e.what());
|
qDebug("Error: %s", e.what());
|
||||||
}
|
}
|
||||||
// Check if it worked
|
// Check if it worked
|
||||||
@ -1585,7 +1585,7 @@ void QBtSession::saveTempFastResumeData() {
|
|||||||
if (h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking) continue;
|
if (h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking) continue;
|
||||||
qDebug("Saving fastresume data for %s", qPrintable(h.name()));
|
qDebug("Saving fastresume data for %s", qPrintable(h.name()));
|
||||||
h.save_resume_data();
|
h.save_resume_data();
|
||||||
}catch(std::exception e){}
|
}catch(std::exception e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1630,7 +1630,7 @@ void QBtSession::saveFastResumeData() {
|
|||||||
// Remove torrent from session
|
// Remove torrent from session
|
||||||
if (rda->handle.is_valid())
|
if (rda->handle.is_valid())
|
||||||
s->remove_torrent(rda->handle);
|
s->remove_torrent(rda->handle);
|
||||||
}catch(libtorrent::libtorrent_exception){}
|
}catch(libtorrent::libtorrent_exception) {}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
save_resume_data_alert const* rd = dynamic_cast<save_resume_data_alert const*>(a);
|
save_resume_data_alert const* rd = dynamic_cast<save_resume_data_alert const*>(a);
|
||||||
@ -1659,7 +1659,7 @@ void QBtSession::saveFastResumeData() {
|
|||||||
// Remove torrent from session
|
// Remove torrent from session
|
||||||
s->remove_torrent(rd->handle);
|
s->remove_torrent(rd->handle);
|
||||||
s->pop_alert();
|
s->pop_alert();
|
||||||
} catch(libtorrent::invalid_handle&){}
|
} catch(libtorrent::invalid_handle&) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2405,7 +2405,7 @@ void QBtSession::readAlerts() {
|
|||||||
else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) {
|
else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) {
|
||||||
// Level: fatal
|
// Level: fatal
|
||||||
QTorrentHandle h(p->handle);
|
QTorrentHandle h(p->handle);
|
||||||
if (h.is_valid()){
|
if (h.is_valid()) {
|
||||||
// Authentication
|
// Authentication
|
||||||
if (p->status_code != 401) {
|
if (p->status_code != 401) {
|
||||||
qDebug("Received a tracker error for %s: %s", p->url.c_str(), p->msg.c_str());
|
qDebug("Received a tracker error for %s: %s", p->url.c_str(), p->msg.c_str());
|
||||||
@ -2422,7 +2422,7 @@ void QBtSession::readAlerts() {
|
|||||||
}
|
}
|
||||||
else if (tracker_reply_alert* p = dynamic_cast<tracker_reply_alert*>(a.get())) {
|
else if (tracker_reply_alert* p = dynamic_cast<tracker_reply_alert*>(a.get())) {
|
||||||
const QTorrentHandle h(p->handle);
|
const QTorrentHandle h(p->handle);
|
||||||
if (h.is_valid()){
|
if (h.is_valid()) {
|
||||||
qDebug("Received a tracker reply from %s (Num_peers=%d)", p->url.c_str(), p->num_peers);
|
qDebug("Received a tracker reply from %s (Num_peers=%d)", p->url.c_str(), p->num_peers);
|
||||||
// Connection was successful now. Remove possible old errors
|
// Connection was successful now. Remove possible old errors
|
||||||
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
|
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
|
||||||
@ -2435,7 +2435,7 @@ void QBtSession::readAlerts() {
|
|||||||
}
|
}
|
||||||
} else if (tracker_warning_alert* p = dynamic_cast<tracker_warning_alert*>(a.get())) {
|
} else if (tracker_warning_alert* p = dynamic_cast<tracker_warning_alert*>(a.get())) {
|
||||||
const QTorrentHandle h(p->handle);
|
const QTorrentHandle h(p->handle);
|
||||||
if (h.is_valid()){
|
if (h.is_valid()) {
|
||||||
// Connection was successful now but there is a warning message
|
// Connection was successful now but there is a warning message
|
||||||
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
|
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
|
||||||
const QString tracker_url = misc::toQString(p->url);
|
const QString tracker_url = misc::toQString(p->url);
|
||||||
@ -2504,7 +2504,7 @@ void QBtSession::readAlerts() {
|
|||||||
}
|
}
|
||||||
else if (torrent_checked_alert* p = dynamic_cast<torrent_checked_alert*>(a.get())) {
|
else if (torrent_checked_alert* p = dynamic_cast<torrent_checked_alert*>(a.get())) {
|
||||||
QTorrentHandle h(p->handle);
|
QTorrentHandle h(p->handle);
|
||||||
if (h.is_valid()){
|
if (h.is_valid()) {
|
||||||
const QString hash = h.hash();
|
const QString hash = h.hash();
|
||||||
qDebug("%s have just finished checking", qPrintable(hash));
|
qDebug("%s have just finished checking", qPrintable(hash));
|
||||||
// Save seed status
|
// Save seed status
|
||||||
|
@ -41,7 +41,7 @@ using namespace libtorrent;
|
|||||||
class SpeedSample {
|
class SpeedSample {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpeedSample(){}
|
SpeedSample() {}
|
||||||
void addSample(int s);
|
void addSample(int s);
|
||||||
qreal average() const;
|
qreal average() const;
|
||||||
void clear();
|
void clear();
|
||||||
@ -106,7 +106,7 @@ void TorrentSpeedMonitor::removeSamples(const QString &hash)
|
|||||||
void TorrentSpeedMonitor::removeSamples(const QTorrentHandle& h) {
|
void TorrentSpeedMonitor::removeSamples(const QTorrentHandle& h) {
|
||||||
try {
|
try {
|
||||||
m_samples.remove(h.hash());
|
m_samples.remove(h.hash());
|
||||||
} catch(invalid_handle&){}
|
} catch(invalid_handle&) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const
|
qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const
|
||||||
@ -133,6 +133,6 @@ void TorrentSpeedMonitor::getSamples()
|
|||||||
if (!it->is_paused())
|
if (!it->is_paused())
|
||||||
m_samples[misc::toQString(it->info_hash())].addSample(it->status().download_payload_rate);
|
m_samples[misc::toQString(it->info_hash())].addSample(it->status().download_payload_rate);
|
||||||
#endif
|
#endif
|
||||||
} catch(invalid_handle&){}
|
} catch(invalid_handle&) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ enum ArticleRoles {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// display a right-click menu
|
// display a right-click menu
|
||||||
void RSSImp::displayRSSListMenu(const QPoint& pos){
|
void RSSImp::displayRSSListMenu(const QPoint& pos) {
|
||||||
if (!m_feedList->indexAt(pos).isValid()) {
|
if (!m_feedList->indexAt(pos).isValid()) {
|
||||||
// No item under the mouse, clear selection
|
// No item under the mouse, clear selection
|
||||||
m_feedList->clearSelection();
|
m_feedList->clearSelection();
|
||||||
@ -99,7 +99,7 @@ void RSSImp::displayRSSListMenu(const QPoint& pos){
|
|||||||
myRSSListMenu.exec(QCursor::pos());
|
myRSSListMenu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSSImp::displayItemsListMenu(const QPoint&){
|
void RSSImp::displayItemsListMenu(const QPoint&) {
|
||||||
QMenu myItemListMenu(this);
|
QMenu myItemListMenu(this);
|
||||||
QList<QListWidgetItem*> selectedItems = listArticles->selectedItems();
|
QList<QListWidgetItem*> selectedItems = listArticles->selectedItems();
|
||||||
if (selectedItems.size() > 0) {
|
if (selectedItems.size() > 0) {
|
||||||
@ -203,7 +203,7 @@ void RSSImp::on_newFeedButton_clicked() {
|
|||||||
QString newUrl = QInputDialog::getText(this, tr("Please type a rss stream url"), tr("Stream URL:"), QLineEdit::Normal, default_url, &ok);
|
QString newUrl = QInputDialog::getText(this, tr("Please type a rss stream url"), tr("Stream URL:"), QLineEdit::Normal, default_url, &ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
newUrl = newUrl.trimmed();
|
newUrl = newUrl.trimmed();
|
||||||
if (!newUrl.isEmpty()){
|
if (!newUrl.isEmpty()) {
|
||||||
if (m_feedList->hasFeed(newUrl)) {
|
if (m_feedList->hasFeed(newUrl)) {
|
||||||
QMessageBox::warning(this, tr("qBittorrent"),
|
QMessageBox::warning(this, tr("qBittorrent"),
|
||||||
tr("This rss feed is already in the list."),
|
tr("This rss feed is already in the list."),
|
||||||
@ -242,8 +242,8 @@ void RSSImp::deleteSelectedItems() {
|
|||||||
tr("&Yes"), tr("&No"),
|
tr("&Yes"), tr("&No"),
|
||||||
QString(), 0, 1);
|
QString(), 0, 1);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
foreach (QTreeWidgetItem *item, selectedItems){
|
foreach (QTreeWidgetItem *item, selectedItems) {
|
||||||
if (m_feedList->currentFeed() == item){
|
if (m_feedList->currentFeed() == item) {
|
||||||
textBrowser->clear();
|
textBrowser->clear();
|
||||||
m_currentArticle = 0;
|
m_currentArticle = 0;
|
||||||
listArticles->clear();
|
listArticles->clear();
|
||||||
@ -374,7 +374,7 @@ void RSSImp::renameFiles() {
|
|||||||
//right-click on stream : refresh it
|
//right-click on stream : refresh it
|
||||||
void RSSImp::refreshSelectedItems() {
|
void RSSImp::refreshSelectedItems() {
|
||||||
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems();
|
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems();
|
||||||
foreach (QTreeWidgetItem* item, selectedItems){
|
foreach (QTreeWidgetItem* item, selectedItems) {
|
||||||
RssFilePtr file = m_feedList->getRSSItem(item);
|
RssFilePtr file = m_feedList->getRSSItem(item);
|
||||||
// Update icons
|
// Update icons
|
||||||
if (item == m_feedList->stickyUnreadItem()) {
|
if (item == m_feedList->stickyUnreadItem()) {
|
||||||
@ -402,7 +402,7 @@ void RSSImp::copySelectedFeedsURL() {
|
|||||||
QStringList URLs;
|
QStringList URLs;
|
||||||
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems();
|
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems();
|
||||||
QTreeWidgetItem* item;
|
QTreeWidgetItem* item;
|
||||||
foreach (item, selectedItems){
|
foreach (item, selectedItems) {
|
||||||
if (m_feedList->isFeed(item))
|
if (m_feedList->isFeed(item))
|
||||||
URLs << m_feedList->getItemID(item);
|
URLs << m_feedList->getItemID(item);
|
||||||
}
|
}
|
||||||
@ -412,7 +412,7 @@ void RSSImp::copySelectedFeedsURL() {
|
|||||||
void RSSImp::on_markReadButton_clicked() {
|
void RSSImp::on_markReadButton_clicked() {
|
||||||
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems();
|
QList<QTreeWidgetItem*> selectedItems = m_feedList->selectedItems();
|
||||||
QTreeWidgetItem* item;
|
QTreeWidgetItem* item;
|
||||||
foreach (item, selectedItems){
|
foreach (item, selectedItems) {
|
||||||
RssFilePtr rss_item = m_feedList->getRSSItem(item);
|
RssFilePtr rss_item = m_feedList->getRSSItem(item);
|
||||||
rss_item->markAsRead();
|
rss_item->markAsRead();
|
||||||
updateItemInfos(item);
|
updateItemInfos(item);
|
||||||
@ -428,7 +428,7 @@ void RSSImp::fillFeedsList(QTreeWidgetItem *parent, const RssFolderPtr& rss_pare
|
|||||||
} else {
|
} else {
|
||||||
children = m_rssManager->getContent();
|
children = m_rssManager->getContent();
|
||||||
}
|
}
|
||||||
foreach (const RssFilePtr& rss_child, children){
|
foreach (const RssFilePtr& rss_child, children) {
|
||||||
QTreeWidgetItem* item;
|
QTreeWidgetItem* item;
|
||||||
if (!parent)
|
if (!parent)
|
||||||
item = new QTreeWidgetItem(m_feedList);
|
item = new QTreeWidgetItem(m_feedList);
|
||||||
@ -471,12 +471,12 @@ void RSSImp::refreshArticleList(QTreeWidgetItem* item) {
|
|||||||
m_currentArticle = 0;
|
m_currentArticle = 0;
|
||||||
listArticles->clear();
|
listArticles->clear();
|
||||||
qDebug("Got the list of news");
|
qDebug("Got the list of news");
|
||||||
foreach (const RssArticlePtr &article, news){
|
foreach (const RssArticlePtr &article, news) {
|
||||||
QListWidgetItem* it = new QListWidgetItem(listArticles);
|
QListWidgetItem* it = new QListWidgetItem(listArticles);
|
||||||
it->setData(Article::TitleRole, article->title());
|
it->setData(Article::TitleRole, article->title());
|
||||||
it->setData(Article::FeedUrlRole, article->parent()->url());
|
it->setData(Article::FeedUrlRole, article->parent()->url());
|
||||||
it->setData(Article::IdRole, article->guid());
|
it->setData(Article::IdRole, article->guid());
|
||||||
if (article->isRead()){
|
if (article->isRead()) {
|
||||||
it->setData(Article::ColorRole, QVariant(QColor("grey")));
|
it->setData(Article::ColorRole, QVariant(QColor("grey")));
|
||||||
it->setData(Article::IconRole, QVariant(QIcon(":/Icons/sphere.png")));
|
it->setData(Article::IconRole, QVariant(QIcon(":/Icons/sphere.png")));
|
||||||
}else{
|
}else{
|
||||||
@ -571,12 +571,12 @@ void RSSImp::updateItemInfos(QTreeWidgetItem *item) {
|
|||||||
updateItemInfos(item->parent());
|
updateItemInfos(item->parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSSImp::updateFeedIcon(const QString &url, const QString &icon_path){
|
void RSSImp::updateFeedIcon(const QString &url, const QString &icon_path) {
|
||||||
QTreeWidgetItem *item = m_feedList->getTreeItemFromUrl(url);
|
QTreeWidgetItem *item = m_feedList->getTreeItemFromUrl(url);
|
||||||
item->setData(0,Qt::DecorationRole, QVariant(QIcon(icon_path)));
|
item->setData(0,Qt::DecorationRole, QVariant(QIcon(icon_path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSSImp::updateFeedInfos(const QString &url, const QString &display_name, uint nbUnread){
|
void RSSImp::updateFeedInfos(const QString &url, const QString &display_name, uint nbUnread) {
|
||||||
qDebug() << Q_FUNC_INFO << display_name;
|
qDebug() << Q_FUNC_INFO << display_name;
|
||||||
QTreeWidgetItem *item = m_feedList->getTreeItemFromUrl(url);
|
QTreeWidgetItem *item = m_feedList->getTreeItemFromUrl(url);
|
||||||
RssFeedPtr stream = qSharedPointerCast<RssFeed>(m_feedList->getRSSItem(item));
|
RssFeedPtr stream = qSharedPointerCast<RssFeed>(m_feedList->getRSSItem(item));
|
||||||
@ -589,7 +589,7 @@ void RSSImp::updateFeedInfos(const QString &url, const QString &display_name, ui
|
|||||||
// Update Unread item
|
// Update Unread item
|
||||||
updateItemInfos(m_feedList->stickyUnreadItem());
|
updateItemInfos(m_feedList->stickyUnreadItem());
|
||||||
// If the feed is selected, update the displayed news
|
// If the feed is selected, update the displayed news
|
||||||
if (m_feedList->currentItem() == item ){
|
if (m_feedList->currentItem() == item ) {
|
||||||
refreshArticleList(item);
|
refreshArticleList(item);
|
||||||
} else {
|
} else {
|
||||||
// Update unread items
|
// Update unread items
|
||||||
@ -670,7 +670,7 @@ RSSImp::RSSImp(QWidget *parent) : QWidget(parent), m_rssManager(new RssManager)
|
|||||||
qDebug("RSSImp constructed");
|
qDebug("RSSImp constructed");
|
||||||
}
|
}
|
||||||
|
|
||||||
RSSImp::~RSSImp(){
|
RSSImp::~RSSImp() {
|
||||||
qDebug("Deleting RSSImp...");
|
qDebug("Deleting RSSImp...");
|
||||||
saveFoldersOpenState();
|
saveFoldersOpenState();
|
||||||
delete m_feedList;
|
delete m_feedList;
|
||||||
|
@ -315,7 +315,7 @@ bool RssArticle::isRead() const{
|
|||||||
return m_read;
|
return m_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RssArticle::markAsRead(){
|
void RssArticle::markAsRead() {
|
||||||
m_read = true;
|
m_read = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,9 +34,8 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QVariantHash>
|
#include <QVariantHash>
|
||||||
|
|
||||||
#include "rssdownloadrule.h"
|
#include "rssdownloadrule.h"
|
||||||
|
s
|
||||||
// This class is not thread-safe (not required)
|
// This class is not thread-safe (not required)
|
||||||
class RssDownloadRuleList
|
class RssDownloadRuleList
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ RssFeed::RssFeed(RssManager* manager, RssFolder* parent, const QString &url):
|
|||||||
loadItemsFromDisk();
|
loadItemsFromDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
RssFeed::~RssFeed(){
|
RssFeed::~RssFeed() {
|
||||||
if (!m_icon.startsWith(":/") && QFile::exists(m_icon))
|
if (!m_icon.startsWith(":/") && QFile::exists(m_icon))
|
||||||
QFile::remove(m_icon);
|
QFile::remove(m_icon);
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ QString RssFeed::title() const{
|
|||||||
return m_title;
|
return m_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RssFeed::rename(const QString &new_name){
|
void RssFeed::rename(const QString &new_name) {
|
||||||
qDebug() << "Renaming stream to" << new_name;
|
qDebug() << "Renaming stream to" << new_name;
|
||||||
m_alias = new_name;
|
m_alias = new_name;
|
||||||
}
|
}
|
||||||
@ -321,14 +321,14 @@ void RssFeed::resizeList() {
|
|||||||
RssArticleList listItems = m_articles.values();
|
RssArticleList listItems = m_articles.values();
|
||||||
RssManager::sortNewsList(listItems);
|
RssManager::sortNewsList(listItems);
|
||||||
const int excess = nb_articles - max_articles;
|
const int excess = nb_articles - max_articles;
|
||||||
for (uint i=nb_articles-excess; i<nb_articles; ++i){
|
for (uint i=nb_articles-excess; i<nb_articles; ++i) {
|
||||||
m_articles.remove(listItems.at(i)->guid());
|
m_articles.remove(listItems.at(i)->guid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// existing and opening test after download
|
// existing and opening test after download
|
||||||
bool RssFeed::parseXmlFile(const QString &file_path){
|
bool RssFeed::parseXmlFile(const QString &file_path) {
|
||||||
qDebug("openRss() called");
|
qDebug("openRss() called");
|
||||||
QFile fileRss(file_path);
|
QFile fileRss(file_path);
|
||||||
if (!fileRss.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!fileRss.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
@ -41,7 +41,7 @@ class RssManager;
|
|||||||
|
|
||||||
typedef QHash<QString, RssArticlePtr> RssArticleHash;
|
typedef QHash<QString, RssArticlePtr> RssArticleHash;
|
||||||
typedef QSharedPointer<RssFeed> RssFeedPtr;
|
typedef QSharedPointer<RssFeed> RssFeedPtr;
|
||||||
typedef QList<RssFeedPtr> RssFeedList;
|
typedef RssFeedList RssFeedList;
|
||||||
|
|
||||||
class RssFeed: public QObject, public RssFile {
|
class RssFeed: public QObject, public RssFile {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -45,7 +45,7 @@ RssManager::RssManager():
|
|||||||
m_refreshTimer.start(m_refreshInterval*60000);
|
m_refreshTimer.start(m_refreshInterval*60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
RssManager::~RssManager(){
|
RssManager::~RssManager() {
|
||||||
qDebug("Deleting RSSManager...");
|
qDebug("Deleting RSSManager...");
|
||||||
delete m_rssDownloader;
|
delete m_rssDownloader;
|
||||||
delete m_downloadRules;
|
delete m_downloadRules;
|
||||||
@ -54,7 +54,7 @@ RssManager::~RssManager(){
|
|||||||
qDebug("RSSManager deleted");
|
qDebug("RSSManager deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
void RssManager::updateRefreshInterval(uint val){
|
void RssManager::updateRefreshInterval(uint val) {
|
||||||
if (m_refreshInterval != val) {
|
if (m_refreshInterval != val) {
|
||||||
m_refreshInterval = val;
|
m_refreshInterval = val;
|
||||||
m_refreshTimer.start(m_refreshInterval*60000);
|
m_refreshTimer.start(m_refreshInterval*60000);
|
||||||
@ -66,13 +66,13 @@ void RssManager::loadStreamList() {
|
|||||||
RssSettings settings;
|
RssSettings settings;
|
||||||
const QStringList streamsUrl = settings.getRssFeedsUrls();
|
const QStringList streamsUrl = settings.getRssFeedsUrls();
|
||||||
const QStringList aliases = settings.getRssFeedsAliases();
|
const QStringList aliases = settings.getRssFeedsAliases();
|
||||||
if (streamsUrl.size() != aliases.size()){
|
if (streamsUrl.size() != aliases.size()) {
|
||||||
std::cerr << "Corrupted Rss list, not loading it\n";
|
std::cerr << "Corrupted Rss list, not loading it\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
qDebug() << Q_FUNC_INFO << streamsUrl;
|
qDebug() << Q_FUNC_INFO << streamsUrl;
|
||||||
foreach (QString s, streamsUrl){
|
foreach (QString s, streamsUrl) {
|
||||||
QStringList path = s.split("\\", QString::SkipEmptyParts);
|
QStringList path = s.split("\\", QString::SkipEmptyParts);
|
||||||
if (path.empty()) continue;
|
if (path.empty()) continue;
|
||||||
const QString feed_url = path.takeLast();
|
const QString feed_url = path.takeLast();
|
||||||
|
@ -96,7 +96,7 @@ void engineSelectDlg::dropEvent(QDropEvent *event) {
|
|||||||
// Decode if we accept drag 'n drop or not
|
// Decode if we accept drag 'n drop or not
|
||||||
void engineSelectDlg::dragEnterEvent(QDragEnterEvent *event) {
|
void engineSelectDlg::dragEnterEvent(QDragEnterEvent *event) {
|
||||||
QString mime;
|
QString mime;
|
||||||
foreach (mime, event->mimeData()->formats()){
|
foreach (mime, event->mimeData()->formats()) {
|
||||||
qDebug("mimeData: %s", qPrintable(mime));
|
qDebug("mimeData: %s", qPrintable(mime));
|
||||||
}
|
}
|
||||||
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) {
|
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) {
|
||||||
@ -195,14 +195,14 @@ void engineSelectDlg::enableSelection(bool enable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the color of a row in data model
|
// Set the color of a row in data model
|
||||||
void engineSelectDlg::setRowColor(int row, QString color){
|
void engineSelectDlg::setRowColor(int row, QString color) {
|
||||||
QTreeWidgetItem *item = pluginsTree->topLevelItem(row);
|
QTreeWidgetItem *item = pluginsTree->topLevelItem(row);
|
||||||
for (int i=0; i<pluginsTree->columnCount(); ++i){
|
for (int i=0; i<pluginsTree->columnCount(); ++i) {
|
||||||
item->setData(i, Qt::ForegroundRole, QVariant(QColor(color)));
|
item->setData(i, Qt::ForegroundRole, QVariant(QColor(color)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QTreeWidgetItem*> engineSelectDlg::findItemsWithUrl(QString url){
|
QList<QTreeWidgetItem*> engineSelectDlg::findItemsWithUrl(QString url) {
|
||||||
QList<QTreeWidgetItem*> res;
|
QList<QTreeWidgetItem*> res;
|
||||||
for (int i=0; i<pluginsTree->topLevelItemCount(); ++i) {
|
for (int i=0; i<pluginsTree->topLevelItemCount(); ++i) {
|
||||||
QTreeWidgetItem *item = pluginsTree->topLevelItem(i);
|
QTreeWidgetItem *item = pluginsTree->topLevelItem(i);
|
||||||
@ -212,7 +212,7 @@ QList<QTreeWidgetItem*> engineSelectDlg::findItemsWithUrl(QString url){
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id){
|
QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id) {
|
||||||
QList<QTreeWidgetItem*> res;
|
QList<QTreeWidgetItem*> res;
|
||||||
for (int i=0; i<pluginsTree->topLevelItemCount(); ++i) {
|
for (int i=0; i<pluginsTree->topLevelItemCount(); ++i) {
|
||||||
QTreeWidgetItem *item = pluginsTree->topLevelItem(i);
|
QTreeWidgetItem *item = pluginsTree->topLevelItem(i);
|
||||||
@ -353,7 +353,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) {
|
|||||||
qDebug("Checking if update is needed");
|
qDebug("Checking if update is needed");
|
||||||
bool file_correct = false;
|
bool file_correct = false;
|
||||||
QFile versions(versions_file);
|
QFile versions(versions_file);
|
||||||
if (!versions.open(QIODevice::ReadOnly | QIODevice::Text)){
|
if (!versions.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
qDebug("* Error: Could not read versions.txt file");
|
qDebug("* Error: Could not read versions.txt file");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -398,13 +398,13 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) {
|
|||||||
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
||||||
setCursor(QCursor(Qt::ArrowCursor));
|
setCursor(QCursor(Qt::ArrowCursor));
|
||||||
qDebug("engineSelectDlg received %s", qPrintable(url));
|
qDebug("engineSelectDlg received %s", qPrintable(url));
|
||||||
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)){
|
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)) {
|
||||||
// Icon downloaded
|
// Icon downloaded
|
||||||
QImage fileIcon;
|
QImage fileIcon;
|
||||||
if (fileIcon.load(filePath)) {
|
if (fileIcon.load(filePath)) {
|
||||||
QList<QTreeWidgetItem*> items = findItemsWithUrl(url);
|
QList<QTreeWidgetItem*> items = findItemsWithUrl(url);
|
||||||
QTreeWidgetItem *item;
|
QTreeWidgetItem *item;
|
||||||
foreach (item, items){
|
foreach (item, items) {
|
||||||
QString id = item->text(ENGINE_ID);
|
QString id = item->text(ENGINE_ID);
|
||||||
QString iconPath;
|
QString iconPath;
|
||||||
QFile icon(filePath);
|
QFile icon(filePath);
|
||||||
@ -439,7 +439,7 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
|||||||
|
|
||||||
void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
|
void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
|
||||||
setCursor(QCursor(Qt::ArrowCursor));
|
setCursor(QCursor(Qt::ArrowCursor));
|
||||||
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)){
|
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)) {
|
||||||
qDebug("Could not download favicon: %s, reason: %s", qPrintable(url), qPrintable(reason));
|
qDebug("Could not download favicon: %s, reason: %s", qPrintable(url), qPrintable(reason));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -53,13 +53,13 @@ class pluginSourceDlg: public QDialog, private Ui::pluginSourceDlg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
pluginSourceDlg(QWidget* parent): QDialog(parent){
|
pluginSourceDlg(QWidget* parent): QDialog(parent) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
~pluginSourceDlg(){}
|
~pluginSourceDlg() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -183,7 +183,7 @@ QString SearchEngine::selectedCategory() const {
|
|||||||
return comboCategory->itemData(comboCategory->currentIndex()).toString();
|
return comboCategory->itemData(comboCategory->currentIndex()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchEngine::~SearchEngine(){
|
SearchEngine::~SearchEngine() {
|
||||||
qDebug("Search destruction");
|
qDebug("Search destruction");
|
||||||
// save the searchHistory for later uses
|
// save the searchHistory for later uses
|
||||||
saveSearchHistory();
|
saveSearchHistory();
|
||||||
@ -273,7 +273,7 @@ void SearchEngine::on_enginesButton_clicked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the last searchs from a QIniSettings to a QStringList
|
// get the last searchs from a QIniSettings to a QStringList
|
||||||
void SearchEngine::startSearchHistory(){
|
void SearchEngine::startSearchHistory() {
|
||||||
QIniSettings settings("qBittorrent", "qBittorrent");
|
QIniSettings settings("qBittorrent", "qBittorrent");
|
||||||
searchHistory.setStringList(settings.value("Search/searchHistory",QStringList()).toStringList());
|
searchHistory.setStringList(settings.value("Search/searchHistory",QStringList()).toStringList());
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ void SearchEngine::giveFocusToSearchInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Function called when we click on search button
|
// Function called when we click on search button
|
||||||
void SearchEngine::on_search_button_clicked(){
|
void SearchEngine::on_search_button_clicked() {
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
if (!has_python) {
|
if (!has_python) {
|
||||||
if (QMessageBox::question(this, tr("Missing Python Interpreter"),
|
if (QMessageBox::question(this, tr("Missing Python Interpreter"),
|
||||||
@ -306,7 +306,7 @@ void SearchEngine::on_search_button_clicked(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (searchProcess->state() != QProcess::NotRunning){
|
if (searchProcess->state() != QProcess::NotRunning) {
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
searchProcess->kill();
|
searchProcess->kill();
|
||||||
#else
|
#else
|
||||||
@ -327,7 +327,7 @@ void SearchEngine::on_search_button_clicked(){
|
|||||||
|
|
||||||
const QString pattern = search_pattern->text().trimmed();
|
const QString pattern = search_pattern->text().trimmed();
|
||||||
// No search pattern entered
|
// No search pattern entered
|
||||||
if (pattern.isEmpty()){
|
if (pattern.isEmpty()) {
|
||||||
QMessageBox::critical(0, tr("Empty search pattern"), tr("Please type a search pattern first"));
|
QMessageBox::critical(0, tr("Empty search pattern"), tr("Please type a search pattern first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ void SearchEngine::on_search_button_clicked(){
|
|||||||
#endif
|
#endif
|
||||||
// if the pattern is not in the pattern
|
// if the pattern is not in the pattern
|
||||||
QStringList wordList = searchHistory.stringList();
|
QStringList wordList = searchHistory.stringList();
|
||||||
if (wordList.indexOf(pattern) == -1){
|
if (wordList.indexOf(pattern) == -1) {
|
||||||
//update the searchHistory list
|
//update the searchHistory list
|
||||||
wordList.append(pattern);
|
wordList.append(pattern);
|
||||||
// verify the max size of the history
|
// verify the max size of the history
|
||||||
@ -399,7 +399,7 @@ void SearchEngine::saveResultsColumnsWidth() {
|
|||||||
if (!line.isEmpty()) {
|
if (!line.isEmpty()) {
|
||||||
width_list = line.split(' ');
|
width_list = line.split(' ');
|
||||||
}
|
}
|
||||||
for (short i=0; i<nbColumns; ++i){
|
for (short i=0; i<nbColumns; ++i) {
|
||||||
if (treeview->columnWidth(i)<1 && width_list.size() == nbColumns && width_list.at(i).toInt()>=1) {
|
if (treeview->columnWidth(i)<1 && width_list.size() == nbColumns && width_list.at(i).toInt()>=1) {
|
||||||
// load the former width
|
// load the former width
|
||||||
new_width_list << width_list.at(i);
|
new_width_list << width_list.at(i);
|
||||||
@ -439,7 +439,7 @@ void SearchEngine::downloadTorrent(QString engine_url, QString torrent_url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchEngine::searchStarted(){
|
void SearchEngine::searchStarted() {
|
||||||
// Update SearchEngine widgets
|
// Update SearchEngine widgets
|
||||||
search_status->setText(tr("Searching..."));
|
search_status->setText(tr("Searching..."));
|
||||||
search_status->repaint();
|
search_status->repaint();
|
||||||
@ -449,16 +449,16 @@ void SearchEngine::searchStarted(){
|
|||||||
// search Qprocess return output as soon as it gets new
|
// search Qprocess return output as soon as it gets new
|
||||||
// stuff to read. We split it into lines and add each
|
// stuff to read. We split it into lines and add each
|
||||||
// line to search results calling appendSearchResult().
|
// line to search results calling appendSearchResult().
|
||||||
void SearchEngine::readSearchOutput(){
|
void SearchEngine::readSearchOutput() {
|
||||||
QByteArray output = searchProcess->readAllStandardOutput();
|
QByteArray output = searchProcess->readAllStandardOutput();
|
||||||
output.replace("\r", "");
|
output.replace("\r", "");
|
||||||
QList<QByteArray> lines_list = output.split('\n');
|
QList<QByteArray> lines_list = output.split('\n');
|
||||||
if (!search_result_line_truncated.isEmpty()){
|
if (!search_result_line_truncated.isEmpty()) {
|
||||||
QByteArray end_of_line = lines_list.takeFirst();
|
QByteArray end_of_line = lines_list.takeFirst();
|
||||||
lines_list.prepend(search_result_line_truncated+end_of_line);
|
lines_list.prepend(search_result_line_truncated+end_of_line);
|
||||||
}
|
}
|
||||||
search_result_line_truncated = lines_list.takeLast().trimmed();
|
search_result_line_truncated = lines_list.takeLast().trimmed();
|
||||||
foreach (const QByteArray &line, lines_list){
|
foreach (const QByteArray &line, lines_list) {
|
||||||
appendSearchResult(QString::fromUtf8(line));
|
appendSearchResult(QString::fromUtf8(line));
|
||||||
}
|
}
|
||||||
if (currentSearchTab)
|
if (currentSearchTab)
|
||||||
@ -490,7 +490,7 @@ void SearchEngine::updateNova() {
|
|||||||
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);
|
||||||
package_file.close();
|
package_file.close();
|
||||||
if (!search_dir.exists("engines")){
|
if (!search_dir.exists("engines")) {
|
||||||
search_dir.mkdir("engines");
|
search_dir.mkdir("engines");
|
||||||
}
|
}
|
||||||
QFile package_file2(search_dir.absolutePath().replace("\\", "/")+"/engines/__init__.py");
|
QFile package_file2(search_dir.absolutePath().replace("\\", "/")+"/engines/__init__.py");
|
||||||
@ -508,7 +508,7 @@ void SearchEngine::updateNova() {
|
|||||||
|
|
||||||
filePath = search_dir.absoluteFilePath("nova2dl.py");
|
filePath = search_dir.absoluteFilePath("nova2dl.py");
|
||||||
if (getPluginVersion(":/"+nova_folder+"/nova2dl.py") > getPluginVersion(filePath)) {
|
if (getPluginVersion(":/"+nova_folder+"/nova2dl.py") > getPluginVersion(filePath)) {
|
||||||
if (QFile::exists(filePath)){
|
if (QFile::exists(filePath)) {
|
||||||
QFile::remove(filePath);
|
QFile::remove(filePath);
|
||||||
QFile::remove(filePath+"c");
|
QFile::remove(filePath+"c");
|
||||||
}
|
}
|
||||||
@ -517,7 +517,7 @@ void SearchEngine::updateNova() {
|
|||||||
|
|
||||||
filePath = search_dir.absoluteFilePath("novaprinter.py");
|
filePath = search_dir.absoluteFilePath("novaprinter.py");
|
||||||
if (getPluginVersion(":/"+nova_folder+"/novaprinter.py") > getPluginVersion(filePath)) {
|
if (getPluginVersion(":/"+nova_folder+"/novaprinter.py") > getPluginVersion(filePath)) {
|
||||||
if (QFile::exists(filePath)){
|
if (QFile::exists(filePath)) {
|
||||||
QFile::remove(filePath);
|
QFile::remove(filePath);
|
||||||
QFile::remove(filePath+"c");
|
QFile::remove(filePath+"c");
|
||||||
}
|
}
|
||||||
@ -526,7 +526,7 @@ void SearchEngine::updateNova() {
|
|||||||
|
|
||||||
filePath = search_dir.absoluteFilePath("helpers.py");
|
filePath = search_dir.absoluteFilePath("helpers.py");
|
||||||
if (getPluginVersion(":/"+nova_folder+"/helpers.py") > getPluginVersion(filePath)) {
|
if (getPluginVersion(":/"+nova_folder+"/helpers.py") > getPluginVersion(filePath)) {
|
||||||
if (QFile::exists(filePath)){
|
if (QFile::exists(filePath)) {
|
||||||
QFile::remove(filePath);
|
QFile::remove(filePath);
|
||||||
QFile::remove(filePath+"c");
|
QFile::remove(filePath+"c");
|
||||||
}
|
}
|
||||||
@ -534,7 +534,7 @@ void SearchEngine::updateNova() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
filePath = search_dir.absoluteFilePath("socks.py");
|
filePath = search_dir.absoluteFilePath("socks.py");
|
||||||
if (QFile::exists(filePath)){
|
if (QFile::exists(filePath)) {
|
||||||
QFile::remove(filePath);
|
QFile::remove(filePath);
|
||||||
QFile::remove(filePath+"c");
|
QFile::remove(filePath+"c");
|
||||||
}
|
}
|
||||||
@ -542,7 +542,7 @@ void SearchEngine::updateNova() {
|
|||||||
|
|
||||||
if (nova_folder == "nova3") {
|
if (nova_folder == "nova3") {
|
||||||
filePath = search_dir.absoluteFilePath("sgmllib3.py");
|
filePath = search_dir.absoluteFilePath("sgmllib3.py");
|
||||||
if (QFile::exists(filePath)){
|
if (QFile::exists(filePath)) {
|
||||||
QFile::remove(filePath);
|
QFile::remove(filePath);
|
||||||
QFile::remove(filePath+"c");
|
QFile::remove(filePath+"c");
|
||||||
}
|
}
|
||||||
@ -551,7 +551,7 @@ void SearchEngine::updateNova() {
|
|||||||
QDir destDir(QDir(misc::searchEngineLocation()).absoluteFilePath("engines"));
|
QDir destDir(QDir(misc::searchEngineLocation()).absoluteFilePath("engines"));
|
||||||
QDir shipped_subDir(":/"+nova_folder+"/engines/");
|
QDir shipped_subDir(":/"+nova_folder+"/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);
|
||||||
// Copy python classes
|
// Copy python classes
|
||||||
if (file.endsWith(".py")) {
|
if (file.endsWith(".py")) {
|
||||||
@ -580,7 +580,7 @@ void SearchEngine::updateNova() {
|
|||||||
// Slot called when search is Finished
|
// Slot called when search is Finished
|
||||||
// Search can be finished for 3 reasons :
|
// Search can be finished for 3 reasons :
|
||||||
// Error | Stopped by user | Finished normally
|
// Error | Stopped by user | Finished normally
|
||||||
void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
|
void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus) {
|
||||||
if (searchTimeout->isActive()) {
|
if (searchTimeout->isActive()) {
|
||||||
searchTimeout->stop();
|
searchTimeout->stop();
|
||||||
}
|
}
|
||||||
@ -589,17 +589,17 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
|
|||||||
if (useNotificationBalloons && mp_mainWindow->getCurrentTabWidget() != this) {
|
if (useNotificationBalloons && mp_mainWindow->getCurrentTabWidget() != this) {
|
||||||
mp_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Search has finished"));
|
mp_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Search has finished"));
|
||||||
}
|
}
|
||||||
if (exitcode){
|
if (exitcode) {
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
search_status->setText(tr("Search aborted"));
|
search_status->setText(tr("Search aborted"));
|
||||||
#else
|
#else
|
||||||
search_status->setText(tr("An error occured during search..."));
|
search_status->setText(tr("An error occured during search..."));
|
||||||
#endif
|
#endif
|
||||||
}else{
|
}else{
|
||||||
if (search_stopped){
|
if (search_stopped) {
|
||||||
search_status->setText(tr("Search aborted"));
|
search_status->setText(tr("Search aborted"));
|
||||||
}else{
|
}else{
|
||||||
if (no_search_results){
|
if (no_search_results) {
|
||||||
search_status->setText(tr("Search returned no results"));
|
search_status->setText(tr("Search returned no results"));
|
||||||
}else{
|
}else{
|
||||||
search_status->setText(tr("Search has finished"));
|
search_status->setText(tr("Search has finished"));
|
||||||
@ -614,9 +614,9 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
|
|||||||
// SLOT to append one line to search results list
|
// SLOT to append one line to search results list
|
||||||
// Line is in the following form :
|
// Line is in the following form :
|
||||||
// file url | file name | file size | nb seeds | nb leechers | Search engine url
|
// file url | file name | file size | nb seeds | nb leechers | Search engine url
|
||||||
void SearchEngine::appendSearchResult(const QString &line){
|
void SearchEngine::appendSearchResult(const QString &line) {
|
||||||
if (!currentSearchTab) {
|
if (!currentSearchTab) {
|
||||||
if (searchProcess->state() != QProcess::NotRunning){
|
if (searchProcess->state() != QProcess::NotRunning) {
|
||||||
searchProcess->terminate();
|
searchProcess->terminate();
|
||||||
}
|
}
|
||||||
if (searchTimeout->isActive()) {
|
if (searchTimeout->isActive()) {
|
||||||
@ -627,7 +627,7 @@ void SearchEngine::appendSearchResult(const QString &line){
|
|||||||
}
|
}
|
||||||
const QStringList parts = line.split("|");
|
const QStringList parts = line.split("|");
|
||||||
const int nb_fields = parts.size();
|
const int nb_fields = parts.size();
|
||||||
if (nb_fields < NB_PLUGIN_COLUMNS-1){ //-1 because desc_link is optional
|
if (nb_fields < NB_PLUGIN_COLUMNS-1) { //-1 because desc_link is optional
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_ASSERT(currentSearchTab);
|
Q_ASSERT(currentSearchTab);
|
||||||
@ -669,7 +669,7 @@ void SearchEngine::appendSearchResult(const QString &line){
|
|||||||
void SearchEngine::closeTab(int index) {
|
void SearchEngine::closeTab(int index) {
|
||||||
if (index == tabWidget->indexOf(currentSearchTab)) {
|
if (index == tabWidget->indexOf(currentSearchTab)) {
|
||||||
qDebug("Deleted current search Tab");
|
qDebug("Deleted current search Tab");
|
||||||
if (searchProcess->state() != QProcess::NotRunning){
|
if (searchProcess->state() != QProcess::NotRunning) {
|
||||||
searchProcess->terminate();
|
searchProcess->terminate();
|
||||||
}
|
}
|
||||||
if (searchTimeout->isActive()) {
|
if (searchTimeout->isActive()) {
|
||||||
@ -686,13 +686,13 @@ void SearchEngine::closeTab(int index) {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// Clear search results list
|
// Clear search results list
|
||||||
void SearchEngine::closeTab_button_clicked(){
|
void SearchEngine::closeTab_button_clicked() {
|
||||||
if (all_tab.size()) {
|
if (all_tab.size()) {
|
||||||
qDebug("currentTab rank: %d", tabWidget->currentIndex());
|
qDebug("currentTab rank: %d", tabWidget->currentIndex());
|
||||||
qDebug("currentSearchTab rank: %d", tabWidget->indexOf(currentSearchTab));
|
qDebug("currentSearchTab rank: %d", tabWidget->indexOf(currentSearchTab));
|
||||||
if (tabWidget->currentIndex() == tabWidget->indexOf(currentSearchTab)) {
|
if (tabWidget->currentIndex() == tabWidget->indexOf(currentSearchTab)) {
|
||||||
qDebug("Deleted current search Tab");
|
qDebug("Deleted current search Tab");
|
||||||
if (searchProcess->state() != QProcess::NotRunning){
|
if (searchProcess->state() != QProcess::NotRunning) {
|
||||||
searchProcess->terminate();
|
searchProcess->terminate();
|
||||||
}
|
}
|
||||||
if (searchTimeout->isActive()) {
|
if (searchTimeout->isActive()) {
|
||||||
@ -711,11 +711,11 @@ void SearchEngine::closeTab_button_clicked(){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Download selected items in search results list
|
// Download selected items in search results list
|
||||||
void SearchEngine::on_download_button_clicked(){
|
void SearchEngine::on_download_button_clicked() {
|
||||||
//QModelIndexList selectedIndexes = currentSearchTab->getCurrentTreeView()->selectionModel()->selectedIndexes();
|
//QModelIndexList selectedIndexes = currentSearchTab->getCurrentTreeView()->selectionModel()->selectedIndexes();
|
||||||
QModelIndexList selectedIndexes = all_tab.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
|
QModelIndexList selectedIndexes = all_tab.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
|
||||||
foreach (const QModelIndex &index, selectedIndexes){
|
foreach (const QModelIndex &index, selectedIndexes) {
|
||||||
if (index.column() == NAME){
|
if (index.column() == NAME) {
|
||||||
// Get Item url
|
// Get Item url
|
||||||
QSortFilterProxyModel* model = all_tab.at(tabWidget->currentIndex())->getCurrentSearchListProxy();
|
QSortFilterProxyModel* model = all_tab.at(tabWidget->currentIndex())->getCurrentSearchListProxy();
|
||||||
QString torrent_url = model->data(model->index(index.row(), URL_COLUMN)).toString();
|
QString torrent_url = model->data(model->index(index.row(), URL_COLUMN)).toString();
|
||||||
@ -729,7 +729,7 @@ void SearchEngine::on_download_button_clicked(){
|
|||||||
void SearchEngine::on_goToDescBtn_clicked()
|
void SearchEngine::on_goToDescBtn_clicked()
|
||||||
{
|
{
|
||||||
QModelIndexList selectedIndexes = all_tab.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
|
QModelIndexList selectedIndexes = all_tab.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
|
||||||
foreach (const QModelIndex &index, selectedIndexes){
|
foreach (const QModelIndex &index, selectedIndexes) {
|
||||||
if (index.column() == NAME) {
|
if (index.column() == NAME) {
|
||||||
QSortFilterProxyModel* model = all_tab.at(tabWidget->currentIndex())->getCurrentSearchListProxy();
|
QSortFilterProxyModel* model = all_tab.at(tabWidget->currentIndex())->getCurrentSearchListProxy();
|
||||||
const QString desc_url = model->data(model->index(index.row(), DESC_LINK)).toString();
|
const QString desc_url = model->data(model->index(index.row(), DESC_LINK)).toString();
|
||||||
|
@ -65,17 +65,17 @@ public:
|
|||||||
|
|
||||||
static qreal getPluginVersion(QString filePath) {
|
static qreal getPluginVersion(QString filePath) {
|
||||||
QFile plugin(filePath);
|
QFile plugin(filePath);
|
||||||
if (!plugin.exists()){
|
if (!plugin.exists()) {
|
||||||
qDebug("%s plugin does not exist, returning 0.0", qPrintable(filePath));
|
qDebug("%s plugin does not exist, returning 0.0", qPrintable(filePath));
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if (!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){
|
if (!plugin.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
qreal version = 0.0;
|
qreal version = 0.0;
|
||||||
while (!plugin.atEnd()){
|
while (!plugin.atEnd()) {
|
||||||
QByteArray line = plugin.readLine();
|
QByteArray line = plugin.readLine();
|
||||||
if (line.startsWith("#VERSION: ")){
|
if (line.startsWith("#VERSION: ")) {
|
||||||
line = line.split(' ').last().trimmed();
|
line = line.split(' ').last().trimmed();
|
||||||
version = line.toFloat();
|
version = line.toFloat();
|
||||||
qDebug("plugin %s version: %.2f", qPrintable(filePath), version);
|
qDebug("plugin %s version: %.2f", qPrintable(filePath), version);
|
||||||
|
@ -44,14 +44,14 @@ class SearchListDelegate: public QItemDelegate {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SearchListDelegate(QObject *parent=0) : QItemDelegate(parent){}
|
SearchListDelegate(QObject *parent=0) : QItemDelegate(parent) {}
|
||||||
|
|
||||||
~SearchListDelegate(){}
|
~SearchListDelegate() {}
|
||||||
|
|
||||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||||
painter->save();
|
painter->save();
|
||||||
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
||||||
switch(index.column()){
|
switch(index.column()) {
|
||||||
case SearchEngine::SIZE:
|
case SearchEngine::SIZE:
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
||||||
|
@ -77,7 +77,7 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
|
|||||||
connect(resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(downloadSelectedItem(const QModelIndex&)));
|
connect(resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(downloadSelectedItem(const QModelIndex&)));
|
||||||
|
|
||||||
// Load last columns width for search results list
|
// Load last columns width for search results list
|
||||||
if (!loadColWidthResultsList()){
|
if (!loadColWidthResultsList()) {
|
||||||
resultsBrowser->header()->resizeSection(0, 275);
|
resultsBrowser->header()->resizeSection(0, 275);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ bool SearchTab::loadColWidthResultsList() {
|
|||||||
if (width_list.size() < SearchListModel->columnCount())
|
if (width_list.size() < SearchListModel->columnCount())
|
||||||
return false;
|
return false;
|
||||||
unsigned int listSize = width_list.size();
|
unsigned int listSize = width_list.size();
|
||||||
for (unsigned int i=0; i<listSize; ++i){
|
for (unsigned int i=0; i<listSize; ++i) {
|
||||||
resultsBrowser->header()->resizeSection(i, width_list.at(i).toInt());
|
resultsBrowser->header()->resizeSection(i, width_list.at(i).toInt());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -141,9 +141,9 @@ QStandardItemModel* SearchTab::getCurrentSearchListModel() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the color of a row in data model
|
// Set the color of a row in data model
|
||||||
void SearchTab::setRowColor(int row, QString color){
|
void SearchTab::setRowColor(int row, QString color) {
|
||||||
proxyModel->setDynamicSortFilter(false);
|
proxyModel->setDynamicSortFilter(false);
|
||||||
for (int i=0; i<proxyModel->columnCount(); ++i){
|
for (int i=0; i<proxyModel->columnCount(); ++i) {
|
||||||
proxyModel->setData(proxyModel->index(row, i), QVariant(QColor(color)), Qt::ForegroundRole);
|
proxyModel->setData(proxyModel->index(row, i), QVariant(QColor(color)), Qt::ForegroundRole);
|
||||||
}
|
}
|
||||||
proxyModel->setDynamicSortFilter(true);
|
proxyModel->setDynamicSortFilter(true);
|
||||||
|
@ -50,7 +50,7 @@ class SpeedLimitDialog : public QDialog, private Ui_bandwidth_dlg {
|
|||||||
move(misc::screenCenter(this));
|
move(misc::screenCenter(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
~SpeedLimitDialog(){
|
~SpeedLimitDialog() {
|
||||||
qDebug("Deleting bandwidth allocation dialog");
|
qDebug("Deleting bandwidth allocation dialog");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class SpeedLimitDialog : public QDialog, private Ui_bandwidth_dlg {
|
|||||||
protected slots:
|
protected slots:
|
||||||
void updateSpinValue(int val) const {
|
void updateSpinValue(int val) const {
|
||||||
qDebug("Called updateSpinValue with %d", val);
|
qDebug("Called updateSpinValue with %d", val);
|
||||||
if (val <= 0){
|
if (val <= 0) {
|
||||||
spinBandwidth->setValue(0);
|
spinBandwidth->setValue(0);
|
||||||
spinBandwidth->setSpecialValueText(QString::fromUtf8("∞"));
|
spinBandwidth->setSpecialValueText(QString::fromUtf8("∞"));
|
||||||
spinBandwidth->setSuffix(QString::fromUtf8(""));
|
spinBandwidth->setSuffix(QString::fromUtf8(""));
|
||||||
|
@ -253,7 +253,7 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) {
|
|||||||
throw std::exception();
|
throw std::exception();
|
||||||
} catch(std::exception&) {
|
} catch(std::exception&) {
|
||||||
qDebug("Caught error loading torrent");
|
qDebug("Caught error loading torrent");
|
||||||
if (!from_url.isNull()){
|
if (!from_url.isNull()) {
|
||||||
QBtSession::instance()->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
|
QBtSession::instance()->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
|
||||||
QFile::remove(filePath);
|
QFile::remove(filePath);
|
||||||
}else{
|
}else{
|
||||||
@ -278,7 +278,7 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) {
|
|||||||
hash = misc::toQString(t->info_hash());
|
hash = misc::toQString(t->info_hash());
|
||||||
// Use left() to remove .old extension
|
// Use left() to remove .old extension
|
||||||
QString newFileName;
|
QString newFileName;
|
||||||
if (fileName.endsWith(QString::fromUtf8(".old"))){
|
if (fileName.endsWith(QString::fromUtf8(".old"))) {
|
||||||
newFileName = fileName.left(fileName.size()-4);
|
newFileName = fileName.left(fileName.size()-4);
|
||||||
}else{
|
}else{
|
||||||
newFileName = fileName;
|
newFileName = fileName;
|
||||||
@ -526,7 +526,7 @@ void torrentAdditionDialog::updateDiskSpaceLabels() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrentAdditionDialog::on_browseButton_clicked(){
|
void torrentAdditionDialog::on_browseButton_clicked() {
|
||||||
Q_ASSERT(!is_magnet);
|
Q_ASSERT(!is_magnet);
|
||||||
QString new_path;
|
QString new_path;
|
||||||
QString root_folder;
|
QString root_folder;
|
||||||
@ -546,7 +546,7 @@ void torrentAdditionDialog::on_browseButton_clicked(){
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QString truncated_path = getCurrentTruncatedSavePath(&root_folder);
|
QString truncated_path = getCurrentTruncatedSavePath(&root_folder);
|
||||||
if (!truncated_path.isEmpty() && QDir(truncated_path).exists()){
|
if (!truncated_path.isEmpty() && QDir(truncated_path).exists()) {
|
||||||
new_path = QFileDialog::getExistingDirectory(this, tr("Choose save path"), truncated_path);
|
new_path = QFileDialog::getExistingDirectory(this, tr("Choose save path"), truncated_path);
|
||||||
}else{
|
}else{
|
||||||
new_path = QFileDialog::getExistingDirectory(this, tr("Choose save path"), QDir::homePath());
|
new_path = QFileDialog::getExistingDirectory(this, tr("Choose save path"), QDir::homePath());
|
||||||
@ -583,7 +583,7 @@ void torrentAdditionDialog::on_browseButton_clicked(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrentAdditionDialog::on_CancelButton_clicked(){
|
void torrentAdditionDialog::on_CancelButton_clicked() {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,17 +592,17 @@ bool torrentAdditionDialog::allFiltered() const {
|
|||||||
return PropListModel->model()->allFiltered();
|
return PropListModel->model()->allFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrentAdditionDialog::savePiecesPriorities(){
|
void torrentAdditionDialog::savePiecesPriorities() {
|
||||||
qDebug("Saving pieces priorities");
|
qDebug("Saving pieces priorities");
|
||||||
Q_ASSERT(!is_magnet);
|
Q_ASSERT(!is_magnet);
|
||||||
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities(t->num_files());
|
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities(t->num_files());
|
||||||
TorrentTempData::setFilesPriority(hash, priorities);
|
TorrentTempData::setFilesPriority(hash, priorities);
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrentAdditionDialog::on_OkButton_clicked(){
|
void torrentAdditionDialog::on_OkButton_clicked() {
|
||||||
Preferences pref;
|
Preferences pref;
|
||||||
qDebug() << "void torrentAdditionDialog::on_OkButton_clicked() - ENTER";
|
qDebug() << "void torrentAdditionDialog::on_OkButton_clicked() - ENTER";
|
||||||
if (savePathTxt->currentText().trimmed().isEmpty()){
|
if (savePathTxt->currentText().trimmed().isEmpty()) {
|
||||||
QMessageBox::critical(0, tr("Empty save path"), tr("Please enter a save path"));
|
QMessageBox::critical(0, tr("Empty save path"), tr("Please enter a save path"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -671,7 +671,7 @@ void torrentAdditionDialog::on_OkButton_clicked(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if there is at least one selected file
|
// Check if there is at least one selected file
|
||||||
if (!is_magnet && t->num_files() > 1 && allFiltered()){
|
if (!is_magnet && t->num_files() > 1 && allFiltered()) {
|
||||||
QMessageBox::warning(0, tr("Invalid file selection"), tr("You must select at least one file in the torrent"));
|
QMessageBox::warning(0, tr("Invalid file selection"), tr("You must select at least one file in the torrent"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -683,8 +683,8 @@ void torrentAdditionDialog::on_OkButton_clicked(){
|
|||||||
pref.setSavePath(getCurrentTruncatedSavePath());
|
pref.setSavePath(getCurrentTruncatedSavePath());
|
||||||
|
|
||||||
// Check if savePath exists
|
// Check if savePath exists
|
||||||
if (!savePath.exists()){
|
if (!savePath.exists()) {
|
||||||
if (!savePath.mkpath(savePath.path())){
|
if (!savePath.mkpath(savePath.path())) {
|
||||||
QMessageBox::critical(0, tr("Save path creation error"), tr("Could not create the save path"));
|
QMessageBox::critical(0, tr("Save path creation error"), tr("Could not create the save path"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ TorrentCreatorDlg::~TorrentCreatorDlg() {
|
|||||||
delete creatorThread;
|
delete creatorThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentCreatorDlg::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);
|
||||||
@ -83,7 +83,7 @@ void TorrentCreatorDlg::on_addFolder_button_clicked(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentCreatorDlg::on_addFile_button_clicked(){
|
void TorrentCreatorDlg::on_addFile_button_clicked() {
|
||||||
QIniSettings settings("qBittorrent", "qBittorrent");
|
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);
|
||||||
@ -104,11 +104,11 @@ int TorrentCreatorDlg::getPieceSize() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Main function that create a .torrent file
|
// Main function that create a .torrent file
|
||||||
void TorrentCreatorDlg::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);
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ void TorrentCreatorThread::create(QString _input_path, QString _save_path, QStri
|
|||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendProgressUpdateSignal(int i, int num, TorrentCreatorThread *parent){
|
void sendProgressUpdateSignal(int i, int num, TorrentCreatorThread *parent) {
|
||||||
parent->sendProgressSignal((int)(i*100./(float)num));
|
parent->sendProgressSignal((int)(i*100./(float)num));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ void TorrentCreatorThread::run() {
|
|||||||
create_torrent t(fs, piece_size);
|
create_torrent t(fs, piece_size);
|
||||||
|
|
||||||
// Add url seeds
|
// Add url seeds
|
||||||
foreach (const QString &seed, url_seeds){
|
foreach (const QString &seed, url_seeds) {
|
||||||
t.add_url_seed(seed.trimmed().toStdString());
|
t.add_url_seed(seed.trimmed().toStdString());
|
||||||
}
|
}
|
||||||
foreach (const QString &tracker, trackers) {
|
foreach (const QString &tracker, trackers) {
|
||||||
@ -138,7 +138,7 @@ void TorrentCreatorThread::run() {
|
|||||||
} else {
|
} else {
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
} catch (std::exception& e){
|
} catch (std::exception& e) {
|
||||||
emit creationFailure(QString::fromLocal8Bit(e.what()));
|
emit creationFailure(QString::fromLocal8Bit(e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ public:
|
|||||||
return data.value("sequential", false).toBool();
|
return data.value("sequential", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setSeedingMode(QString hash,bool seed){
|
static void setSeedingMode(QString hash,bool seed) {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||||
@ -127,7 +127,7 @@ public:
|
|||||||
settings.setValue("torrents-tmp", all_data);
|
settings.setValue("torrents-tmp", all_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isSeedingMode(QString hash){
|
static bool isSeedingMode(QString hash) {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||||
|
@ -44,7 +44,7 @@ class trackerLogin : public QDialog, private Ui::authentication{
|
|||||||
QTorrentHandle h;
|
QTorrentHandle h;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
trackerLogin(QWidget *parent, QTorrentHandle h): QDialog(parent), h(h){
|
trackerLogin(QWidget *parent, QTorrentHandle h): QDialog(parent), h(h) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
login_logo->setPixmap(QPixmap(QString::fromUtf8(":/Icons/oxygen/encrypted.png")));
|
login_logo->setPixmap(QPixmap(QString::fromUtf8(":/Icons/oxygen/encrypted.png")));
|
||||||
@ -53,19 +53,19 @@ class trackerLogin : public QDialog, private Ui::authentication{
|
|||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
~trackerLogin(){}
|
~trackerLogin() {}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void trackerLoginCancelled(QPair<QTorrentHandle,QString> tracker);
|
void trackerLoginCancelled(QPair<QTorrentHandle,QString> tracker);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void on_loginButton_clicked(){
|
void on_loginButton_clicked() {
|
||||||
// login
|
// login
|
||||||
h.set_tracker_login(lineUsername->text(), linePasswd->text());
|
h.set_tracker_login(lineUsername->text(), linePasswd->text());
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_cancelButton_clicked(){
|
void on_cancelButton_clicked() {
|
||||||
// Emit a signal to GUI to stop asking for authentication
|
// Emit a signal to GUI to stop asking for authentication
|
||||||
emit trackerLoginCancelled(QPair<QTorrentHandle,QString>(h, h.current_tracker()));
|
emit trackerLoginCancelled(QPair<QTorrentHandle,QString>(h, h.current_tracker()));
|
||||||
close();
|
close();
|
||||||
|
@ -53,14 +53,14 @@ class TransferListDelegate: public QItemDelegate {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TransferListDelegate(QObject *parent) : QItemDelegate(parent){}
|
TransferListDelegate(QObject *parent) : QItemDelegate(parent) {}
|
||||||
|
|
||||||
~TransferListDelegate(){}
|
~TransferListDelegate() {}
|
||||||
|
|
||||||
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);
|
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
||||||
painter->save();
|
painter->save();
|
||||||
switch(index.column()){
|
switch(index.column()) {
|
||||||
case TorrentModelItem::TR_AMOUNT_DOWNLOADED:
|
case TorrentModelItem::TR_AMOUNT_DOWNLOADED:
|
||||||
case TorrentModelItem::TR_AMOUNT_LEFT:
|
case TorrentModelItem::TR_AMOUNT_LEFT:
|
||||||
case TorrentModelItem::TR_SIZE:{
|
case TorrentModelItem::TR_SIZE:{
|
||||||
|
@ -323,7 +323,7 @@ void TransferListWidget::increasePrioSelectedTorrents() {
|
|||||||
if (!h.is_seed()) {
|
if (!h.is_seed()) {
|
||||||
torrent_queue.push(qMakePair(h.queue_position(), h));
|
torrent_queue.push(qMakePair(h.queue_position(), h));
|
||||||
}
|
}
|
||||||
}catch(invalid_handle&){}
|
}catch(invalid_handle&) {}
|
||||||
}
|
}
|
||||||
// Increase torrents priority (starting with the ones with highest priority)
|
// Increase torrents priority (starting with the ones with highest priority)
|
||||||
while(!torrent_queue.empty()) {
|
while(!torrent_queue.empty()) {
|
||||||
@ -347,7 +347,7 @@ void TransferListWidget::decreasePrioSelectedTorrents() {
|
|||||||
if (!h.is_seed()) {
|
if (!h.is_seed()) {
|
||||||
torrent_queue.push(qMakePair(h.queue_position(), h));
|
torrent_queue.push(qMakePair(h.queue_position(), h));
|
||||||
}
|
}
|
||||||
}catch(invalid_handle&){}
|
}catch(invalid_handle&) {}
|
||||||
}
|
}
|
||||||
// Decrease torrents priority (starting with the ones with lowest priority)
|
// Decrease torrents priority (starting with the ones with lowest priority)
|
||||||
while(!torrent_queue.empty()) {
|
while(!torrent_queue.empty()) {
|
||||||
@ -520,7 +520,7 @@ void TransferListWidget::recheckSelectedTorrents() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// hide/show columns menu
|
// hide/show columns menu
|
||||||
void TransferListWidget::displayDLHoSMenu(const QPoint&){
|
void TransferListWidget::displayDLHoSMenu(const QPoint&) {
|
||||||
QMenu hideshowColumn(this);
|
QMenu hideshowColumn(this);
|
||||||
hideshowColumn.setTitle(tr("Column visibility"));
|
hideshowColumn.setTitle(tr("Column visibility"));
|
||||||
QList<QAction*> actions;
|
QList<QAction*> actions;
|
||||||
|
@ -120,7 +120,7 @@ void EventManager::setGlobalPreferences(QVariantMap m) {
|
|||||||
QString locale = m["locale"].toString();
|
QString locale = m["locale"].toString();
|
||||||
if (pref.getLocale() != locale) {
|
if (pref.getLocale() != locale) {
|
||||||
QTranslator *translator = new QTranslator;
|
QTranslator *translator = new QTranslator;
|
||||||
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
|
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
|
||||||
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
||||||
}else{
|
}else{
|
||||||
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
||||||
|
@ -394,9 +394,9 @@ void HttpConnection::respondCommand(const QString& command) {
|
|||||||
if (command == "download") {
|
if (command == "download") {
|
||||||
QString urls = m_parser.post("urls");
|
QString urls = m_parser.post("urls");
|
||||||
QStringList list = urls.split('\n');
|
QStringList list = urls.split('\n');
|
||||||
foreach (QString url, list){
|
foreach (QString url, list) {
|
||||||
url = url.trimmed();
|
url = url.trimmed();
|
||||||
if (!url.isEmpty()){
|
if (!url.isEmpty()) {
|
||||||
if (url.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
if (url.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
||||||
qDebug("Converting bc link to magnet link");
|
qDebug("Converting bc link to magnet link");
|
||||||
url = misc::bcLinkToMagnet(url);
|
url = misc::bcLinkToMagnet(url);
|
||||||
@ -600,7 +600,7 @@ void HttpConnection::respondCommand(const QString& command) {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (command == "recheck"){
|
if (command == "recheck") {
|
||||||
QBtSession::instance()->recheckTorrent(m_parser.post("hash"));
|
QBtSession::instance()->recheckTorrent(m_parser.post("hash"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -618,7 +618,7 @@ void HttpConnection::decreaseTorrentsPriority(const QStringList &hashes) {
|
|||||||
if (!h.is_seed()) {
|
if (!h.is_seed()) {
|
||||||
torrent_queue.push(qMakePair(h.queue_position(), h));
|
torrent_queue.push(qMakePair(h.queue_position(), h));
|
||||||
}
|
}
|
||||||
}catch(invalid_handle&){}
|
}catch(invalid_handle&) {}
|
||||||
}
|
}
|
||||||
// Decrease torrents priority (starting with the ones with lowest priority)
|
// Decrease torrents priority (starting with the ones with lowest priority)
|
||||||
while(!torrent_queue.empty()) {
|
while(!torrent_queue.empty()) {
|
||||||
@ -643,7 +643,7 @@ void HttpConnection::increaseTorrentsPriority(const QStringList &hashes)
|
|||||||
if (!h.is_seed()) {
|
if (!h.is_seed()) {
|
||||||
torrent_queue.push(qMakePair(h.queue_position(), h));
|
torrent_queue.push(qMakePair(h.queue_position(), h));
|
||||||
}
|
}
|
||||||
}catch(invalid_handle&){}
|
}catch(invalid_handle&) {}
|
||||||
}
|
}
|
||||||
// Increase torrents priority (starting with the ones with highest priority)
|
// Increase torrents priority (starting with the ones with highest priority)
|
||||||
while(!torrent_queue.empty()) {
|
while(!torrent_queue.empty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user