|
wiRedPanda
Logic Circuit Simulator
|
Owns the document/tab model: the current tab, tab creation/closing/switching, and the file open/save/reload/autosave workflow. More...
#include <WorkspaceManager.h>
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 |
| WorkSpace * | currentTab () 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. | |
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.
| WorkspaceManager::WorkspaceManager | ( | QTabWidget * | tab, |
| MainWindowHost & | host, | ||
| QObject * | parent = nullptr ) |
| tab | The tab widget whose contents this manager owns (non-owning). |
| host | Application context for status/palette/dialog-parent/IC-button feedback. |
Definition at line 27 of file WorkspaceManager.cpp.
| bool WorkspaceManager::closeFiles | ( | ) |
Definition at line 538 of file WorkspaceManager.cpp.
References 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().
| int WorkspaceManager::confirmSave | ( | bool | multiple | ) |
Definition at line 258 of file WorkspaceManager.cpp.
References currentFile().
Referenced by closeTab().
| void WorkspaceManager::createNewTab | ( | ) |
Definition at line 146 of file WorkspaceManager.cpp.
References ICRegistry::blobRenamed(), WorkSpace::fileChanged(), qCDebug, sentryBreadcrumb(), and setCurrentFile().
Referenced by loadPandaFile(), newTab(), and openICInTab().
|
nodiscard |
Definition at line 86 of file WorkspaceManager.cpp.
|
nodiscard |
Definition at line 54 of file WorkspaceManager.cpp.
Referenced by confirmSave(), currentTabName(), icListFile(), reloadFile(), save(), saveFile(), and saveFileAs().
|
inlinenodiscard |
Definition at line 45 of file WorkspaceManager.h.
| 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().
|
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().
|
nodiscard |
Definition at line 105 of file WorkspaceManager.cpp.
|
overrideprotected |
Closes the tab under the cursor when its tab bar is middle-clicked.
Definition at line 39 of file WorkspaceManager.cpp.
References closeTab().
|
nodiscard |
Definition at line 549 of file WorkspaceManager.cpp.
References Settings::autosaveFiles().
|
nodiscard |
Definition at line 91 of file WorkspaceManager.cpp.
References currentFile(), WorkSpace::fileInfo(), WorkSpace::isInlineIC(), and WorkSpace::parentWorkspace().
Referenced by loadPandaFile(), openICInTab(), and save().
| void WorkspaceManager::loadAutosaveFiles | ( | ) |
Definition at line 585 of file WorkspaceManager.cpp.
References Settings::autosaveFiles(), Application::interactiveMode, loadPandaFile(), qCDebug, and Settings::setAutosaveFiles().
| void WorkspaceManager::loadPandaFile | ( | const QString & | fileName | ) |
Definition at line 287 of file WorkspaceManager.cpp.
References closeTab(), createNewTab(), icListFile(), and qCDebug.
Referenced by loadAutosaveFiles(), MainWindow::MainWindow(), openFile(), and reloadFile().
| void WorkspaceManager::newTab | ( | ) |
Definition at line 279 of file WorkspaceManager.cpp.
References createNewTab(), Application::guardedSlot(), and sentryBreadcrumb().
| 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().
| void WorkspaceManager::openFile | ( | ) |
Definition at line 370 of file WorkspaceManager.cpp.
References FileDialogProvider::getOpenFileName(), Application::guardedSlot(), loadPandaFile(), FileDialogs::provider(), and sentryBreadcrumb().
| void WorkspaceManager::openICInTab | ( | const QString & | blobName, |
| int | icElementId, | ||
| const QByteArray & | blob ) |
Definition at line 320 of file WorkspaceManager.cpp.
References createNewTab(), WorkSpace::icBlobSaved(), icListFile(), WorkSpace::inlineBlobName(), WorkSpace::isInlineIC(), WorkSpace::onChildICBlobSaved(), and WorkSpace::parentWorkspace().
Referenced by MainWindow::MainWindow().
| void WorkspaceManager::recentFileAdded | ( | const QString & | filePath | ) |
Emitted when a file-backed tab is (re)named, to feed the recent-files list.
Referenced by setCurrentFile().
| void WorkspaceManager::reloadFile | ( | ) |
Definition at line 490 of file WorkspaceManager.cpp.
References closeTab(), currentFile(), Application::guardedSlot(), loadPandaFile(), and sentryBreadcrumb().
| void WorkspaceManager::save | ( | const QString & | fileName = {} | ) |
Definition at line 191 of file WorkspaceManager.cpp.
References Settings::autosaveFiles(), currentFile(), FileDialogResult::fileName, FileDialogProvider::getSaveFileName(), icListFile(), FileDialogs::provider(), WorkSpace::Saved, and Settings::setAutosaveFiles().
Referenced by closeTab(), saveFile(), and saveFileAs().
| void WorkspaceManager::saveFile | ( | ) |
Definition at line 403 of file WorkspaceManager.cpp.
References currentFile(), FileDialogResult::fileName, FileDialogProvider::getSaveFileName(), Application::guardedSlot(), FileDialogs::provider(), save(), saveFileAs(), and sentryBreadcrumb().
| void WorkspaceManager::saveFileAs | ( | ) |
Definition at line 446 of file WorkspaceManager.cpp.
References currentFile(), FileDialogResult::fileName, FileDialogProvider::getSaveFileName(), Application::guardedSlot(), FileDialogs::provider(), save(), and sentryBreadcrumb().
Referenced by saveFile().
| 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().
| void WorkspaceManager::setDolphinFileName | ( | const QString & | fileName | ) |
Definition at line 113 of file WorkspaceManager.cpp.
| 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().