MailJD nbsp;·nbsp; Test Dashboard nbsp;·nbsp; Coverage
LCOV - code coverage report
Current view: top level - app - FolderOperationsController.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 % 3 3
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 100.0 % 4 4

             Branch data     Line data    Source code
       1                 :             : #pragma once
       2                 :             : 
       3                 :             : #include <QObject>
       4                 :             : #include <QStringList>
       5                 :             : #include <functional>
       6                 :             : 
       7                 :             : #include "data/Models.h"
       8                 :             : 
       9                 :             : class CommandBar;
      10                 :             : class FolderTree;
      11                 :             : class ImapService;
      12                 :             : 
      13                 :             : // FolderOperationsController owns the IMAP folder management flows that
      14                 :             : // historically lived inside MainWindow (Sprint 65 P2.2 extraction):
      15                 :             : //   - create / rename / delete / move (T-290)
      16                 :             : //   - special-folder protection (INBOX, Sent, Trash, ... cannot be touched)
      17                 :             : //   - the bottom-up child-delete chain incl. the BYE workaround (the
      18                 :             : //     currently SELECTed folder must be left before deleting it)
      19                 :             : //
      20                 :             : // MainWindow feeds it the current folder list + IMAP hierarchy delimiter
      21                 :             : // (both also needed elsewhere in MainWindow); user feedback flows back via
      22                 :             : // the keyedStatusMessage signal. Modal prompts go through the same
      23                 :             : // std::function test seams MainWindow uses (overridable in unit tests).
      24                 :             : class FolderOperationsController : public QObject {
      25                 :             :   Q_OBJECT
      26                 :             : #ifdef MAILJD_UNIT_TEST
      27                 :             :   friend class TestFolderOperations;
      28                 :             :   friend class TestMainWindow;
      29                 :             : #endif
      30                 :             : #ifdef MAILJD_E2E_TESTING
      31                 :             :   friend class TestE2EInteractive;
      32                 :             : #endif
      33                 :             : 
      34                 :             : public:
      35                 :             :   struct Deps {
      36                 :             :     ImapService *imap = nullptr;
      37                 :             :     FolderTree *folderTree = nullptr;
      38                 :             :     CommandBar *commandBar = nullptr;
      39                 :             :   };
      40                 :             : 
      41                 :             :   explicit FolderOperationsController(const Deps &deps,
      42                 :             :                                       QObject *parent = nullptr);
      43                 :             : 
      44                 :             :   // Kept in sync by MainWindow's folder-list handler.
      45                 :          36 :   void setFolderList(const QList<FolderInfo> &folders) { m_folders = folders; }
      46                 :          27 :   void setDelimiter(const QString &delimiter) { m_delimiter = delimiter; }
      47                 :             : 
      48                 :             :   QStringList folderFlagsForPath(const QString &folderPath) const;
      49                 :             :   bool isProtectedFolderPath(const QString &folderPath) const;
      50                 :             : 
      51                 :             :   // T-290 folder management flows (wired to FolderTree context-menu signals
      52                 :             :   // in the constructor; also invoked by shortcuts and ':'-commands).
      53                 :             :   void createFolder(const QString &parentPath);
      54                 :             :   void deleteFolder(const QString &folderPath);
      55                 :             :   void renameFolder(const QString &folderPath);
      56                 :             :   void moveFolder(const QString &folderPath);
      57                 :             : 
      58                 :             : signals:
      59                 :             :   void keyedStatusMessage(const QString &key, const QString &message,
      60                 :             :                           int timeoutMs);
      61                 :             : 
      62                 :             : private:
      63                 :          15 :   QString effectiveDelimiter() const {
      64   [ +  +  +  + ]:          22 :     return m_delimiter.isEmpty() ? QStringLiteral(".") : m_delimiter;
      65                 :             :   }
      66                 :             : 
      67                 :             :   Deps m_d;
      68                 :             :   QList<FolderInfo> m_folders;
      69                 :             :   QString m_delimiter; // IMAP hierarchy delimiter (e.g. "." or "/")
      70                 :             : 
      71                 :             :   // Modal test seams — default to real Qt dialogs, overridden in unit tests.
      72                 :             :   std::function<QString(const QString &title, const QString &label,
      73                 :             :                         const QString &initial, bool *ok)>
      74                 :             :       m_promptText;
      75                 :             :   std::function<bool(const QString &title, const QString &text)> m_confirm;
      76                 :             : };
        

Generated by: LCOV version 2.0-1