MailJD nbsp;·nbsp; Test Dashboard nbsp;·nbsp; Coverage
LCOV - code coverage report
Current view: top level - ui - CalendarWidget.h (source / functions) Coverage Total Hit
Test: MailJD Coverage (Unit + E2E) Lines: 100.0 % 4 4
Test Date: 2026-06-21 21:10:19 Functions: 100.0 % 4 4
Legend: Lines:     hit not hit

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include <QDate>
       4              : #include <QMap>
       5              : #include <QSet>
       6              : #include <QWidget>
       7              : 
       8              : #include "data/CalendarModels.h"
       9              : 
      10              : class CalendarStore;
      11              : class EventDetailPopup;
      12              : 
      13              : // Custom-painted calendar widget with month and week views.
      14              : // Sprint 32 – T-336
      15              : class CalendarWidget : public QWidget {
      16          586 :   Q_OBJECT
      17              : public:
      18              :   enum ViewMode { MonthView, WeekView, DayView, YearView };
      19              : 
      20              :   explicit CalendarWidget(QWidget *parent = nullptr);
      21              : 
      22              :   void setCalendarStore(CalendarStore *store);
      23              :   void setViewMode(ViewMode mode);
      24           26 :   ViewMode viewMode() const { return m_viewMode; }
      25              :   void navigateToDate(const QDate &date);
      26           18 :   QDate selectedDate() const { return m_currentDate; }
      27              : 
      28              :   void setVisibleCalendars(const QSet<QString> &paths);
      29           11 :   QSet<QString> visibleCalendars() const { return m_visibleCalendars; }
      30              :   static QList<CalendarEvent>
      31              :   expandEventsForDisplay(const QList<CalendarEvent> &events,
      32              :                          const QDate &rangeStart,
      33              :                          const QDate &rangeEnd);
      34              : 
      35              : signals:
      36              :   void dateClicked(const QDate &date);
      37              :   void eventClicked(const CalendarEvent &event);
      38              :   void closeRequested();
      39              :   // T-533: Click-to-create (from empty area or drag selection)
      40              :   void createEventRequested(const QDate &date,
      41              :                             const QTime &startTime = {},
      42              :                             const QTime &endTime = {});
      43              :   // T-534: Double-click to edit existing event
      44              :   void editEventRequested(const CalendarEvent &event);
      45              :   // T-532: Delete from EventDetailPopup
      46              :   void deleteEventRequested(const CalendarEvent &event);
      47              : 
      48              : protected:
      49              :   void paintEvent(QPaintEvent *event) override;
      50              :   void keyPressEvent(QKeyEvent *event) override;
      51              :   void mousePressEvent(QMouseEvent *event) override;
      52              :   void mouseDoubleClickEvent(QMouseEvent *event) override;
      53              :   void mouseMoveEvent(QMouseEvent *event) override;      // T-533: drag
      54              :   void mouseReleaseEvent(QMouseEvent *event) override;    // T-533: drag
      55              :   void wheelEvent(QWheelEvent *event) override;
      56              :   void resizeEvent(QResizeEvent *event) override;
      57              :   // Sprint 76 (T-76.B4): repaint chrome (mode/today buttons, day/month names)
      58              :   // when the app language changes — labels are tr()-resolved at paint time.
      59              :   void changeEvent(QEvent *event) override;
      60              : 
      61              : private:
      62              :   // Sprint 76 (T-76.B4): locale following the app's manual language selection
      63              :   // (i18n/language, "auto" → system locale) instead of QLocale::system(), so
      64              :   // day/month names respect the user's chosen UI language.
      65              :   QLocale appLocale() const;
      66              : 
      67              : private:
      68              :   QDate firstVisibleDate() const;
      69              :   QDate dateForCell(int row, int col) const;
      70              :   QRect cellRectForDate(const QDate &date) const;
      71              :   void loadEventsForVisibleRange();
      72              :   void moveSelection(int dayDelta);
      73              :   void switchMonth(int delta);
      74              :   void paintToolbar(QPainter &p);
      75              :   void paintMonthView(QPainter &p);
      76              :   void paintWeekView(QPainter &p);
      77              :   void paintDayView(QPainter &p);   // T-425
      78              :   void paintYearView(QPainter &p);  // T-425
      79              :   void showEventPopup(const CalendarEvent &event, const QPoint &pos);
      80              :   void showCalendarFilterMenu(const QPoint &globalPos);
      81              :   CalendarEvent eventAtPosition(const QPoint &pos) const;
      82              :   // T-533: Map pixel position to time in Week/Day view
      83              :   QDateTime timeAtPosition(const QPoint &pos) const;
      84              : 
      85              :   CalendarStore *m_store = nullptr;
      86              :   EventDetailPopup *m_popup = nullptr;
      87              :   ViewMode m_viewMode = MonthView;
      88              :   QDate m_currentDate;
      89              :   QDate m_displayMonth;
      90              : 
      91              :   QList<CalendarEvent> m_visibleEvents;
      92              :   QMap<QDate, QList<CalendarEvent>> m_eventsByDate;
      93              :   QSet<QString> m_visibleCalendars; // empty = show all
      94              :   int m_selectedEventIndex = -1;
      95              :   int m_hoveredCol = -1;
      96              :   int m_hoveredRow = -1;
      97              :   int m_wheelAccumulator = 0;
      98              :   int m_weekScrollOffset = 0; // T-427: vertical scroll offset in pixels
      99              : 
     100              :   // T-533: Drag-to-select state
     101              :   bool m_isDragging = false;
     102              :   QPoint m_dragStartPos;
     103              :   QPoint m_dragCurrentPos;
     104              :   QDateTime m_dragStartTime;
     105              :   QDateTime m_dragEndTime;
     106              : };
        

Generated by: LCOV version 2.0-1