kplato

kptrequestresourcespanel.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 - 2005 Dag Andersen <danders@get2net.dk>
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;
7 version 2 of the License.
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 KPTREQUESTRESOURCESPANEL_H
21#define KPTREQUESTRESOURCESPANEL_H
22
23#include "kpttastderesourcespanelbase.h"
24#include "kptduration.h"
25
26#include <tqlistview.h>
27#include <tqstring.h>
28#include <tqtable.h>
29//class TQCheckTableItem;
30
31class KCommand;
32class KMacroCommand;
33
34namespace KPlato
35{
36
37class Account;
38class Accounts;
39class Task;
40class ResourceGroup;
41class Resource;
42class ResourceGroupRequest;
43class ResourceRequest;
44class StandardWorktime;
45class Part;
46class Duration;
47
48class ResourceTableItem {
49public:
50 ResourceTableItem(Resource *resource, ResourceRequest *request, bool check = false);
51 ~ResourceTableItem() ;
52
53 void update();
54 void insert(TQTable *table, int row);
55 void ok(ResourceGroupRequest *group);
56
57 bool isChecked() const { return m_checked; }
58 bool isOrigChecked() const { return m_origChecked; }
59 Resource *resource() { return m_resource; }
60 ResourceRequest *request() { return m_request; }
61 int numRequests() const { return m_checked ? 1 : 0; }
62 int units() const { return m_units; }
63
64 Resource *m_resource;
65 int m_units, m_origUnits;
66 bool m_checked, m_origChecked;
67 TQCheckTableItem *m_checkitem;
68 ResourceRequest *m_request;
69 int m_curAccountItem;
70 TQString m_curAccountText;
71};
72
73class GroupLVItem : public TQListViewItem {
74public:
75 GroupLVItem(TQListView *parent, ResourceGroup *group, Task &task);
76 ~GroupLVItem();
77
78 void update();
79 void insert(TQTable *table);
80 const TQPtrList<ResourceTableItem> &resources() const { return m_resources; }
81 void ok(Task &task);
82
83 int numRequests();
84 bool isNull() const;
85
86 ResourceGroup *m_group;
87 int m_units;
88 TQPtrList<ResourceTableItem> m_resources;
89 ResourceGroupRequest *m_request;
90};
91
92
93class RequestResourcesPanel : public TaskResourcesPanelBase {
94 TQ_OBJECT
95
96public:
97 RequestResourcesPanel(TQWidget *parent, Task &task, bool baseline=false);
98
99 KCommand *buildCommand(Part *part);
100
101 bool ok();
102
103private slots:
104 void sendChanged();
105
106 void groupChanged(TQListViewItem *item);
107 void resourceChanged(int, int);
108 void unitsChanged(int);
109
110signals:
111 void changed();
112
113private:
114 Task &m_task;
115 StandardWorktime *m_worktime;
116 GroupLVItem *selectedGroup;
117 bool m_blockChanged;
118
119};
120
121} //KPlato namespace
122
123#endif