-
Notifications
You must be signed in to change notification settings - Fork 0
/
tablecolumn.h
75 lines (58 loc) · 1.85 KB
/
tablecolumn.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef TABLECOLUMN_H
#define TABLECOLUMN_H
#include "classtable.h"
#include "qgraphicstableitem.h"
#include "tableitem.h"
#include <QDateTime>
#include <QGraphicsLineItem>
#include <QGraphicsRectItem>
#include <QList>
class TableColumn : public QGraphicsRectItem {
friend class ClassTable;
friend class TableItem;
public:
//构造函数,指定所属的ClassTable
TableColumn( int, QDateTime, QDateTime, ClassTable * = nullptr,
int xPos = 0 );
//析构函数
~TableColumn() override;
void paint( QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr ) override;
void show();
void hide();
void resize( QResizeEvent *tableEvent );
void remove();
void setStart( QDateTime );
void setEnd( QDateTime );
int getXPos() const;
int getYPos() const;
qint64 getTimeLen() const;
static int itemYPosShouldBe( QDateTime itemStart, QDateTime colStart,
QDateTime colEnd, int colHeight );
int itemYPosShouldBe( QDateTime itemStart ) const;
bool includeNow() const;
//绘制
void drawOnTable() const;
protected:
//上级ClassTable的指针
ClassTable *parentTablePtr;
//下级TableItem的指针们
QList< TableItem * > childrenItemPtrList;
QList< QGraphicsTableItem * > childQGraphicsItemPtrList;
//列的名称,比如“星期二”
QString name;
//列的编号,比如2
ClassTable::dayOfWeek index;
//列的宽度、高度,基于ClassTable的计算
int width, height;
int visibleWidth;
//这一列上边缘代表的时间,比如5月25日00:00:00
QDateTime start;
//下边缘代表的时间,比如5月25日23:59:59
QDateTime end;
QGraphicsRectItem *backgroundItemPtr;
QGraphicsLineItem *timeLineItemPtr;
int timeLineWidth = 3;
QColor timeLineColor = Qt::red;
};
#endif // TABLECOLUMN_H