-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtableviewmodel.h
114 lines (91 loc) · 3.13 KB
/
tableviewmodel.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
/*
* This file is part of EasyTimeTracker.
*
* EasyTimeTracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyTimeTracker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with EasyTimeTracker. If not, see <http://www.gnu.org/licenses/>.
*
* EasyTimeTracker: First creation by 2BlackCoffees: http://www.twoblackcoffees.com/
*
**/
#ifndef SPREADSHEET_H
#define SPREADSHEET_H
#include "misc.h"
#include "iconnection.h"
#include <QTableView>
#include <QDateTime>
#include <QStringList>
#include <QMutex>
#include <QFile>
#include <memory.h>
class TimeTrackingModel;
namespace Col {
enum Col {
DAY, START_TIME, END_TIME, PAUSE_TIME, WORKED_TIME, REQUIRED_TIME, DUE_OVER_HOURS, COMMENT,
MAX_COL /* Leave me last !*/
};
}
class TableViewModel : public QAbstractTableModel
{
Q_OBJECT
public:
enum TUserRole {
USER_ROLE_START_TIME_IS_VALID,
USER_ROLE_END_TIME_IS_VALID,
USER_ROLE_FORCE_CHANGES,
USER_ROLE_GET_MONTH_OF_SHEET
};
explicit TableViewModel(QWidget *parent);
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant data(const QModelIndex &index,
int role=Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role=Qt::DisplayRole) const;
int rowCount(const QModelIndex &) const;
int columnCount(const QModelIndex &) const;
bool setData(const QModelIndex &index, const QVariant &value,
int role=Qt::EditRole);
bool setHeaderData(int, Qt::Orientation, const QVariant&,
int=Qt::EditRole) {
return false;
}
QModelIndex getIndexOfToday(Col::Col column) {
return index(QDate::currentDate().day() - 1, column);
}
bool sheetOfCurMonth() const;
void setUserName(const QString & userName);
void setNewBaseDate(const QDate & baseDate);
TimeTrackingModel * getTimeTrackingModel() {
return mTimeTrackingModel;
}
public slots:
//void lockUnlock(bool unlock);
private:
mutable QMutex* mutex;
enum { MagicNumber = 0x7F51C883, ColumnCount = Col::MAX_COL };
const QString mColNameDay;
const QString mColNameStartTime;
const QString mColNameEndTime;
const QString mColNamePauseTime;
const QString mColNameWorkedTime;
const QString mColNameRequiredTime;
const QString mColNameDueOverHours;
const QString mColNameComment;
QStringList mColumnsName;
QStringList mColumnsPattern;
int mSignalActDeactSemaphore;
IConnection* mParent;
QWidget* mParentWidget;
bool mDirty;
TimeTrackingModel* mTimeTrackingModel;
QString formatString(const QString &string) const;
};
#endif