kplato

kptdoublelistviewbase.h
1/* This file is part of the KDE project
2 Copyright (C) 2005 Dag Andersen <kplato@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KPTDOUBLELISTVIEWBASE_H
21#define KPTDOUBLELISTVIEWBASE_H
22
23#include <tqcolor.h>
24#include <tqmap.h>
25#include <tqptrvector.h>
26#include <tqsplitter.h>
27
28#include <tdelistview.h>
29
30class TQListViewItem;
31
32class TDEListViewItem;
33class KPrinter;
34
35namespace KPlato
36{
37
38class View;
39class Project;
40
41class ListView : public TDEListView
42{
43public:
44 ListView(TQWidget *parent)
45 : TDEListView(parent)
46 {}
47
48 virtual void paintToPrinter(TQPainter * p, int cx, int cy, int cw, int ch);
49};
50
59class DoubleListViewBase : public TQSplitter
60{
61 TQ_OBJECT
62
63public:
64
65 DoubleListViewBase(TQWidget *parent, bool description=false);
66
67 //~DoubleListViewBase();
68
69 ListView *masterListView() const { return m_masterList; }
70 ListView *slaveListView() const { return m_slaveList; }
71 void setOpen(TQListViewItem *item, bool open);
72
73 void setNameHeader(TQString text);
74 void setTotalHeader(TQString text);
75 void setDescriptionHeader(TQString text);
76 void addSlaveColumn(TQString text);
77 virtual void print(KPrinter &printer);
78
79 virtual void calculate();
80 void clearLists();
81 virtual void createSlaveItems();
82 void clearSlaveList();
83 void setFormat(int fieldwidth=0, char fmt='f', int prec=0);
84 void setMasterFormat(int fieldwidth=0, char fmt='f', int prec=0);
85 void setSlaveFormat(int fieldwidth=0, char fmt='f', int prec=0);
86 virtual TQSize sizeHint() const;
87
88 class MasterListItem;
89 class SlaveListItem : public TDEListViewItem {
90 public:
91 SlaveListItem(MasterListItem *master, TQListView *parent, TQListViewItem *after, bool highlight=false);
92 SlaveListItem(MasterListItem *master, TQListViewItem *parent, TQListViewItem *after, bool highlight=false);
93 ~SlaveListItem();
94 void masterItemDeleted() { m_masterItem = 0; }
95
96 virtual void setColumn(int col, double value);
97 virtual void clearColumn(int col);
98
99 double value(int col) const { return m_valueMap[col]; }
100 void setLimit(int col, double limit);
101 void setHighlight(bool on) { m_highlight = on; }
102
103 virtual void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align);
104
105 void setFormat(int fieldwidth=0, char fmt='f', int prec=0);
106
107 protected:
108 MasterListItem *m_masterItem;
109 double m_value;
110 bool m_highlight;
111
112 TQMap<int, double> m_valueMap;
113 TQMap<int, double> m_limitMap;
114
115 int m_fieldwidth;
116 char m_fmt;
117 int m_prec;
118 };
119
120 class MasterListItem : public TDEListViewItem {
121 public:
122 MasterListItem(TQListView *parent, bool highlight=false);
123 MasterListItem(TQListView *parent, TQString text, bool highlight=false);
124 MasterListItem(TQListViewItem *parent, bool highlight=false);
125 MasterListItem(TQListViewItem *parent, TQString text, bool highlight=false);
126 ~MasterListItem();
127
129 void createSlaveItems(TQListView *lv, TQListViewItem *after=0);
130 void slaveItemDeleted();
131 void setSlaveOpen(bool on);
132 SlaveListItem *slaveItem() const { return m_slaveItem; }
133 double value() const { return m_value; }
134
135 void setTotal(double tot);
136 double calcTotal();
137 void addToTotal(double v);
138 void setSlaveItem(int col, double value);
139 void setSlaveLimit(int col, double limit);
140 void setLimit(double limit) { m_limit = limit; }
141 void setHighlight(bool on) { m_highlight = on; }
142 void setSlaveHighlight(bool on);
143 void clearColumn(int col);
144 void calcSlaveItems();
145 virtual double calcSlaveItems(int col);
146
147 virtual void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align);
148
149 void setFormat(int fieldwidth=0, char fmt='f', int prec=0);
150
151 protected:
152 SlaveListItem *m_slaveItem;
153 double m_value;
154 double m_limit;
155 bool m_highlight;
156
157 TQMap<int, double> m_valueMap;
158
159 int m_fieldwidth;
160 char m_fmt;
161 int m_prec;
162 };
163
164public:
165 virtual void paintContents(TQPainter *p);
166
167protected slots:
168 void slotExpanded(TQListViewItem* item);
169 void slotCollapsed(TQListViewItem* item);
170
171private:
172
173private:
174 ListView *m_masterList;
175 ListView *m_slaveList;
176
177 int m_fieldwidth;
178 char m_fmt;
179 int m_prec;
180};
181
182} //KPlato namespace
183
184#endif
Project is the main node in a project, it contains child nodes and possibly sub-projects.
Definition kptproject.h:52