From 2adedebde5492a6f26d0b220bbb5781f90284857 Mon Sep 17 00:00:00 2001 From: zhaolei <353719554@qq.com> Date: Sat, 17 Jan 2026 12:55:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=A4=B4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Workflow/WFWidget/include/PaiComboBox.h | 130 +++++++ Workflow/WFWidget/include/PaiDialog.h | 205 +++++++++++ Workflow/WFWidget/include/PaiHeaderView.h | 181 ++++++++++ Workflow/WFWidget/include/PaiLabel.h | 76 +++++ Workflow/WFWidget/include/PaiLineEdit.h | 234 +++++++++++++ Workflow/WFWidget/include/PaiListDialog.h | 103 ++++++ .../WFWidget/include/PaiListItemDelegate.h | 46 +++ Workflow/WFWidget/include/PaiMenuToolBar.h | 109 ++++++ Workflow/WFWidget/include/PaiMessageBox.h | 322 ++++++++++++++++++ Workflow/WFWidget/include/PaiPromptLineEdit.h | 63 ++++ Workflow/WFWidget/include/PaiPushButton.h | 91 +++++ Workflow/WFWidget/include/PaiRadioButton.h | 39 +++ Workflow/WFWidget/include/PaiSearchLineEdit.h | 64 ++++ Workflow/WFWidget/include/PaiSpinBox.h | 56 +++ Workflow/WFWidget/include/PaiTabWidget.h | 266 +++++++++++++++ .../WFWidget/include/PaiTableItemDelegate.h | 67 ++++ Workflow/WFWidget/include/PaiTableWidget.h | 208 +++++++++++ Workflow/WFWidget/include/PaiTextEdit.h | 56 +++ Workflow/WFWidget/include/PaiTitleBar.h | 201 +++++++++++ Workflow/WFWidget/include/PaiToolBar.h | 127 +++++++ Workflow/WFWidget/include/PaiToolBarView.h | 110 ++++++ Workflow/WFWidget/include/PaiToolButton.h | 76 +++++ .../WFWidget/include/PaiTreeItemDelegate.h | 154 +++++++++ Workflow/WFWidget/include/PaiTreeWidget.h | 106 ++++++ Workflow/WFWidget/include/PaiWidget.h | 68 ++++ Workflow/WFWidget/include/PaiWidgetAction.h | 86 +++++ Workflow/WFWidget/include/PaiWindow.h | 231 +++++++++++++ Workflow/WFWidget/include/PaiWorkspace.h | 176 ++++++++++ 28 files changed, 3651 insertions(+) create mode 100644 Workflow/WFWidget/include/PaiComboBox.h create mode 100644 Workflow/WFWidget/include/PaiDialog.h create mode 100644 Workflow/WFWidget/include/PaiHeaderView.h create mode 100644 Workflow/WFWidget/include/PaiLabel.h create mode 100644 Workflow/WFWidget/include/PaiLineEdit.h create mode 100644 Workflow/WFWidget/include/PaiListDialog.h create mode 100644 Workflow/WFWidget/include/PaiListItemDelegate.h create mode 100644 Workflow/WFWidget/include/PaiMenuToolBar.h create mode 100644 Workflow/WFWidget/include/PaiMessageBox.h create mode 100644 Workflow/WFWidget/include/PaiPromptLineEdit.h create mode 100644 Workflow/WFWidget/include/PaiPushButton.h create mode 100644 Workflow/WFWidget/include/PaiRadioButton.h create mode 100644 Workflow/WFWidget/include/PaiSearchLineEdit.h create mode 100644 Workflow/WFWidget/include/PaiSpinBox.h create mode 100644 Workflow/WFWidget/include/PaiTabWidget.h create mode 100644 Workflow/WFWidget/include/PaiTableItemDelegate.h create mode 100644 Workflow/WFWidget/include/PaiTableWidget.h create mode 100644 Workflow/WFWidget/include/PaiTextEdit.h create mode 100644 Workflow/WFWidget/include/PaiTitleBar.h create mode 100644 Workflow/WFWidget/include/PaiToolBar.h create mode 100644 Workflow/WFWidget/include/PaiToolBarView.h create mode 100644 Workflow/WFWidget/include/PaiToolButton.h create mode 100644 Workflow/WFWidget/include/PaiTreeItemDelegate.h create mode 100644 Workflow/WFWidget/include/PaiTreeWidget.h create mode 100644 Workflow/WFWidget/include/PaiWidget.h create mode 100644 Workflow/WFWidget/include/PaiWidgetAction.h create mode 100644 Workflow/WFWidget/include/PaiWindow.h create mode 100644 Workflow/WFWidget/include/PaiWorkspace.h diff --git a/Workflow/WFWidget/include/PaiComboBox.h b/Workflow/WFWidget/include/PaiComboBox.h new file mode 100644 index 0000000..a6c61c4 --- /dev/null +++ b/Workflow/WFWidget/include/PaiComboBox.h @@ -0,0 +1,130 @@ +/** + * @file PaiComboBox.h + * @brief ComboBox控件 + * @date 2011-10-17 + */ +#ifndef PAI_FRAME_WIDGET_PAICOMBOBOX_H +#define PAI_FRAME_WIDGET_PAICOMBOBOX_H + +#include +#include +#include +#include "Turtle.h" + +namespace pai +{ + namespace gui + { + class PaiLineEdit; + } +} + +namespace pai +{ +namespace gui +{ +/** + * @class PaiComboBox + * @brief PaiComboBox是P.A.I系统定制发布的组合框 + */ +class PAI_WIDGET_EXPORT PaiComboBox : public QComboBox +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiComboBox(QWidget *pParent = NULL); + + /** + * @brief 构造函数 + * @param[in] showAddButton 是否显示右侧按钮 + * @param[in] pParent 父窗口句柄 + */ + PaiComboBox(bool showAddButton, QWidget *pParent = NULL); + + /** + * @brief 析构函数 + */ + virtual ~PaiComboBox(); + + /** + * @brief 设置是否使用实时过滤,默认为false不使用。 + * @param[in] flag true 使用实时过滤,反之关闭实时过滤 + */ + void SetRealTimeValidate(bool flag); + + /** + * @brief 设置是否添加Editbutton。 + * @param[in] show true 添加Editbutton,反之则不添加 + */ + void SetShowAddButton(bool show); + + /** + * @brief 重写函数,实现对显示数量的设定 + */ + virtual void showPopup (); + + /** + * @brief 获取选择列表一次显示的项目最大条数 + * @return 最大条数 + */ + int GetMaxVisibleItems() const; + + /** + * @brief 设置选择列表一次显示的项目最大条数 + * @param[in] count 最大显示条数 + */ + void SetMaxVisibleItems(const int count); + + /** + * @brief 重写系统函数,使得在对ComboBox设置styleSheet的时候, + * 它的下拉列表能够作出一些对应的调整,以使外观更加合适。 + * @param[in] styleSheet sytleSheet字符串 + */ + void setStyleSheet(const QString & styleSheet); + +protected: + /** + * @brief 重写keyPressEvent,用来处理输入限制的问题 + * @param[in] pEvent 键盘按压事件 + */ + virtual void keyPressEvent(QKeyEvent *pEvent); + + /** + * @brief 重写resizeEvent,用来处理变换大小的问题 + * @param[in] pEvent 重置大小事件 + */ + virtual void resizeEvent (QResizeEvent *pEvent); + + /** + * @brief 重绘 + * @param[in] pEvent 重画事件 + */ + virtual void paintEvent(QPaintEvent *pEvent); + +private: + /** + * @brief 初始化组件 + */ + void InitComboBox(); + +private: + PaiLineEdit *m_pLineEdit; ///< 名称编辑框 + QToolButton *m_pEditButton; ///< 编辑按钮 + bool m_RealTimeValidate; ///< 实时校验标志 + bool m_AddButton; ///< 添加按钮 + int m_MaxVisibleItems; ///< 最大可视条数 + QMargins m_margin; ///< 间隔区域 + +signals: + /** + * @brief EditButton的点击事件 + */ + void EditButtonClicked(); +}; + +} +} +#endif ///< PAI_FRAME_WIDGET_PAICOMBOBOX_H diff --git a/Workflow/WFWidget/include/PaiDialog.h b/Workflow/WFWidget/include/PaiDialog.h new file mode 100644 index 0000000..bb56f50 --- /dev/null +++ b/Workflow/WFWidget/include/PaiDialog.h @@ -0,0 +1,205 @@ +/** + * @file PaiDialog.h + * @brief PAI系统默认对话框 + * @date 2011-10-17 + */ +#ifndef PAI_FRAME_WIDGET_PAIDIALOG_H +#define PAI_FRAME_WIDGET_PAIDIALOG_H + +#include +#include +#include + +#include "PaiTitleBar.h" +#include "Turtle.h" + +namespace pai +{ +namespace gui +{ +/** + * @class PaiDialog + * @brief PAI系统默认对话框 + */ +class PAI_WIDGET_EXPORT PaiDialog: public QDialog +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + * @param[in] flags 窗口类型 + */ + PaiDialog(QWidget *pParent = NULL, Qt::WindowFlags flags = 0); + + /** + * @brief 析构函数 + */ + virtual ~PaiDialog(); + + /** + * @brief 获得控件容器,UI或控件可以放到里面 + * @return 控件容器 + */ + QWidget* GetContainer(); + + /** + * @brief 设置TitleBar的显示属性 + * @param[in] flags titleBar的flags + */ + void SetTitleBarFlags(PaiTitleBar::TitleBarFlags flags); + + /** + * @brief 返回TitleBarFlags + * @return 对话框标志 + */ + PaiTitleBar::TitleBarFlags GetTitleBarFlags() const; + + /** + * @brief 设置dialog的title,覆盖基类函数,会将其设置到titlebar + * @param[in] windowTitle dialog的title + */ + void setWindowTitle(const QString & windowTitle); + + /** + * @brief 设置Layout到当前对话框,覆盖基类函数,会设为Container的Layout + * @param[in] pLayout layout manager + */ + void setLayout(QLayout *pLayout); + + /** + * @brief 获得当前对话框的layout,覆盖基类函数,实际返回的时Contgainer的layout + * @return 布局 + */ + QLayout* layout() const; + + /** + * @brief 在TitleBar上Logo和系统菜单中间的区域插入Widget + * @param[in] pWidget 要插入的Widgt + * @param[in] alignment 在哪一侧,接受Qt::AlignLeft和Qt::AlignRight + */ + void InsertTitleBarWidget(QWidget *pWidget, Qt::Alignment alignment); + + /** + * @brief 设置是否运输用鼠标改变窗口大小 + * @param[in] constraint 是否固定大小 + */ + void SetConstraintSize(bool constraint); + + /** + * @brief 设置window的Geometry,覆盖基类函数,用来判断window是否是最大化 + * @param[in] x x轴坐标 + * @param[in] y y轴坐标 + * @param[in] with 宽度 + * @param[in] height 高度 + */ + void setGeometry(int x, int y, int with, int height); + + /** + * @brief 设置window的Geometry,覆盖基类函数,用来判断window是否是最大化 + * @param[in] rect 矩形区域 + */ + void setGeometry(const QRect & rect); + + /** + * @brief 设置鼠标改变窗体大小显示方式 + * @param[in] mode 0:松开鼠标后窗体变动;1:鼠标左键按下拖动时,窗体大小实时变动; + */ + static void SetWindowChangeSizeMode(int mode); + +public slots: + /** + * @brief 当在有最小化按钮时,需要调整对话框出现的位置 + */ + void show(); + + /** + * @brief 当在有最小化按钮时,需要调整对话框出现的位置 + * @return 对话框出现的位置 + */ + int exec(); + +protected: + /** + * @brief 重写鼠标点击事件 + * @param[in] pEvent 鼠标按压事件 + */ + virtual void mousePressEvent(QMouseEvent *pEvent); + + /** + * @brief 重写鼠标释放事件 + * @param[in] pEvent 鼠标释放事件 + */ + virtual void mouseReleaseEvent(QMouseEvent *pEvent); + + /** + * @brief 重写鼠标移动事件 + * @param[in] pEvent 鼠标移动事件 + */ + virtual void mouseMoveEvent(QMouseEvent *pEvent); + + /** + * @brief 一旦鼠标样式更改,没隔100毫秒判断一次鼠标位置,以便更改鼠标样式 + * @param[in] pEvent 定时器事件 + */ + virtual void timerEvent(QTimerEvent *pEvent); + + /** + * @brief 用来绘制边框 + * @param[in] pEvent 绘制事件 + */ + virtual void paintEvent(QPaintEvent *pEvent); + +private: + /** + * @enum ResizeDirction + * @brief Resize事件中拖动的方向 + */ + enum ResizeDirction + { + ResizeDirction_None = 0, ///< 无方向 + ResizeDirction_Top = 1, ///< 向上 + ResizeDirction_Bottom = 2, ///< 向下 + ResizeDirction_Left = 3, ///< 向左 + ResizeDirction_Right = 4, ///< 向右 + ResizeDirction_TopLeft = 5, ///< 左上 + ResizeDirction_TopRight = 6, ///< 右上 + ResizeDirction_BottomLeft = 7, ///< 左下 + ResizeDirction_BottomRight = 8 ///< 右下 + }; + + /** + * @brief 触发Resize事件之前用来更新鼠标样式 + * @param[in] mousePosition 当前鼠标所在的坐标 + */ + void SetCursorShape(const QPoint & mousePosition); + + /** + * @brief Resize事件的实现 + * @param[in] mousePosition 当前鼠标所移动的位置 + */ + void ResizeFrame(const QPoint & mousePosition); + +private: + pai::gui::PaiTitleBar *m_pTitleBar; ///< 标题栏 + QWidget *m_pContainer; ///< 容器指针 + ResizeDirction m_ResizeDirction; ///< 方向 + bool m_IsPress; ///< 按压标志 + bool m_moved; ///< 窗口大小是否拖动 + QRubberBand *m_pRubberBand; ///< 橡皮筋 + int m_TimerID; ///< 定时器id + bool m_ConstSize; ///< 因为在设置固定大小后,无法最小化,这里特殊控制一下 + static int m_WinChangeSizeMode; ///< 鼠标改变窗体大小方式: 0:鼠标左键弹起后窗体变动;1:鼠标左键按下拖动时,窗体显示实时变动; + static bool m_InitWinChangeSizeMode; ///< 因为当前配置保存在配置文件中,暂时添加此变量表示是否初始化加载配置文件 + +signals: + /** + * @brief 关闭按钮按下后释放次信号,如果需要在对话框关闭前处理事务,则可直联次信号。 + */ + void CloseButtonClicked(); +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAIDIALOG_H diff --git a/Workflow/WFWidget/include/PaiHeaderView.h b/Workflow/WFWidget/include/PaiHeaderView.h new file mode 100644 index 0000000..e3cee4a --- /dev/null +++ b/Workflow/WFWidget/include/PaiHeaderView.h @@ -0,0 +1,181 @@ +/** + * @file PaiHeaderView.h + * @brief PaiHeaderView 是P.A.I系统定制发布的表头控件 + * @attention 目前只支持水平标题,而且只在TableView使用过,如有其它控件的需求请扩展 + * + ******************************************************************* + * ENHANCEMENTS * + ******************************************************************* + * 1.可以选择要显示或隐藏的列 + * 2.可以控制列的最小宽度不小于标题文字的宽度 + * @date 2012-01-11 + */ +#ifndef PAI_FRAME_WIDGET_PAIHEADERVIEW_H +#define PAI_FRAME_WIDGET_PAIHEADERVIEW_H + +#include +#include "Turtle.h" + +class QToolButton; +class QCheckBox; + +namespace pai +{ +namespace gui +{ +/** + * @class PaiHeaderView + * @brief 具有PAI功能的表格标题栏(目前只可应用在水平标题) + */ +class PAI_WIDGET_EXPORT PaiHeaderView: public QHeaderView +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] orientation 方向 + * @param[in] pParent 父窗口句柄 + */ + PaiHeaderView(Qt::Orientation orientation, QWidget *pParent= NULL); + + /** + * @brief 析构函数 + */ + virtual ~PaiHeaderView(); + + /** + * @brief 设置是否可以在表格上可以有选择行的显示某些列的功能 + * @param[in] selectable 是否打开该功能 + */ + void SetSectionVisibleSelectable(bool selectable); + + /** + * @brief 设置表头项目不可以被隐藏 + * @param[in] sectionList 不可以被隐藏的表头名 + */ + void SetUnselectableSections(const QStringList & sectionList); + + /** + * @brief 读取PaiSettings记录,恢复未隐藏显示的列 + */ + void RecallMemberedSections(); + + /** + * @brief 记录当前显示的表头 + */ + void RememberCurrentSections(); + + /** + * @brief 设置是否可选中列,如果可选中则会在指定列的左侧添加一个CheckBox + * @param[in] logicalIndex 目标列的逻辑索引 + * @param[in] checkable 是否可选中 + * @param[in] pCheckBox 需要添加的CheckBox,如果checkable为false,则可不传递此参数。 + */ + void SetColumnCheckable(const int logicalIndex, const bool checkable, QCheckBox *pCheckBox = NULL); + + /** + * @brief 在发生插入或删除列操作时,调整CheckBox的位置 + * @param[in] insert 是否为插入操作。true表示插入操作,fasle表示删除操作 + * @param[in] column 插入或删除的行序号 + */ + void AdjustCheckBoxMap(bool insert, int column); + +protected: + /** + * @brief 重载,在最后一列绘制可以选择显示列的按钮 + * @param[in] pPainter 画笔 + * @param[in] rect 区域 + * @param[in] logicalIndex 逻辑索引 + */ + void paintSection(QPainter *pPainter, const QRect & rect, int logicalIndex) const; + + /** + * @brief 使可以控制列按当前比列增大或缩小 + * @param[in] pEvent 重置大小事件 + */ + void resizeEvent(QResizeEvent *pEvent); + + /** + * @brief 重载鼠标事件处理函数,在右键点击时发射信号 + * @param[in] pEvent 鼠标按压事件 + */ + void mousePressEvent (QMouseEvent *pEvent); + +private: + /** + * @brief 计算列的最合适宽度 + * @param[in] logicalIndex 表头的索引号 + * @return 最适宽度 + */ + int SectionSuitableWidth(int logicalIndex); + + /** + * @brief 获得做后一个可见列的逻辑索引(logical index) + * @return 逻辑索引 + */ + int LastVisibleSection() const; + + /** + * @brief If hide is true the section specified by logicalIndex is hidden; otherwise the section is shown + * @param[in] logicalIndex logical index + * @param[in] hide hidden or show + */ + void SetSectionHidden(int logicalIndex, bool hide); + +private slots: + /** + * @brief 设置最小宽度为字体宽度 + * @param[in] logicalIndex 表头的索引号 + * @param[in] oldSize 原始大小 + * @param[in] newSize 移动后获得的新尺寸 + */ + void AdjustSectionSuitable(int logicalIndex, int oldSize, int newSize); + + /** + * @brief 交换当前列的显示状态 + */ + void ReverseSectionVisible(); + + /** + * @brief 弹出列选择显示菜单 + */ + void ShowSectionVisibleMenu(); + + /** + * @brief 处理CheckBox选中信号 + */ + void CheckBoxStateChanged(); + +private: + bool m_SectionSelectableVisible; ///< 控制是否可以在表格上可以有选择行的显示某些列的功能 + QToolButton *m_pSectionSelectToolButton; ///< 选择显示列按钮 + QStringList m_UnselectableSections; ///< 不可以被隐藏的表头名字列表 + QMap m_ColumnCheckBoxMap; ///< 列序号和对应列的CheckBox的映射 + +signals: + /** + * @brief 右键点击表头时发射此消息 + * @param[in] logicalIndex 逻辑列序号 + * @param[in] globalPos 鼠标全局坐标 + */ + void TitleRightClicked(int logicalIndex, const QPoint & globalPos); + + /** + * @brief 如果存在选中框,且选中框状态发生变化则释放此信号 + * @param[in] logicalIndex 选中状态改变的逻辑列序号 + * @param[in] checkstate 选中状态 + */ + void CheckStateChanged(int logicalIndex, Qt::CheckState checkstate); + + /** + * @brief 列隐藏或列显示时发送此信号 + * @param[in] logicalIndex 逻辑列序号 + * @param[in] visible shown or hidden + */ + void SectionVisibleChanged(int logicalIndex, bool visible); +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAIHEADERVIEW_H diff --git a/Workflow/WFWidget/include/PaiLabel.h b/Workflow/WFWidget/include/PaiLabel.h new file mode 100644 index 0000000..531fdef --- /dev/null +++ b/Workflow/WFWidget/include/PaiLabel.h @@ -0,0 +1,76 @@ +/* + * PaiLabel.h + * + * Created on: 2011-10-17 + * Author: dev + */ +#ifndef PAI_FRAME_WIDGET_PAILABEL_H +#define PAI_FRAME_WIDGET_PAILABEL_H + +#include +#include "Turtle.h" + +namespace pai +{ +namespace gui +{ +/** + * @class PaiLabel + * @brief 文本显示控件 + */ +class PAI_WIDGET_EXPORT PaiLabel : public QLabel +{ + Q_OBJECT +public: + /** + * @enum PromptType + * @brief 不同模式下文字显示的颜色和图标不同 + */ + enum PromptType + { + PT_Information, ///< 普通信息 + PT_Question, ///< 疑问信息 + PT_Warning, ///< 警告信息 + PT_Error, ///< 错误信息 + PT_NO_STYLE_Text, ///< 不设置任何风格的纯文本信息 + PT_NO_STYLE ///< 无风格 + }; + + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiLabel(QWidget *pParent = NULL); + + /** + * @brief 构造函数 + * @param[in] text 显示文本 + * @param[in] pParent 父窗口句柄 + */ + PaiLabel(const QString & text, QWidget *pParent = NULL); + + /** + * @brief 析构函数 + */ + virtual ~PaiLabel(); + + /** + * @brief 显示提示信息 + * @param[in] type 输入需显示的错误表示 + */ + void ShowPromptMessge(PromptType type = PT_Information); + +protected: + /** + * @brief 重新实现该函数来添加额外的元素 + * @param[in] pEvent 绘制事件 + */ + virtual void paintEvent(QPaintEvent *pEvent); + +private: + PromptType m_PromptType; ///< 显示信息类型 +}; + +} +} +#endif ///< PAI_FRAME_WIDGET_PAILABEL_H diff --git a/Workflow/WFWidget/include/PaiLineEdit.h b/Workflow/WFWidget/include/PaiLineEdit.h new file mode 100644 index 0000000..27258b9 --- /dev/null +++ b/Workflow/WFWidget/include/PaiLineEdit.h @@ -0,0 +1,234 @@ +/** + * @file PaiLineEdit.h + * @brief PaiLineEdit是P.A.I系统定制发布的单行文本框控件 + * @date 2011-10-21 + */ +#ifndef PAI_FRAME_WIDGET_PAILINEEDIT_H +#define PAI_FRAME_WIDGET_PAILINEEDIT_H + +#include +#include "Turtle.h" +class QTimer; +class QPushButton; + +namespace pai +{ +class SmartCompleter; +namespace gui +{ +/** + * @class PaiLineEdit + * @brief P.A.I系统定制发布的单行文本框控件,用户可以方便地设置密码风格,错误风格和搜索框风格 + */ +class PAI_WIDGET_EXPORT PaiLineEdit : public QLineEdit +{ + Q_OBJECT +public: + /** + * @enum PromptType + * @brief 不同模式下文字显示的颜色和图标不同 + */ + enum PromptType + { + PT_NULL, ///< 无提示信息 + PT_Information, ///< 普通信息 + PT_Question, ///< 疑问信息 + PT_Warning, ///< 警告信息 + PT_Error ///< 错误信息 + }; + + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiLineEdit(QWidget *pParent = NULL); + + /** + * @brief 构造函数 + * @param[in] text 单行文本框里的文本初始值 + * @param[in] pParent 父窗口句柄 + */ + PaiLineEdit(const QString & text, QWidget *pParent = NULL); + ~PaiLineEdit(); + /** + * @brief 设置校验器的错误提示 + * @param[in] validateFailure 校验器的错误提示 + */ + void SetValidatorFailureMessage(const QString & validateFailure); + + /** + * @brief 设置超出最大长度的错误提示 + * @param[in] exceedMaxLength 超出最大长度的错误提示 + */ + void SetExceedMaxLengthMessage(const QString & exceedMaxLength); + + /** + * @brief 当输入框内没有文字的时候显示该提示信息 + * @param[in] text 提示信息 + * @note 请勿使用基类的 setPlaceholderText() + */ + void setPlaceholderText(const QString & text); + + /** + * @brief 获得 placeholder 信息 + * @return 文本 + */ + QString placeholderText() const; + + /** + * @brief 显示提示信息 + * @param[in] message 输入需显示的信息 + * @param[in] type 输入需显示的错误表示 + */ + virtual void ShowPromptMessge(const QString & message, PromptType type = PT_Information); + + /** + * @brief 输入框是否为空 + * return true 空 false 非空 + */ + bool IsEmpty(); + + /** + * @brief 设置输入字符后多长时间没有响应就认为编辑停止 + * @param[in] duration 持续时间(毫秒),当前默认300毫秒 + * @note 如果过编辑完成,则同时立即认为编辑停止,不再等待 + * 如需等待搜索结果,再响应returnPressed或editFilished等信号, + * 请将该值设为60ms以下,根据测试人从输入字符到按回车键的间隔在60ms以下 + */ + void SetEditStopDuration(int duration); + + /** + * @brief 设置模糊匹配Completer + * @param[in] pComleter 模糊匹配Completer的指针 + */ + void SetSmartCompleter(pai::SmartCompleter *pComleter); + /** + * @brief 得到当前模糊匹配Completer + */ + pai::SmartCompleter *SmartCompleter() const; + + +protected: + /** + * @brief 向文本框的右侧设置搜索按钮 + * @param[in] iconPath icon路径 + */ + void SetRightIcon(const QString & iconPath); + + /** + * @brief 检验输入的是否合法并显示警告信息 + * @param[in] inputText 输入的字符串 + */ + void CheckInput(const QString & inputText); + + /** + * @brief 重写mousePressEvent + * @param[in] pEvent 鼠标按压事件 + */ + virtual void mousePressEvent(QMouseEvent *pEvent); + + /** + * @brief 设置LineEdit 的宽度 + * @return 控件的宽度和高度 + */ + virtual QSize sizeHint() const; + + /** + * @brief 重新实现该函数来添加额外的元素 + * @param[in] pEvent 重绘事件 + */ + virtual void paintEvent(QPaintEvent *pEvent); + + /** + * @brief 重新keyReleaseEvent函数 为了实现输入非法字符,提示警告信息 + * @param[in] pEvent 键盘释放事件 + */ + virtual void keyReleaseEvent(QKeyEvent *pEvent); + + /** + * @brief keyPressEvent函数 为了实现输入非法字符,提示警告信息 + * @param[in] pEvent 键盘按压事件 + */ + virtual void keyPressEvent(QKeyEvent *pEvent); + + /** + * @brief 重写inputMethodEvent函数 为了实现输入非法字符,提示警告信息 + * @param[in] pEvent 输入方式事件 + */ + virtual void inputMethodEvent(QInputMethodEvent *pEvent); + + /** + * @brief 重写contextMenuEvent函数 为了实现输入字符长度大于100时,提示警告信息 + * @param[in] pEvent 上下文菜单事件 + */ + virtual void contextMenuEvent(QContextMenuEvent *pEvent); + +private: + /** + * @brief 初始化控件 + */ + void Init(); + + /** + * @brief 处理键盘上下键和回车键的操作 + * @param[in] key 键盘上被按的方向键 + */ + void DealDirectionKey(int key); + +private slots: + /** + * @brief 文本编辑完成 + */ + void TextEditingFinished(); + + /** + * @brief 编辑停止超过固定秒后发送停止信号,时间间隙可由SetEditStopDuration(...)函数设置 + */ + void EmitEditingStoped(); + + /** + * @brief FuzzyComleter的响应 + */ + void InsertCompletion(const QString &completion); + +protected: + QString m_PlaceholderText; ///< Placeholder文本 + QString m_PromptMessage; ///< 提示信息 + QString m_ValidateMessage; ///< 校验信息 + QString m_ExceedMaxLengthMessage; ///< 过长信息 + PromptType m_PromptType; ///< 提示类型 + QTimer *m_pDelayTimer; ///< 用于检查是否停止编辑 + QPushButton *m_pRightPBtn; ///< 按钮 + pai::SmartCompleter *m_pCompleter; ///< 模糊匹配的 + +signals: + /** + * @brief 文本编辑完成 + * @param[in] text 当前文本 + */ + void EditingFinished(const QString & text); + + /** + * @brief 编辑停止 + * @note 如果过编辑完成,则同时立即发射该信号,不再等待 + * 如需等待搜索结果,再响应returnPressed或editFilished等信号, + * 请将该值设为60ms以下,根据测试人从输入字符到按回车键的间隔在60ms以下 + * @param[in] text 当前文本 + */ + void EditingStoped(const QString & text); + + /** + * @brief 右边的按钮被点击后触发的信号 + */ + void RightIconClicked(); + + /** + *@brief 点击鼠标发出此信号 + */ + void LeftMousePress(); +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAILINEEDIT_H diff --git a/Workflow/WFWidget/include/PaiListDialog.h b/Workflow/WFWidget/include/PaiListDialog.h new file mode 100644 index 0000000..c666486 --- /dev/null +++ b/Workflow/WFWidget/include/PaiListDialog.h @@ -0,0 +1,103 @@ +/** + * @file PaiListDialog.h + * @brief PAI系统默认列表对话框 + * @date 2014-11-25 + */ +#ifndef PAI_FRAME_WIDGET_LISTDIALOG_H +#define PAI_FRAME_WIDGET_LISTDIALOG_H + +#include + +#include "PaiDialog.h" + +class QListView; + +namespace pai +{ + namespace gui + { + class PaiPushButton; + class PaiSearchLineEdit; + } +} + +namespace pai +{ +namespace gui +{ +/** + * @class PaiListDialog + * @brief 列表对话框(带搜索功能) + */ +class PAI_WIDGET_EXPORT PaiListDialog : public PaiDialog +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父亲 + */ + PaiListDialog(QWidget *pParent = NULL); + + /** + * @brief 析构函数 + */ + virtual ~PaiListDialog(); + + /** + * @brief 设置数据 + * @param[in] textList item文本 + */ + void SetTextList(const QStringList & textList); + +private: + /** + * @brief 过滤要显示的行 + * @param[in] keyword 搜索关键字 + * @param[in] row 行号 + * @return 是否过滤 + */ + bool Filter(const QString & keyword, int row); + +private slots: + /** + * @brief 搜索控件,输入完成执行的槽 + * @param[in] keyword 搜索关键字 + */ + void OnSearchData(const QString & keyword); + + /** + * @brief 点击ok按钮调用的槽 + */ + void OkButtonClicked(); + + /** + * @brief 某个item被双击时执行的槽 + * @param[in] index 被双击item的索引 + */ + void ItemDoubleClicked(const QModelIndex & index); + + /** + * @brief 但前索引改变时执行的槽 + * @param[in] current 当前索引 + * @param[in] previous 之前索引 + */ + void EnableOkButton(const QModelIndex & current, const QModelIndex & previous); + +private: + PaiSearchLineEdit *m_pSearchLineEdit;///< 搜索框 + QListView *m_pListWgt; ///< 列表显示框 + PaiPushButton *m_pOkPBtn; ///< ok按钮 + PaiPushButton *m_pCancelPBtn; ///< cancel按钮 + +signals: + /** + * @brief 点击ok按钮发送的信号 + * @param[in] text 当前item文本 + */ + void SelectedAccepted(const QString & text); +}; + +} +} +#endif ///< PAI_FRAME_WIDGET_LISTDIALOG_H diff --git a/Workflow/WFWidget/include/PaiListItemDelegate.h b/Workflow/WFWidget/include/PaiListItemDelegate.h new file mode 100644 index 0000000..3c94d41 --- /dev/null +++ b/Workflow/WFWidget/include/PaiListItemDelegate.h @@ -0,0 +1,46 @@ +/** + * @file PaiListItemDelegate.h + * @brief PAI系统ListItem默认风格 + * @date 2014-11-25 + */ +#ifndef PAI_FRAME_WIDGET_PAILISTITEMDELEGATE_H +#define PAI_FRAME_WIDGET_PAILISTITEMDELEGATE_H + +#include +#include + +class QListView; + +namespace pai +{ +namespace gui +{ +/** + * @class PaiListItemDelegate + * @brief PAI风格 listItem delegate + */ +class PaiListItemDelegate: public QStyledItemDelegate +{ +public: + /** + * @brief 构造函数 + * @param[in] pParent 父亲 + */ + PaiListItemDelegate(QObject *pParent = NULL); + +protected: + /** + * @brief 重新实现重绘函数 + * @param[in] pPainter 画笔 + * @param[in] option 选项 + * @param[in] index Model 索引 + */ + void paint(QPainter *pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const; + +private: + QPen m_GridPen; ///< 画笔 +}; + +} +} +#endif ///< PAI_FRAME_WIDGET_PAILISTITEMDELEGATE_H diff --git a/Workflow/WFWidget/include/PaiMenuToolBar.h b/Workflow/WFWidget/include/PaiMenuToolBar.h new file mode 100644 index 0000000..19b8f4c --- /dev/null +++ b/Workflow/WFWidget/include/PaiMenuToolBar.h @@ -0,0 +1,109 @@ +/** + * @file PaiMenuToolBar.h + * @brief 菜单栏组件 + * @date 2011-08-23 + */ +#ifndef PAI_FRAME_WIDGET_PAIMENUTOOLBAR_H +#define PAI_FRAME_WIDGET_PAIMENUTOOLBAR_H + +#include + +#include "PaiToolBar.h" +#include "Turtle.h" + +namespace pai +{ + namespace gui + { + class MenuToolButton; + } +} + +namespace pai +{ +namespace gui +{ + +/** + * @class PaiMenuToolBar + * @brief P.A.I系统的插件的内容区通常有一个带菜单的工具栏,这个类定制了这种工具栏 + */ +class PAI_WIDGET_EXPORT PaiMenuToolBar:public pai::gui::PaiToolBar +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] title 标题 + * @param[in] pParent 父窗口句柄 + */ + PaiMenuToolBar(const QString & title,QWidget *pParent); + + /** + * @brief 析构函数 + */ + virtual ~PaiMenuToolBar(); + + /** + * @brief 得到菜单句柄 + * @return 菜单 + */ + QMenu* GetMenu() const; + + /** + * @brief 得到视图菜单句柄 + * @return 视图菜单句柄 + */ + QMenu* GetViewsMenu() const; + + /** + * @brief 设置工具栏按钮可见性 + * @param[in] flag 工具栏按钮是否可见 + */ + void setMenuButtonVisible(bool flag); + + /** + * @brief 向视图菜单中添加菜单项 + * @param[in] name 区域名 + * @param[in] viewID 菜单对应视图ID + */ + void AddViewsMenuAction(QString & name, std::string viewID); + + /** + * @brief 设置菜单选中状态 + * @param[in] viewID 菜单对应视图ID + * @param[in] checked 菜单选中状态 + */ + void SetViewMenuChecked(const QString & viewID, bool checked); + + /** + * @brief 清空Menu列表内容 + * @param[in] isVisible 是否显示Menu控件 + */ + void Clear(bool isVisible); + +public slots: + /** + * @brief 关闭TabWidget + * @param[in] extensionID 关闭的ID + */ + void CloseTabWidget(const QString & extensionID); + +protected: + /** + * @brief 绘制事件 + * @param[in] pEvent 绘制事件 + */ + virtual void paintEvent(QPaintEvent *pEvent); + +private: + QMenu *m_pRootMenu; ///< 根菜单 + QMenu *m_pViewsMenu; ///< 视图菜单栏 + MenuToolButton *m_pMenuButton; ///< 菜单按钮 + QAction *m_pMenuButtonAct;///< 菜单Action +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAIMENUTOOLBAR_H diff --git a/Workflow/WFWidget/include/PaiMessageBox.h b/Workflow/WFWidget/include/PaiMessageBox.h new file mode 100644 index 0000000..005bc27 --- /dev/null +++ b/Workflow/WFWidget/include/PaiMessageBox.h @@ -0,0 +1,322 @@ +/** + * @file PaiMessageBox.h + * @brief 实现自定义的MessageBox对话框 + * @date 2012-03-06 + */ +#ifndef PAI_FRAME_PIPROJECTMANAGEMENT_PAIMESSAGEBOX_H +#define PAI_FRAME_PIPROJECTMANAGEMENT_PAIMESSAGEBOX_H + +#include + +#include "PaiDialog.h" +#include "Turtle.h" + +class QLabel; + +namespace pai +{ + namespace gui + { + class PaiPushButton; + class PaiTextEdit; + } +} + +namespace pai +{ +namespace gui +{ + +/** + * @class PaiMessageBox + * @brief 自定义的MessageBox对话框 + */ +class PAI_WIDGET_EXPORT PaiMessageBox : public PaiDialog +{ + Q_OBJECT + Q_ENUMS(Icon) + Q_FLAGS(StandardButtons) +public: + /** + * @enum Icon + * @brief 标准内置提示图标 + */ + enum Icon + { + Icon_None = 0, ///< 无图标 + Icon_Information = 1, ///< 信息图标 + Icon_Warning = 2, ///< 警告图标 + Icon_Critical = 3, ///< 错误图标 + Icon_Question = 4 ///< 提问图标 + }; + + /** + * @enum StandardButton + * @brief 内置标准按钮 + */ + enum StandardButton + { + NoButton = 0x00000000, ///< 无按钮 + Ok = 0x00000400, ///< OK按钮 + Save = 0x00000800, ///< 保存按钮 + SaveAll = 0x00001000, ///< 保存所有按钮 + Open = 0x00002000, ///< 打开按钮 + Yes = 0x00004000, ///< Yes按钮 + YesToAll = 0x00008000, ///< Yes to all 按钮 + No = 0x00010000, ///< NO按钮 + NoToAll = 0x00020000, ///< NO to all 按钮 + Abort = 0x00040000, ///< 忽略按钮 + Retry = 0x00080000, ///< 重试按钮 + Ignore = 0x00100000, ///< 忽略按钮 + Close = 0x00200000, ///< 关闭按钮 + Cancel = 0x00400000, ///< 取消按钮 + Discard = 0x00800000, ///< 打开按钮 + Help = 0x01000000, ///< 放弃按钮 + Apply = 0x02000000, ///< 应用按钮 + Reset = 0x04000000, ///< 重置按钮 + RestoreDefaults = 0x08000000, ///< 恢复默认按钮 + + FirstButton = Ok, ///< 首个按钮 + LastButton = RestoreDefaults///< 末尾按钮 + }; + Q_DECLARE_FLAGS(StandardButtons, StandardButton) + + /** + * @brief 构造函数 + * @param[in] pParent 父对象 + */ + PaiMessageBox(QWidget *pParent = NULL); + + /** + * @brief 构造函数 + * @param[in] icon 内置标准图标 + * @param[in] title 对话框标题 + * @param[in] text 显示的提示文本 + * @param[in] buttons 要使用的标准按钮 + * @param[in] pParent 父对象 + * @param[in] flag 对话框属性标志位 + */ + PaiMessageBox(Icon icon, + const QString & title, + const QString & text, + StandardButtons buttons = NoButton, + QWidget *pParent = NULL, + Qt::WindowFlags flag = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); + + /** + * @brief 构造函数 + * @param[in] icon 内置标准图标 + * @param[in] title 对话框标题 + * @param[in] text 显示的提示文本 + * @param[in] details 显示的细节文本,会用TextEdit来显示。 + * @param[in] buttons 要使用的标准按钮 + * @param[in] pParent 父类 + * @param[in] flag 对话框属性标志位 + */ + PaiMessageBox(Icon icon, + const QString & title, + const QString & text, + const QString & details, + StandardButtons buttons = NoButton, + QWidget *pParent = NULL, + Qt::WindowFlags flag = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); + + /** + * @brief 析构函数 + */ + virtual ~PaiMessageBox (); + + /** + * @brief 设置标准图标 + * @param[in] icon 图标 + */ + void SetIcon(Icon icon); + + /** + * @brief 设置标准按钮 + * @param[in] buttons 按钮 + */ + void SetStandardButtons(StandardButtons buttons); + + /** + * @brief 设置默认按钮 + * @param[in] button 默认按钮 + */ + void SetDefaultButton(StandardButton button); + + /** + * @brief 设置显示文本 + * @param[in] text 文本内容 + */ + void SetText(const QString & text); + + /** + * @brief 设置细节描述文本 + * @param[in] text 文本内容 + */ + void SetDetailedText(const QString & text); + + /** + * @brief 更改标准按钮的名字 + * @param[in] button 标准按钮 + * @param[in] name 新名字 + */ + void SetStandardButtonName(StandardButton button, const QString & name); + + /** + * @brief 获得当前详细描述信息 + * @return 当前详细描述信息 + */ + QString GetDetailedText() const; + + /** + * @brief 标准提示对话框 + * @param[in] pParent 父类 + * @param[in] title 对话框标题 + * @param[in] text 显示的提示文本 + * @param[in] buttons 要使用的标准按钮 + * @param[in] defaultButton 默认按钮 + * @return 触发按钮 + */ + static StandardButton Information(QWidget *pParent, + const QString & title, + const QString & text, + StandardButtons buttons = Ok, + StandardButton defaultButton = NoButton); + + /** + * @brief 标准提问对话框 + * @param[in] pParent 父类 + * @param[in] title 对话框标题 + * @param[in] text 显示的提示文本 + * @param[in] buttons 要使用的标准按钮 + * @param[in] defaultButton 默认按钮 + * @return 触发按钮 + */ + static StandardButton Question(QWidget *pParent, + const QString & title, + const QString & text, + StandardButtons buttons = Ok, + StandardButton defaultButton = NoButton); + + /** + * @brief 标准警告对话框 + * @param[in] pParent 父类 + * @param[in] title 对话框标题 + * @param[in] text 显示的提示文本 + * @param[in] buttons 要使用的标准按钮 + * @param[in] defaultButton 默认按钮 + * @return 触发按钮 + */ + static StandardButton Warning(QWidget *pParent, + const QString & title, + const QString & text, + StandardButtons buttons = Ok, + StandardButton defaultButton = NoButton); + + /** + * @brief 标准严重错误对话框 + * @param[in] pParent 父类 + * @param[in] title 对话框标题 + * @param[in] text 显示的提示文本 + * @param[in] buttons 要使用的标准按钮 + * @param[in] defaultButton 默认按钮 + * @return 触发按钮 + */ + static StandardButton Critical(QWidget *pParent, + const QString & title, + const QString & text, + StandardButtons buttons = Ok, + StandardButton defaultButton = NoButton); + +protected: + /** + * @brief 点击析用退出按钮 + * @param[in] pEvent 关闭事件 + */ + void closeEvent(QCloseEvent *pEvent); + +private: + /** + * @brief 静态标准对话框 + * @param[in] pParent 父类 + * @param[in] title 对话框标题 + * @param[in] text 显示的提示文本 + * @param[in] buttons 要使用的标准按钮 + * @param[in] defaultButton 默认按钮 + */ + static StandardButton ShowNewMessageBox(QWidget *pParent, + Icon icon, + const QString & title, + const QString & text, + StandardButtons buttons, + StandardButton defaultButton); + + /** + * @brief 初始化对话框 + */ + void InitDialog(); + + /** + * @brief 获得标准按钮的显示文本 + * @param[in] button 标准按钮 + * @return 标准按钮的显示文本 + */ + QString GetStandardButtonText(StandardButton button); + + /** + * @brief 添加一个标准按钮,使用该函数后务必 + * 调用RestoreButtonPos来调整布局 + * @param[in] button 标准按钮 + * @return 标准按钮 + */ + PaiPushButton* AddButton(StandardButton button); + + /** + * @brief 重新按以设定好的顺序调整布局 + */ + void RestoreButtonPos(); + + /** + * @brief 获得点击系统关闭按钮后等同功能的按钮 + * @return 点击系统关闭按钮后等同功能的按钮 + */ + StandardButton DetectedEscapeButton(); + + /** + * @brief 设置返回值为该button + * @param[in] button 要返回的按钮 + */ + void SetResutlButton(StandardButton button); + +private slots: + /** + * @brief 表准按钮被点击时执行 + */ + void ButtonClicked(); + +private: + QLabel *m_pIconLabel; ///< 图标标签 + QLabel *m_pTextLabel; ///< 文本标签 + QWidget *m_pBtnWgt; ///< 按钮组件 + PaiTextEdit *m_pDetailsTEdit; ///< 文本编辑组件 + + QMap m_FlagToBtn; ///< 标记和对应的按钮映射 + QList m_BtnPos; ///< separate left and right with NoButton + QList m_EscapeBtns; ///< 退出按钮 + QMap m_BtnNames; ///< the name of the standard button + +signals: + /** + * @brief 当点击标准按钮时发射该信号 + * @param[in] button 点击的按钮 + */ + void ButtonClicked(StandardButton button); +}; + +} +} + +Q_DECLARE_OPERATORS_FOR_FLAGS(pai::gui::PaiMessageBox::StandardButtons) + +#endif ///< PAI_FRAME_PIPROJECTMANAGEMENT_PAIMESSAGEBOX_H diff --git a/Workflow/WFWidget/include/PaiPromptLineEdit.h b/Workflow/WFWidget/include/PaiPromptLineEdit.h new file mode 100644 index 0000000..72b5847 --- /dev/null +++ b/Workflow/WFWidget/include/PaiPromptLineEdit.h @@ -0,0 +1,63 @@ +/** + * @file PaiPromptLineEdit.h + * @brief 带提示信息的LineEdit的输入框控件 + * @date 2013-10-12 + */ +#ifndef PAI_FRAME_WIDGET_PAIPROMPTLINEEDIT_H +#define PAI_FRAME_WIDGET_PAIPROMPTLINEEDIT_H + +#include "PaiLineEdit.h" + +namespace pai +{ + namespace gui + { + class PaiLabel; + } +} +#include "Turtle.h" + +namespace pai +{ +namespace gui +{ + +/** + * @class PaiPromptLineEdit + * @brief PaiPromptLineEdit 只是针对项目管理一些带有提示的输入框(横向显示提示信息的风格)。 + */ +class PAI_WIDGET_EXPORT PaiPromptLineEdit : public PaiLineEdit +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiPromptLineEdit(QWidget *pParent = NULL); + /** + * @brief 析构函数 + */ + virtual ~PaiPromptLineEdit(); + + /** + * @brief 设置label的信息 + * @param[in] pLabel 接收到的指针 + */ + void SetPromptLabel(PaiLabel *pLabel); + + /** + * @brief 显示提示信息 + * @param[in] message 输入需显示的信息 + * @param[in] type 输入需显示的错误表示 + */ + virtual void ShowPromptMessge(const QString & message, PromptType type = PT_Information); + +private: + pai::gui::PaiLabel *m_pMessageLabel; ///< 信息标签 +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAIPROMPTLINEEDIT_H diff --git a/Workflow/WFWidget/include/PaiPushButton.h b/Workflow/WFWidget/include/PaiPushButton.h new file mode 100644 index 0000000..ecafdde --- /dev/null +++ b/Workflow/WFWidget/include/PaiPushButton.h @@ -0,0 +1,91 @@ +/* + * PaiPushButton.h + * + * Created on: 2012-1-31 + * Author: dev + */ +#ifndef PAI_FRAME_WIDGET_PAIPUSHBUTTON_H +#define PAI_FRAME_WIDGET_PAIPUSHBUTTON_H + +#include +#include "Turtle.h" + +namespace pai +{ +namespace gui +{ + +/** + * @class PaiPushButton + * @brief PaiPushButton是P.A.I系统定制发布的按钮 + */ +class PAI_WIDGET_EXPORT PaiPushButton : public QPushButton +{ + Q_OBJECT +public: + /** + * @brief 析构函数 + */ + virtual ~PaiPushButton(); + + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiPushButton(QWidget *pParent = NULL); + + /** + * @brief 构造函数 + * @param[in] text 按鈕文本 + * @param[in] pParent 父窗口句柄 + */ + PaiPushButton(const QString & text, QWidget *pParent = NULL); + + /** + * @brief 构造函数 + * @param[in] icon 按鈕图标 + * @param[in] text 按钮文本 + * @param[in] pParent 父窗口句柄 + */ + PaiPushButton(const QIcon & icon, const QString & text, QWidget *pParent = NULL); + + /** + * @brief 设置为可弹出窗口器件的按鈕 + * @param[in] pPopupCenterWidget 弹出窗口器件 + */ + void SetPopupWidget(QWidget *pPopupCenterWidget); + +public slots: + /** + * @brief 关闭已弹出窗口器件 + */ + void ClosePopupWidget(); + +protected: + /** + * @brief 重载鼠标按下事件 + * @param[in] pEvent 按下鼠标事件参数 + */ + virtual void mousePressEvent(QMouseEvent *pEvent); + + /** + * @brief 重载鼠标按起事件 + * @param[in] pEvent 按起鼠标事件参数 + */ + virtual void mouseReleaseEvent(QMouseEvent *pEvent); + + /** + * @brief 重载绘制事件 + * @param[in] pEvent 绘制事件参数 + */ + virtual void paintEvent(QPaintEvent *pEvent); + +private: + QWidget *m_pPopupWidget; ///< 弹出窗口器件对象 + QWidget *m_pPopupFrame; ///< 弹出窗口器件的容器对象 +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAIPUSHBUTTON_H diff --git a/Workflow/WFWidget/include/PaiRadioButton.h b/Workflow/WFWidget/include/PaiRadioButton.h new file mode 100644 index 0000000..a4838a4 --- /dev/null +++ b/Workflow/WFWidget/include/PaiRadioButton.h @@ -0,0 +1,39 @@ +/** + * @file PaiRadioButton.h + * @brief PaiRadioButton是P.A.I系统定制发布的单选按钮 + * @date 2012-01-31 + */ +#ifndef PAI_FRAME_WIDGET_PAIRADIOBUTTON_H +#define PAI_FRAME_WIDGET_PAIRADIOBUTTON_H + +#include +#include "Turtle.h" +namespace pai +{ + namespace gui + { + /** + * @class PaiRadioButton + * @brief PaiRadioButton是P.A.I系统定制发布的单选按钮 + */ + + class PAI_WIDGET_EXPORT PaiRadioButton : public QRadioButton + { + Q_OBJECT + public: + /** + * @brief 构造函数 + * @param[in] parent 父窗口句柄 + */ + PaiRadioButton(QWidget *parent = 0); + /** + * @brief 构造函数 + * @param[in] text 按钮文字初始值 + * @param[in] parent 父窗口句柄 + */ + PaiRadioButton(const QString &text, QWidget *parent = 0); + }; + } +} + +#endif ///< PAI_FRAME_WIDGET_PAIRADIOBUTTON_H diff --git a/Workflow/WFWidget/include/PaiSearchLineEdit.h b/Workflow/WFWidget/include/PaiSearchLineEdit.h new file mode 100644 index 0000000..0e9cda5 --- /dev/null +++ b/Workflow/WFWidget/include/PaiSearchLineEdit.h @@ -0,0 +1,64 @@ +/** + * @file PaiSearchLineEdit.h + * @brief 定义一个具有搜索功能的LineEdit控件 + */ +#ifndef PAI_FRAME_WIDGET_PAISEARCHLINEEDIT_H +#define PAI_FRAME_WIDGET_PAISEARCHLINEEDIT_H + +#include "PaiLineEdit.h" +#include "Turtle.h" + +class QPushButton; + +namespace pai +{ +namespace gui +{ +/** + * @class PaiSearchLineEdit + * @brief 具有搜索功能的LineEdit + */ +class PAI_WIDGET_EXPORT PaiSearchLineEdit : public PaiLineEdit +{ + Q_OBJECT +public: + /** + * @brief 构造函数、 + * @param[in] pParent 父窗口句柄 + */ + PaiSearchLineEdit(QWidget *pParent = NULL); + + /** + * @brief 析构函数 + */ + virtual ~PaiSearchLineEdit(); + + /** + * @brief 更新右侧按钮图标 + * @param[in] icon 按钮图标 + */ + void UpdateRightIcon(const QIcon & icon); + +protected: + /** + * @brief 鼠标滑入事件 + * @param[in] pEvent 鼠标滑入事件 + */ + virtual void enterEvent(QEvent *pEvent); + +private slots: + /** + * @brief 改变右侧按钮图标 + */ + void SetCurrentIcon(); + + /** + * @brief 清空搜索框 + */ + void CleanSearchBox(); +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAISEARCHLINEEDIT_H diff --git a/Workflow/WFWidget/include/PaiSpinBox.h b/Workflow/WFWidget/include/PaiSpinBox.h new file mode 100644 index 0000000..f6142a2 --- /dev/null +++ b/Workflow/WFWidget/include/PaiSpinBox.h @@ -0,0 +1,56 @@ +/** + * @file PaiSpinBox.h + * @brief PaiSpinBox是P.A.I系统定制发布的微调文本框控件 + * @date 2011-10-23 + */ +#ifndef PAI_FRAME_WIDGET_PAISPINBOX_H +#define PAI_FRAME_WIDGET_PAISPINBOX_H + +#include +#include "Turtle.h" +namespace pai +{ +namespace gui +{ + +/** + * @class PaiSpinBox + * @brief PaiTextEdit是P.A.I系统定制发布的微调文本框控件 + */ +class PAI_WIDGET_EXPORT PaiSpinBox : public QSpinBox +{ + Q_OBJECT +public: + /** + * @enum EControlStyle + * @brief 错误风格标记 + */ + enum EControlStyle + { + ErrorFlag = 0x1 ///< 标志该文本框包含了错误信息,边框变为红色 + }; + + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiSpinBox(QWidget *pParent = NULL); + + /** + * @brief 设置或取消风格,目前支持错误风格 + * @param[in] style 要设置的微调文本框风格的枚举值 + * @param[in] has true表示要设置,false指示要取消 + */ + void SetStyle(pai::gui::PaiSpinBox::EControlStyle style, bool has); + +protected: + /** + * @brief 当清空时认为输入最小值 + * @param[in] input 输入字符串 + */ + virtual void fixup(QString & input) const; +}; +} +} + +#endif ///< PAI_FRAME_WIDGET_PAISPINBOX_H diff --git a/Workflow/WFWidget/include/PaiTabWidget.h b/Workflow/WFWidget/include/PaiTabWidget.h new file mode 100644 index 0000000..96b796d --- /dev/null +++ b/Workflow/WFWidget/include/PaiTabWidget.h @@ -0,0 +1,266 @@ +/** + * @file PaiTabWidget.h + * @brief PAI风格TabWidget + * @date 2011-7-19 + */ +#ifndef PAI_FRAME_WIDGET_PAITABWIDGET_H +#define PAI_FRAME_WIDGET_PAITABWIDGET_H + +#include +#include +#include "Turtle.h" +class QByteArray; + +namespace pai +{ +namespace gui +{ + +/** + * @struct DragState + * @brief 该结构代表了页签被拖拽时的上下文参数 + */ +struct DragState +{ + bool isValid; ///< 拖拽参数是否合法 + bool isDragging; ///< 是否正在拖拽中 + QWidget *pDraggingWidget;///< 拖拽的页面 + QIcon tabIcon; ///< 拖拽的页签的图标 + QString tabText; ///< 拖拽的页签的文本 + QPoint pressPosition; ///< 鼠标初始点击位置 + QRect srcRect; ///< 被拖拽页面的矩形 + qint64 appPid; ///< 进程id +}; + +/** + * @brief 序列化拖拽页签时的上下文参数 + * @param[in] dragState 拖拽页签时的上下文参数 + * @param[out] blob 序列化的二进制数组 + */ +extern void Serialize(const DragState& dragState, QByteArray& blob); + +/** + * @brief 从二进制流中反序列化出拖拽参数 + * @param[out] dragState 拖拽参数 + * @param blob 反序列化的二进制数组 + */ +extern void Unserialize(DragState& dragState, QByteArray& blob); + +/** + * @class PaiInfoTabBar + * @brief P.A.I 系统里消息提示区风格的标签栏 + */ +class PaiInfoTabBar : public QTabBar +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + * @param[in] isSubTabBar 是否为子页签组件 + * @param[in] behavior 选择模式 + */ + PaiInfoTabBar(QWidget *pParent = NULL, + bool isSubTabBar = true, + SelectionBehavior behavior = SelectPreviousTab); + + /** + * @brief 设置是否可拖拽 + * @param[in] draggable 是否可拖拽 + */ + void SetDraggable(bool draggable); + +protected: + /** + * @brief 自绘制页签栏来支持错误状态 + * @param[in] pEvent 绘制事件 + * @note 该重绘函数主要解决在未拖动的情况的绘制,其中style sheet中 + * margin: 0px 0px 1px 5px; padding-right:0px; padding-left:5px;必需设置, + * 否则因系统会因为大约5像素的偏差而导致文字的...(elide)被设置错误,在拖动的情况下则完全由QSS来决定。 + */ + virtual void paintEvent(QPaintEvent *pEvent); + + /** + * @brief 重写鼠标按下事件来初始化拖拽参数 + * @param[in] pEvent 鼠标事件 + */ + virtual void mousePressEvent(QMouseEvent *pEvent); + + /** + * @brief 重写鼠标移动事件来实现页签拖拽到其他位置 + * @param[in] pEvent 鼠标事件 + */ + virtual void mouseMoveEvent(QMouseEvent *pEvent); + + /** + * @brief 重写鼠标释放事件来来重置拖拽参数 + * @param[in] pEvent 鼠标事件 + */ + virtual void mouseReleaseEvent(QMouseEvent *pEvent); + + /** + * @brief 重写事件响应函数来处理Tooltip事件 + * @param[in] pEvent 事件 + */ + virtual bool event(QEvent *pEvent); + + /** + * @brief 重写时钟事件来重置光标 + * @param[in] pEvent 定时器事件 + */ + virtual void timerEvent(QTimerEvent *pEvent); + +private: + /** + * @brief 初始化拖拽参数 + */ + void InitDragState(); + + /** + * @brief 是否可拖拽,取决于父页签容器是否属于一个PaiWorkspace + * @return 是否可拖拽 + */ + bool IsDraggable() const; + +private: + DragState m_DragState; ///< 拖拽参数 + bool m_IsSubTabwidget; ///< 是否为子Tabwidget + bool m_draggable; ///< 是否可拖拽 + int m_OutOfConsoleTimer; ///< 定时器 +}; + + +/** + * @class PaiTabWidget + * @brief P.A.I 系统里消息提示区风格的标签控件 + */ +class PAI_WIDGET_EXPORT PaiTabWidget : public QTabWidget +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父控件句柄 + * @param[in] isSubTabBar 是否为子Tabbar + * @param[in] behavior 选择模式 + */ + PaiTabWidget(QWidget *pParent, + bool isSubTabBar = true, + QTabBar::SelectionBehavior behavior = QTabBar::SelectPreviousTab); + + /** + * @brief 是否显示标签 + * @param[in] visible 是否显示 + */ + void SetTabVisible(bool visible); + + /** + * @brief 通过发送信号关闭指定位置的页签,这种方式保证了如果有插件的页签关联了该信号则相关槽函数得以执行。 + * @param[in] index 序列号 + */ + void CloseTab(int index); + + /** + * @brief 通过发送信号关闭所有的页签,这种方式保证了如果有插件的页签关联了该信号则相关槽函数得以执行。 + */ + void CloseAll(); + + /** + * @brief 设置此标签控件是否接收拖拽来的页签 + * @param[in] dropable 是否接收拖拽 + */ + void SetDropable(bool dropable = true); + + /** + * @brief 获得此标签控件是否接收拖拽来的页签 + * @return 是否可以拖拽 + */ + bool IsDropable(); + + /** + * @brief 设置此标签控件中的页签是否可以被拖拽出去 + * @param[in] draggable 是否可以拖拽 + */ + void SetTabBarDraggable(bool draggable); + +public slots: + /** + * @brief 响应Tab页切换的消息 + * @param[in] index 切换后的当前Tab页面的index + */ + void OnCurrentChanged(int index); + +protected: + /** + * @brief 重写该函数来发出一个Tab被添加的消息 + * @param[in] index 索引号 + */ + virtual void tabInserted(int index); + + /** + * @brief 重写该函数来发出最后一个Tab被移除的消息 + * @param[in] index 索引号 + */ + virtual void tabRemoved(int index); + + /** + * @brief 绘制事件 + * @param[in] pEvent 绘制事件 + */ + virtual void paintEvent(QPaintEvent *pEvent); + + /** + * @brief 重写该函数来移除QWebView类型的tab页面对拖拽页签的处理 + * @param[in] pObject 监视对象 + * @param[in] pEvent 监视对象的事件 + * @return 是否被过滤 + */ + virtual bool eventFilter(QObject *pObject, QEvent *pEvent); + +private slots: + /** + * @brief 响应标签关闭的消息 + * @param[in] index 当前要关闭的标签索引 + */ + void OnTabClose(int index); + +private: + bool m_IsDropableTab; ///< 标签控件标志,否接收拖拽来的页签 + QString m_ClosedTabID; ///< 关闭页签ID + +signals: + /** + * @brief 此信号在Tab页的Close按钮被点击时触发 + * @param[in] extensionID 将要被关闭的Tab页面的ID + */ + void TabWillBeClosed(const QString & extensionID); + + /** + * @brief 此信号在所有的tab页都被关闭后触发 + * @param[in] areaName 该TabWidget所占的区域名 + */ + void AllTabClosed(QString areaName); + + /** + * @brief 此信号在Tab页切换时触发 + * @param[in] extensionID 切换后的当前Tab页面的ID + */ + void CurrentTabChanged(const QString & extensionID); + + /** + * @brief 此信号在添加Tab页时触发 + * @param[in] index 新添加的Tab页的索引 + */ + void TabInserted(int index); + + /** + * @brief 此信号tab页被关闭后触发 + * @param[in] extensionID 将要被关闭的Tab页面的ID + */ + void TabRemoved(const QString & extensionID); +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAITABWIDGET_H diff --git a/Workflow/WFWidget/include/PaiTableItemDelegate.h b/Workflow/WFWidget/include/PaiTableItemDelegate.h new file mode 100644 index 0000000..70eb1f0 --- /dev/null +++ b/Workflow/WFWidget/include/PaiTableItemDelegate.h @@ -0,0 +1,67 @@ +/* + * @file PaiTableItemDelegate.h + * @brief 一些PAI系统中常见的节点绘制类 + * @date 2012-10-16 + */ +#ifndef PAI_FRAME_WIDGET_PAITABLEITEMDELEGATE_H +#define PAI_FRAME_WIDGET_PAITABLEITEMDELEGATE_H + +#include +#include +#include +#include "Turtle.h" + +namespace pai +{ + namespace gui + { + /** + * @class PaiTableItemDelegate + * @brief PAI 风格 item delegate 只画水平方向 grid line, 同时负责cell的颜色 + */ + class PAI_WIDGET_EXPORT PaiTableItemDelegate: public QStyledItemDelegate +{ +public: + /** + * @enum DATA_ROLE + * @brief 数据角色 + */ + enum DATA_ROLE + { + HOVERING_ROLE = 1024 ///< 悬浮 + }; + +public: + /** + * @brief 构造函数 + * @param[in] pTableView 所属QTableView + */ + PaiTableItemDelegate(QTableView *pTableView); + + /** + * @brief 是否显示表格线 + * @param[in] horizontal 水平方向线 + * @param[in] verticalLine 垂直方向线 + */ + virtual void setShowGrid(bool horizontal, bool verticalLine); + +protected: + /** + * @brief 重新实现重绘函数 + * @param[in] pPainter 画笔 + * @param[in] option 绘制选项 + * @param[in] index 模型索引 + */ + virtual void paint(QPainter *pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const; + +private: + QPen m_GridPen; ///< 网格画笔 + bool m_HorizontalLine; ///< 水平线 + bool m_VerticallLine; ///< 垂直线 + +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAITABLEITEMDELEGATE_H diff --git a/Workflow/WFWidget/include/PaiTableWidget.h b/Workflow/WFWidget/include/PaiTableWidget.h new file mode 100644 index 0000000..f5c4a6e --- /dev/null +++ b/Workflow/WFWidget/include/PaiTableWidget.h @@ -0,0 +1,208 @@ +/** + * @file PaiTableWidget.h + * @brief PaiTableWidget 是P.A.I系统定制发布的表格控件 + * @date 2012-04-27 + */ +#ifndef PAI_FRAME_WIDGET_PAITABLEWIDGET_H +#define PAI_FRAME_WIDGET_PAITABLEWIDGET_H + +#include +#include +#include "Turtle.h" + +class QCheckBox; + +namespace pai +{ +namespace gui +{ + +/** + * @class PaiTableWidget + * @brief PaiTableWidget 是P.A.I系统定制发布的表格控件 + */ +class PAI_WIDGET_EXPORT PaiTableWidget : public QTableWidget +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiTableWidget(QWidget *pParent = NULL); + + /** + * @brief 析构函数 + */ + virtual ~PaiTableWidget(); + + /** + * @brief 表格高度自增加,不会出现滚动条 + * @param[in] ok 是否自动增加 + * @param[in] maxRowCount 当行数超过该数字时高度不再增加,出现滚动条 + */ + void SetAutoHeight(const bool ok, const int maxRowCount = 10); + + /** + * @brief 删除多行 + * @param[in] rowIndex 从该行开始删除 + * @param[in] count 删除的行数, 如果越界将到最大行时终止 + */ + void RemoveRows(const int rowIndex, const int count); + + /** + * @brief 删除所有行 + */ + void RemoveRows(); + + /** + * @brief 设置是否显示单元格边框 + * @param[in] horizontalLine 水平方向线 + * @param[in] verticalLine 垂直方向线 + */ + virtual void setShowGrid(bool horizontalLine, bool verticalLine); + + /** + * @brief 设置表格的提示信息 + * @param[in] message 提示信息 + */ + void ShowPromptMessage(const QString & message); + + /** + * @brief 设置当表格内容为空时要显示的提示字符串 + * @param[in] message 提示信息 + */ + void SetFilterEmptyMessage(const QString & message); + + /** + * @brief 设置是否可以在表格上可以有选择行的显示某些列的功能 + * @param[in] selectable 是否打开该功能 + */ + void SetColumnVisibleSelectable(bool selectable); + + /** + * @brief 设置不可以被隐藏的列 + * @param[in] columnList 不可以被隐藏的列的名字列表 + */ + void SetUnselectableColumns(const QStringList & columnList); + + /** + *@brief 恢复记录的非隐藏表头 + */ + void RecallMemberedSections(); + + /** + * @brief 设置是否可选中列,如果可选中则会在指定列的左侧添加一个CheckBox.(只可作用于水平表头) + * @param[in] logicalIndex 目标列的逻辑索引 + * @param[in] checkable 是否可选中 + * @param[in] pCheckBox 需要添加的CheckBox,如果checkable为false,则可不传递此参数。 + */ + void SetColumnCheckable(const int logicalIndex, const bool checkable, QCheckBox *pCheckBox = NULL); + +public slots: + /** + * @brief 根据关键字搜索 + * @param[in] keyword 搜索的关键字 + * @param[in] column 要搜索的列 + */ + void Filter(const QString & keyword, int column = 0); + + /** + * @brief 根据关键字搜索 + * @param[in] keyword 搜索的关键字 + * @param[in] columns 要搜索的列 + * @param[in] ignoreLines 忽略搜索的行 + */ + void Filter(const QString & keyword, QList columns, QList ignoreLines = QList()); + + /** + * @brief 重写添加列函数,使及时调整HeaderView的CheckBox + * @param[in] column 要插入的列位置 + */ + void insertColumn(int column); + + /** + * @brief 重写移除列函数,使及时调整HeaderView的CheckBox + * @param[in] column 要删除的位置 + */ + void removeColumn(int column); + +protected: + /** + * @brief 按照上一次的过滤规则,对某一行惊醒过滤 + * @param[in] rowIndex 要过滤的行索引 + * @return 是否通过过滤 + */ + virtual bool Filter(int rowIndex); + + /** + * @brief 实现该函数用来写字符串 + * @param[in] pEvent 绘制事件 + */ + virtual void paintEvent(QPaintEvent *pEvent); + + /** + * @brief 实现鼠标右键菜单 + * @param[in] pEvent 右键菜单事件 + */ + virtual void contextMenuEvent(QContextMenuEvent *pEvent); + + /** + * @brief 实现快捷键功能 + * @param[in] pEvent 键盘按压事件 + */ + virtual void keyPressEvent(QKeyEvent *pEvent); + +private: + /** + * @brief 记录非隐藏表头 + */ + void RememberCurrentSections(); + +private slots: + /** + * @brief 重新设置高度以适应自动变化 + */ + void ResetTableHeight(); + + /** + * @brief 行数发生变化 + */ + void RowCountChanged(); + + /** + * @brief 设置剪切板内容 + */ + void SetClipboard(); + + /** + * @brief 当单元格的数据发送改变室的槽函数 + * @param[in] pItem 对应的单元格 + */ + void TableItemChanged(QTableWidgetItem *pItem); + +protected: + QString m_FilterKeyword; ///< 最近一次过滤的关键字 + +private: + bool m_AutoHeight; ///< 自动调整高度 + bool m_ShowFilterEmptyMessage; ///< 显示搜索空提示 + int m_AutoHeightMaxRowCount; ///< 最大行数 + QString m_MessageWhileFilterEmpty; ///< 空提示文本 + QString m_PromptMessage; ///< 提示文本 + QList m_FilterColumns; ///< 最近一次过滤的的列 + QList m_IgnoreLines; ///< 最近一次忽略搜索的行 + int m_IgnoreHeight; ///< 忽略行的高度,用于显示提示信息 + +signals: + /** + * @brief 行数发生变化 + * @param[in] count 变化后的行数 + */ + void RowCountChanged(const int count); +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAITABLEWIDGET_H diff --git a/Workflow/WFWidget/include/PaiTextEdit.h b/Workflow/WFWidget/include/PaiTextEdit.h new file mode 100644 index 0000000..617010f --- /dev/null +++ b/Workflow/WFWidget/include/PaiTextEdit.h @@ -0,0 +1,56 @@ +/** + * @file PaiTextEdit.h + * @brief PaiTextEdit是P.A.I系统定制发布的多行文本框控件 + * @date 2011-10-22 + */ +#ifndef PAI_FRAME_WIDGET_PAITEXTEDIT_H +#define PAI_FRAME_WIDGET_PAITEXTEDIT_H + +#include +#include "Turtle.h" +namespace pai +{ +namespace gui +{ + +/** + * @class PaiTextEdit + * @brief PaiTextEdit是P.A.I系统定制发布的多行文本框控件 + */ +class PAI_WIDGET_EXPORT PaiTextEdit : public QTextEdit +{ +public: + /** + * @enum EControlStyle + * @brief 控制风格 + */ + enum EControlStyle + { + ErrorFlag = 0x1 ///< 标志该文本框包含了错误信息,边框变为红色 + }; + + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiTextEdit(QWidget *pParent = NULL); + + /** + * @brief 构造函数 + * @param[in] text 多行文本框里的文本初始值 + * @param[in] pParent 父窗口句柄 + */ + PaiTextEdit(const QString & text, QWidget *pParent = NULL); + + /** + * @brief 设置或取消风格,目前支持错误风格 + * @param[in] style 要设置的多行文本框风格的枚举值 + * @param[in] has true表示要设置,false指示要取消 + */ + void SetStyle(pai::gui::PaiTextEdit::EControlStyle style, bool has); +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAITEXTEDIT_H diff --git a/Workflow/WFWidget/include/PaiTitleBar.h b/Workflow/WFWidget/include/PaiTitleBar.h new file mode 100644 index 0000000..c14153f --- /dev/null +++ b/Workflow/WFWidget/include/PaiTitleBar.h @@ -0,0 +1,201 @@ +/* + * @file PaiTitleBar.h + * @brief 自定义的标题栏 + * @date 2012-11-29 + */ +#ifndef PAI_FRAME_WIDGET_PAITITLEBAR_H +#define PAI_FRAME_WIDGET_PAITITLEBAR_H + +#include +#include +#include "Turtle.h" + +namespace pai +{ + namespace gui + { + class PaiToolButton; + } +} + +class QMenu; +class QHBoxLayout; + +namespace pai +{ +namespace gui +{ +/** + * @class PaiStatusBar + * @brief PAI 系统默认风格状态栏 + */ +class PAI_WIDGET_EXPORT PaiStatusBar: public QStatusBar +{ +public: + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiStatusBar(QWidget *pParent = NULL); + + /** + * @brief 析构函数 + */ + virtual ~PaiStatusBar(); +}; + +/** + * @class PaiTitleBar + * @brief PAI 系统标准标题栏 + */ +class PAI_WIDGET_EXPORT PaiTitleBar: public QWidget +{ + Q_OBJECT + Q_FLAGS(TitleBarFlags) +public: + /** + * @enum TitleBarFlag + * @brief Title Bar 所可选的部分功能 + */ + enum TitleBarFlag + { + CloseButtonHint = 0x01, ///< 关闭按钮可视化标志 + MaximumButtonHint = 0x02, ///< 最大化按钮可视化标志 + MinimumButtonHint = 0x04, ///< 最小化按钮可视化标志 + LogoButtonHint = 0x08 ///< logo按钮可视化标志 + }; + Q_DECLARE_FLAGS(TitleBarFlags, TitleBarFlag) + + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiTitleBar(QWidget *pParent = NULL); + + /** + * @brief 析构函数 + */ + virtual ~PaiTitleBar(); + + /** + * @brief 修改titleBar的title + * @param[in] title 新的title + */ + void SetTitle(const QString & title); + + /** + * @brief 设置titleBar的flag,可以设置所有button的隐藏 + * @param[in] flags titleBar的flags + */ + void SetTitleBarFlags(TitleBarFlags flags); + + /** + * @brief 返回TitleBarFlags + * @return 标题栏标记 + */ + PaiTitleBar::TitleBarFlags GetTitleBarFlags() const; + + /** + * @brief 创建system menu + * @param[in] pMenu 菜单 + */ + void CreateSystemMenu(QMenu *pMenu); + + /** + * @brief 在Logo和系统菜单中间的区域插入Widget + * @param[in] pWidget 要插入的Widgt + * @param[in] alignment 在哪一侧,接受Qt::AlignLeft和Qt::AlignRight + */ + void InsertWidget(QWidget *pWidget, Qt::Alignment alignment); + + /** + * @brief 修改restore图标状态 + * @param[in] maximized 设这成恢复最大的图标 + */ + void ChangeRestoreButtonState(bool maximized); + +protected: + /** + * @brief 重写paint事件 + * @param[in] pEvent 事件对象 + */ + virtual void paintEvent(QPaintEvent *pEvent); + + /** + * @brief 重写鼠标点击事件 + * @param[in] pEvent 事件对象 + */ + virtual void mousePressEvent(QMouseEvent *pEvent); + + /** + * @brief 重写鼠标抬起事件 + * @param[in] pEvent 事件对象 + */ + virtual void mouseReleaseEvent(QMouseEvent *pEvent); + + /** + * @brief 重写鼠标移动事件 + * @param[in] pEvent 事件对象 + */ + virtual void mouseMoveEvent(QMouseEvent *pEvent); + + /** + * @brief 重写鼠标双击事件 + * @param[in] pEvent 事件对象 + */ + virtual void mouseDoubleClickEvent(QMouseEvent *pEvent); + + /** + * @brief 重写resize事件 + * @param[in] pEvent 事件对象 + */ + virtual void resizeEvent(QResizeEvent *pEvent); + +protected slots: + /** + * @brief 修改restore图标状态 + */ + void ChangeRestoreButtonState(); + +private: + /** + * @brief 根据titlebar的宽幅和m_iTitleNameCenterStand进行比较,返回titlebar标题文字显示区域 + * @param[in] pixelTitle 标题 + * @return 返回titlebar标题文字显示区域 + */ + QRect GetTitleNameRect(int pixelTitle); + +private: + QPoint m_MovePosition; ///< 鼠标点击的坐标,用于拖动titleBar所在的mainFrame + QString m_title; ///< 显示的title + PaiToolButton *m_pExitButton; ///< 退出按钮 + PaiToolButton *m_pMaximumButton; ///< 最大按钮 + PaiToolButton *m_pMinimumButton; ///< 最小按钮 + PaiToolButton *m_pLogoButton; ///< Logo按钮 + QHBoxLayout *m_pRightHLayout; ///< 为了方便向右侧插入窗体 + QHBoxLayout *m_pLeftHLayout; ///< 为了方便向左侧插入窗体 + TitleBarFlags m_titleBarFlags; //< 标题按钮是否显示的flag + +signals: + /** + * @brief Exit按钮被点击的时候发出此信号 + */ + void HandleExitButton(); + + /** + * @brief Minimum按钮被点击的时候发出此信号 + */ + void HandleMinimumButton(); + + /** + * @brief Maximum按钮被点击的时候发出此信号 + */ + void HandleMaximumButton(); +}; + +} +} + +Q_DECLARE_OPERATORS_FOR_FLAGS(pai::gui::PaiTitleBar::TitleBarFlags) ///< 此句必须放在命名控件之外 + +#endif ///< PAI_FRAME_WIDGET_PAITITLEBAR_H diff --git a/Workflow/WFWidget/include/PaiToolBar.h b/Workflow/WFWidget/include/PaiToolBar.h new file mode 100644 index 0000000..6873c5e --- /dev/null +++ b/Workflow/WFWidget/include/PaiToolBar.h @@ -0,0 +1,127 @@ +/** + * @file PaiToolBar.h + * @brief 工具栏 + * @date 2011-9-16 + */ +#ifndef PAI_FRAME_WIDGET_PAITOOLBAR_H +#define PAI_FRAME_WIDGET_PAITOOLBAR_H + +#include +#include +#include "Turtle.h" + +/** + * @brief BEGIN_PAITOOLBAR_WIDGET这个宏为自定义控件创建QWidgetAction, 必须结合END_PAITOOLBAR_WIDGET使用,两个宏中间是创建自定义控件的代码 + * @param[out] pWidget 返回的QAction指针,也是自定义控件的指针,两个同名,但作用域不同 + * @param[in] pObject1 自定义Action的指针,用于创建信号连接,如果不需要就使用NULL,信号连接代码也写在两个宏中间,对应使用R1,R2变量 + * @param[in] pObject2 自定义Action的指针 + */ +#define BEGIN_PAITOOLBAR_WIDGET(pWidget, pObject1, pObject2) \ + QAction *pWidget = NULL; \ + { \ + QObject *pTmpReceiver1 = pObject1; \ + QObject *pTmpReceiver2 = pObject2; \ + class Local_Widget_Action : public QWidgetAction \ + { \ + public: \ + Local_Widget_Action(QObject *pReceiver1, QObject *pReciever2, QObject *pParent = NULL) : \ + QWidgetAction(pParent), \ + pR1(pReceiver1), \ + pR2(pReciever2){} \ + virtual QWidget* createWidget(QWidget *pParent) { +/** + * @brief 结束创建QWidgetAction + * @param[out] pWidget 返回的QAction指针 + */ + +#define END_PAITOOLBAR_WIDGET(pWidget) \ + pWidget->setParent(pParent); \ + return pWidget;} \ + QObject *pR1, pR2; \ + }* pAction = new Local_Widget_Action (pTmpReceiver1, pTmpReceiver2); \ + pWidget = pAction; \ + } + +namespace pai +{ +namespace gui +{ + +/** + * @class PaiToolBar + * @brief P.A.I 风格的工具栏 + */ +class PAI_WIDGET_EXPORT PaiToolBar : public QToolBar +{ +public: + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiToolBar(QWidget *pParent = NULL); + + /** + * @brief 构造函数 + * @param[in] title 标题 + * @param[in] pParent 父窗口句柄 + */ + PaiToolBar(const QString & title, QWidget *pParent = NULL); + + /** + * @brief 析构函数 + */ + virtual ~PaiToolBar(); + + /** + * @brief 选择需要显示的边框,默认全都显示 + * @param[in] top 上 + * @param[in] bottom 下 + * @param[in] left 左 + * @param[in] right 右 + */ + void ShowBorder(bool top, bool bottom, bool left, bool right); + + /** + * @brief 添加一个弹簧控件使以后再添加的QAction靠右 + * @return 弹簧控件对应的QAction,可以用它做Unregister + */ + QAction* AddSpacer(); + + /** + * @brief 设置左边缘距离 + * @param[in] margin 左边缘距离 + */ + void SetLeftMargin(int margin); + + /** + * @brief 在标准间距(space)的基础上,再添加固定的间距 + * @param[in] space 间距大小,默认4像素 + * @return 对应Action + */ + QAction* AddConstSpace(int space = 4); + +protected: + /** + * @brief 重绘ToolBar + * @param[in] pEvent 事件对象 + */ + virtual void paintEvent(QPaintEvent *pEvent); + +private: + /** + * @brief 初始化ToolBar + */ + void InitToolBar(); + +private: + bool m_ShowTopEdge; ///< 显示上方边界 + bool m_ShowBottomEdge; ///< 显示下方边界 + bool m_ShowLeftEdge; ///< 显示左方边界 + bool m_ShowRightEdge; ///< 显示右方边界 + QWidget *m_pLeftMarginWgt; ///< 用来支撑left margin +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAITOOLBAR_H diff --git a/Workflow/WFWidget/include/PaiToolBarView.h b/Workflow/WFWidget/include/PaiToolBarView.h new file mode 100644 index 0000000..953566c --- /dev/null +++ b/Workflow/WFWidget/include/PaiToolBarView.h @@ -0,0 +1,110 @@ +/** + * @file PaiToolBarView.h + * @brief P.A.I 风格工具栏,默认包含一个工具栏,并且不能被删除 + * @date 2011-09-16 + */ +#ifndef PAI_FRAME_WIDGET_PAITOOLBARVIEW_H +#define PAI_FRAME_WIDGET_PAITOOLBARVIEW_H + +#include +#include "Turtle.h" + +class QVBoxLayout; +class QToolBar; + +namespace pai +{ + +/** + * @class PaiToolBarView + * @brief P.A.I 风格工具栏,默认包含一个工具栏,并且不能被删除 + */ +class PAI_WIDGET_EXPORT PaiToolBarView : public QWidget +{ +public: + /** + * @enum EToolBarType + * @brief 风格 + */ + enum EToolBarType + { + NORMAL_TOOLBAR = 40, ///< 普通风格 + SMALL_TOOLBAR = 28 ///< 小模式ToolBar + }; + + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + * @param[in] type 风格类型 + */ + PaiToolBarView(QWidget *pParent = NULL, EToolBarType type = NORMAL_TOOLBAR); + + /** + * @brief 析构函数 + */ + virtual ~PaiToolBarView(); + + /** + * @brief 获得视口 + * @return 视口 + */ + QWidget* GetViewport(); + + /** + * @brief 重新设置一个视口,原视口会被清楚,新视口的的parent将会视为这个类的对象 + * @param[in] pWidget 视口组件 + */ + void SetViewport(QWidget *pWidget); + + /** + * @brief 添加一个新的工具栏 + * @param[in] pToolBar 工具栏组件 + * @param[in] type 风格类型 + */ + void AddToolBar(QToolBar *pToolBar, EToolBarType type = NORMAL_TOOLBAR); + + /** + * @brief 去掉指定的工具栏 + * @param[in] pToolBar 工具栏组件 + */ + void RemoveToolBar(QToolBar *pToolBar); + + /** + * @brief 获得当前存在的工具栏指针序列 + * @return 当前存在的工具栏指针序列 + */ + QList GetToolBars(); + + /** + * @brief 向指定工具栏添加QAction,如果工具栏未指定,将会被添加到第一个工具栏 + * @param[in] pAction action对象 + * @param[in] pToolBar 工具栏组件 + */ + void AddAction(QAction *pAction, QToolBar *pToolBar = NULL); + + /** + * @brief 向指定工具栏添加QWidget,如果工具栏未指定,将会被添加到第一个工具栏 + * @param[in] pWidget widget对象 + * @param[in] pToolBar 工具栏组件 + */ + void AddWidget(QWidget *pWidget, QToolBar *pToolBar = NULL); + + /** + * @brief 添加一个ToolButton(这里toolbar有2个固定的值所以可以将toolbutton设置为固定的大小) + * @param[in] pToolButton toolbutton对象 + * @param[in] pToolBar 工具栏组件 + */ + void AddToolButton(QWidget *pToolButton, QToolBar *pToolBar = NULL); + +private: + QWidget *m_pToolBarArea; ///< 工具栏区域 + QWidget *m_pViewport; ///< 视图 + QList m_ToolBars; ///< 工具栏 + QVBoxLayout *m_pMainVLayout; ///< 主布局 + QVBoxLayout *m_pToolBarLayout; ///< 工具栏布局 +}; + +} + +#endif ///< PAI_FRAME_WIDGET_PAITOOLBARVIEW_H + diff --git a/Workflow/WFWidget/include/PaiToolButton.h b/Workflow/WFWidget/include/PaiToolButton.h new file mode 100644 index 0000000..1f30544 --- /dev/null +++ b/Workflow/WFWidget/include/PaiToolButton.h @@ -0,0 +1,76 @@ +/** + * @file PaiToolButton.h + * @brief PaiToolButton是P.A.I系统定制发布的工具按钮 + * @date 2012-1-31 + */ +#ifndef PAI_FRAME_WIDGET_PAITOOLBUTTON_H +#define PAI_FRAME_WIDGET_PAITOOLBUTTON_H + +#include +#include "Turtle.h" + +namespace pai +{ +namespace gui +{ + +/** + * @class PaiToolButton + * @brief PaiToolButton是P.A.I系统定制发布的工具按钮 + */ +class PAI_WIDGET_EXPORT PaiToolButton : public QToolButton +{ + Q_OBJECT +public: + /** + * @brief 析构函数 + */ + virtual ~PaiToolButton(); + + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiToolButton(QWidget *pParent = NULL); + + /** + * @brief 构造函数 + * @param[in] icon 按鈕图标 + * @param[in] pParent 父窗口句柄 + */ + PaiToolButton(const QIcon & icon, QWidget *pParent = NULL); + + /** + * @brief 设置为可弹出窗口器件的按鈕 + * @param[in] pPopupCenterWidget 弹出窗口器件 + */ + void SetPopupWidget(QWidget *pPopupCenterWidget); + +protected: + /** + * @brief 重载鼠标按下事件 + * @param[in] pEvent 按下鼠标事件参数 + */ + virtual void mousePressEvent(QMouseEvent *pEvent); + + /** + * @brief 重载绘制事件 + * @param[in] pEvent 绘制事件参数 + */ + virtual void paintEvent(QPaintEvent *pEvent); + + /** + * @brief 鼠标进入事件 + * @param[in] pEvent 进入事件参数 + */ + virtual void enterEvent(QEvent *pEvent); + +private: + QWidget *m_pPopupWidget; ///< 弹出窗口器件对象 + QWidget *m_pPopupFrame; ///< 弹出窗口器件的容器对象 +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAITOOLBUTTON_H diff --git a/Workflow/WFWidget/include/PaiTreeItemDelegate.h b/Workflow/WFWidget/include/PaiTreeItemDelegate.h new file mode 100644 index 0000000..22064d9 --- /dev/null +++ b/Workflow/WFWidget/include/PaiTreeItemDelegate.h @@ -0,0 +1,154 @@ +/** + * @file PaiTreeItemDelegate.h + * @brief PAI系统中常见的数据树节点ItemDelegate类 + * @date 2011-09-29 + */ +#ifndef PAI_FRAME_WIDGET_PAITREEITEMDELEGATE_H +#define PAI_FRAME_WIDGET_PAITREEITEMDELEGATE_H + +#include +#include +#include "Turtle.h" + +namespace pai +{ +namespace gui +{ +/** +* @class PaiTreeItemDelegate +* @brief 参数编辑面板所用的ItemDelegate +*/ +class PAI_WIDGET_EXPORT PaiTreeItemDelegate:public QStyledItemDelegate +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父类对象指针 + */ + PaiTreeItemDelegate(QObject * parent = 0); +protected: + /** + * @brief 获取合适的节点宽高 + * @param[in] option 绘制参数 + * @param[in] index 树节点索引 + * @return 返回合适的节点宽高 + */ + virtual QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const; + + /** + * @brief 重新绘制树节点 + * @param[in] pPainter 绘制设备上下文 + * @param[in] option 绘制参数 + * @param[in] index 树节点索引 + */ + virtual void paint(QPainter *pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const; +}; + +/** + * @class PaiCagegoryTreeItemDelegate + * @brief 模块管理树所用的ItemDelegate + */ +class PAI_WIDGET_EXPORT PaiCagegoryTreeItemDelegate : public QStyledItemDelegate +{ +public: + /** + * @brief 构造函数 + * @param[in] pParent 父类对象指针 + */ + PaiCagegoryTreeItemDelegate(QObject *pParent = NULL); + + /** + * @brief 设置行高 + * @param[in] height 行高值 + */ + void SetRowHeight(int height); + +protected: + /** + * @brief 重新绘制树节点 + * @param[in] pPainter 绘制设备上下文 + * @param[in] option 绘制参数 + * @param[in] index 树节点索引 + */ + virtual void paint(QPainter *pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const; + + /** + * @brief 获取合适的节点宽高 + * @param[in] option 绘制参数 + * @param[in] index 树节点索引 + * @return 返回合适的节点宽高 + */ + virtual QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const; + +private: + int m_RowHeight; ///< 行高 +}; + +/** + * @class PaiNameLimitedTreeItemDelegate + * @brief 限定重命名文本内容的TreeItemDelegate + */ +class PAI_WIDGET_EXPORT PaiNameLimitedTreeItemDelegate : public PaiTreeItemDelegate +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiNameLimitedTreeItemDelegate(QWidget *pParent = NULL); + + /** + * @brief 构造函数 + * @param[in] regExp 对输入作限定的正则表达式 + * @param[in] pParent 父窗口句柄 + */ + PaiNameLimitedTreeItemDelegate(const QRegExp & regExp, QWidget *pParent = NULL); + + /** + * @brief 重写函数,返回带输入限定的LineEdit + * @param[in] pParent 父窗口句柄 + * @param[in] option 绘制参数 + * @param[in] index 树节点索引 + */ + virtual QWidget *createEditor(QWidget *pParent, const QStyleOptionViewItem & option, const QModelIndex & index) const; + + /** + * @brief 重写函数,设置输入组件的值 + * @param[in] pEditor 编辑控件对象 + * @param[in] index 树节点索引 + */ + virtual void setEditorData(QWidget *pEditor, const QModelIndex & index) const; + + /** + * @brief 重写函数,将LineEdit数值更新到model,不合发则还原至原始值。 + * @param[in] pEditor 编辑控件对象 + * @param[in] pModel 项目模型 + * @param[in] index 树节点索引 + */ + virtual void setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex & index) const; + + /** + * @brief 重写函数,更新LineEdit大小。 + * @param[in] pEditor 编辑控件对象 + * @param[in] option 绘制参数 + * @param[in] index 树节点索引 + */ + virtual void updateEditorGeometry(QWidget *pEditor, const QStyleOptionViewItem & option, const QModelIndex & index) const; + +private: + QRegExp m_RegExp; ///< 名称限定的正则表达式 + +signals: + /** + * @brief 当编辑新的名称写入model时,释放此信号 + * @param[in] index 树节点索引 + */ + void ModelDataChanged(const QModelIndex & index) const; +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAITREEITEMDELEGATE_H diff --git a/Workflow/WFWidget/include/PaiTreeWidget.h b/Workflow/WFWidget/include/PaiTreeWidget.h new file mode 100644 index 0000000..40d903d --- /dev/null +++ b/Workflow/WFWidget/include/PaiTreeWidget.h @@ -0,0 +1,106 @@ +/** + * @file PaiTreeWidget.h + * @brief P.A.I系统定制发布的树控件 + * @date 2012-10-18 + */ +#ifndef PAI_FRAME_WIDGET_PAITREEWIDGET_H +#define PAI_FRAME_WIDGET_PAITREEWIDGET_H + +#include +#include "Turtle.h" + +class QLabel; + +namespace pai +{ +namespace gui +{ +/** + * @class PaiTreeWidget + * @brief PaiTreeWidget是P.A.I系统定制发布的树控件 + */ +class PAI_WIDGET_EXPORT PaiTreeWidget : public QTreeWidget +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiTreeWidget(QWidget *pParent = NULL); + + /** + * @brief 析构函数 + */ + virtual ~PaiTreeWidget(); + +public slots: + /** + * @brief 按节点名搜索树,只显示搜索到的节点 + * @param[in] keyword 搜索的关键字 + * @param[in] column 要搜索的列 + */ + void Filter(const QString & keyword, int column = 0); + + /** + * @brief 按节点名搜索树,只显示搜索到的节点 + * @param[in] keyword 搜索的关键字 + * @param[in] columns 要搜索的列 + */ + void Filter(const QString & keyword, QList columns); + +private: + /** + * @brief 指定节点是否属于查找结果的子代,本函数仅供Filter函数调用。 + * @param[in] pItem 指定节点 + * @return 返回数否属于查找结果的直系子代 + */ + bool IsGenerationOfFoundItem(QTreeWidgetItem *pItem); + +private: + bool m_InSearching; ///< 表示是否正在进行搜索 + QLabel *m_pTipLabel; ///< 搜索结果为空的提示文本信息框 + +signals: + /** + * @brief 搜索完成后触发此消息 + * @param[in] pRootItem 根节点 + */ + void SearchFinished(QTreeWidgetItem *pRootItem); +}; + +/** + * @class PaiTreeWidgetItem + * @brief 数据树item类,支持排序 + */ +class PAI_WIDGET_EXPORT PaiTreeWidgetItem : public QTreeWidgetItem +{ +public: + /** + * @brief 构造函数 + */ + PaiTreeWidgetItem(); + + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiTreeWidgetItem(QTreeWidgetItem *pParent); + + /** + * @brief 析构函数 + */ + virtual ~PaiTreeWidgetItem(); + + /** + * @brief 重写QTreeWidgetItem的比较函数 + * @param[in] otherItem 其他比较对象 + * @return 返回与其他item对象的比较结果 + */ + virtual bool operator < (const QTreeWidgetItem & otherItem) const; +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAITREEWIDGET_H diff --git a/Workflow/WFWidget/include/PaiWidget.h b/Workflow/WFWidget/include/PaiWidget.h new file mode 100644 index 0000000..c6a6572 --- /dev/null +++ b/Workflow/WFWidget/include/PaiWidget.h @@ -0,0 +1,68 @@ +/** + * @file PaiWidget.h + * @brief 带有边框的widget + * @date 2013-1-29 + */ +#ifndef PAI_FRAME_WIDGET_PAIWIDGET_H +#define PAI_FRAME_WIDGET_PAIWIDGET_H + +#include +#include "Turtle.h" + +namespace pai +{ +namespace gui +{ +/** +* @class PaiWidget +* @brief 带有边框的widget +*/ +class PAI_WIDGET_EXPORT PaiWidget : public QWidget +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + * @param[in] flags Qt::WindowFlags + */ + PaiWidget(QWidget *pParent = NULL, Qt::WindowFlags flags = 0); + + /** + * @brief 析构函数 + */ + virtual ~PaiWidget(); + + /** + * @brief 选择需要显示的边框,默认全都显示 + * @param[in] top 顶部边框是否显示 + * @param[in] bottom 底部边框是否显示 + * @param[in] left 左部边框是否显示 + * @param[in] right 右部边框是否显示 + */ + void ShowBorder(bool top, bool bottom, bool left, bool right); + + /** + * @brief 设置背景颜色 + * @param[in] color 背景颜色 + */ + void SetBackgroundColor(const QColor & color); + +protected: + /** + * @brief 用来绘制边框 + * @param[in] pEvent 事件对象 + */ + virtual void paintEvent(QPaintEvent *pEvent); + +private: + bool m_ShowTopBorder; ///< 是否显示顶部边框 + bool m_ShowBottomBorder; ///< 是否显示底部边框 + bool m_ShowLeftBorder; ///< 是否显示左部边框 + bool m_ShowRightBorder; ///< 是否显示右部边框 + QColor m_BackgroundColor; ///< 背景颜色 +}; + +} +} +#endif ///< PAI_FRAME_WIDGET_PAIWIDGET_H diff --git a/Workflow/WFWidget/include/PaiWidgetAction.h b/Workflow/WFWidget/include/PaiWidgetAction.h new file mode 100644 index 0000000..e8c669e --- /dev/null +++ b/Workflow/WFWidget/include/PaiWidgetAction.h @@ -0,0 +1,86 @@ +/** + * @file PaiWidgetAction.h + * @brief PAI自定义的WidgetAction + * @date 2012-11-30 + */ +#ifndef PAI_FRAME_WIDGET_PAIWIDGETACTION_H +#define PAI_FRAME_WIDGET_PAIWIDGETACTION_H + +#include +#include "Turtle.h" + +namespace pai +{ +namespace gui +{ +/** + * @class PaiHorizonGroupWidget + * @brief PAI自定义的水平组合类 + */ +class PAI_WIDGET_EXPORT PaiHorizonGroupWidget : public QWidget +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pFirstWidget 第一个Widget + * @param[in] pSecondWidget 第二个Widget + * @param[in] spacing 间隔 + * @param[in] pParent 父窗口句柄 + */ + PaiHorizonGroupWidget(QWidget *pFirstWidget, QWidget *pSecondWidget, int spacing = 0, QWidget *pParent = NULL); + + /** + * @brief 析构函数 + */ + virtual ~PaiHorizonGroupWidget(); +}; + +/** + * @class PaiWidgetAction + * @brief PAI自定义的WidgetAction基类 + */ +class PAI_WIDGET_EXPORT PaiWidgetAction : public QWidgetAction +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父窗口句柄 + */ + PaiWidgetAction(QObject *pParent = NULL); + + /** + * @brief 创建控件,需要子类实现 + * @param[in] pParent 父窗口句柄 + * @return 返回创建控件指针 + */ + virtual QWidget* NewWidget(QWidget *pParent) = 0; + + /** + * @brief 关联信号,由子类决定是否需要实现 + * @param[in] pWidget 一般是NewWidget返回的控件指针 + */ + virtual void ConnectSignals(QWidget *pWidget); + + /** + * @brief 获得默认控件指针,即第一个创建出来的工具栏上的,而不是扩展菜单中的。 + * @return 返回默认控件指针 + */ + QWidget* GetDefaultWidget() const; + +protected: + /** + * @brief 重写createWidget + * @param[in] pParent 父窗口句柄 + */ + virtual QWidget* createWidget(QWidget *pParent); + +private: + QWidget *m_pDefaultWidget; ///< 默认控件指针,即第一个创建出来的工具栏上的,而不是扩展菜单中的。 +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAIWIDGETACTION_H diff --git a/Workflow/WFWidget/include/PaiWindow.h b/Workflow/WFWidget/include/PaiWindow.h new file mode 100644 index 0000000..d0b8388 --- /dev/null +++ b/Workflow/WFWidget/include/PaiWindow.h @@ -0,0 +1,231 @@ +/** + * @file PaiWindow.h + * @brief PAI系统风格默认窗体 + * @date 2012-12-13 + */ +#ifndef PAI_FRAME_WIDGET_PAIWINDOW_H +#define PAI_FRAME_WIDGET_PAIWINDOW_H + +#include +#include +#include +#include + +#include "PaiTitleBar.h" +#include "Turtle.h" + +namespace pai +{ +namespace gui +{ +/** + * @class PaiWindow + * @brief PAI 系统风格默认窗体 + */ +class PAI_WIDGET_EXPORT PaiWindow: public QFrame +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] parent 父窗口句柄 + */ + PaiWindow(QWidget *parent = NULL); + + /** + * @brief 析构函数 + */ + virtual ~PaiWindow(); + + /** + * @brief 获得控件容器,UI或控件可以放到里面 + * @return 控件容器 + */ + QWidget* GetContainer(); + + /** + * @brief 设置TitleBar的显示属性 + * @param[in] flags titleBar的flags + */ + void SetTitleBarFlags(PaiTitleBar::TitleBarFlags flags); + + /** + * @brief 设置状态栏是否显示 + * @param[in] visible 显示与否 + */ + void SetStatusBarVisible(bool visible); + + /** + * @brief 设置标题栏是否显示 + * @param[in] visible 显示与否 + */ + void SetTitleBarVisible(bool visible); + + /** + * @brief 设置Layout到当前对话框 + * @note 覆盖基类函数,会设为Container的Layout + * @param[in] pLayout layout manager + */ + void setLayout(QLayout *pLayout); + + /** + * @brief 获得当前对话框的layout + * @note 覆盖基类函数,实际返回的时Container的layout + * @return 对话框的layout + */ + QLayout* layout() const; + + /** + * @brief 返回statusBar的指针 + * @return 返回statusBar的指针 + */ + QStatusBar* statusBar(); + + /** + * @brief 返回systemMenu的指针 + * @return 返回systemMenu的指针 + */ + QMenu* systemMenu(); + + /** + * @brief 返回settingMenu的指针 + * @return 返回settingMenu的指针 + */ + QMenu* settingMenu(); + + /** + * @brief 更新title bar的menu + */ + void updateMenu(); + + /** + * @brief 在TitleBar上Logo和系统菜单中间的区域插入Widget + * @param[in] pWidget 要插入的Widgt + * @param[in] alignment 在哪一侧,接受Qt::AlignLeft和Qt::AlignRight + */ + void InsertTitleBarWidget(QWidget *pWidget, Qt::Alignment alignment); + + /** + * @brief 设置window的Geometry + * @note 覆盖基类函数,用来判断window是否是最大化 + * @param[in] x 左部坐标 + * @param[in] y 顶部坐标 + * @param[in] w 宽度 + * @param[in] h 高度 + */ + void setGeometry(int x, int y, int w, int h); + + /** + * @brief 设置window的Geometry + * @note 覆盖基类函数,用来判断window是否是最大化 + * @param[in] rect 矩形坐标 + */ + void setGeometry(const QRect &rect); + + /** + * @brief 设置window的WindowStates + * @note 覆盖基类函数,用来设置标题栏最大化按钮 + * @param[in] state Qt::WindowStates + */ + void setWindowState(Qt::WindowStates state); + + /** + * @brief 设置鼠标改变窗体大小显示方式 + * @param[in] mode 0:松开鼠标后窗体变动;1:鼠标左键按下拖动时,窗体大小实时变动 + */ + static void SetWindowChangeSizeMode(int mode); + +public slots: + /** + * @brief 设置window的title + * @note 覆盖基类函数,会将其设置到titlebar + * @param[in] windowTitle dialog的title + */ + void setWindowTitle(const QString & windowTitle); + +protected: + /** + * @brief 重写鼠标点击事件 + * @param[in] pEvent 事件对象 + */ + virtual void mousePressEvent(QMouseEvent *pEvent); + + /** + * @brief 重写鼠标抬起事件 + * @param[in] pEvent 事件对象 + */ + virtual void mouseReleaseEvent(QMouseEvent *pEvent); + + /** + * @brief 重写鼠标移动事件 + * @param[in] pEvent 事件对象 + */ + virtual void mouseMoveEvent(QMouseEvent *pEvent); + + /** + * @brief 一旦鼠标样式更改,每隔100毫秒判断一次鼠标位置,以便更改鼠标样式 + * @param[in] pEvent 事件对象 + */ + virtual void timerEvent(QTimerEvent *pEvent); + + /** + * @brief 重载此函数来调用页签控件的关闭流程 + * @param[in] pEvent 事件对象 + */ + virtual void closeEvent(QCloseEvent *pEvent); + + /** + * @brief 用来绘制边框 + * @param[in] pEvent 事件对象 + */ + virtual void paintEvent(QPaintEvent *pEvent); + +private: + /** + * @enum ResizeDirction + * @brief Resize事件中拖动的方向 + */ + enum ResizeDirction + { + ResizeDirction_None = 0, ///< 未知方向的拖动 + ResizeDirction_Top = 1, ///< 向上拖动 + ResizeDirction_Bottom = 2, ///< 向下拖动 + ResizeDirction_Left = 3, ///< 向左拖动 + ResizeDirction_Right = 4, ///< 向右拖动 + ResizeDirction_TopLeft = 5, ///< 向左上拖动 + ResizeDirction_TopRight = 6, ///< 向右上拖动 + ResizeDirction_BottomLeft = 7, ///< 向左下拖动 + ResizeDirction_BottomRight = 8 ///< 向右下拖动 + }; + + /** + * @brief 触发Resize事件之前用来更新鼠标样式 + * @param[in] mousePosion 当前鼠标所在的坐标 + */ + void setCursorShape(const QPoint & mousePosion); + + /** + * @brief Resize事件的实现 + * @param[in] mousePosion 当前鼠标所移动的位置 + */ + void resizeFrame(const QPoint & mousePosion); + +private: + ResizeDirction m_ResizeDirction; ///< 拖动的方向变量 + bool m_IsPress; ///< 鼠标是否按下 + bool m_IsMoved; ///< 鼠标是否拖动 + QRubberBand *m_pRubberBand; ///< 窗口大小改变时显示的边框 + pai::gui::PaiTitleBar *m_pTitleBar; ///< 自定义的titleBar + pai::gui::PaiStatusBar *m_pStatusBar; ///< 自定义的statusBar + QMenu *m_pSystemMenu; ///< 自定义的systemMenu + QMenu *m_pSettingMenu; ///< 自定义的settingMenu + QWidget *m_pContainerWidget; ///< 容器指针 + int m_TimerID; ///< 定时器ID + static int m_WinChangeSizeMode; ///< 鼠标改变窗体大小方式: 0:鼠标左键弹起后窗体变动;1:鼠标左键按下拖动时,窗体显示实时变动; + static bool m_IsInitWinChangeSizeMode; ///< 因为当前配置保存在配置文件中,暂时添加此变量表示是否初始化加载配置文件 +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAIWINDOW_H diff --git a/Workflow/WFWidget/include/PaiWorkspace.h b/Workflow/WFWidget/include/PaiWorkspace.h new file mode 100644 index 0000000..09a58cb --- /dev/null +++ b/Workflow/WFWidget/include/PaiWorkspace.h @@ -0,0 +1,176 @@ +/** + * @file PaiWorkspace.h + * @brief 该类代表一个复杂布局(支持停靠、区域拆分和页签等方式组织管理界面)的容器控件 + * @date 2012-05-07 + */ +#ifndef PAI_FRAME_WIDGET_PAIWORKSPACE_H +#define PAI_FRAME_WIDGET_PAIWORKSPACE_H + +#include "PaiTabWidget.h" +#include "Turtle.h" +namespace pai +{ + namespace gui + { + class PaiDropMask; + } +} + +namespace pai +{ +namespace gui +{ +/** + * @class PaiWorkspaceExtension + * @brief 虚基类,用于定义PaiWorkspace的功能拓展。 + */ +class PaiWorkspaceExtension +{ +public: + /** + * @brief 将视图加到指定的页签控件并建立两者之间的关系,这种解决方案效率较低,以后会重构 + * @param[in] pView 被拖拽的视图 + * @param[in] icon 待添加的视图的图标 + * @param[in] text 待添加的视图的名字 + * @param[in] pTabWidget 页签控件 + * @return 是否添加成功 + */ + virtual bool AddViewToTabWidget(QWidget *pView, + const QIcon & icon, + const QString & text, + pai::gui::PaiTabWidget *pTabWidget) = 0; + + /** + * @brief 将视图从指定的页签控件移走并切断两者之间的关系,这种解决方案效率较低,以后会重构 + * @param[in] pView 被拖拽走的视图 + * @param[in] pTabWidget 脱离时的页签控件 + * @return 是否移除成功 + */ + virtual bool RemoveViewFromTabWidget(QWidget *pView, pai::gui::PaiTabWidget *pTabWidget) = 0; +}; + +/** + * @class PaiWorkspace + * @brief 该类代表一个复杂布局(支持停靠、区域拆分和页签等方式组织管理界面)的容器控件 + */ +class PAI_WIDGET_EXPORT PaiWorkspace : public QWidget +{ + Q_OBJECT +public: + /** + * @brief 构造函数 + * @param[in] pParent 父控件句柄 + */ + PaiWorkspace(QWidget *pParent); + + /** + * @brief 析构函数 + */ + virtual ~PaiWorkspace(); + + /** + * @brief 添加一个Widget到指定区域,本函数为临时实现 + * @param[in] areaName 区域名 + * @param[in] pWidget 待添加的控件 + * @param[in] text 待添加的控件的名字 + * @param[in] icon 待添加的控件的图标 + */ + void AddWidget(const QString & areaName, QWidget *pWidget, const QString & text, const QIcon & icon); + + /** + * @brief 将视图加到指定的页签控件并建立两者之间的关系,这种解决方案效率较低,以后会重构 + * @param[in] pView 被拖拽的视图 + * @param[in] icon 待添加的视图的图标 + * @param[in] text 待添加的视图的名字 + * @param[in] pTabWidget 页签控件 + * @return 是否添加成功 + */ + static bool AddViewToTabWidget(QWidget *pView, const QIcon & icon, const QString & text, pai::gui::PaiTabWidget *pTabWidget); + + /** + * @brief 将视图从指定的页签控件移走并切断两者之间的关系,这种解决方案效率较低,以后会重构 + * @param[in] pView 被拖拽走的视图 + * @param[in] pTabWidget 脱离时的页签控件 + * @return 是否移除成功 + */ + static bool RemoveViewFromTabWidget(QWidget *pView, pai::gui::PaiTabWidget *pTabWidget); + + /** + * @brief 获取主Tab组件,通常依据此组件设置窗口标题 + * @return 返回主Tab组件 + */ + PaiTabWidget* GetPrimaryTabWidget() const; + + /** + * @brief 设置拓展对象,为PaiWorkspace增加功能 + * @param[in] pExtension 功能拓展对象 + */ + static void SetExtension(PaiWorkspaceExtension *pExtension); + +protected: + /** + * @brief 支持拖动页签到别的区域 + * @param[in] pEvent 拖拽事件 + */ + virtual void dropEvent(QDropEvent *pEvent); + + /** + * @brief 重载此函数来判断拖拽进来的数据是否合法,并给出落点提示 + * @param[in] pEvent 拖拽事件 + */ + virtual void dragEnterEvent(QDragEnterEvent *pEvent); + + /** + * @brief 重载此函数来判断拖拽进来的数据是否合法,并给出落点提示 + * @param[in] pEvent 拖拽事件 + */ + virtual void dragMoveEvent(QDragMoveEvent *pEvent); + + /** + * @brief 重载此函数来取消落点区域位置提示的显示 + * @param[in] pEvent 拖拽事件 + */ + virtual void dragLeaveEvent(QDragLeaveEvent *pEvent); + + /** + * @brief 重载此函数来调用页签控件的关闭流程 + * @param[in] pEvent 关闭事件 + */ + virtual void closeEvent(QCloseEvent *pEvent); + + /** + * @brief 重载eventFilter + * @param[in] pObject 事件源 + * @param[in] pEvent 事件对象 + */ + virtual bool eventFilter(QObject *pObject, QEvent *pEvent); + +private slots: + /** + * @brief 当所有的页签都被挪走后关闭工作区域 + */ + void OnAllTabRemoved(); + +private: + PaiDropMask *m_pDropAreaHint; ///< 拖动中的页签的落点的区域位置提示 + DragState m_DragState; ///< 拖拽参数 + PaiTabWidget *m_pMainTabWidget; ///< 主tab页 + static PaiWorkspaceExtension *m_pWorkspaceExtension; ///< PaiWorkspace功能拓展,目前需要拓展与TabWidget之间的注册和反注册功能 + +signals: + /** + * @brief 切换父窗口的title + * @param[in] title 标题 + */ + void CurrentTitleChanged(const QString & title); + + /** + * @brief 当数据副标题变化信号,window连接后可用于标题刷新 + */ + void SubtitleChanged(); +}; + +} +} + +#endif ///< PAI_FRAME_WIDGET_PAIWORKSPACE_H