mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 12:59:56 -07:00
Merge pull request #2861 from DoumanAsh/search_status_tab
Search status tab
This commit is contained in:
commit
ed45ff89f8
4 changed files with 186 additions and 161 deletions
|
@ -148,7 +148,8 @@ void SearchEngine::tab_changed(int t)
|
||||||
{//when we switch from a tab that is not empty to another that is empty the download button
|
{//when we switch from a tab that is not empty to another that is empty the download button
|
||||||
//doesn't have to be available
|
//doesn't have to be available
|
||||||
if (t>-1) {//-1 = no more tab
|
if (t>-1) {//-1 = no more tab
|
||||||
if (all_tab.at(tabWidget->currentIndex())->getCurrentSearchListModel()->rowCount()) {
|
currentSearchTab = all_tab.at(tabWidget->currentIndex());
|
||||||
|
if (currentSearchTab->getCurrentSearchListModel()->rowCount()) {
|
||||||
download_button->setEnabled(true);
|
download_button->setEnabled(true);
|
||||||
goToDescBtn->setEnabled(true);
|
goToDescBtn->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
@ -156,6 +157,7 @@ void SearchEngine::tab_changed(int t)
|
||||||
download_button->setEnabled(false);
|
download_button->setEnabled(false);
|
||||||
goToDescBtn->setEnabled(false);
|
goToDescBtn->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
search_status->setText(currentSearchTab->status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +196,7 @@ void SearchEngine::on_search_button_clicked() {
|
||||||
search_button->setText(tr("Search"));
|
search_button->setText(tr("Search"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
allTabsSetActiveState(false);
|
||||||
}
|
}
|
||||||
searchProcess->waitForFinished();
|
searchProcess->waitForFinished();
|
||||||
// Reload environment variables (proxy)
|
// Reload environment variables (proxy)
|
||||||
|
@ -207,6 +210,7 @@ void SearchEngine::on_search_button_clicked() {
|
||||||
}
|
}
|
||||||
// Tab Addition
|
// Tab Addition
|
||||||
currentSearchTab = new SearchTab(this);
|
currentSearchTab = new SearchTab(this);
|
||||||
|
activeSearchTab = currentSearchTab;
|
||||||
connect(currentSearchTab->header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveResultsColumnsWidth()));
|
connect(currentSearchTab->header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveResultsColumnsWidth()));
|
||||||
all_tab.append(currentSearchTab);
|
all_tab.append(currentSearchTab);
|
||||||
QString tabName = pattern;
|
QString tabName = pattern;
|
||||||
|
@ -278,7 +282,8 @@ 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..."));
|
activeSearchTab->status = tr("Searching...");
|
||||||
|
search_status->setText(activeSearchTab->status);
|
||||||
search_status->repaint();
|
search_status->repaint();
|
||||||
search_button->setText(tr("Stop"));
|
search_button->setText(tr("Stop"));
|
||||||
}
|
}
|
||||||
|
@ -298,8 +303,8 @@ void SearchEngine::readSearchOutput() {
|
||||||
foreach (const QByteArray &line, lines_list) {
|
foreach (const QByteArray &line, lines_list) {
|
||||||
appendSearchResult(QString::fromUtf8(line));
|
appendSearchResult(QString::fromUtf8(line));
|
||||||
}
|
}
|
||||||
if (currentSearchTab)
|
if (activeSearchTab)
|
||||||
currentSearchTab->getCurrentLabel()->setText(tr("Results")+QString::fromUtf8(" <i>(")+QString::number(nb_search_results)+QString::fromUtf8(")</i>:"));
|
activeSearchTab->getCurrentLabel()->setText(tr("Results")+QString::fromUtf8(" <i>(")+QString::number(nb_search_results)+QString::fromUtf8(")</i>:"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchEngine::downloadFinished(int exitcode, QProcess::ExitStatus) {
|
void SearchEngine::downloadFinished(int exitcode, QProcess::ExitStatus) {
|
||||||
|
@ -412,7 +417,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();
|
||||||
}
|
}
|
||||||
|
@ -422,24 +427,28 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus) {
|
||||||
}
|
}
|
||||||
if (exitcode) {
|
if (exitcode) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
search_status->setText(tr("Search aborted"));
|
activeSearchTab->status = tr("Search aborted");
|
||||||
#else
|
#else
|
||||||
search_status->setText(tr("An error occurred during search..."));
|
activeSearchTab->status = tr("An error occurred during search...");
|
||||||
#endif
|
#endif
|
||||||
}else{
|
} else {
|
||||||
if (search_stopped) {
|
if (search_stopped) {
|
||||||
search_status->setText(tr("Search aborted"));
|
activeSearchTab->status = tr("Search aborted");
|
||||||
}else{
|
} else {
|
||||||
if (no_search_results) {
|
if (no_search_results) {
|
||||||
search_status->setText(tr("Search returned no results"));
|
activeSearchTab->status = tr("Search returned no results");
|
||||||
}else{
|
} else {
|
||||||
search_status->setText(tr("Search has finished"));
|
activeSearchTab->status = tr("Search has finished");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentSearchTab)
|
if (activeSearchTab)
|
||||||
currentSearchTab->getCurrentLabel()->setText(tr("Results", "i.e: Search results")+QString::fromUtf8(" <i>(")+QString::number(nb_search_results)+QString::fromUtf8(")</i>:"));
|
if (currentSearchTab == activeSearchTab) search_status->setText(activeSearchTab->status);
|
||||||
|
activeSearchTab->getCurrentLabel()->setText(tr("Results", "i.e: Search results")+QString::fromUtf8(" <i>(")+QString::number(nb_search_results)+QString::fromUtf8(")</i>:"));
|
||||||
|
activeSearchTab->isActive = false;
|
||||||
|
activeSearchTab = 0;
|
||||||
|
|
||||||
search_button->setText(tr("Search"));
|
search_button->setText(tr("Search"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,7 +456,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus) {
|
||||||
// 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 (!activeSearchTab) {
|
||||||
if (searchProcess->state() != QProcess::NotRunning) {
|
if (searchProcess->state() != QProcess::NotRunning) {
|
||||||
searchProcess->terminate();
|
searchProcess->terminate();
|
||||||
}
|
}
|
||||||
|
@ -462,9 +471,9 @@ void SearchEngine::appendSearchResult(const QString &line) {
|
||||||
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(activeSearchTab);
|
||||||
// Add item to search result list
|
// Add item to search result list
|
||||||
QStandardItemModel* cur_model = currentSearchTab->getCurrentSearchListModel();
|
QStandardItemModel* cur_model = activeSearchTab->getCurrentSearchListModel();
|
||||||
Q_ASSERT(cur_model);
|
Q_ASSERT(cur_model);
|
||||||
int row = cur_model->rowCount();
|
int row = cur_model->rowCount();
|
||||||
cur_model->insertRow(row);
|
cur_model->insertRow(row);
|
||||||
|
@ -498,8 +507,9 @@ void SearchEngine::appendSearchResult(const QString &line) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchEngine::closeTab(int index) {
|
void SearchEngine::closeTab(int index) {
|
||||||
if (index == tabWidget->indexOf(currentSearchTab)) {
|
// Search is run for active tab so if user decided to close it, then stop search
|
||||||
qDebug("Deleted current search Tab");
|
if (activeSearchTab && index == tabWidget->indexOf(activeSearchTab)) {
|
||||||
|
qDebug("Closed active search Tab");
|
||||||
if (searchProcess->state() != QProcess::NotRunning) {
|
if (searchProcess->state() != QProcess::NotRunning) {
|
||||||
searchProcess->terminate();
|
searchProcess->terminate();
|
||||||
}
|
}
|
||||||
|
@ -507,7 +517,8 @@ void SearchEngine::closeTab(int index) {
|
||||||
searchTimeout->stop();
|
searchTimeout->stop();
|
||||||
}
|
}
|
||||||
search_stopped = true;
|
search_stopped = true;
|
||||||
currentSearchTab = 0;
|
if (currentSearchTab == activeSearchTab) currentSearchTab = 0;
|
||||||
|
activeSearchTab = 0;
|
||||||
}
|
}
|
||||||
delete all_tab.takeAt(index);
|
delete all_tab.takeAt(index);
|
||||||
if (!all_tab.size()) {
|
if (!all_tab.size()) {
|
||||||
|
@ -544,3 +555,10 @@ void SearchEngine::on_goToDescBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void SearchEngine::allTabsSetActiveState(bool newState)
|
||||||
|
{
|
||||||
|
foreach(SearchTab *tab, all_tab) {
|
||||||
|
tab->isActive = newState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -50,81 +50,83 @@ class QTimer;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class SearchEngine : public QWidget, public Ui::search_engine{
|
class SearchEngine : public QWidget, public Ui::search_engine{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(SearchEngine)
|
Q_DISABLE_COPY(SearchEngine)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum PluginColumn { PL_DL_LINK, PL_NAME, PL_SIZE, PL_SEEDS, PL_LEECHS, PL_ENGINE_URL, PL_DESC_LINK, NB_PLUGIN_COLUMNS };
|
enum PluginColumn { PL_DL_LINK, PL_NAME, PL_SIZE, PL_SEEDS, PL_LEECHS, PL_ENGINE_URL, PL_DESC_LINK, NB_PLUGIN_COLUMNS };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SearchEngine(MainWindow *mp_mainWindow);
|
SearchEngine(MainWindow *mp_mainWindow);
|
||||||
~SearchEngine();
|
~SearchEngine();
|
||||||
QString selectedCategory() const;
|
QString selectedCategory() const;
|
||||||
QString selectedEngine() const;
|
QString selectedEngine() const;
|
||||||
|
|
||||||
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)) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
qreal version = 0.0;
|
||||||
|
while (!plugin.atEnd()) {
|
||||||
|
QByteArray line = plugin.readLine();
|
||||||
|
if (line.startsWith("#VERSION: ")) {
|
||||||
|
line = line.split(' ').last().trimmed();
|
||||||
|
version = line.toFloat();
|
||||||
|
qDebug("plugin %s version: %.2f", qPrintable(filePath), version);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
if (!plugin.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
qreal version = 0.0;
|
|
||||||
while (!plugin.atEnd()) {
|
|
||||||
QByteArray line = plugin.readLine();
|
|
||||||
if (line.startsWith("#VERSION: ")) {
|
|
||||||
line = line.split(' ').last().trimmed();
|
|
||||||
version = line.toFloat();
|
|
||||||
qDebug("plugin %s version: %.2f", qPrintable(filePath), version);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void on_download_button_clicked();
|
void on_download_button_clicked();
|
||||||
void downloadTorrent(QString engine_url, QString torrent_url);
|
void downloadTorrent(QString engine_url, QString torrent_url);
|
||||||
void giveFocusToSearchInput();
|
void giveFocusToSearchInput();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
// Search slots
|
// Search slots
|
||||||
void tab_changed(int);//to prevent the use of the download button when the tab is empty
|
void tab_changed(int);//to prevent the use of the download button when the tab is empty
|
||||||
void on_search_button_clicked();
|
void on_search_button_clicked();
|
||||||
void closeTab(int index);
|
void closeTab(int index);
|
||||||
void appendSearchResult(const QString &line);
|
void appendSearchResult(const QString &line);
|
||||||
void searchFinished(int exitcode,QProcess::ExitStatus);
|
void searchFinished(int exitcode,QProcess::ExitStatus);
|
||||||
void readSearchOutput();
|
void readSearchOutput();
|
||||||
void searchStarted();
|
void searchStarted();
|
||||||
void updateNova();
|
void updateNova();
|
||||||
void selectMultipleBox(const QString &text);
|
void selectMultipleBox(const QString &text);
|
||||||
void on_enginesButton_clicked();
|
void on_enginesButton_clicked();
|
||||||
void saveResultsColumnsWidth();
|
void saveResultsColumnsWidth();
|
||||||
void downloadFinished(int exitcode, QProcess::ExitStatus);
|
void downloadFinished(int exitcode, QProcess::ExitStatus);
|
||||||
void fillCatCombobox();
|
void fillCatCombobox();
|
||||||
void fillEngineComboBox();
|
void fillEngineComboBox();
|
||||||
void searchTextEdited(QString);
|
void searchTextEdited(QString);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_goToDescBtn_clicked();
|
void on_goToDescBtn_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Search related
|
// Search related
|
||||||
LineEdit* search_pattern;
|
LineEdit* search_pattern;
|
||||||
QProcess *searchProcess;
|
QProcess *searchProcess;
|
||||||
QList<QProcess*> downloaders;
|
QList<QProcess*> downloaders;
|
||||||
bool search_stopped;
|
bool search_stopped;
|
||||||
bool no_search_results;
|
bool no_search_results;
|
||||||
QByteArray search_result_line_truncated;
|
QByteArray search_result_line_truncated;
|
||||||
unsigned long nb_search_results;
|
unsigned long nb_search_results;
|
||||||
SupportedEngines *supported_engines;
|
SupportedEngines *supported_engines;
|
||||||
QTimer *searchTimeout;
|
QTimer *searchTimeout;
|
||||||
QPointer<SearchTab> currentSearchTab;
|
QPointer<SearchTab> currentSearchTab; // Selected tab
|
||||||
QList<QPointer<SearchTab> > all_tab; // To store all tabs
|
QPointer<SearchTab> activeSearchTab; // Tab with running search
|
||||||
const SearchCategories full_cat_names;
|
QList<QPointer<SearchTab> > all_tab; // To store all tabs
|
||||||
MainWindow *mp_mainWindow;
|
const SearchCategories full_cat_names;
|
||||||
|
MainWindow *mp_mainWindow;
|
||||||
|
inline void allTabsSetActiveState(bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,101 +42,106 @@
|
||||||
|
|
||||||
SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
|
SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
|
||||||
{
|
{
|
||||||
box=new QVBoxLayout();
|
box = new QVBoxLayout();
|
||||||
results_lbl=new QLabel();
|
results_lbl = new QLabel();
|
||||||
resultsBrowser = new QTreeView();
|
resultsBrowser = new QTreeView();
|
||||||
resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
box->addWidget(results_lbl);
|
box->addWidget(results_lbl);
|
||||||
box->addWidget(resultsBrowser);
|
box->addWidget(resultsBrowser);
|
||||||
|
// New tab is created with new search
|
||||||
|
isActive = true;
|
||||||
|
|
||||||
setLayout(box);
|
setLayout(box);
|
||||||
// Set Search results list model
|
// Set Search results list model
|
||||||
SearchListModel = new QStandardItemModel(0, SearchSortModel::NB_SEARCH_COLUMNS);
|
SearchListModel = new QStandardItemModel(0, SearchSortModel::NB_SEARCH_COLUMNS);
|
||||||
SearchListModel->setHeaderData(SearchSortModel::NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
SearchListModel->setHeaderData(SearchSortModel::NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
||||||
SearchListModel->setHeaderData(SearchSortModel::SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
SearchListModel->setHeaderData(SearchSortModel::SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
||||||
SearchListModel->setHeaderData(SearchSortModel::SEEDS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources"));
|
SearchListModel->setHeaderData(SearchSortModel::SEEDS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources"));
|
||||||
SearchListModel->setHeaderData(SearchSortModel::LEECHS, Qt::Horizontal, tr("Leechers", "i.e: Number of partial sources"));
|
SearchListModel->setHeaderData(SearchSortModel::LEECHS, Qt::Horizontal, tr("Leechers", "i.e: Number of partial sources"));
|
||||||
SearchListModel->setHeaderData(SearchSortModel::ENGINE_URL, Qt::Horizontal, tr("Search engine"));
|
SearchListModel->setHeaderData(SearchSortModel::ENGINE_URL, Qt::Horizontal, tr("Search engine"));
|
||||||
|
|
||||||
proxyModel = new SearchSortModel();
|
proxyModel = new SearchSortModel();
|
||||||
proxyModel->setDynamicSortFilter(true);
|
proxyModel->setDynamicSortFilter(true);
|
||||||
proxyModel->setSourceModel(SearchListModel);
|
proxyModel->setSourceModel(SearchListModel);
|
||||||
resultsBrowser->setModel(proxyModel);
|
resultsBrowser->setModel(proxyModel);
|
||||||
|
|
||||||
SearchDelegate = new SearchListDelegate();
|
SearchDelegate = new SearchListDelegate();
|
||||||
resultsBrowser->setItemDelegate(SearchDelegate);
|
resultsBrowser->setItemDelegate(SearchDelegate);
|
||||||
|
|
||||||
resultsBrowser->hideColumn(SearchSortModel::DL_LINK); // Hide url column
|
resultsBrowser->hideColumn(SearchSortModel::DL_LINK); // Hide url column
|
||||||
resultsBrowser->hideColumn(SearchSortModel::DESC_LINK);
|
resultsBrowser->hideColumn(SearchSortModel::DESC_LINK);
|
||||||
|
|
||||||
resultsBrowser->setRootIsDecorated(false);
|
resultsBrowser->setRootIsDecorated(false);
|
||||||
resultsBrowser->setAllColumnsShowFocus(true);
|
resultsBrowser->setAllColumnsShowFocus(true);
|
||||||
resultsBrowser->setSortingEnabled(true);
|
resultsBrowser->setSortingEnabled(true);
|
||||||
|
|
||||||
// Connect signals to slots (search part)
|
// Connect signals to slots (search part)
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort by Seeds
|
// Sort by Seeds
|
||||||
resultsBrowser->sortByColumn(SearchSortModel::SEEDS, Qt::DescendingOrder);
|
resultsBrowser->sortByColumn(SearchSortModel::SEEDS, Qt::DescendingOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchTab::downloadSelectedItem(const QModelIndex& index) {
|
void SearchTab::downloadSelectedItem(const QModelIndex& index) {
|
||||||
QString engine_url = proxyModel->data(proxyModel->index(index.row(), SearchSortModel::ENGINE_URL)).toString();
|
QString engine_url = proxyModel->data(proxyModel->index(index.row(), SearchSortModel::ENGINE_URL)).toString();
|
||||||
QString torrent_url = proxyModel->data(proxyModel->index(index.row(), SearchSortModel::DL_LINK)).toString();
|
QString torrent_url = proxyModel->data(proxyModel->index(index.row(), SearchSortModel::DL_LINK)).toString();
|
||||||
setRowColor(index.row(), "blue");
|
setRowColor(index.row(), "blue");
|
||||||
parent->downloadTorrent(engine_url, torrent_url);
|
parent->downloadTorrent(engine_url, torrent_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchTab::~SearchTab() {
|
SearchTab::~SearchTab() {
|
||||||
delete box;
|
delete box;
|
||||||
delete results_lbl;
|
delete results_lbl;
|
||||||
delete resultsBrowser;
|
delete resultsBrowser;
|
||||||
delete SearchListModel;
|
delete SearchListModel;
|
||||||
delete proxyModel;
|
delete proxyModel;
|
||||||
delete SearchDelegate;
|
delete SearchDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHeaderView* SearchTab::header() const {
|
QHeaderView* SearchTab::header() const {
|
||||||
return resultsBrowser->header();
|
return resultsBrowser->header();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SearchTab::loadColWidthResultsList() {
|
bool SearchTab::loadColWidthResultsList() {
|
||||||
QString line = Preferences::instance()->getSearchColsWidth();
|
QString line = Preferences::instance()->getSearchColsWidth();
|
||||||
if (line.isEmpty())
|
if (line.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
QStringList width_list = line.split(' ');
|
|
||||||
if (width_list.size() > SearchListModel->columnCount())
|
QStringList width_list = line.split(' ');
|
||||||
return false;
|
if (width_list.size() > SearchListModel->columnCount())
|
||||||
unsigned int listSize = width_list.size();
|
return false;
|
||||||
for (unsigned int i=0; i<listSize; ++i) {
|
|
||||||
resultsBrowser->header()->resizeSection(i, width_list.at(i).toInt());
|
unsigned int listSize = width_list.size();
|
||||||
}
|
for (unsigned int i=0; i<listSize; ++i) {
|
||||||
return true;
|
resultsBrowser->header()->resizeSection(i, width_list.at(i).toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QLabel* SearchTab::getCurrentLabel()
|
QLabel* SearchTab::getCurrentLabel()
|
||||||
{
|
{
|
||||||
return results_lbl;
|
return results_lbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeView* SearchTab::getCurrentTreeView()
|
QTreeView* SearchTab::getCurrentTreeView()
|
||||||
{
|
{
|
||||||
return resultsBrowser;
|
return resultsBrowser;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSortFilterProxyModel* SearchTab::getCurrentSearchListProxy() const
|
QSortFilterProxyModel* SearchTab::getCurrentSearchListProxy() const
|
||||||
{
|
{
|
||||||
return proxyModel;
|
return proxyModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStandardItemModel* SearchTab::getCurrentSearchListModel() const
|
QStandardItemModel* SearchTab::getCurrentSearchListModel() const
|
||||||
{
|
{
|
||||||
return SearchListModel;
|
return SearchListModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the color of a row in data model
|
// Set the color of a row in data model
|
||||||
|
|
|
@ -47,32 +47,32 @@ class QStandardItemModel;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class SearchTab: public QWidget, public Ui::search_engine {
|
class SearchTab: public QWidget, public Ui::search_engine {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVBoxLayout *box;
|
QVBoxLayout *box;
|
||||||
QLabel *results_lbl;
|
QLabel *results_lbl;
|
||||||
QTreeView *resultsBrowser;
|
QTreeView *resultsBrowser;
|
||||||
QStandardItemModel *SearchListModel;
|
QStandardItemModel *SearchListModel;
|
||||||
SearchSortModel *proxyModel;
|
SearchSortModel *proxyModel;
|
||||||
SearchListDelegate *SearchDelegate;
|
SearchListDelegate *SearchDelegate;
|
||||||
SearchEngine *parent;
|
SearchEngine *parent;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void downloadSelectedItem(const QModelIndex& index);
|
void downloadSelectedItem(const QModelIndex& index);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SearchTab(SearchEngine *parent);
|
SearchTab(SearchEngine *parent);
|
||||||
~SearchTab();
|
~SearchTab();
|
||||||
bool loadColWidthResultsList();
|
bool loadColWidthResultsList();
|
||||||
QLabel * getCurrentLabel();
|
QLabel * getCurrentLabel();
|
||||||
QStandardItemModel* getCurrentSearchListModel() const;
|
QStandardItemModel* getCurrentSearchListModel() const;
|
||||||
QSortFilterProxyModel* getCurrentSearchListProxy() const;
|
QSortFilterProxyModel* getCurrentSearchListProxy() const;
|
||||||
QTreeView * getCurrentTreeView();
|
QTreeView * getCurrentTreeView();
|
||||||
void setRowColor(int row, QString color);
|
void setRowColor(int row, QString color);
|
||||||
QHeaderView* header() const;
|
QHeaderView* header() const;
|
||||||
|
bool isActive;
|
||||||
|
QString status;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue