@brief Load/Update browser contents *----------------------------------------------------------------------------*/
| 1339 | /** @brief Load/Update browser contents |
| 1340 | *----------------------------------------------------------------------------*/ |
| 1341 | void NewsTabWidget::updateWebView(QModelIndex index) |
| 1342 | { |
| 1343 | if (!index.isValid()) { |
| 1344 | hideWebContent(); |
| 1345 | return; |
| 1346 | } |
| 1347 | |
| 1348 | QString newsId = newsModel_->dataField(index.row(), "id").toString(); |
| 1349 | linkNewsString_ = getLinkNews(index.row()); |
| 1350 | QString linkString = linkNewsString_; |
| 1351 | QUrl newsUrl = QUrl::fromEncoded(linkString.toUtf8()); |
| 1352 | |
| 1353 | bool showDescriptionNews_ = mainWindow_->showDescriptionNews_; |
| 1354 | QModelIndex currentIndex = feedsProxyModel_->mapToSource(feedsView_->currentIndex()); |
| 1355 | QVariant displayNews = feedsModel_->dataField(currentIndex, "displayNews"); |
| 1356 | QString feedId = newsModel_->dataField(index.row(), "feedId").toString(); |
| 1357 | QModelIndex feedIndex = feedsModel_->indexById(feedId.toInt()); |
| 1358 | |
| 1359 | if (!displayNews.toString().isEmpty()) |
| 1360 | showDescriptionNews_ = !displayNews.toInt(); |
| 1361 | |
| 1362 | if (!showDescriptionNews_) { |
| 1363 | if (mainWindow_->externalBrowserOn_ <= 0) { |
| 1364 | locationBar_->setText(newsUrl.toString()); |
| 1365 | setWebToolbarVisible(true, false); |
| 1366 | |
| 1367 | webView_->history()->setMaximumItemCount(0); |
| 1368 | webView_->load(newsUrl); |
| 1369 | webView_->history()->setMaximumItemCount(100); |
| 1370 | } else { |
| 1371 | openUrl(newsUrl); |
| 1372 | } |
| 1373 | } else { |
| 1374 | setWebToolbarVisible(false, false); |
| 1375 | |
| 1376 | QString htmlStr; |
| 1377 | QString content = newsModel_->dataField(index.row(), "content").toString(); |
| 1378 | if (!content.contains(QzRegExp("<html(.*)</html>", Qt::CaseInsensitive))) { |
| 1379 | QString description = newsModel_->dataField(index.row(), "description").toString(); |
| 1380 | if (content.isEmpty() || (description.length() > content.length())) { |
| 1381 | content = description; |
| 1382 | } |
| 1383 | |
| 1384 | QString titleString = newsModel_->dataField(index.row(), "title").toString(); |
| 1385 | if (!linkString.isEmpty()) { |
| 1386 | titleString = QString("<a href='%1' class='unread'>%2</a>"). |
| 1387 | arg(linkString, titleString); |
| 1388 | } |
| 1389 | |
| 1390 | QDateTime dtLocal; |
| 1391 | QString dateString = newsModel_->dataField(index.row(), "published").toString(); |
| 1392 | if (!dateString.isNull()) { |
| 1393 | QDateTime dtLocalTime = QDateTime::currentDateTime(); |
| 1394 | QDateTime dtUTC = QDateTime(dtLocalTime.date(), dtLocalTime.time(), Qt::UTC); |
| 1395 | int nTimeShift = dtLocalTime.secsTo(dtUTC); |
| 1396 | |
| 1397 | QDateTime dt = QDateTime::fromString(dateString, Qt::ISODate); |
| 1398 | dtLocal = dt.addSecs(nTimeShift); |
nothing calls this directly
no test coverage detected