|
|
@ -42,101 +42,104 @@ |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|