MailJD nbsp;·nbsp; Test Dashboard nbsp;·nbsp; Coverage
LCOV - code coverage report
Current view: top level - ui - FilterChipWidget.cpp (source / functions) Coverage Total Hit
Test: MailJD Coverage (Unit + E2E) Lines: 60.0 % 35 21
Test Date: 2026-06-21 21:10:19 Functions: 25.0 % 4 1
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 40.3 % 72 29

             Branch data     Line data    Source code
       1                 :             : #include "FilterChipWidget.h"
       2                 :             : #include <QHBoxLayout>
       3                 :             : #include <QEvent>
       4                 :             : #include <QLabel>
       5                 :             : #include <QToolButton>
       6                 :             : #include <QMouseEvent>
       7                 :             : #include <QStyle>
       8                 :             : 
       9                 :          31 : FilterChipWidget::FilterChipWidget(const QString &field, const QString &value, QWidget *parent)
      10         [ +  - ]:          31 :     : QWidget(parent), m_field(field), m_value(value) {
      11                 :             :   
      12         [ +  - ]:          62 :   setObjectName("filterChip");
      13                 :             :   
      14   [ +  -  +  -  :          31 :   auto *layout = new QHBoxLayout(this);
             -  +  -  - ]
      15         [ +  - ]:          31 :   layout->setContentsMargins(8, 2, 2, 2);
      16         [ +  - ]:          31 :   layout->setSpacing(4);
      17                 :             : 
      18                 :          31 :   QString displayText;
      19         [ -  + ]:          31 :   if (field.isEmpty()) {
      20                 :           0 :     displayText = value;
      21                 :             :   } else {
      22   [ +  -  +  - ]:          31 :     displayText = QString("%1: %2").arg(field, value);
      23                 :             :   }
      24                 :             : 
      25   [ +  -  +  -  :          31 :   m_label = new QLabel(displayText, this);
             -  +  -  - ]
      26         [ +  - ]:          31 :   layout->addWidget(m_label);
      27                 :             : 
      28   [ +  -  +  -  :          31 :   m_removeButton = new QToolButton(this);
             -  +  -  - ]
      29   [ +  -  +  - ]:          31 :   m_removeButton->setText("×");
      30   [ +  -  +  - ]:          31 :   m_removeButton->setToolTip(tr("Remove filter"));
      31         [ +  - ]:          62 :   m_removeButton->setObjectName("filterChipRemoveButton");
      32   [ +  -  +  - ]:          31 :   m_removeButton->setCursor(Qt::PointingHandCursor);
      33         [ +  - ]:          31 :   m_removeButton->setFixedSize(16, 16);
      34                 :             :   
      35         [ +  - ]:          31 :   connect(m_removeButton, &QToolButton::clicked, this, &FilterChipWidget::removeRequested);
      36         [ +  - ]:          31 :   layout->addWidget(m_removeButton);
      37                 :             : 
      38   [ +  -  +  - ]:          31 :   setCursor(Qt::PointingHandCursor);
      39                 :          31 : }
      40                 :             : 
      41                 :           0 : void FilterChipWidget::mousePressEvent(QMouseEvent *event) {
      42         [ #  # ]:           0 :   if (event->button() == Qt::LeftButton) {
      43                 :           0 :     emit removeRequested();
      44                 :             :   }
      45                 :           0 :   QWidget::mousePressEvent(event);
      46                 :           0 : }
      47                 :             : 
      48                 :           0 : void FilterChipWidget::changeEvent(QEvent *event) {
      49         [ #  # ]:           0 :   if (event->type() == QEvent::LanguageChange)
      50                 :           0 :     retranslateUi();
      51                 :           0 :   QWidget::changeEvent(event);
      52                 :           0 : }
      53                 :             : 
      54                 :           0 : void FilterChipWidget::retranslateUi() {
      55   [ #  #  #  # ]:           0 :   m_removeButton->setToolTip(tr("Remove filter"));
      56                 :           0 : }
        

Generated by: LCOV version 2.0-1