wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
WorkspaceManager Class Reference

Owns the document/tab model: the current tab, tab creation/closing/switching, and the file open/save/reload/autosave workflow. More...

#include <WorkspaceManager.h>

Inheritance diagram for WorkspaceManager:
[legend]

Public Member Functions

bool closeFiles ()
bool closeTab (int tabIndex)
 Closes the tab at tabIndex (prompting to save if needed). Returns false if cancelled.
int confirmSave (bool multiple)
void createNewTab ()
QDir currentDir () const
QFileInfo currentFile () const
WorkSpacecurrentTab () const
void currentTabChanged (WorkSpace *tab)
 Emitted when the active tab changes (or becomes null); the shell rebinds the chrome.
QString currentTabName () const
QString dolphinFileName () const
bool hasModifiedFiles ()
QFileInfo icListFile () const
void loadAutosaveFiles ()
void loadPandaFile (const QString &fileName)
void newTab ()
void onCurrentIndexChanged (int newIndex)
 Reacts to QTabWidget::currentChanged: updates the current tab and emits currentTabChanged.
void openFile ()
void openICInTab (const QString &blobName, int icElementId, const QByteArray &blob)
void recentFileAdded (const QString &filePath)
 Emitted when a file-backed tab is (re)named, to feed the recent-files list.
void reloadFile ()
void save (const QString &fileName={})
void saveFile ()
void saveFileAs ()
void setCurrentFile (const QFileInfo &fileInfo)
 Updates the tab title / tooltip / recent files for the workspace that emitted fileChanged.
void setDolphinFileName (const QString &fileName)
void titleChanged ()
 WorkspaceManager (QTabWidget *tab, MainWindowHost &host, QObject *parent=nullptr)

Protected Member Functions

bool eventFilter (QObject *watched, QEvent *event) override
 Closes the tab under the cursor when its tab bar is middle-clicked.

Detailed Description

Owns the document/tab model: the current tab, tab creation/closing/switching, and the file open/save/reload/autosave workflow.

Extracted from MainWindow via ownership inversion. It holds the current WorkSpace and drives the QTabWidget's contents (it does not own the widget — the UI does). UI feedback (status messages, palette refresh, IC tool-button state, dialog parenting) is reached through MainWindowHost; chrome rebinding is the shell's job, triggered by the currentTabChanged() signal. The public operations are kept callable from MainWindow delegators so the CLI batch mode, the MCP server, and tests are unaffected.

Definition at line 34 of file WorkspaceManager.h.

Constructor & Destructor Documentation

◆ WorkspaceManager()

WorkspaceManager::WorkspaceManager ( QTabWidget * tab,
MainWindowHost & host,
QObject * parent = nullptr )
Parameters
tabThe tab widget whose contents this manager owns (non-owning).
hostApplication context for status/palette/dialog-parent/IC-button feedback.

Definition at line 27 of file WorkspaceManager.cpp.

Member Function Documentation

◆ closeFiles()

bool WorkspaceManager::closeFiles ( )

Definition at line 538 of file WorkspaceManager.cpp.

References closeTab().

◆ closeTab()

bool WorkspaceManager::closeTab ( int tabIndex)

Closes the tab at tabIndex (prompting to save if needed). Returns false if cancelled.

Definition at line 672 of file WorkspaceManager.cpp.

References confirmSave(), qCDebug, save(), and sentryBreadcrumb().

Referenced by closeFiles(), eventFilter(), loadPandaFile(), and reloadFile().

◆ confirmSave()

int WorkspaceManager::confirmSave ( bool multiple)

Definition at line 258 of file WorkspaceManager.cpp.

References currentFile().

Referenced by closeTab().

◆ createNewTab()

void WorkspaceManager::createNewTab ( )

◆ currentDir()

QDir WorkspaceManager::currentDir ( ) const
nodiscard

Definition at line 86 of file WorkspaceManager.cpp.

◆ currentFile()

QFileInfo WorkspaceManager::currentFile ( ) const
nodiscard

◆ currentTab()

WorkSpace * WorkspaceManager::currentTab ( ) const
inlinenodiscard

Definition at line 45 of file WorkspaceManager.h.

◆ currentTabChanged()

void WorkspaceManager::currentTabChanged ( WorkSpace * tab)

Emitted when the active tab changes (or becomes null); the shell rebinds the chrome.

Referenced by MainWindow::MainWindow(), and onCurrentIndexChanged().

◆ currentTabName()

QString WorkspaceManager::currentTabName ( ) const
nodiscard

Display name of the current tab (file name, numbered placeholder, or "[blob]" for an inline IC), without the unsaved "*" marker. Used for the window title.

Definition at line 81 of file WorkspaceManager.cpp.

References currentFile().

◆ dolphinFileName()

QString WorkspaceManager::dolphinFileName ( ) const
nodiscard

Definition at line 105 of file WorkspaceManager.cpp.

◆ eventFilter()

bool WorkspaceManager::eventFilter ( QObject * watched,
QEvent * event )
overrideprotected

Closes the tab under the cursor when its tab bar is middle-clicked.

Definition at line 39 of file WorkspaceManager.cpp.

References closeTab().

◆ hasModifiedFiles()

bool WorkspaceManager::hasModifiedFiles ( )
nodiscard

Definition at line 549 of file WorkspaceManager.cpp.

References Settings::autosaveFiles().

◆ icListFile()

QFileInfo WorkspaceManager::icListFile ( ) const
nodiscard

◆ loadAutosaveFiles()

void WorkspaceManager::loadAutosaveFiles ( )

◆ loadPandaFile()

void WorkspaceManager::loadPandaFile ( const QString & fileName)

◆ newTab()

void WorkspaceManager::newTab ( )

◆ onCurrentIndexChanged()

void WorkspaceManager::onCurrentIndexChanged ( int newIndex)

Reacts to QTabWidget::currentChanged: updates the current tab and emits currentTabChanged.

Definition at line 721 of file WorkspaceManager.cpp.

References currentTabChanged(), qCDebug, and sentryBreadcrumb().

◆ openFile()

◆ openICInTab()

void WorkspaceManager::openICInTab ( const QString & blobName,
int icElementId,
const QByteArray & blob )

◆ recentFileAdded()

void WorkspaceManager::recentFileAdded ( const QString & filePath)

Emitted when a file-backed tab is (re)named, to feed the recent-files list.

Referenced by setCurrentFile().

◆ reloadFile()

void WorkspaceManager::reloadFile ( )

◆ save()

◆ saveFile()

◆ saveFileAs()

◆ setCurrentFile()

void WorkspaceManager::setCurrentFile ( const QFileInfo & fileInfo)

Updates the tab title / tooltip / recent files for the workspace that emitted fileChanged.

Definition at line 623 of file WorkspaceManager.cpp.

References qCDebug, recentFileAdded(), and titleChanged().

Referenced by createNewTab().

◆ setDolphinFileName()

void WorkspaceManager::setDolphinFileName ( const QString & fileName)

Definition at line 113 of file WorkspaceManager.cpp.

◆ titleChanged()

void WorkspaceManager::titleChanged ( )

Emitted when the current tab's title or modified state changes, so the shell can refresh the window title.

Referenced by MainWindow::MainWindow(), and setCurrentFile().


The documentation for this class was generated from the following files: