00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KPTDOUBLELISTVIEWBASE_H
00021 #define KPTDOUBLELISTVIEWBASE_H
00022
00023 #include <qcolor.h>
00024 #include <qmap.h>
00025 #include <qptrvector.h>
00026 #include <qsplitter.h>
00027
00028 #include <klistview.h>
00029
00030 class QListViewItem;
00031
00032 class KListViewItem;
00033 class KPrinter;
00034
00035 namespace KPlato
00036 {
00037
00038 class View;
00039 class Project;
00040
00041 class ListView : public KListView
00042 {
00043 public:
00044 ListView(QWidget *parent)
00045 : KListView(parent)
00046 {}
00047
00048 virtual void paintToPrinter(QPainter * p, int cx, int cy, int cw, int ch);
00049 };
00050
00059 class DoubleListViewBase : public QSplitter
00060 {
00061 Q_OBJECT
00062 public:
00063
00064 DoubleListViewBase(QWidget *parent, bool description=false);
00065
00066
00067
00068 ListView *masterListView() const { return m_masterList; }
00069 ListView *slaveListView() const { return m_slaveList; }
00070 void setOpen(QListViewItem *item, bool open);
00071
00072 void setNameHeader(QString text);
00073 void setTotalHeader(QString text);
00074 void setDescriptionHeader(QString text);
00075 void addSlaveColumn(QString text);
00076 virtual void print(KPrinter &printer);
00077
00078 virtual void calculate();
00079 void clearLists();
00080 virtual void createSlaveItems();
00081 void clearSlaveList();
00082 void setFormat(int fieldwidth=0, char fmt='f', int prec=0);
00083 void setMasterFormat(int fieldwidth=0, char fmt='f', int prec=0);
00084 void setSlaveFormat(int fieldwidth=0, char fmt='f', int prec=0);
00085 virtual QSize sizeHint() const;
00086
00087 class MasterListItem;
00088 class SlaveListItem : public KListViewItem {
00089 public:
00090 SlaveListItem(MasterListItem *master, QListView *parent, QListViewItem *after, bool highlight=false);
00091 SlaveListItem(MasterListItem *master, QListViewItem *parent, QListViewItem *after, bool highlight=false);
00092 ~SlaveListItem();
00093 void masterItemDeleted() { m_masterItem = 0; }
00094
00095 virtual void setColumn(int col, double value);
00096 virtual void clearColumn(int col);
00097
00098 double value(int col) const { return m_valueMap[col]; }
00099 void setLimit(int col, double limit);
00100 void setHighlight(bool on) { m_highlight = on; }
00101
00102 virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align);
00103
00104 void setFormat(int fieldwidth=0, char fmt='f', int prec=0);
00105
00106 protected:
00107 MasterListItem *m_masterItem;
00108 double m_value;
00109 bool m_highlight;
00110
00111 QMap<int, double> m_valueMap;
00112 QMap<int, double> m_limitMap;
00113
00114 int m_fieldwidth;
00115 char m_fmt;
00116 int m_prec;
00117 };
00118
00119 class MasterListItem : public KListViewItem {
00120 public:
00121 MasterListItem(QListView *parent, bool highlight=false);
00122 MasterListItem(QListView *parent, QString text, bool highlight=false);
00123 MasterListItem(QListViewItem *parent, bool highlight=false);
00124 MasterListItem(QListViewItem *parent, QString text, bool highlight=false);
00125 ~MasterListItem();
00126
00128 void createSlaveItems(QListView *lv, QListViewItem *after=0);
00129 void slaveItemDeleted();
00130 void setSlaveOpen(bool on);
00131 SlaveListItem *slaveItem() const { return m_slaveItem; }
00132 double value() const { return m_value; }
00133
00134 void setTotal(double tot);
00135 double calcTotal();
00136 void addToTotal(double v);
00137 void setSlaveItem(int col, double value);
00138 void setSlaveLimit(int col, double limit);
00139 void setLimit(double limit) { m_limit = limit; }
00140 void setHighlight(bool on) { m_highlight = on; }
00141 void setSlaveHighlight(bool on);
00142 void clearColumn(int col);
00143 void calcSlaveItems();
00144 virtual double calcSlaveItems(int col);
00145
00146 virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align);
00147
00148 void setFormat(int fieldwidth=0, char fmt='f', int prec=0);
00149
00150 protected:
00151 SlaveListItem *m_slaveItem;
00152 double m_value;
00153 double m_limit;
00154 bool m_highlight;
00155
00156 QMap<int, double> m_valueMap;
00157
00158 int m_fieldwidth;
00159 char m_fmt;
00160 int m_prec;
00161 };
00162
00163 public:
00164 virtual void paintContents(QPainter *p);
00165
00166 protected slots:
00167 void slotExpanded(QListViewItem* item);
00168 void slotCollapsed(QListViewItem* item);
00169
00170 private:
00171
00172 private:
00173 ListView *m_masterList;
00174 ListView *m_slaveList;
00175
00176 int m_fieldwidth;
00177 char m_fmt;
00178 int m_prec;
00179 };
00180
00181 }
00182
00183 #endif