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.

153 lines
5.2 KiB
C++

/**
*
* @file FITKTreeWidget.h
* @brief 树形菜单窗口
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-10-08
*
*/
#ifndef _FITK_TREE_WIDGET_H___
#define _FITK_TREE_WIDGET_H___
#include "FITKWidgetAPI.h"
#include <QTreeWidget>
#include "FITK_Kernel/FITKCore/FITKAbstractGUIObject.h"
namespace Core
{
class FITKAbstractOperator;
}
namespace Comp
{
/**
* @brief 树形菜单窗口1
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-10-08
*/
class FITKWidgetAPI FITKTreeWidget : public QTreeWidget, public Core::FITKAbstractGUIObject
{
Q_OBJECT
public:
/**
* @brief Construct a new FITKTreeWidget object
* @param[i] parent 父对象
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-10-08
*/
explicit FITKTreeWidget(QWidget* parent = nullptr);
/**
* @brief Destroy the FITKTreeWidget object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-10-08
*/
virtual ~FITKTreeWidget() = default;
/**
* @brief 创建树形菜单根节点项
* @param[i] parent 父对象
* @param[i] text 显示文本
* @param[i] type 类型标记
* @param[i] icon 图标
* @param[i] state 状态 : -1不使用 0不选择 1选择
* @return QTreeWidgetItem *
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-10-22
*/
static QTreeWidgetItem* CreateTreeRootItem(QTreeWidget* parent, const QString & text,
int type = 0, const QString& icon = "", int state = -1);
/**
* @brief 创建树形菜单项
* @param[i] parent 父对象
* @param[i] text 显示文本
* @param[i] type 类型标记
* @param[i] icon 图标
* @param[i] state 状态 : -1不使用 0不选择 1选择
* @return QTreeWidgetItem*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-10-08
*/
static QTreeWidgetItem* CreateTreeItem(QTreeWidgetItem* parent, const QString & text,
int type = 0, const QString& icon = "", int state = -1);
/**
* @brief 获取操作器
* @param[i] operName 操作器名称
* @return Core::FITKAbstractOperator*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-10-08
*/
static Core::FITKAbstractOperator* GetOperator(const QString& operName);
template <class T>
/**
* @brief 获取操作器,并进行强制类型转换
* @param[i] operName 操作器名称
* @return T*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-10-08
*/
T* getOperatorT(const QString & operName)
{
return dynamic_cast<T*> (this->GetOperator(operName));
}
protected:
/**
* @brief 树形菜单节点点击事件,子类重写实现
* @param[i] item 点击对象
* @param[i] column 列数
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-10-08
*/
virtual void on_itemClicked(QTreeWidgetItem *item, int column);
/**
* @brief 树形菜单节点双击事件,子类重写实现
* @param[i] item 点击对象
* @param[i] column 列数
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-10-08
*/
virtual void on_itemDoubleClicked(QTreeWidgetItem *item, int column);
/**
* @brief 树形菜单节点状态改变事件,子类重写实现
* @param[i] item 点击对象
* @param[i] state 改变之后的状态
* @param[i] column 列数
* @return void
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-10-22
*/
virtual void on_itemStateChanged(QTreeWidgetItem *item, bool state, int column);
private slots:
/**
* @brief 树形菜单节点点击槽函数。调用on_itemClicked
* @param[i] item 点击对象
* @param[i] column 列数
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-10-08
*/
void slot_itemClicked(QTreeWidgetItem *item, int column);
/**
* @brief 树形菜单节点双击槽函数。调用on_itemDoubleClicked
* @param[i] item 点击对象
* @param[i] column 列数
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-10-08
*/
void slot_itemDoubleClicked(QTreeWidgetItem *item, int column);
/**
* @brief 树形菜单节点状态改变槽函数。调用on_itemStateChanged
* @param[i] item 点击对象
* @param[i] column 列数
* @return void
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-10-22
*/
void slot_itemStateChanged(QTreeWidgetItem *item, int column);
};
}
#endif