Line data Source code
1 : #include "UpdateTitleOperation.h"
2 : #include "../models/AllNewsFeedItem.h"
3 : #include <QDebug>
4 :
5 2 : UpdateTitleOperation::UpdateTitleOperation(OperationManager *parent, FeedItem* feed) :
6 : DBOperation(parent),
7 2 : feed(feed)
8 : {
9 2 : }
10 :
11 2 : void UpdateTitleOperation::execute()
12 : {
13 2 : if (feed->metaObject() == &AllNewsFeedItem::staticMetaObject) {
14 : // Nope.
15 :
16 1 : return;
17 : }
18 :
19 1 : QSqlQuery query(db());
20 1 : query.prepare("UPDATE FeedItemTable SET title = :title WHERE id = :feed_id");
21 1 : query.bindValue(":title", feed->getTitle());
22 1 : query.bindValue(":feed_id", feed->getDbID());
23 :
24 1 : if (!query.exec()) {
25 0 : reportSQLError(query, "Unable to set title.");
26 :
27 0 : return;
28 : }
29 1 : }
|