Browse Source

FEATURE: Search engine results can now be opened in a Web browser (plugins will be progressively ported, only btjunkie is working atm)

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
c14deec893
  1. 1
      Changelog
  2. 10
      src/previewlistdelegate.h
  3. 92
      src/previewselect.cpp
  4. 112
      src/previewselect.h
  5. 7
      src/searchengine/nova2/engines/btjunkie.py
  6. 2
      src/searchengine/nova2/engines/versions.txt
  7. 5
      src/searchengine/nova2/novaprinter.py
  8. 7
      src/searchengine/search.ui
  9. 69
      src/searchengine/searchengine.cpp
  10. 10
      src/searchengine/searchengine.h
  11. 10
      src/searchengine/searchlistdelegate.h
  12. 27
      src/searchengine/searchtab.cpp
  13. 3
      src/src.pro
  14. 30
      src/transferlistwidget.cpp

1
Changelog

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
- FEATURE: Added "Time Active/Seeded" column to transfer list
- FEATURE: Give feedback regarding the IP filter parsing
- FEATURE: Added a button to reload the IP filter
- FEATURE: Search engine results can now be opened in a Web browser
- COSMETIC: Same deletion confirmation dialog in the GUI and Web UI
- COSMETIC: Simplified the top toolbar
- COSMETIC: Display execution log as a tab instead of a modal window

10
src/previewlistdelegate.h

@ -39,11 +39,7 @@ @@ -39,11 +39,7 @@
#include <QProgressBar>
#include <QApplication>
#include "misc.h"
// Defines for properties list columns
#define NAME 0
#define SIZE 1
#define PROGRESS 2
#include "previewselect.h"
class PreviewListDelegate: public QItemDelegate {
Q_OBJECT
@ -58,11 +54,11 @@ class PreviewListDelegate: public QItemDelegate { @@ -58,11 +54,11 @@ class PreviewListDelegate: public QItemDelegate {
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
switch(index.column()){
case SIZE:
case PreviewSelect::SIZE:
QItemDelegate::drawBackground(painter, opt, index);
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
break;
case PROGRESS:{
case PreviewSelect::PROGRESS:{
float progress = index.data().toDouble()*100.;
QStyleOptionProgressBarV2 newopt;
newopt.rect = opt.rect;

92
src/previewselect.cpp

@ -0,0 +1,92 @@ @@ -0,0 +1,92 @@
#include <QStandardItemModel>
#include <QHeaderView>
#include <QMessageBox>
#include <QFile>
#include <libtorrent/version.hpp>
#include <libtorrent/session.hpp>
#include "misc.h"
#include "previewlistdelegate.h"
#include "previewselect.h"
PreviewSelect::PreviewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent), h(h){
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
// Preview list
previewListModel = new QStandardItemModel(0, 3);
previewListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name"));
previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress"));
previewList->setModel(previewListModel);
listDelegate = new PreviewListDelegate(this);
previewList->setItemDelegate(listDelegate);
previewList->header()->resizeSection(0, 200);
// Fill list in
std::vector<libtorrent::size_type> fp;
h.file_progress(fp);
unsigned int nbFiles = h.num_files();
for(unsigned int i=0; i<nbFiles; ++i){
QString fileName = h.filename_at(i);
QString extension = fileName.split(QString::fromUtf8(".")).last().toUpper();
if(misc::isPreviewable(extension)) {
int row = previewListModel->rowCount();
previewListModel->insertRow(row);
previewListModel->setData(previewListModel->index(row, NAME), QVariant(fileName));
previewListModel->setData(previewListModel->index(row, SIZE), QVariant((qlonglong)h.filesize_at(i)));
previewListModel->setData(previewListModel->index(row, PROGRESS), QVariant((double)fp[i]/h.filesize_at(i)));
indexes << i;
}
}
previewList->selectionModel()->select(previewListModel->index(0, NAME), QItemSelectionModel::Select);
previewList->selectionModel()->select(previewListModel->index(0, SIZE), QItemSelectionModel::Select);
previewList->selectionModel()->select(previewListModel->index(0, PROGRESS), QItemSelectionModel::Select);
if(!previewListModel->rowCount()){
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
close();
}
connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString)));
if(previewListModel->rowCount() == 1){
qDebug("Torrent file only contains one file, no need to display selection dialog before preview");
// Only one file : no choice
on_previewButton_clicked();
}else{
qDebug("Displaying media file selection dialog for preview");
show();
}
}
PreviewSelect::~PreviewSelect(){
delete previewListModel;
delete listDelegate;
}
void PreviewSelect::on_previewButton_clicked(){
QModelIndex index;
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(NAME);
if(selectedIndexes.size() == 0) return;
#if LIBTORRENT_VERSION_MINOR > 14
// Flush data
h.flush_cache();
#endif
QString path;
foreach(index, selectedIndexes){
path = h.files_path().at(indexes.at(index.row()));
// File
if(QFile::exists(path)){
emit readyToPreviewFile(path);
} else {
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
}
close();
return;
}
qDebug("Cannot find file: %s", path.toLocal8Bit().data());
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
close();
}
void PreviewSelect::on_cancelButton_clicked(){
close();
}

112
src/previewselect.h

@ -32,114 +32,36 @@ @@ -32,114 +32,36 @@
#define PREVIEWSELECT_H
#include <QDialog>
#include <QStandardItemModel>
#include <QHeaderView>
#include <QMessageBox>
#include <QFile>
#include <libtorrent/version.hpp>
#include <libtorrent/session.hpp>
#include <QList>
#include "ui_preview.h"
#include "previewlistdelegate.h"
#include "misc.h"
#include "qtorrenthandle.h"
#define NAME 0
#define SIZE 1
#define PROGRESS 2
class QStandardItemModel;
class PreviewListDelegate;
class previewSelect: public QDialog, private Ui::preview {
class PreviewSelect: public QDialog, private Ui::preview {
Q_OBJECT
private:
QStandardItemModel *previewListModel;
PreviewListDelegate *listDelegate;
QTorrentHandle h;
QList<int> indexes;
public:
enum PreviewColumn { NAME, SIZE, PROGRESS };
public:
PreviewSelect(QWidget* parent, QTorrentHandle h);
~PreviewSelect();
signals:
void readyToPreviewFile(QString) const;
protected slots:
void on_previewButton_clicked(){
QModelIndex index;
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(NAME);
if(selectedIndexes.size() == 0) return;
#if LIBTORRENT_VERSION_MINOR > 14
// Flush data
h.flush_cache();
#endif
QString path;
foreach(index, selectedIndexes){
path = h.files_path().at(indexes.at(index.row()));
// File
if(QFile::exists(path)){
emit readyToPreviewFile(path);
} else {
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
}
close();
return;
}
qDebug("Cannot find file: %s", path.toLocal8Bit().data());
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
close();
}
void on_cancelButton_clicked(){
close();
}
void on_previewButton_clicked();
void on_cancelButton_clicked();
public:
previewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent), h(h){
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
// Preview list
previewListModel = new QStandardItemModel(0, 3);
previewListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name"));
previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress"));
previewList->setModel(previewListModel);
listDelegate = new PreviewListDelegate(this);
previewList->setItemDelegate(listDelegate);
previewList->header()->resizeSection(0, 200);
// Fill list in
std::vector<libtorrent::size_type> fp;
h.file_progress(fp);
unsigned int nbFiles = h.num_files();
for(unsigned int i=0; i<nbFiles; ++i){
QString fileName = h.filename_at(i);
QString extension = fileName.split(QString::fromUtf8(".")).last().toUpper();
if(misc::isPreviewable(extension)) {
int row = previewListModel->rowCount();
previewListModel->insertRow(row);
previewListModel->setData(previewListModel->index(row, NAME), QVariant(fileName));
previewListModel->setData(previewListModel->index(row, SIZE), QVariant((qlonglong)h.filesize_at(i)));
previewListModel->setData(previewListModel->index(row, PROGRESS), QVariant((double)fp[i]/h.filesize_at(i)));
indexes << i;
}
}
previewList->selectionModel()->select(previewListModel->index(0, NAME), QItemSelectionModel::Select);
previewList->selectionModel()->select(previewListModel->index(0, SIZE), QItemSelectionModel::Select);
previewList->selectionModel()->select(previewListModel->index(0, PROGRESS), QItemSelectionModel::Select);
if(!previewListModel->rowCount()){
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
close();
}
connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString)));
if(previewListModel->rowCount() == 1){
qDebug("Torrent file only contains one file, no need to display selection dialog before preview");
// Only one file : no choice
on_previewButton_clicked();
}else{
qDebug("Displaying media file selection dialog for preview");
show();
}
}
private:
QStandardItemModel *previewListModel;
PreviewListDelegate *listDelegate;
QTorrentHandle h;
QList<int> indexes;
~previewSelect(){
delete previewListModel;
delete listDelegate;
}
};
#endif

7
src/searchengine/nova2/engines/btjunkie.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#VERSION: 2.23
#VERSION: 2.31
#AUTHORS: Christophe Dumez (chris@qbittorrent.org)
# Redistribution and use in source and binary forms, with or without
@ -54,10 +54,13 @@ class btjunkie(object): @@ -54,10 +54,13 @@ class btjunkie(object):
def start_a(self, attr):
params = dict(attr)
#print params
if params.has_key('href') and params['href'].startswith("http://dl.btjunkie.org/torrent"):
if params.has_key('href'):
if params['href'].startswith("http://dl.btjunkie.org/torrent"):
self.current_item = {}
self.th_counter = 0
self.current_item['link']=params['href'].strip()
elif self.th_counter == 0 and params['href'].startswith("/torrent/") and params['href'].find('/files/') == -1:
self.current_item['desc_link'] = 'http://btjunkie.org'+params['href'].strip()
def handle_data(self, data):
if self.th_counter == 0:

2
src/searchengine/nova2/engines/versions.txt

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
isohunt: 1.32
torrentreactor: 1.21
btjunkie: 2.23
btjunkie: 2.31
mininova: 1.40
piratebay: 1.30
vertor: 1.1

5
src/searchengine/nova2/novaprinter.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#VERSION: 1.33
#VERSION: 1.41
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@ -35,6 +35,9 @@ def prettyPrinter(dictionary): @@ -35,6 +35,9 @@ def prettyPrinter(dictionary):
if isinstance(dictionary[key], str):
dictionary[key] = unicode(dictionary[key], 'utf-8')
dictionary['size'] = anySizeToBytes(dictionary['size'])
if dictionary.has_key('desc_link'):
print u"%s|%s|%s|%s|%s|%s|%s"%(dictionary['link'],dictionary['name'],dictionary['size'],dictionary['seeds'],dictionary['leech'],dictionary['engine_url'],dictionary['desc_link'])
else:
print u"%s|%s|%s|%s|%s|%s"%(dictionary['link'],dictionary['name'],dictionary['size'],dictionary['seeds'],dictionary['leech'],dictionary['engine_url'])
def anySizeToBytes(size_string):

7
src/searchengine/search.ui

@ -136,6 +136,13 @@ @@ -136,6 +136,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="goToDescBtn">
<property name="text">
<string>Go to description page</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">

69
src/searchengine/searchengine.cpp

@ -42,6 +42,7 @@ @@ -42,6 +42,7 @@
#include <QMimeData>
#include <QSortFilterProxyModel>
#include <QFileDialog>
#include <QDesktopServices>
#ifdef Q_WS_WIN
#include <stdlib.h>
@ -64,6 +65,7 @@ SearchEngine::SearchEngine(MainWindow *parent) : QWidget(parent), mp_mainWindow( @@ -64,6 +65,7 @@ SearchEngine::SearchEngine(MainWindow *parent) : QWidget(parent), mp_mainWindow(
// Icons
search_button->setIcon(misc::getIcon("edit-find"));
download_button->setIcon(misc::getIcon("download"));
goToDescBtn->setIcon(misc::getIcon("application-x-mswinurl"));
enginesButton->setIcon(misc::getIcon("preferences-system-network"));
// new qCompleter to the search pattern
startSearchHistory();
@ -253,8 +255,10 @@ void SearchEngine::tab_changed(int t) @@ -253,8 +255,10 @@ void SearchEngine::tab_changed(int t)
{//-1 = no more tab
if(all_tab.at(tabWidget->currentIndex())->getCurrentSearchListModel()->rowCount()) {
download_button->setEnabled(true);
goToDescBtn->setEnabled(true);
} else {
download_button->setEnabled(false);
goToDescBtn->setEnabled(false);
}
}
}
@ -487,39 +491,39 @@ void SearchEngine::updateNova() { @@ -487,39 +491,39 @@ void SearchEngine::updateNova() {
package_file2.close();
// Copy search plugin files (if necessary)
QString filePath = search_dir.absoluteFilePath("nova2.py");
if(getPluginVersion(":/nova/nova2.py") > getPluginVersion(filePath)) {
if(getPluginVersion(":/nova2/nova2.py") > getPluginVersion(filePath)) {
if(QFile::exists(filePath)) {
misc::safeRemove(filePath);
misc::safeRemove(filePath+"c");
}
QFile::copy(":/nova/nova2.py", filePath);
QFile::copy(":/nova2/nova2.py", filePath);
}
filePath = search_dir.absoluteFilePath("nova2dl.py");
if(getPluginVersion(":/nova/nova2dl.py") > getPluginVersion(filePath)) {
if(getPluginVersion(":/nova2/nova2dl.py") > getPluginVersion(filePath)) {
if(QFile::exists(filePath)){
misc::safeRemove(filePath);
misc::safeRemove(filePath+"c");
}
QFile::copy(":/nova/nova2dl.py", filePath);
QFile::copy(":/nova2/nova2dl.py", filePath);
}
filePath = search_dir.absoluteFilePath("novaprinter.py");
if(getPluginVersion(":/nova/novaprinter.py") > getPluginVersion(filePath)) {
if(getPluginVersion(":/nova2/novaprinter.py") > getPluginVersion(filePath)) {
if(QFile::exists(filePath)){
misc::safeRemove(filePath);
misc::safeRemove(filePath+"c");
}
QFile::copy(":/nova/novaprinter.py", filePath);
QFile::copy(":/nova2/novaprinter.py", filePath);
}
filePath = search_dir.absoluteFilePath("helpers.py");
if(getPluginVersion(":/nova/helpers.py") > getPluginVersion(filePath)) {
if(getPluginVersion(":/nova2/helpers.py") > getPluginVersion(filePath)) {
if(QFile::exists(filePath)){
misc::safeRemove(filePath);
misc::safeRemove(filePath+"c");
}
QFile::copy(":/nova/helpers.py", filePath);
QFile::copy(":/nova2/helpers.py", filePath);
}
filePath = search_dir.absoluteFilePath("socks.py");
@ -527,9 +531,9 @@ void SearchEngine::updateNova() { @@ -527,9 +531,9 @@ void SearchEngine::updateNova() {
misc::safeRemove(filePath);
misc::safeRemove(filePath+"c");
}
QFile::copy(":/nova/socks.py", filePath);
QFile::copy(":/nova2/socks.py", filePath);
QDir destDir(QDir(misc::searchEngineLocation()).absoluteFilePath("engines"));
QDir shipped_subDir(":/nova/engines/");
QDir shipped_subDir(":/nova2/engines/");
QStringList files = shipped_subDir.entryList();
foreach(const QString &file, files){
QString shipped_file = shipped_subDir.absoluteFilePath(file);
@ -598,7 +602,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){ @@ -598,7 +602,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
// SLOT to append one line to search results list
// Line is in the following form :
// file url | file name | file size | nb seeds | nb leechers | Search engine url
void SearchEngine::appendSearchResult(QString line){
void SearchEngine::appendSearchResult(const QString &line){
if(!currentSearchTab) {
if(searchProcess->state() != QProcess::NotRunning){
searchProcess->terminate();
@ -609,8 +613,9 @@ void SearchEngine::appendSearchResult(QString line){ @@ -609,8 +613,9 @@ void SearchEngine::appendSearchResult(QString line){
search_stopped = true;
return;
}
QStringList parts = line.split("|");
if(parts.size() != 6){
const QStringList parts = line.split("|");
const int nb_fields = parts.size();
if(nb_fields < NB_PLUGIN_COLUMNS-1){ //-1 because desc_link is optional
return;
}
Q_ASSERT(currentSearchTab);
@ -620,28 +625,32 @@ void SearchEngine::appendSearchResult(QString line){ @@ -620,28 +625,32 @@ void SearchEngine::appendSearchResult(QString line){
int row = cur_model->rowCount();
cur_model->insertRow(row);
cur_model->setData(cur_model->index(row, 5), parts.at(0).trimmed()); // download URL
cur_model->setData(cur_model->index(row, 0), parts.at(1).trimmed()); // Name
cur_model->setData(cur_model->index(row, 1), parts.at(2).trimmed().toLongLong()); // Size
cur_model->setData(cur_model->index(row, DL_LINK), parts.at(PL_DL_LINK).trimmed()); // download URL
cur_model->setData(cur_model->index(row, NAME), parts.at(PL_NAME).trimmed()); // Name
cur_model->setData(cur_model->index(row, SIZE), parts.at(PL_SIZE).trimmed().toLongLong()); // Size
bool ok = false;
qlonglong nb_seeders = parts.at(3).trimmed().toLongLong(&ok);
qlonglong nb_seeders = parts.at(PL_SEEDS).trimmed().toLongLong(&ok);
if(!ok || nb_seeders < 0) {
cur_model->setData(cur_model->index(row, 2), tr("Unknown")); // Seeders
cur_model->setData(cur_model->index(row, SEEDS), tr("Unknown")); // Seeders
} else {
cur_model->setData(cur_model->index(row, 2), nb_seeders); // Seeders
cur_model->setData(cur_model->index(row, SEEDS), nb_seeders); // Seeders
}
qlonglong nb_leechers = parts.at(4).trimmed().toLongLong(&ok);
qlonglong nb_leechers = parts.at(PL_LEECHS).trimmed().toLongLong(&ok);
if(!ok || nb_leechers < 0) {
cur_model->setData(cur_model->index(row, 3), tr("Unknown")); // Leechers
cur_model->setData(cur_model->index(row, LEECHS), tr("Unknown")); // Leechers
} else {
cur_model->setData(cur_model->index(row, 3), nb_leechers); // Leechers
cur_model->setData(cur_model->index(row, LEECHS), nb_leechers); // Leechers
}
cur_model->setData(cur_model->index(row, 4), parts.at(5).trimmed()); // Engine URL
cur_model->setData(cur_model->index(row, ENGINE_URL), parts.at(PL_ENGINE_URL).trimmed()); // Engine URL
// Description Link
if(nb_fields == NB_PLUGIN_COLUMNS)
cur_model->setData(cur_model->index(row, DESC_LINK), parts.at(PL_DESC_LINK).trimmed());
no_search_results = false;
++nb_search_results;
// Enable clear & download buttons
download_button->setEnabled(true);
goToDescBtn->setEnabled(true);
}
#if QT_VERSION >= 0x040500
@ -660,6 +669,7 @@ void SearchEngine::closeTab(int index) { @@ -660,6 +669,7 @@ void SearchEngine::closeTab(int index) {
delete all_tab.takeAt(index);
if(!all_tab.size()) {
download_button->setEnabled(false);
goToDescBtn->setEnabled(false);
}
}
#else
@ -703,3 +713,16 @@ void SearchEngine::on_download_button_clicked(){ @@ -703,3 +713,16 @@ void SearchEngine::on_download_button_clicked(){
}
}
}
void SearchEngine::on_goToDescBtn_clicked()
{
QModelIndexList selectedIndexes = all_tab.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
foreach(const QModelIndex &index, selectedIndexes){
if(index.column() == NAME) {
QSortFilterProxyModel* model = all_tab.at(tabWidget->currentIndex())->getCurrentSearchListProxy();
const QString desc_url = model->data(model->index(index.row(), DESC_LINK)).toString();
if(!desc_url.isEmpty())
QDesktopServices::openUrl(QUrl(desc_url));
}
}
}

10
src/searchengine/searchengine.h

@ -50,6 +50,11 @@ class SearchEngine : public QWidget, public Ui::search_engine{ @@ -50,6 +50,11 @@ class SearchEngine : public QWidget, public Ui::search_engine{
Q_OBJECT
Q_DISABLE_COPY(SearchEngine)
public:
enum SearchColumn { NAME, SIZE, SEEDS, LEECHS, ENGINE_URL, DL_LINK, DESC_LINK, NB_SEARCH_COLUMNS };
private:
enum PluginColumn { PL_DL_LINK, PL_NAME, PL_SIZE, PL_SEEDS, PL_LEECHS, PL_ENGINE_URL, PL_DESC_LINK, NB_PLUGIN_COLUMNS };
public:
SearchEngine(MainWindow *mp_mainWindow);
~SearchEngine();
@ -91,7 +96,7 @@ protected slots: @@ -91,7 +96,7 @@ protected slots:
#else
void closeTab(int index);
#endif
void appendSearchResult(QString line);
void appendSearchResult(const QString &line);
void searchFinished(int exitcode,QProcess::ExitStatus);
void readSearchOutput();
void searchStarted();
@ -113,6 +118,9 @@ protected slots: @@ -113,6 +118,9 @@ protected slots:
void pythonDownloadFailure(QString url, QString error);
#endif
private slots:
void on_goToDescBtn_clicked();
private:
// Search related
QProcess *searchProcess;

10
src/searchengine/searchlistdelegate.h

@ -38,13 +38,7 @@ @@ -38,13 +38,7 @@
#include <QPainter>
#include <QProgressBar>
#include "misc.h"
// Defines for search results list columns
#define NAME 0
#define SIZE 1
#define SEEDERS 2
#define LEECHERS 3
#define ENGINE 4
#include "searchengine.h"
class SearchListDelegate: public QItemDelegate {
Q_OBJECT
@ -58,7 +52,7 @@ class SearchListDelegate: public QItemDelegate { @@ -58,7 +52,7 @@ class SearchListDelegate: public QItemDelegate {
painter->save();
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
switch(index.column()){
case SIZE:
case SearchEngine::SIZE:
QItemDelegate::drawBackground(painter, opt, index);
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
break;

27
src/searchengine/searchtab.cpp

@ -40,12 +40,6 @@ @@ -40,12 +40,6 @@
#include "searchengine.h"
#include "qinisettings.h"
#define SEARCH_NAME 0
#define SEARCH_SIZE 1
#define SEARCH_SEEDERS 2
#define SEARCH_LEECHERS 3
#define SEARCH_ENGINE 4
SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
{
box=new QVBoxLayout();
@ -57,12 +51,12 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent) @@ -57,12 +51,12 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
setLayout(box);
// Set Search results list model
SearchListModel = new QStandardItemModel(0,6);
SearchListModel->setHeaderData(SEARCH_NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
SearchListModel->setHeaderData(SEARCH_SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
SearchListModel->setHeaderData(SEARCH_SEEDERS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources"));
SearchListModel->setHeaderData(SEARCH_LEECHERS, Qt::Horizontal, tr("Leechers", "i.e: Number of partial sources"));
SearchListModel->setHeaderData(SEARCH_ENGINE, Qt::Horizontal, tr("Search engine"));
SearchListModel = new QStandardItemModel(0, SearchEngine::NB_SEARCH_COLUMNS);
SearchListModel->setHeaderData(SearchEngine::NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
SearchListModel->setHeaderData(SearchEngine::SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
SearchListModel->setHeaderData(SearchEngine::SEEDS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources"));
SearchListModel->setHeaderData(SearchEngine::LEECHS, Qt::Horizontal, tr("Leechers", "i.e: Number of partial sources"));
SearchListModel->setHeaderData(SearchEngine::ENGINE_URL, Qt::Horizontal, tr("Search engine"));
proxyModel = new QSortFilterProxyModel();
proxyModel->setDynamicSortFilter(true);
@ -72,7 +66,8 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent) @@ -72,7 +66,8 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
SearchDelegate = new SearchListDelegate();
resultsBrowser->setItemDelegate(SearchDelegate);
resultsBrowser->hideColumn(URL_COLUMN); // Hide url column
resultsBrowser->hideColumn(SearchEngine::DL_LINK); // Hide url column
resultsBrowser->hideColumn(SearchEngine::DESC_LINK);
resultsBrowser->setRootIsDecorated(false);
resultsBrowser->setAllColumnsShowFocus(true);
@ -87,12 +82,12 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent) @@ -87,12 +82,12 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
}
// Sort by Seeds
resultsBrowser->sortByColumn(SEEDERS, Qt::DescendingOrder);
resultsBrowser->sortByColumn(SearchEngine::SEEDS, Qt::DescendingOrder);
}
void SearchTab::downloadSelectedItem(const QModelIndex& index) {
QString engine_url = proxyModel->data(proxyModel->index(index.row(), ENGINE_URL_COLUMN)).toString();
QString torrent_url = proxyModel->data(proxyModel->index(index.row(), URL_COLUMN)).toString();
QString engine_url = proxyModel->data(proxyModel->index(index.row(), SearchEngine::ENGINE_URL)).toString();
QString torrent_url = proxyModel->data(proxyModel->index(index.row(), SearchEngine::DL_LINK)).toString();
setRowColor(index.row(), "red");
parent->downloadTorrent(engine_url, torrent_url);
}

3
src/src.pro

@ -139,7 +139,8 @@ nox { @@ -139,7 +139,8 @@ nox {
torrentadditiondlg.cpp \
sessionapplication.cpp \
torrentimportdlg.cpp \
executionlog.cpp
executionlog.cpp \
previewselect.cpp
win32 {
HEADERS += programupdater.h

30
src/transferlistwidget.cpp

@ -28,19 +28,6 @@ @@ -28,19 +28,6 @@
* Contact : chris@qbittorrent.org
*/
#include "transferlistwidget.h"
#include "qbtsession.h"
#include "torrentpersistentdata.h"
#include "transferlistdelegate.h"
#include "previewselect.h"
#include "speedlimitdlg.h"
#include "options_imp.h"
#include "mainwindow.h"
#include "preferences.h"
#include "torrentmodel.h"
#include "deletionconfirmationdlg.h"
#include "propertieswidget.h"
#include <libtorrent/version.hpp>
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
#include <QDesktopServices>
@ -52,9 +39,24 @@ @@ -52,9 +39,24 @@
#include <QMenu>
#include <QRegExp>
#include <QFileDialog>
#include <QMessageBox>
#include <libtorrent/version.hpp>
#include <vector>
#include <queue>
#include "transferlistwidget.h"
#include "qbtsession.h"
#include "torrentpersistentdata.h"
#include "transferlistdelegate.h"
#include "previewselect.h"
#include "speedlimitdlg.h"
#include "options_imp.h"
#include "mainwindow.h"
#include "preferences.h"
#include "torrentmodel.h"
#include "deletionconfirmationdlg.h"
#include "propertieswidget.h"
#include "qinisettings.h"
using namespace libtorrent;
@ -426,7 +428,7 @@ void TransferListWidget::previewSelectedTorrents() { @@ -426,7 +428,7 @@ void TransferListWidget::previewSelectedTorrents() {
foreach(const QString &hash, hashes) {
const QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid() && h.has_metadata()) {
new previewSelect(this, h);
new PreviewSelect(this, h);
}
}
}

Loading…
Cancel
Save