mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 21:28:07 -06:00
Add date column to the built-in search engine
Adds a date column to the built-in search engine to show when a torrent was published/uploaded on the engine site. When a plugin wants to show a date, it can now add a `pub_date` entry to its result dict. The value format is a unix timestamp (an integer representing seconds since epoch). Plugins with no date support will keep working. PR #20703.
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "base/global.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/search/searchhandler.h"
|
||||
#include "base/utils/datetime.h"
|
||||
#include "base/utils/foreignapps.h"
|
||||
#include "base/utils/random.h"
|
||||
#include "base/utils/string.h"
|
||||
@@ -301,6 +302,7 @@ int SearchController::generateSearchId() const
|
||||
* - "nbLeechers"
|
||||
* - "siteUrl"
|
||||
* - "descrLink"
|
||||
* - "pubDate"
|
||||
*/
|
||||
QJsonObject SearchController::getResults(const QList<SearchResult> &searchResults, const bool isSearchActive, const int totalResults) const
|
||||
{
|
||||
@@ -315,7 +317,8 @@ QJsonObject SearchController::getResults(const QList<SearchResult> &searchResult
|
||||
{u"nbSeeders"_s, searchResult.nbSeeders},
|
||||
{u"nbLeechers"_s, searchResult.nbLeechers},
|
||||
{u"siteUrl"_s, searchResult.siteUrl},
|
||||
{u"descrLink"_s, searchResult.descrLink}
|
||||
{u"descrLink"_s, searchResult.descrLink},
|
||||
{u"pubDate"_s, Utils::DateTime::toSecsSinceEpoch(searchResult.pubDate)}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1685,6 +1685,7 @@ window.qBittorrent.DynamicTable = (function() {
|
||||
this.newColumn('nbSeeders', '', 'QBT_TR(Seeders)QBT_TR[CONTEXT=SearchResultsTable]', 100, true);
|
||||
this.newColumn('nbLeechers', '', 'QBT_TR(Leechers)QBT_TR[CONTEXT=SearchResultsTable]', 100, true);
|
||||
this.newColumn('siteUrl', '', 'QBT_TR(Search engine)QBT_TR[CONTEXT=SearchResultsTable]', 250, true);
|
||||
this.newColumn('pubDate', '', 'QBT_TR(Published On)QBT_TR[CONTEXT=SearchResultsTable]', 200, true);
|
||||
|
||||
this.initColumnsFunctions();
|
||||
},
|
||||
@@ -1701,10 +1702,17 @@ window.qBittorrent.DynamicTable = (function() {
|
||||
td.set('text', formattedValue);
|
||||
td.set('title', formattedValue);
|
||||
};
|
||||
const displayDate = function(td, row) {
|
||||
const value = this.getRowValue(row) * 1000;
|
||||
const formattedValue = (isNaN(value) || (value <= 0)) ? "" : (new Date(value).toLocaleString());
|
||||
td.set('text', formattedValue);
|
||||
td.set('title', formattedValue);
|
||||
};
|
||||
|
||||
this.columns['fileSize'].updateTd = displaySize;
|
||||
this.columns['nbSeeders'].updateTd = displayNum;
|
||||
this.columns['nbLeechers'].updateTd = displayNum;
|
||||
this.columns['pubDate'].updateTd = displayDate;
|
||||
},
|
||||
|
||||
getFilteredAndSortedRows: function() {
|
||||
|
||||
@@ -988,6 +988,7 @@
|
||||
nbLeechers: result.nbLeechers,
|
||||
nbSeeders: result.nbSeeders,
|
||||
siteUrl: result.siteUrl,
|
||||
pubDate: result.pubDate,
|
||||
};
|
||||
|
||||
newRows.push(row);
|
||||
|
||||
Reference in New Issue
Block a user