Removed "date_updated" column.

This commit is contained in:
Martin Rotter 2013-12-24 13:58:12 +01:00
parent 55dcca35be
commit 81ec000e48
10 changed files with 17 additions and 22 deletions

View File

@ -59,7 +59,6 @@ CREATE TABLE IF NOT EXISTS Messages (
url TEXT, url TEXT,
author TEXT, author TEXT,
date_created TEXT NOT NULL CHECK (date_created != ''), date_created TEXT NOT NULL CHECK (date_created != ''),
date_updated TEXT,
contents TEXT, contents TEXT,
FOREIGN KEY (feed) REFERENCES Feeds (id) FOREIGN KEY (feed) REFERENCES Feeds (id)

View File

@ -67,8 +67,7 @@
#define MSG_DB_URL_INDEX 6 #define MSG_DB_URL_INDEX 6
#define MSG_DB_AUTHOR_INDEX 7 #define MSG_DB_AUTHOR_INDEX 7
#define MSG_DB_DCREATED_INDEX 8 #define MSG_DB_DCREATED_INDEX 8
#define MSG_DB_DUPDATED_INDEX 9 #define MSG_DB_CONTENTS_INDEX 9
#define MSG_DB_CONTENTS_INDEX 10
// Indexes of columns as they are DEFINED IN THE TABLE for CATEGORIES. // Indexes of columns as they are DEFINED IN THE TABLE for CATEGORIES.
#define CAT_DB_ID_INDEX 0 #define CAT_DB_ID_INDEX 0

View File

@ -205,8 +205,8 @@ void FeedsModelStandardFeed::updateMessages(const QList<Message> &messages) {
"WHERE feed = :feed AND title = :title AND url = :url;"); "WHERE feed = :feed AND title = :title AND url = :url;");
query_insert.prepare("INSERT INTO Messages " query_insert.prepare("INSERT INTO Messages "
"(feed, title, url, author, date_created, date_updated, contents) " "(feed, title, url, author, date_created, contents) "
"VALUES (:feed, :title, :url, :author, :date_created, :date_updated, :contents);"); "VALUES (:feed, :title, :url, :author, :date_created, :contents);");
foreach (const Message &message, messages) { foreach (const Message &message, messages) {
query_select.bindValue(":feed", feed_id); query_select.bindValue(":feed", feed_id);
@ -231,7 +231,6 @@ void FeedsModelStandardFeed::updateMessages(const QList<Message> &messages) {
query_insert.bindValue(":url", message.m_url); query_insert.bindValue(":url", message.m_url);
query_insert.bindValue(":author", message.m_author); query_insert.bindValue(":author", message.m_author);
query_insert.bindValue(":date_created", message.m_created.toString(Qt::ISODate)); query_insert.bindValue(":date_created", message.m_created.toString(Qt::ISODate));
query_insert.bindValue(":date_updated", message.m_updated.toString(Qt::ISODate));
query_insert.bindValue(":contents", message.m_contents); query_insert.bindValue(":contents", message.m_contents);
query_insert.exec(); query_insert.exec();

View File

@ -93,7 +93,7 @@ Message MessagesModel::messageAt(int row_index) const {
message.m_contents = rec.value(MSG_DB_CONTENTS_INDEX).toString(); message.m_contents = rec.value(MSG_DB_CONTENTS_INDEX).toString();
message.m_title = rec.value(MSG_DB_TITLE_INDEX).toString(); message.m_title = rec.value(MSG_DB_TITLE_INDEX).toString();
message.m_url = rec.value(MSG_DB_URL_INDEX).toString(); message.m_url = rec.value(MSG_DB_URL_INDEX).toString();
message.m_updated = TextFactory::parseDateTime(rec.value(MSG_DB_DUPDATED_INDEX).toString()); message.m_created = TextFactory::parseDateTime(rec.value(MSG_DB_DCREATED_INDEX).toString());
return message; return message;
} }
@ -101,13 +101,13 @@ Message MessagesModel::messageAt(int row_index) const {
void MessagesModel::setupHeaderData() { void MessagesModel::setupHeaderData() {
m_headerData << tr("Id") << tr("Read") << tr("Deleted") << tr("Important") << m_headerData << tr("Id") << tr("Read") << tr("Deleted") << tr("Important") <<
tr("Feed") << tr("Title") << tr("Url") << tr("Author") << tr("Feed") << tr("Title") << tr("Url") << tr("Author") <<
tr("Created on") << tr("Updated on") << tr("Contents"); tr("Created on") << tr("Contents");
m_tooltipData << tr("Id of the message.") << tr("Is message read?") << m_tooltipData << tr("Id of the message.") << tr("Is message read?") <<
tr("Is message deleted?") << tr("Is message important?") << tr("Is message deleted?") << tr("Is message important?") <<
tr("Id of feed which this message belongs to.") << tr("Id of feed which this message belongs to.") <<
tr("Title of the message.") << tr("Url of the message.") << tr("Title of the message.") << tr("Url of the message.") <<
tr("Author of the message.") << tr("Creation date of the message.") << tr("Author of the message.") << tr("Creation date of the message.") <<
tr("Date of the most recent update of the message.") << tr("Contents of the message."); tr("Contents of the message.");
} }
Qt::ItemFlags MessagesModel::flags(const QModelIndex &index) const { Qt::ItemFlags MessagesModel::flags(const QModelIndex &index) const {
@ -136,7 +136,7 @@ QVariant MessagesModel::data(const QModelIndex &index, int role) const {
case Qt::DisplayRole: { case Qt::DisplayRole: {
int index_column = index.column(); int index_column = index.column();
if (index_column == MSG_DB_DUPDATED_INDEX) { if (index_column == MSG_DB_DCREATED_INDEX) {
// This column contains QDateTime. // This column contains QDateTime.
return TextFactory::parseDateTime(QSqlTableModel::data(index, return TextFactory::parseDateTime(QSqlTableModel::data(index,
role).toString()).toString(Qt::DefaultLocaleShortDate); role).toString()).toString(Qt::DefaultLocaleShortDate);

View File

@ -17,7 +17,6 @@ class Message {
QString m_author; QString m_author;
QString m_contents; QString m_contents;
QDateTime m_created; QDateTime m_created;
QDateTime m_updated;
}; };
class MessagesModel : public QSqlTableModel { class MessagesModel : public QSqlTableModel {

View File

@ -48,8 +48,7 @@ QList<Message> ParsingFactory::parseAsRSS20(const QString &data) {
new_message.m_author = elem_author2.text(); new_message.m_author = elem_author2.text();
} }
new_message.m_updated = TextFactory::parseDateTime(elem_updated.text()); new_message.m_created = TextFactory::parseDateTime(elem_updated.text());
new_message.m_created = new_message.m_updated;
messages.append(new_message); messages.append(new_message);
} }

View File

@ -9,6 +9,9 @@
// This class contains methods to // This class contains methods to
// parse input Unicode textual data into // parse input Unicode textual data into
// another objects. // another objects.
//
// NOTE: Each parsed message MUST CONTAINT THESE FIELDS.
class ParsingFactory { class ParsingFactory {
private: private:
// Constructors and destructors. // Constructors and destructors.

View File

@ -61,8 +61,8 @@ void FeedMessageViewer::saveSize() {
KEY_MESSAGES_VIEW + QString::number(MSG_DB_AUTHOR_INDEX), KEY_MESSAGES_VIEW + QString::number(MSG_DB_AUTHOR_INDEX),
m_messagesView->columnWidth(MSG_DB_AUTHOR_INDEX)); m_messagesView->columnWidth(MSG_DB_AUTHOR_INDEX));
settings->setValue(APP_CFG_GUI, settings->setValue(APP_CFG_GUI,
KEY_MESSAGES_VIEW + QString::number(MSG_DB_DUPDATED_INDEX), KEY_MESSAGES_VIEW + QString::number(MSG_DB_DCREATED_INDEX),
m_messagesView->columnWidth(MSG_DB_DUPDATED_INDEX)); m_messagesView->columnWidth(MSG_DB_DCREATED_INDEX));
} }
void FeedMessageViewer::loadSize() { void FeedMessageViewer::loadSize() {
@ -78,9 +78,9 @@ void FeedMessageViewer::loadSize() {
settings->value(APP_CFG_GUI, settings->value(APP_CFG_GUI,
KEY_MESSAGES_VIEW + QString::number(MSG_DB_AUTHOR_INDEX), KEY_MESSAGES_VIEW + QString::number(MSG_DB_AUTHOR_INDEX),
default_msg_section_size).toInt()); default_msg_section_size).toInt());
m_messagesView->setColumnWidth(MSG_DB_DUPDATED_INDEX, m_messagesView->setColumnWidth(MSG_DB_DCREATED_INDEX,
settings->value(APP_CFG_GUI, settings->value(APP_CFG_GUI,
KEY_MESSAGES_VIEW + QString::number(MSG_DB_DUPDATED_INDEX), KEY_MESSAGES_VIEW + QString::number(MSG_DB_DCREATED_INDEX),
default_msg_section_size).toInt()); default_msg_section_size).toInt());
// TODO: Perhaps make toolbar icon size changeable, // TODO: Perhaps make toolbar icon size changeable,
// this concerns toolbars of web browsers too. // this concerns toolbars of web browsers too.

View File

@ -73,7 +73,6 @@ void MessagesView::setupAppearance() {
header()->setSectionResizeMode(MSG_DB_URL_INDEX, QHeaderView::Interactive); header()->setSectionResizeMode(MSG_DB_URL_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_AUTHOR_INDEX, QHeaderView::Interactive); header()->setSectionResizeMode(MSG_DB_AUTHOR_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_DCREATED_INDEX, QHeaderView::Interactive); header()->setSectionResizeMode(MSG_DB_DCREATED_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_DUPDATED_INDEX, QHeaderView::Interactive);
header()->setSectionResizeMode(MSG_DB_CONTENTS_INDEX, QHeaderView::Interactive); header()->setSectionResizeMode(MSG_DB_CONTENTS_INDEX, QHeaderView::Interactive);
#else #else
// Setup column resize strategies. // Setup column resize strategies.
@ -86,7 +85,6 @@ void MessagesView::setupAppearance() {
header()->setResizeMode(MSG_DB_URL_INDEX, QHeaderView::Interactive); header()->setResizeMode(MSG_DB_URL_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_AUTHOR_INDEX, QHeaderView::Interactive); header()->setResizeMode(MSG_DB_AUTHOR_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_DCREATED_INDEX, QHeaderView::Interactive); header()->setResizeMode(MSG_DB_DCREATED_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_DUPDATED_INDEX, QHeaderView::Interactive);
header()->setResizeMode(MSG_DB_CONTENTS_INDEX, QHeaderView::Interactive); header()->setResizeMode(MSG_DB_CONTENTS_INDEX, QHeaderView::Interactive);
#endif #endif
@ -96,7 +94,6 @@ void MessagesView::setupAppearance() {
hideColumn(MSG_DB_DELETED_INDEX); hideColumn(MSG_DB_DELETED_INDEX);
hideColumn(MSG_DB_FEED_INDEX); hideColumn(MSG_DB_FEED_INDEX);
hideColumn(MSG_DB_URL_INDEX); hideColumn(MSG_DB_URL_INDEX);
hideColumn(MSG_DB_DCREATED_INDEX);
hideColumn(MSG_DB_CONTENTS_INDEX); hideColumn(MSG_DB_CONTENTS_INDEX);
} }
@ -116,7 +113,7 @@ void MessagesView::setupAppearance() {
// Make sure that initial sorting is that unread messages are visible // Make sure that initial sorting is that unread messages are visible
// first. // first.
// NOTE: This can be rewritten so that it's changeable. // NOTE: This can be rewritten so that it's changeable.
sortByColumn(MSG_DB_DUPDATED_INDEX, Qt::AscendingOrder); sortByColumn(MSG_DB_DCREATED_INDEX, Qt::AscendingOrder);
} }
void MessagesView::keyPressEvent(QKeyEvent *event) { void MessagesView::keyPressEvent(QKeyEvent *event) {

View File

@ -170,7 +170,7 @@ void WebBrowser::navigateToMessage(const Message &message) {
tr("Written by ") + message.m_author, tr("Written by ") + message.m_author,
message.m_url, message.m_url,
message.m_contents, message.m_contents,
message.m_updated.toString(Qt::DefaultLocaleLongDate))); message.m_created.toString(Qt::DefaultLocaleLongDate)));
emit iconChanged(m_index, emit iconChanged(m_index,
IconThemeFactory::getInstance()->fromTheme("mail-mark-read")); IconThemeFactory::getInstance()->fromTheme("mail-mark-read"));
} }