| 1 |
/* |
| 2 |
* libkysdk-qtwidgets's Library |
| 3 |
* |
| 4 |
* Copyright (C) 2023, KylinSoft Co., Ltd. |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU Lesser General Public |
| 8 |
* License as published by the Free Software Foundation; either |
| 9 |
* version 3 of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* Lesser General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this library. If not, see <https://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
* Authors: Zhenyu Wang <[email protected]> |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef KTABLEHEADVIEW_H |
| 24 |
#define KTABLEHEADVIEW_H |
| 25 |
|
| 26 |
#include <QCheckBox> |
| 27 |
#include <QHeaderView> |
| 28 |
#include <QMap> |
| 29 |
#include <QObject> |
| 30 |
|
| 31 |
namespace kdk |
| 32 |
{ |
| 33 |
|
| 34 |
/** |
| 35 |
* @brief 继承自QHeaderView,设置view视图标题 |
| 36 |
* @since 2.5.2.0 |
| 37 |
*/ |
| 38 |
class KTableHeaderViewPrivate; |
| 39 |
|
| 40 |
class KTableHeaderView : public QHeaderView |
| 41 |
{ |
| 42 |
Q_OBJECT |
| 43 |
public: |
| 44 |
/** |
| 45 |
* @brief KTableHeaderView 构造函数 |
| 46 |
* @param orientation 方向 |
| 47 |
* @param parent 父类对象 |
| 48 |
*/ |
| 49 |
KTableHeaderView(Qt::Orientation orientation, QWidget *parent = nullptr); |
| 50 |
|
| 51 |
/** |
| 52 |
* @brief 设置水平标题 |
| 53 |
* @param list |
| 54 |
*/ |
| 55 |
void setTitle(QStringList list); |
| 56 |
|
| 57 |
/** |
| 58 |
* @brief 设置menu |
| 59 |
* @param menu |
| 60 |
* @param column |
| 61 |
*/ |
| 62 |
void setMenu(QMenu *menu, int column); |
| 63 |
|
| 64 |
protected: |
| 65 |
void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const; |
| 66 |
void mousePressEvent(QMouseEvent *e); |
| 67 |
void mouseReleaseEvent(QMouseEvent *e); |
| 68 |
bool event(QEvent *e); |
| 69 |
|
| 70 |
Q_SIGNALS: |
| 71 |
void checkStateChange(int state); |
| 72 |
void clickedHeader(int column); |
| 73 |
|
| 74 |
public slots: |
| 75 |
void checkStateChangeSlot(int iState); |
| 76 |
|
| 77 |
private: |
| 78 |
Q_DECLARE_PRIVATE(KTableHeaderView) |
| 79 |
KTableHeaderViewPrivate *const d_ptr; |
| 80 |
}; |
| 81 |
|
| 82 |
} |
| 83 |
#endif // KTABLEHEADVIEW_H |