File: TjReport.h

package info (click to toggle)
taskjuggler 2.3.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 8,764 kB
  • ctags: 3,700
  • sloc: cpp: 36,852; sh: 12,761; xml: 5,541; perl: 5,207; makefile: 269; python: 258; lisp: 67
file content (184 lines) | stat: -rw-r--r-- 5,324 bytes parent folder | download
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
/*
 * The TaskJuggler Project Management Software
 *
 * Copyright (c) 2001, 2002, 2003, 2004, 2005 by Chris Schlaeger <cs@kde.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * $Id: TjReport.h 1315 2006-08-11 21:05:41Z cs $
 */

#ifndef _TjReport_h_
#define _TjReport_h_

#include <time.h>
#include <set>
#include <map>

#include <qstring.h>
#include <qlistview.h>

#include "TjReportBase.h"
#include "TaskList.h"
#include "ResourceList.h"
#include "ReportLayers.h"
#include "ltQString.h"
#include "ltstr.h"

class QSplitter;
class QCanvas;
class QCanvasView;
class QTimer;
class KListView;
class KPrinter;
class Report;
class Task;
class Resource;
class QtReportElement;
class Interval;
class JournalIterator;
class TjPrintReport;
class TjObjPosTable;
class TjGanttChart;

class TjReport : public TjReportBase
{
    Q_OBJECT
public:
    TjReport(QWidget* p, ReportManager* m, Report* const rDef,
             const QString& n = QString::null);
    virtual ~TjReport();

    virtual bool generateReport();

    virtual const QtReportElement* getReportElement() const = 0;

    void generateTaskListLine(const QtReportElement* reportElement,
                              const Task* t, QListViewItem* lvi,
                              const Resource* r = 0);
    void generateResourceListLine(const QtReportElement* reportElement,
                                  Resource* r, QListViewItem* lvi,
                                  const Task* t = 0);
    void print();

    virtual TjPrintReport* newPrintReport(KPrinter* pr) = 0;

public slots:
    void zoomIn();
    void zoomOut();
    void zoomTo(const QString& lable);

    virtual void show();
    virtual void hide();

private slots:
    void regenerateChart();
    void collapsReportItem(QListViewItem* lvi);
    void expandReportItem(QListViewItem* lvi);
    void listClicked(QListViewItem* lvi, const QPoint&, int column);
    void listHeaderClicked(int colmun);
    void doPopupMenu(QListViewItem* lvi, const QPoint& pos, int);
    void syncVSlidersGantt2List(int, int);
    void syncVSlidersList2Gantt(int, int);
    void updateStatusBar();

protected:
    TjReport() { }

    virtual bool event(QEvent* ev);
    virtual bool generateList() = 0;

    void prepareChart();

    void generateListHeader(const QString& firstHeader, QtReportElement* tab);

    void showTaskDetails(const Task* task);
    void showResourceDetails(const Resource* resource);

    void generateCustomAttribute(const CoreAttributes* ca, const QString name,
                                 QString& cellText, QPixmap& icon) const;

    virtual QString generateStatusBarText(const QPoint& pos,
                                          CoreAttributes* ca,
                                          CoreAttributes* parent) = 0;

    QString indent(const QString& input, const QListViewItem* lvi,
                   bool right);
    int treeLevel(const QListViewItem* lvi) const;

    QString generateJournal(JournalIterator jit) const;

    void setGanttChartColors();

    time_t stepLength() const;
    void setBestStepUnit();

    void updateZoomSelector();

    QSplitter* splitter;
    KListView* listView;
    QWidget* canvasFrame;

    TjObjPosTable* objPosTable;
    TjGanttChart* ganttChart;

    QCanvasView* ganttHeaderView;
    QCanvasView* ganttChartView;

    /**
     * We some widgets that need to be fit into the window the first time the
     * widget is rendered on the screen. We use the following variable to keep
     * track of this.
     */
    bool autoFit;

    /**
     * We often need to find out if a CoreAttribute is in the ListView and
     * find the appropriate list item. So we keep a dictionary that maps the
     * CoreAttribute ID to the QListViewItem*. As the namespaces of the
     * different CoreAttributes may contain duplicates we use a single
     * character plus colon prefix to create a unified namespace. So
     * t:mytask.subtask is a task and r:team.nick is a resource.
     */
    std::map<const QString, QListViewItem*, ltQString> ca2lviDict;

    /* And the same in the other direction. We use the hex-ed address of the
     * LVI as key. */
    std::map<const QString, CoreAttributes*, ltQString> lvi2caDict;

    /* For nested lists we need to be able to map the lvi to the parent
     * CoreAttributes. */
    std::map<const QString, CoreAttributes*, ltQString> lvi2ParentCaDict;

    /**
     * This is the maximum indentation of the list view. It only takes visible
     * items into account. Visible means not hidden by closed parents.
     */
    int maxDepth;

    int scenario;
    bool showGantt;
    int headerHeight;
    int listHeight;
    int itemHeight;
    int canvasWidth;
    time_t startTime;
    time_t endTime;

    QTimer* statusBarUpdateTimer;
    QTimer* delayTimer;

    TaskList taskList;
    ResourceList resourceList;

    /* The interactive reports treat the indexes, name and gantt columns
     * differently than most other reports. They provide special rendering for
     * them and need to be ignored during generic column rendering. */
    std::set<const char*, ltstr> indexColumns;
    std::set<const char*, ltstr> specialColumns;
} ;

#endif