/** * @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