12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #ifndef COMPAREITEMLISTDIALOG_H
- #define COMPAREITEMLISTDIALOG_H
- #include <QStandardItemModel>
- #include <QSortFilterProxyModel>
- #include "DialogBase.h"
- #include "GlobalVariable.h"
- /**
- * @brief 自定义排序类
- *
- */
- class CSortModel : public QSortFilterProxyModel
- {
- Q_OBJECT
- public:
- explicit CSortModel(QObject *parent = nullptr) : QSortFilterProxyModel(parent) {}
- ~CSortModel() {}
- protected:
- /* 重载比较函数 */
- bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
- };
- /**
- * @brief 对比项列表弹窗
- * 1、对比项具体数据在全局变量中存储,表格中主要存储对比项的ID,用这个ID去查找对比项的具体数据
- *
- */
- namespace Ui {
- class CompareItemListWidget;
- }
- class CompareItemListDialog : public DialogBase
- {
- Q_OBJECT
- public:
- explicit CompareItemListDialog(QWidget *parent = nullptr);
- ~CompareItemListDialog() override;
- /* 设置已有的对比项数据 */
- void setCompareItemList(const QList<CompareItemTableItem_t>& list);
- private slots:
- /* 点击了关闭按钮 */
- void do_pBtn_close_Clicked();
- /* 点击了添加按钮 */
- void do_pBtn_add_Clicked();
- /* 点击了删除按钮 */
- void do_pBtn_delete_Clicked();
- /* 点击了编辑按钮 */
- void do_pBtn_edit_Clicked();
- /* 启用对比项 */
- void do_pBtn_enable_Clicked();
- /* 禁用对比项 */
- void do_pBtn_disable_Clicked();
- /* 显示详情 */
- void do_tableView_doubleClicked(const QModelIndex &index);
- private:
- /* 初始化表格 */
- void initTable();
- /* 添加一行 */
- void addRow(CompareItemTableItem_t tableItem);
- private:
- Ui::CompareItemListWidget *ui;
- QStandardItemModel* m_model; /* 表格模型,存储数据 */
- CSortModel* m_sortModel; /* 排序模型 */
- const int m_userRole_CompareItemID = Qt::UserRole + 1; /* 自定义角色,用于存储对比项ID */
- };
- #endif // COMPAREITEMLISTDIALOG_H
|