kplato

kptpertview.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2003, 2004 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#include "kptpertview.h"
21
22#include "kptview.h"
23#include "kptpertcanvas.h"
24#include "kptpart.h"
25#include "kptproject.h"
26#include "kptrelation.h"
27#include "kptcontext.h"
28
29#include <kdebug.h>
30
31#include <tqsplitter.h>
32#include <tqvbox.h>
33#include <tqlayout.h>
34#include <tqlistview.h>
35#include <tqheader.h>
36#include <tqpopupmenu.h>
37
38#include <kprinter.h>
39
40namespace KPlato
41{
42
43PertView::PertView( View *view, TQWidget *parent, TQLayout *layout )
44 : TQWidget( parent, "Pert view" ),
45 m_mainview( view ),
46 m_node( 0 )
47{
48 init(layout);
49}
50
51PertView::~PertView()
52{
53}
54
55void PertView::init(TQLayout */*layout*/)
56{
57 //kdDebug()<<k_funcinfo<<endl;
58 TQGridLayout *gl = new TQGridLayout(this, 1, 1, -1, -1, "Pert TQGridLayout");
59 m_canvasview = new PertCanvas(this);
60 gl->addWidget(m_canvasview, 0, 0);
61 draw();
62 connect(m_canvasview, TQ_SIGNAL(rightButtonPressed(Node *, const TQPoint &)), this, TQ_SLOT(slotRMBPressed(Node *,const TQPoint &)));
63 connect(m_canvasview, TQ_SIGNAL(updateView(bool)), m_mainview, TQ_SLOT(slotUpdate(bool)));
64
65 connect(m_canvasview, TQ_SIGNAL(addRelation(Node*, Node*)), TQ_SLOT(slotAddRelation(Node*, Node*)));
66 connect(m_canvasview, TQ_SIGNAL(modifyRelation(Relation*)), TQ_SLOT(slotModifyRelation(Relation*)));
67}
68
69void PertView::draw()
70{
71 //kdDebug()<<k_funcinfo<<endl;
72 m_canvasview->draw(m_mainview->getPart()->getProject());
73 m_canvasview->show();
74}
75
76void PertView::slotRMBPressed(Node *node, const TQPoint & point)
77{
78 //kdDebug()<<k_funcinfo<<" node: "<<node->name()<<endl;
79 m_node = node;
80 if (node && (node->type() == Node::Type_Task || node->type() == Node::Type_Milestone)) {
81 TQPopupMenu *menu = m_mainview->popupMenu("task_popup");
82 if (menu)
83 {
84 /*int id =*/ menu->exec(point);
85 //kdDebug()<<k_funcinfo<<"id="<<id<<endl;
86 }
87 return;
88 }
89 if (node && node->type() == Node::Type_Summarytask) {
90 TQPopupMenu *menu = m_mainview->popupMenu("node_popup");
91 if (menu)
92 {
93 /*int id =*/ menu->exec(point);
94 //kdDebug()<<k_funcinfo<<"id="<<id<<endl;
95 }
96 return;
97 }
98 //TODO: Other nodetypes
99}
100
101void PertView::slotAddRelation(Node* par, Node* child)
102{
103 kdDebug()<<k_funcinfo<<endl;
104 emit addRelation(par, child);
105}
106
107void PertView::slotModifyRelation(Relation *rel)
108{
109 kdDebug()<<k_funcinfo<<endl;
110 emit modifyRelation(rel);
111}
112
113void PertView::print(KPrinter &printer)
114{
115 Q_UNUSED(printer);
116 kdDebug()<<k_funcinfo<<endl;
117
118}
119
120Node *PertView::currentNode()
121{
122 return m_canvasview->selectedNode();
123}
124
125bool PertView::setContext(Context::Pertview &context)
126{
127 Q_UNUSED(context);
128 //kdDebug()<<k_funcinfo<<endl;
129 return true;
130}
131
132void PertView::getContext(Context::Pertview &context) const
133{
134 Q_UNUSED(context);
135 //kdDebug()<<k_funcinfo<<endl;
136}
137
138} //KPlato namespace
139
140#include "kptpertview.moc"