Cleanups in code.

This commit is contained in:
Martin Rotter 2016-03-14 08:37:31 +01:00
parent 9a9027f4b7
commit 58846e474e
12 changed files with 3 additions and 50 deletions

View File

@ -48,7 +48,7 @@ QList<Message> Feed::undeletedMessages() const {
"FROM Messages "
"WHERE is_deleted = 0 AND is_pdeleted = 0 AND feed = :feed AND account_id = :account_id;");
query_read_msg.bindValue(QSL(":feed"), messageForeignKeyId());
query_read_msg.bindValue(QSL(":feed"), customId());
query_read_msg.bindValue(QSL(":account_id"), account_id);
if (query_read_msg.exec()) {

View File

@ -96,8 +96,6 @@ class Feed : public RootItem {
void updateCounts(bool including_total_count);
virtual int messageForeignKeyId() const = 0;
protected:
virtual QList<Message> obtainNewMessages() = 0;

View File

@ -247,6 +247,7 @@ class RootItem : public QObject {
m_boldFont = bold_font;
}
// NOTE: For standard feed, this WILL equal to id().
int customId() const;
void setCustomId(int custom_id);

View File

@ -400,7 +400,7 @@ QStringList ServiceRoot::textualFeedIds(const QList<Feed*> &feeds) const {
stringy_ids.reserve(feeds.size());
foreach (const Feed *feed, feeds) {
stringy_ids.append(QString("'%1'").arg(QString::number(feed->messageForeignKeyId())));
stringy_ids.append(QString("'%1'").arg(QString::number(feed->customId())));
}
return stringy_ids;

View File

@ -57,10 +57,6 @@ OwnCloudServiceRoot *OwnCloudFeed::serviceRoot() const {
return qobject_cast<OwnCloudServiceRoot*>(getParentServiceRoot());
}
int OwnCloudFeed::messageForeignKeyId() const {
return customId();
}
QList<Message> OwnCloudFeed::obtainNewMessages() {
OwnCloudGetMessagesResponse messages = serviceRoot()->network()->getMessages(customId());

View File

@ -35,7 +35,6 @@ class OwnCloudFeed : public Feed {
bool cleanMessages(bool clear_only_read);
OwnCloudServiceRoot *serviceRoot() const;
int messageForeignKeyId() const;
private:
QList<Message> obtainNewMessages();

View File

@ -501,10 +501,6 @@ bool StandardFeed::editItself(StandardFeed *new_feed_data) {
return true;
}
int StandardFeed::messageForeignKeyId() const {
return id();
}
QList<Message> StandardFeed::obtainNewMessages() {
QByteArray feed_contents;
int download_timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();

View File

@ -82,8 +82,6 @@ class StandardFeed : public Feed {
bool addItself(RootItem *parent);
bool editItself(StandardFeed *new_feed_data);
int messageForeignKeyId() const;
// Other getters/setters.
inline Type type() const {
return m_type;

View File

@ -171,34 +171,6 @@ RecycleBin *StandardServiceRoot::recycleBin() const {
return m_recycleBin;
}
bool StandardServiceRoot::markFeedsReadUnread(QList<Feed*> items, ReadStatus read) {
QSqlDatabase db_handle = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
QSqlQuery query_read_msg(db_handle);
query_read_msg.setForwardOnly(true);
query_read_msg.prepare(QString("UPDATE Messages SET is_read = :read "
"WHERE feed IN (%1) AND is_deleted = 0 AND is_pdeleted = 0;").arg(textualFeedIds(items).join(QSL(", "))));
query_read_msg.bindValue(QSL(":read"), read == RootItem::Read ? 1 : 0);
if (query_read_msg.exec()) {
// Messages are switched, now inform model about need to reload data.
QList<RootItem*> itemss;
foreach (Feed *feed, items) {
feed->updateCounts(false);
itemss.append(feed);
}
itemChanged(itemss);
requestReloadMessageList(read == RootItem::Read);
return true;
}
else {
return false;
}
}
void StandardServiceRoot::loadFromDatabase(){
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
Assignment categories;

View File

@ -69,8 +69,6 @@ class StandardServiceRoot : public ServiceRoot {
// NOTE: This is used for import/export of the model.
bool mergeImportExportModel(FeedsImportExportModel *model, RootItem *target_root_node, QString &output_message);
bool markFeedsReadUnread(QList<Feed*> items, ReadStatus read);
void loadFromDatabase();
void checkArgumentForFeedAdding(const QString &argument);

View File

@ -50,10 +50,6 @@ TtRssFeed::TtRssFeed(const QSqlRecord &record) : Feed(NULL) {
TtRssFeed::~TtRssFeed() {
}
int TtRssFeed::messageForeignKeyId() const {
return customId();
}
TtRssServiceRoot *TtRssFeed::serviceRoot() const {
return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
}

View File

@ -33,7 +33,6 @@ class TtRssFeed : public Feed {
explicit TtRssFeed(const QSqlRecord &record);
virtual ~TtRssFeed();
int messageForeignKeyId() const;
TtRssServiceRoot *serviceRoot() const;
QVariant data(int column, int role) const;
bool canBeEdited() const;