LCOV - code coverage report
Current view: top level - src/operations - SetPinOperation.cpp (source / functions) Coverage Total Hit
Test: coverage.info.cleaned Lines: 81.2 % 16 13
Test Date: 2026-04-19 00:35:54 Functions: 100.0 % 2 2

            Line data    Source code
       1              : #include "SetPinOperation.h"
       2              : #include <QDebug>
       3              : 
       4              : #include "../utilities/UnreadCountReader.h"
       5              : 
       6            3 : SetPinOperation::SetPinOperation(OperationManager *parent, PinnedFeedItem *pinnedNews, qint64 newsID, bool pin) :
       7            3 :     DBOperation(parent), pinnedNews(pinnedNews), newsID(newsID), pin(pin)
       8              : {
       9            3 : }
      10              : 
      11            3 : void SetPinOperation::execute()
      12              : {
      13            3 :     db().transaction();
      14              : 
      15              :     // SQLITE HULK HOGAN IS GUNNA DRIVE A BODY SLAM STRAIGHT INTO THAT PINNED COLUMN, OH YEAH!
      16            3 :     QSqlQuery update(db());
      17            3 :     update.prepare("UPDATE NewsItemTable SET pinned = :pin WHERE id = :news_id");
      18            3 :     update.bindValue(":pin", (int) pin);
      19            3 :     update.bindValue(":news_id", newsID);
      20              : 
      21            3 :     if (!update.exec()) {
      22            0 :         reportSQLError(update, "Unable to set/unset pin on " + QString::number(newsID));
      23            0 :         db().rollback();
      24              : 
      25            0 :         return;
      26              :     }
      27              : 
      28            3 :     db().commit();
      29              : 
      30              :     // Update the unread count of the special pinned feed.
      31            3 :     pinnedNews->setUnreadCount(UnreadCountReader::forPinned(db()));
      32            3 : }
        

Generated by: LCOV version 2.0-1