forked from GoldenCheetah/GoldenCheetah
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqxtscheduleview.h
138 lines (112 loc) · 5.34 KB
/
qxtscheduleview.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/****************************************************************************
**
** Copyright (C) Qxt Foundation. Some rights reserved.
**
** This file is part of the QxtGui module of the Qxt library.
**
** This library is free software; you can redistribute it and/or modify it
** under the terms of the Common Public License, version 1.0, as published
** by IBM, and/or under the terms of the GNU Lesser General Public License,
** version 2.1, as published by the Free Software Foundation.
**
** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
** FITNESS FOR A PARTICULAR PURPOSE.
**
** You should have received a copy of the CPL and the LGPL along with this
** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files
** included with the source distribution for more information.
** If you did not receive a copy of the licenses, contact the Qxt Foundation.
**
** <http://libqxt.org> <[email protected]>
**
****************************************************************************/
#ifndef QXTSCHEDULEVIEW_H_INCLUDED
#define QXTSCHEDULEVIEW_H_INCLUDED
#include <QAbstractScrollArea>
#include <QTime>
#include <QDate>
#include <QDateTime>
#include <QHeaderView>
#include <QRect>
#include "qxtglobal.h"
#include "qxtnamespace.h"
QT_FORWARD_DECLARE_CLASS(QAbstractItemModel)
class QxtScheduleItemDelegate;
class QxtScheduleViewPrivate;
class QxtScheduleInternalItem;
#if 0
enum
{
TIMERANGEPERCOL = 86400,
TIMESTEP = 900
};
#endif
class QXT_GUI_EXPORT QxtScheduleView : public QAbstractScrollArea
{
Q_OBJECT
QXT_DECLARE_PRIVATE(QxtScheduleView)
friend class QxtScheduleInternalItem;
friend class QxtScheduleViewHeaderModel;
public:
enum ViewMode
{
MinuteView,
HourView,
DayView,
CustomView
};
QxtScheduleView(QWidget *parent = 0);
void setModel(QAbstractItemModel *model);
QAbstractItemModel* model() const;
void setViewMode(const QxtScheduleView::ViewMode mode);
QxtScheduleView::ViewMode viewMode() const;
QHeaderView* verticalHeader ( ) const;
QHeaderView* horizontalHeader ( ) const;
void setDateRange(const QDate & fromDate , const QDate & toDate);
void setTimeRange(const QDateTime &fromDateTime , const QDateTime &toTime);
QxtScheduleItemDelegate* delegate () const;
void setItemDelegate (QxtScheduleItemDelegate * delegate);
void setZoomStepWidth(const int zoomWidth , const Qxt::Timeunit unit = Qxt::Second);
void setCurrentZoomDepth(const int depth , const Qxt::Timeunit unit = Qxt::Second);
int currentZoomDepth(const Qxt::Timeunit unit = Qxt::Second);
QPoint mapFromViewport(const QPoint& point) const;
QPoint mapToViewport(const QPoint& point) const;
QModelIndex indexAt(const QPoint &pt);
void raiseItem(const QModelIndex &index);
void handleItemConcurrency(const QModelIndex &index);
QModelIndex currentIndex();
int rows() const;
int cols() const;
QDateTime getStartTime() const;
Q_SIGNALS:
void itemMoved(int rows, int cols, QModelIndex index);
void indexSelected(QModelIndex index);
void indexDoubleClicked(QModelIndex index);
void contextMenuRequested(QModelIndex index);
void newZoomDepth(const int newDepthInSeconds);
void viewModeChanged(const int newViewMode);
protected:
virtual int timePerColumn() const;
virtual void adjustRangeToViewMode(QDateTime *startTime, QDateTime *endTime) const;
virtual void scrollContentsBy(int dx, int dy);
virtual void paintEvent(QPaintEvent *e);
virtual void mouseMoveEvent(QMouseEvent * e);
virtual void mousePressEvent(QMouseEvent * e);
virtual void mouseReleaseEvent(QMouseEvent * e);
virtual void mouseDoubleClickEvent ( QMouseEvent * e );
virtual void resizeEvent(QResizeEvent * e);
virtual void wheelEvent(QWheelEvent * e);
public Q_SLOTS:
void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
void updateGeometries();
void zoomIn();
void zoomOut();
protected Q_SLOTS:
virtual void rowsAboutToBeRemoved(const QModelIndex & parent, int start, int end);
virtual void rowsAboutToBeInserted(const QModelIndex & parent, int start, int end);
virtual void rowsRemoved(const QModelIndex & parent, int start, int end);
virtual void rowsInserted(const QModelIndex & parent, int start, int end);
};
#endif //QXTSCHEDULEVIEW_H_INCLUDED