mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-15 01:33:07 -07:00
Improve coding style
This commit is contained in:
parent
acad35c5bc
commit
c41df9ffbd
147 changed files with 4454 additions and 2227 deletions
|
@ -59,20 +59,23 @@ HtmlBrowser::~HtmlBrowser()
|
|||
|
||||
QVariant HtmlBrowser::loadResource(int type, const QUrl &name)
|
||||
{
|
||||
if (type == QTextDocument::ImageResource) {
|
||||
if (type == QTextDocument::ImageResource)
|
||||
{
|
||||
QUrl url(name);
|
||||
if (url.scheme().isEmpty())
|
||||
url.setScheme("http");
|
||||
|
||||
QIODevice *dev = m_diskCache->data(url);
|
||||
if (dev) {
|
||||
if (dev)
|
||||
{
|
||||
qDebug() << "HtmlBrowser::loadResource() cache " << url.toString();
|
||||
QByteArray res = dev->readAll();
|
||||
delete dev;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (!m_activeRequests.contains(url)) {
|
||||
if (!m_activeRequests.contains(url))
|
||||
{
|
||||
m_activeRequests.insert(url, true);
|
||||
qDebug() << "HtmlBrowser::loadResource() get " << url.toString();
|
||||
QNetworkRequest req(url);
|
||||
|
@ -90,10 +93,12 @@ void HtmlBrowser::resourceLoaded(QNetworkReply *reply)
|
|||
{
|
||||
m_activeRequests.remove(reply->request().url());
|
||||
|
||||
if ((reply->error() == QNetworkReply::NoError) && (reply->size() > 0)) {
|
||||
if ((reply->error() == QNetworkReply::NoError) && (reply->size() > 0))
|
||||
{
|
||||
qDebug() << "HtmlBrowser::resourceLoaded() save " << reply->request().url().toString();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// If resource failed to load, replace it with warning icon and store it in cache for 1 day.
|
||||
// Otherwise HTMLBrowser will keep trying to download it every time article is displayed,
|
||||
// since it's not possible to cache error responses.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue