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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
/* This file is part of the KDE project
Copyright (C) 2005 Dag Andersen <kplato@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KPTDOUBLELISTVIEWBASE_H
#define KPTDOUBLELISTVIEWBASE_H
#include <tqcolor.h>
#include <tqmap.h>
#include <tqptrvector.h>
#include <tqsplitter.h>
#include <klistview.h>
class TQListViewItem;
class KListViewItem;
class KPrinter;
namespace KPlato
{
class View;
class Project;
class ListView : public KListView
{
public:
ListView(TQWidget *parent)
: KListView(parent)
{}
virtual void paintToPrinter(TQPainter * p, int cx, int cy, int cw, int ch);
};
/**
* The class DoubleListViewBase provides a double listview
* where the right listview (the slave) containes columns of
* double values and the left listview (the master) is the 'item' listview
* and also provides for a sum total column of the values in the slave listview.
* This makes it possible to scroll the slave listview and still see the values
* in the master listview.
*/
class DoubleListViewBase : public TQSplitter
{
Q_OBJECT
TQ_OBJECT
public:
DoubleListViewBase(TQWidget *parent, bool description=false);
//~DoubleListViewBase();
ListView *masterListView() const { return m_masterList; }
ListView *slaveListView() const { return m_slaveList; }
void setOpen(TQListViewItem *item, bool open);
void setNameHeader(TQString text);
void setTotalHeader(TQString text);
void setDescriptionHeader(TQString text);
void addSlaveColumn(TQString text);
virtual void print(KPrinter &printer);
virtual void calculate();
void clearLists();
virtual void createSlaveItems();
void clearSlaveList();
void setFormat(int fieldwidth=0, char fmt='f', int prec=0);
void setMasterFormat(int fieldwidth=0, char fmt='f', int prec=0);
void setSlaveFormat(int fieldwidth=0, char fmt='f', int prec=0);
virtual TQSize sizeHint() const;
class MasterListItem;
class SlaveListItem : public KListViewItem {
public:
SlaveListItem(MasterListItem *master, TQListView *parent, TQListViewItem *after, bool highlight=false);
SlaveListItem(MasterListItem *master, TQListViewItem *parent, TQListViewItem *after, bool highlight=false);
~SlaveListItem();
void masterItemDeleted() { m_masterItem = 0; }
virtual void setColumn(int col, double value);
virtual void clearColumn(int col);
double value(int col) const { return m_valueMap[col]; }
void setLimit(int col, double limit);
void setHighlight(bool on) { m_highlight = on; }
virtual void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align);
void setFormat(int fieldwidth=0, char fmt='f', int prec=0);
protected:
MasterListItem *m_masterItem;
double m_value;
bool m_highlight;
TQMap<int, double> m_valueMap;
TQMap<int, double> m_limitMap;
int m_fieldwidth;
char m_fmt;
int m_prec;
};
class MasterListItem : public KListViewItem {
public:
MasterListItem(TQListView *parent, bool highlight=false);
MasterListItem(TQListView *parent, TQString text, bool highlight=false);
MasterListItem(TQListViewItem *parent, bool highlight=false);
MasterListItem(TQListViewItem *parent, TQString text, bool highlight=false);
~MasterListItem();
/// Creates slaveitems for myself and my children
void createSlaveItems(TQListView *lv, TQListViewItem *after=0);
void slaveItemDeleted();
void setSlaveOpen(bool on);
SlaveListItem *slaveItem() const { return m_slaveItem; }
double value() const { return m_value; }
void setTotal(double tot);
double calcTotal();
void addToTotal(double v);
void setSlaveItem(int col, double value);
void setSlaveLimit(int col, double limit);
void setLimit(double limit) { m_limit = limit; }
void setHighlight(bool on) { m_highlight = on; }
void setSlaveHighlight(bool on);
void clearColumn(int col);
void calcSlaveItems();
virtual double calcSlaveItems(int col);
virtual void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align);
void setFormat(int fieldwidth=0, char fmt='f', int prec=0);
protected:
SlaveListItem *m_slaveItem;
double m_value;
double m_limit;
bool m_highlight;
TQMap<int, double> m_valueMap;
int m_fieldwidth;
char m_fmt;
int m_prec;
};
public:
virtual void paintContents(TQPainter *p);
protected slots:
void slotExpanded(TQListViewItem* item);
void slotCollapsed(TQListViewItem* item);
private:
private:
ListView *m_masterList;
ListView *m_slaveList;
int m_fieldwidth;
char m_fmt;
int m_prec;
};
} //KPlato namespace
#endif
|