You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AppFlow/FITK_Component/FITKWidget/FITKMdiArea.h

219 lines
6.3 KiB
C

/**
*
* @file FITKMdiArea.h
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*
*/
#ifndef _FITKVports_H
#define _FITKVports_H
#include "FITKWidgetAPI.h"
#include <QMdiArea>
#include <QMutex>
class QMdiSubWindow;
namespace Comp
{
/**
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
enum class FITKVportsLayoutType
{
CurrentMax, ///< 当前窗口最大化
Cascade, ///< 层叠显示
TileHorizontally, ///< 水平平铺
TileVertically, ///< 垂直平铺
Tab, ///< Tab页显示
};
/**
* @brief TabBar
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
enum class FITKVportsTabPos
{
Top, ///< 顶部
Bottom, ///< 底部
Left, ///< 左侧
Right, ///< 右侧
};
/**
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
class FITKWidgetAPI FITKMdiArea :public QMdiArea
{
Q_OBJECT;
public:
/**
* @brief Construct a new FITKMdiArea object
* @param[i] parent My Param doc
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
FITKMdiArea(QWidget* parent);
/**
* @brief Destroy the FITKMdiArea object
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
virtual ~FITKMdiArea();
/**
* @brief ()
* @param[i] widgwt
* @param[i] title
* @return int ID
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
int addSubWidget(QWidget* widgwt, QString title);
/**
* @brief
* @param[i] type
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
void setLayoutType(FITKVportsLayoutType type);
/**
* @brief Tabtabbar
* @param[i] position tabbar
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
void setTabPos(FITKVportsTabPos pos);
/**
* @brief
* @param[i] objectID ID
* @return QWidget
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
QWidget* getWidget(int objectID);
/**
* @brief
* @param[i] objectID ID
* @return QMdiSubWindow*
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-12
*/
QMdiSubWindow* getSubWidget(int objectID);
/**
* @brief
* @param[i] objectID ID
* @return T*
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
template< class T>
T* getWidget(int objectID)
{
return dynamic_cast<T*>(getWidget(objectID));
}
/**
* @brief
* @param[i] id ID
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
void removeWidget(int id);
/**
* @brief
* @return QWidget
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
QWidget* getCurrentWidget();
/**
* @brief
* @return QMdiSubWindow*
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-12
*/
QMdiSubWindow* getCurrentSubWidget();
/**
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
void removeCurrentWidget();
/**
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
void updateLayout();
protected:
/**
* @brief
* @param[i] event
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
void resizeEvent(QResizeEvent *event) override;
private:
/**
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
void currentMaxViewports();
/**
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
void cascadeViewports();
/**
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
void tileHorizontallyViewports();
/**
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
void tileVerticallyViewports();
private:
/**
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
static QMutex _mutex;
/**
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
FITKVportsLayoutType _layoutType = FITKVportsLayoutType::CurrentMax;
/**
* @brief TabBar
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
FITKVportsTabPos _tabPos = FITKVportsTabPos::Top;
/**
* @brief ID
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
int _objectID = 0;
/**
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-06-06
*/
QHash<int, QMdiSubWindow*> _widgetHash = {};
};
}
#endif