-
Notifications
You must be signed in to change notification settings - Fork 4
/
HistMdl.h
72 lines (63 loc) · 2.04 KB
/
HistMdl.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
#ifndef HISTMDL_H
#define HISTMDL_H
/*
* Copyright 2005-2017 Rochus Keller <mailto:me@rochus-keller.info>
*
* This file is part of the DoorScope application
* see <http://doorscope.ch/>).
*
* GNU General Public License Usage
* This file may be used under the terms of the GNU General Public
* License (GPL) versions 2.0 or 3.0 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in
* the packaging of this file. Please review the following information
* to ensure GNU General Public Licensing requirements will be met:
* http://www.fsf.org/licensing/licenses/info/GPLv2.html and
* http://www.gnu.org/copyleft/gpl.html.
*/
#include <QAbstractItemModel>
#include <Sdb/Obj.h>
#include <QList>
class QTextDocument;
class QTextCursor;
namespace Ds
{
class HistMdl : public QAbstractItemModel
{
Q_OBJECT
public:
enum IndexType { OpIndex = 1, FieldIndex = 2, ValueIndex = 3 };
enum Role {
IndexTypeRole = Qt::UserRole + 1,
FirstRole,
LastRole,
SystemRole,
};
HistMdl(QObject *parent);
~HistMdl();
void setObj( const Sdb::Obj& );
void refill();
static void printDiff( QTextCursor&, const QString& newText, const QString& oldText );
// Overrides
int columnCount( const QModelIndex & parent = QModelIndex() ) const { return 1; }
int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
QModelIndex parent(const QModelIndex &) const;
protected:
void calcDiff( int row ) const;
private:
Sdb::Obj d_obj;
struct Slot
{
quint64 d_first;
quint64 d_last;
QTextDocument* d_doc;
quint8 d_type;
Slot():d_first(0),d_last(0),d_doc(0),d_type(0){}
Slot(quint64 id, quint8 t):d_first(id),d_last(id),d_doc(0),d_type(t){}
};
mutable QList<Slot> d_rows; // First und Last Change per Attribute
};
}
#endif // HISTMDL_H