MailJD nbsp;·nbsp; Test Dashboard nbsp;·nbsp; Coverage
LCOV - code coverage report
Current view: top level - ui - MailFilterProxyModel.cpp (source / functions) Coverage Total Hit
Test: MailJD Coverage (Unit + E2E) Lines: 100.0 % 44 44
Test Date: 2026-07-27 17:53:44 Functions: 100.0 % 6 6
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 70.0 % 70 49

             Branch data     Line data    Source code
       1                 :             : #include "MailFilterProxyModel.h"
       2                 :             : 
       3                 :             : #include "MailListModel.h"
       4                 :             : #include "data/Models.h"
       5                 :             : 
       6                 :          68 : MailFilterProxyModel::MailFilterProxyModel(QObject *parent)
       7                 :          68 :     : QSortFilterProxyModel(parent) {
       8                 :             :   // T-79.B2/M19: keep a thread visible when only a descendant matches the
       9                 :             :   // filter (e.g. unread reply under a read root). Flat models have no
      10                 :             :   // children, so their filtering is unaffected.
      11         [ +  - ]:          68 :   setRecursiveFilteringEnabled(true);
      12                 :          68 : }
      13                 :             : 
      14                 :          46 : void MailFilterProxyModel::setFilterText(const QString &text) {
      15         [ +  + ]:          46 :   if (m_filterText == text) return;
      16                 :          19 :   m_filterText = text;
      17                 :          19 :   invalidateFilter();
      18                 :             : }
      19                 :             : 
      20                 :           7 : void MailFilterProxyModel::setShowUnreadOnly(bool on) {
      21         [ -  + ]:           7 :   if (m_showUnread == on) return;
      22                 :           7 :   m_showUnread = on;
      23                 :           7 :   invalidateFilter();
      24                 :             : }
      25                 :             : 
      26                 :           5 : void MailFilterProxyModel::setShowStarredOnly(bool on) {
      27         [ -  + ]:           5 :   if (m_showStarred == on) return;
      28                 :           5 :   m_showStarred = on;
      29                 :           5 :   invalidateFilter();
      30                 :             : }
      31                 :             : 
      32                 :           2 : void MailFilterProxyModel::setShowWithAttachments(bool on) {
      33         [ +  + ]:           2 :   if (m_showAttachments == on) return;
      34                 :           1 :   m_showAttachments = on;
      35                 :           1 :   invalidateFilter();
      36                 :             : }
      37                 :             : 
      38                 :         976 : bool MailFilterProxyModel::filterAcceptsRow(
      39                 :             :     int sourceRow, const QModelIndex &sourceParent) const {
      40   [ +  -  +  - ]:         976 :   auto idx = sourceModel()->index(sourceRow, 0, sourceParent);
      41                 :             : 
      42                 :             :   // Unread filter: check Seen flag
      43         [ +  + ]:         976 :   if (m_showUnread) {
      44   [ +  -  +  - ]:          15 :     quint32 flags = idx.data(MailListModel::FlagsRole).toUInt();
      45         [ +  + ]:          15 :     if (flags & MailFlag::Seen)
      46                 :           4 :       return false; // mail is read → hide
      47                 :             :   }
      48                 :             : 
      49                 :             :   // Starred filter: check Flagged flag
      50         [ +  + ]:         972 :   if (m_showStarred) {
      51   [ +  -  +  - ]:          10 :     quint32 flags = idx.data(MailListModel::FlagsRole).toUInt();
      52         [ +  + ]:          10 :     if (!(flags & MailFlag::Flagged))
      53                 :           8 :       return false; // mail is not starred → hide
      54                 :             :   }
      55                 :             : 
      56                 :             :   // Attachments filter
      57         [ +  + ]:         964 :   if (m_showAttachments) {
      58   [ +  -  +  - ]:           2 :     bool hasAtt = idx.data(MailListModel::HasAttachmentsRole).toBool();
      59         [ +  + ]:           2 :     if (!hasAtt)
      60                 :           1 :       return false;
      61                 :             :   }
      62                 :             : 
      63                 :             :   // Text filter: match against Subject and From columns
      64         [ +  + ]:         963 :   if (!m_filterText.isEmpty()) {
      65                 :             :     auto subjectIdx =
      66   [ +  -  +  - ]:         117 :         sourceModel()->index(sourceRow, MailListModel::Subject, sourceParent);
      67                 :             :     auto fromIdx =
      68   [ +  -  +  - ]:         117 :         sourceModel()->index(sourceRow, MailListModel::From, sourceParent);
      69                 :             : 
      70   [ +  -  +  - ]:         117 :     QString subject = subjectIdx.data(Qt::DisplayRole).toString();
      71   [ +  -  +  - ]:         117 :     QString from = fromIdx.data(Qt::DisplayRole).toString();
      72                 :             : 
      73   [ +  -  +  +  :         199 :     if (!subject.contains(m_filterText, Qt::CaseInsensitive) &&
                   +  + ]
      74   [ +  -  +  + ]:          82 :         !from.contains(m_filterText, Qt::CaseInsensitive)) {
      75                 :          66 :       return false;
      76                 :             :     }
      77   [ +  +  +  + ]:         183 :   }
      78                 :             : 
      79                 :         897 :   return true;
      80                 :             : }
        

Generated by: LCOV version 2.0-1