FIxed encoding problems.
Leonardo Robol [2011-10-23 19:56]
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 @@
</widget>
<addaction name="menuFile"/>
</widget>
- <widget class="QToolBar" name="mainToolBar">
- <attribute name="toolBarArea">
- <enum>TopToolBarArea</enum>
- </attribute>
- <attribute name="toolBarBreak">
- <bool>false</bool>
- </attribute>
- </widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionExit">
<property name="text">
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);