logplus/Workflow/WFWidget/include/PaiLineEdit.h

235 lines
6.6 KiB
C
Raw Permalink Normal View History

2026-01-17 12:55:45 +08:00
/**
* @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 <QLineEdit>
#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