mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
Fix column sort in search engine. Closes #2621
This commit is contained in:
parent
326a74425f
commit
b23608ec35
3 changed files with 11 additions and 3 deletions
|
@ -475,13 +475,13 @@ void SearchEngine::appendSearchResult(const QString &line) {
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
qlonglong nb_seeders = parts.at(PL_SEEDS).trimmed().toLongLong(&ok);
|
qlonglong nb_seeders = parts.at(PL_SEEDS).trimmed().toLongLong(&ok);
|
||||||
if (!ok || nb_seeders < 0) {
|
if (!ok || nb_seeders < 0) {
|
||||||
cur_model->setData(cur_model->index(row, SearchSortModel::SEEDS), tr("Unknown")); // Seeders
|
cur_model->setData(cur_model->index(row, SearchSortModel::SEEDS), -1); // Seeders
|
||||||
} else {
|
} else {
|
||||||
cur_model->setData(cur_model->index(row, SearchSortModel::SEEDS), nb_seeders); // Seeders
|
cur_model->setData(cur_model->index(row, SearchSortModel::SEEDS), nb_seeders); // Seeders
|
||||||
}
|
}
|
||||||
qlonglong nb_leechers = parts.at(PL_LEECHS).trimmed().toLongLong(&ok);
|
qlonglong nb_leechers = parts.at(PL_LEECHS).trimmed().toLongLong(&ok);
|
||||||
if (!ok || nb_leechers < 0) {
|
if (!ok || nb_leechers < 0) {
|
||||||
cur_model->setData(cur_model->index(row, SearchSortModel::LEECHS), tr("Unknown")); // Leechers
|
cur_model->setData(cur_model->index(row, SearchSortModel::LEECHS), -1); // Leechers
|
||||||
} else {
|
} else {
|
||||||
cur_model->setData(cur_model->index(row, SearchSortModel::LEECHS), nb_leechers); // Leechers
|
cur_model->setData(cur_model->index(row, SearchSortModel::LEECHS), nb_leechers); // Leechers
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,14 @@ class SearchListDelegate: public QItemDelegate {
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
|
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
|
||||||
break;
|
break;
|
||||||
|
case SearchSortModel::SEEDS:
|
||||||
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
|
QItemDelegate::drawDisplay(painter, opt, option.rect, (index.data().toLongLong() >= 0) ? index.data().toString() : tr("Unknown"));
|
||||||
|
break;
|
||||||
|
case SearchSortModel::LEECHS:
|
||||||
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
|
QItemDelegate::drawDisplay(painter, opt, option.rect, (index.data().toLongLong() >= 0) ? index.data().toString() : tr("Unknown"));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
QItemDelegate::paint(painter, option, index);
|
QItemDelegate::paint(painter, option, index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
|
||||||
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(), "red");
|
setRowColor(index.row(), "blue");
|
||||||
parent->downloadTorrent(engine_url, torrent_url);
|
parent->downloadTorrent(engine_url, torrent_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue