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.
nmWATI/Include/iBase/iPlugin/QHeaderViewEx.h

69 lines
1.9 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include <iPlugin_global.h>
#include <QStringList>
#include <QComboBox>
#include <QHeaderView>
#include <QDebug>
#include <QPainter>
#include <QListWidget>
#include <QCheckBox>
#include <QStandardItem>
// 此处是为了响应在QTableWidget中的表头进行下拉选择支持多选而做的三个类。
// 其中QHeaderViewEx是表头点中其某一列时创建QHeaderComboBoxEx而QHeaderComboBoxEx
// 内部又设置了view为QListViewEx
// 表头HeaderView
class I_PLUGIN_EXPORT QHeaderViewEx : public QHeaderView
{
Q_OBJECT
public:
QHeaderViewEx(const QStringList& lstStrText, QWidget *parent = 0);
~QHeaderViewEx();
// 设置表头下拉列表取值
void setColumnItems(const QStringList& lstFields, const QStringList& lstAlls);
// 设置Titles
void changeTitles(QStringList listTitles);
public Q_SLOTS:
// 选择改变时响应
void slotSelChanged(const int, const QStringList);
// 处理表头单元缩放事件
void handleSectionResized(int index);
signals:
void sigGetColumnItems(int index);
void sigSelChanged(const int, const QStringList);
protected:
// 重置表头combo控件大小
void resizeItem(int index);
// 删除comboBox控件
void removeCombo();
// 处理鼠标单击消息
void mouseReleaseEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *e);
// 重绘,此处有待完善,目前是没有版本,直接把父类搬过来了。
void paintSection(QPainter* painter, const QRect &rect, int logicalIndex) const;
private:
QStringList m_lstHeaderTexts; //标题
QStringList m_lstComboxText; ///< 下拉列表中显示表头列表,当前选中的
QStringList m_lstComboxTextAll;///< 下拉列表中显示表头列表,所有的
QComboBox* m_pCbxSel; ///< 表头下拉列表控件
int m_nCurIndex; ///< 被选中的表头单元ID
};