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

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include <QCache>
       4              : #include <QFont>
       5              : #include <QIcon>
       6              : #include <QList>
       7              : #include <QMap>
       8              : #include <QObject>
       9              : #include <QString>
      10              : 
      11              : // T-199b: Provider for Material Design Icons rendered from webfont.
      12              : // Uses QPainter + MDI TTF (7448 glyphs) to render icons on demand.
      13              : // Icons are cached in a QCache to avoid repeated QPainter overhead.
      14              : class MdiIconProvider {
      15              : public:
      16              :   struct IconEntry {
      17              :     QString name;       // e.g. "folder-open"
      18              :     uint codepoint;     // Unicode scalar value e.g. 0xF02D8
      19              :   };
      20              : 
      21              :   static MdiIconProvider &instance();
      22              : 
      23              :   // Load font and parse codemap from Qt resources.
      24              :   // Call once at application startup (or lazily on first use).
      25              :   void init();
      26              : 
      27              :   // Render icon as QIcon for the given size and color.
      28              :   // Result is cached by (name, size).
      29              :   // Invalid default color resolves to the theme's @text_secondary
      30              :   // (67.B3: color decisions live in ThemeManager).
      31              :   QIcon icon(const QString &name, int size = 24,
      32              :              const QColor &color = QColor());
      33              : 
      34              :   // All available icons (sorted by name).
      35           17 :   const QList<IconEntry> &allIcons() const { return m_icons; }
      36              : 
      37              :   // Filter icons whose name contains query (case-insensitive).
      38              : 
      39              :   bool isReady() const { return m_ready; }
      40              :   void ensureInit(); // public: lazy init on first use
      41              : 
      42              : private:
      43           14 :   MdiIconProvider() = default;
      44              : 
      45              :   bool m_ready = false;
      46              :   QFont m_font;
      47              :   QList<IconEntry> m_icons;
      48              :   QMap<QString, uint> m_lookup; // name → codepoint
      49              : 
      50              :   // Cache: key = "name@size" → QIcon
      51              :   mutable QCache<QString, QIcon> m_cache{2048};
      52              : };
        

Generated by: LCOV version 2.0-1