#pragma once #include #include #include #include "workspace/WorkSpace.h" #include "workspace/FileEntry.h" class DockWidget; class DataPanel; class MainWindow; /** * @file DataPanelManager.h * @brief Data Panel Manager * Manages data panels created based on workspace files, supports multiple file types */ class DataPanelManager : public QObject { Q_OBJECT public: explicit DataPanelManager(MainWindow* mainWindow, QObject* parent = nullptr); ~DataPanelManager(); /** * @brief Set current workspace * @param workspace Workspace pointer */ void SetWorkspace(WorkSpace* workspace); /** * @brief Get current active panel count for specific type * @param fileType File type (if not specified, returns total count) * @return Panel count */ int GetActivePanelCount(FileEntryType fileType = static_cast(-1)) const; /** * @brief Get maximum panel count per type * @return Maximum panel count */ int GetMaxPanelCount() const { return 9; } /** * @brief Get panels of specific type * @param fileType File type * @return List of panels for the specified type */ QList GetPanelsOfType(FileEntryType fileType) const; public slots: /** * @brief Handle workspace changes * @param workspace New workspace */ void OnWorkspaceChanged(WorkSpace* workspace); /** * @brief Handle file changes * @param type File type */ void OnFilesChanged(FileEntryType type); /** * @brief Handle panel close event */ void OnPanelClosed(); private: /** * @brief Update panels for specific file type * @param fileType File type to update */ void UpdatePanelsForType(FileEntryType fileType); /** * @brief Create new data panel * @param fileType File type * @param filePath File path * @return Created panel pointer */ DataPanel* CreateDataPanel(FileEntryType fileType, const QString& filePath); /** * @brief Remove panel * @param panel Panel pointer */ void RemovePanel(DataPanel* panel); /** * @brief Clear all panels */ void ClearAllPanels(); /** * @brief Clear panels of specific type * @param fileType File type */ void ClearPanelsOfType(FileEntryType fileType); /** * @brief Generate panel object name * @param fileType File type * @param index Panel index * @return Object name */ QString GeneratePanelObjectName(FileEntryType fileType, int index) const; /** * @brief Find next available index for file type * @param fileType File type * @return Next available index */ int FindNextAvailableIndex(FileEntryType fileType) const; private: MainWindow* mainWindow_; // Main window pointer WorkSpace* currentWorkspace_; // Current workspace QMap dataPanels_; // Panel mapping (key -> panel) QMap dockWidgets_; // Dock widget mapping (key -> dock widget) static const QString PANEL_OBJECT_NAME_PREFIX; // Panel object name prefix };