Improve coding style

This commit is contained in:
Vladimir Golovnev (Glassez) 2020-11-16 10:02:11 +03:00
parent acad35c5bc
commit c41df9ffbd
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
147 changed files with 4454 additions and 2227 deletions

View file

@ -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.