From 609820d3d2df6a2b19550725d63fa1572d4cc634 Mon Sep 17 00:00:00 2001 From: Leonardo Robol Date: Sun, 23 Oct 2011 21:56:15 +0200 Subject: [PATCH] FIxed encoding problems. --- feedpoller.cpp | 5 ++++- mainwindow.cpp | 5 ++++- mainwindow.ui | 8 -------- rssparser.cpp | 7 +++++++ rssparser.h | 5 +++++ 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/feedpoller.cpp b/feedpoller.cpp index 5c2c032..3d7b696 100644 --- a/feedpoller.cpp +++ b/feedpoller.cpp @@ -59,6 +59,7 @@ void FeedPoller::stopPolling () { poll_active = false; + QThread::exit(); } void @@ -72,7 +73,9 @@ FeedPoller::queueWork(const QModelIndex &index) void FeedPoller::networkManagerReplyFinished(QNetworkReply *reply) { - rssContent->insert (nowLoading, reply->readAll()); + // Assume that the string is UTF-8 encoded. This is likely to be + // true, but I should check it in some way. + rssContent->insert (nowLoading, QString::fromUtf8(reply->readAll())); // Now update the database with the new data obtained. QDomDocument doc; diff --git a/mainwindow.cpp b/mainwindow.cpp index 949e9c6..a512f6d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -30,6 +30,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->newsTableView->setColumnHidden(4, true); // Description ui->newsTableView->setColumnHidden(5, true); // Time ui->newsTableView->setColumnHidden(6, true); // Read state + ui->newsTableView->setEditTriggers(QTableView::NoEditTriggers); ui->newsTableView->verticalHeader()->setHidden(true); ui->newsTableView->horizontalHeader()->setStretchLastSection(false); ui->newsTableView->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch); @@ -47,6 +48,7 @@ MainWindow::~MainWindow() void MainWindow::do_exit() { poller->stopPolling(); + poller->wait(); QApplication::exit(); } @@ -78,7 +80,8 @@ void Larss::MainWindow::on_newsTableView_clicked(const QModelIndex &index) // A row got activated, so open it in the webview. QString link = rssParser->getLink(index); - ui->webView->load(link); + // ui->webView->load(link); + ui->webView->setHtml(rssParser->getDescription(index)); // And then mark it as read rssParser->setReadStatus(index, true); diff --git a/mainwindow.ui b/mainwindow.ui index 631e724..dbf773b 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -89,14 +89,6 @@ - - - TopToolBarArea - - - false - - diff --git a/rssparser.cpp b/rssparser.cpp index a9a1cbf..3322a0c 100644 --- a/rssparser.cpp +++ b/rssparser.cpp @@ -112,6 +112,13 @@ Larss::RssParser::getFeed(const QModelIndex &index) return (id - FEEDMODEL_MAX_CATEGORIES); } +QString +Larss::RssParser::getDescription(const QModelIndex &index) +{ + QModelIndex description_index = createIndex(index.row(), 4, index.internalPointer()); + return data(description_index, Qt::DisplayRole).toString(); +} + void Larss::RssParser::selectActiveFeed(quint64 feed_id) { diff --git a/rssparser.h b/rssparser.h index 4b42c93..bd9b772 100644 --- a/rssparser.h +++ b/rssparser.h @@ -42,6 +42,11 @@ namespace Larss { quint64 getFeed (const QModelIndex& index); /** + * @brief Get the description associated with the feed. + */ + QString getDescription (const QModelIndex& index); + + /** * @brief Set the read status on a news. */ void setReadStatus (const QModelIndex& index, bool read); -- 2.1.4