kplato

kptpertview.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003, 2004 Dag Andersen <danders@get2net.dk>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation;
00007    version 2 of the License.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019  
00020 #include "kptpertview.h"
00021 
00022 #include "kptview.h"
00023 #include "kptpertcanvas.h"
00024 #include "kptpart.h"
00025 #include "kptproject.h"
00026 #include "kptrelation.h"
00027 #include "kptcontext.h"
00028 
00029 #include <kdebug.h>
00030 
00031 #include <qsplitter.h>
00032 #include <qvbox.h>
00033 #include <qlayout.h>
00034 #include <qlistview.h>
00035 #include <qheader.h>
00036 #include <qpopupmenu.h>
00037 
00038 #include <kprinter.h>
00039 
00040 namespace KPlato
00041 {
00042 
00043 PertView::PertView( View *view, QWidget *parent, QLayout *layout )
00044     : QWidget( parent, "Pert view" ),
00045     m_mainview( view ),
00046     m_node( 0 )
00047 {
00048     init(layout);
00049 }
00050 
00051 PertView::~PertView()
00052 {
00053 }
00054 
00055 void PertView::init(QLayout */*layout*/)
00056 {
00057     //kdDebug()<<k_funcinfo<<endl;
00058     QGridLayout *gl = new QGridLayout(this, 1, 1, -1, -1, "Pert QGridLayout");
00059     m_canvasview = new PertCanvas(this);
00060         gl->addWidget(m_canvasview, 0, 0);
00061     draw();
00062     connect(m_canvasview, SIGNAL(rightButtonPressed(Node *, const QPoint &)), this, SLOT(slotRMBPressed(Node *,const QPoint &)));
00063     connect(m_canvasview, SIGNAL(updateView(bool)), m_mainview, SLOT(slotUpdate(bool)));
00064 
00065     connect(m_canvasview, SIGNAL(addRelation(Node*, Node*)), SLOT(slotAddRelation(Node*, Node*)));
00066     connect(m_canvasview, SIGNAL(modifyRelation(Relation*)), SLOT(slotModifyRelation(Relation*)));
00067 }    
00068 
00069 void PertView::draw() 
00070 {
00071     //kdDebug()<<k_funcinfo<<endl;
00072     m_canvasview->draw(m_mainview->getPart()->getProject());
00073     m_canvasview->show();
00074 }
00075 
00076 void PertView::slotRMBPressed(Node *node, const QPoint & point)
00077 {
00078     //kdDebug()<<k_funcinfo<<" node: "<<node->name()<<endl;
00079     m_node = node;
00080     if (node && (node->type() == Node::Type_Task || node->type() == Node::Type_Milestone)) {
00081         QPopupMenu *menu = m_mainview->popupMenu("task_popup");
00082         if (menu)
00083         {
00084             /*int id =*/ menu->exec(point);
00085             //kdDebug()<<k_funcinfo<<"id="<<id<<endl;
00086         }
00087         return;
00088     }
00089     if (node && node->type() == Node::Type_Summarytask) {
00090         QPopupMenu *menu = m_mainview->popupMenu("node_popup");
00091         if (menu)
00092         {
00093             /*int id =*/ menu->exec(point);
00094             //kdDebug()<<k_funcinfo<<"id="<<id<<endl;
00095         }
00096         return;
00097     }
00098     //TODO: Other nodetypes
00099 }
00100 
00101 void PertView::slotAddRelation(Node* par, Node* child)
00102 {
00103     kdDebug()<<k_funcinfo<<endl;
00104     emit addRelation(par, child);
00105 }
00106 
00107 void PertView::slotModifyRelation(Relation *rel)
00108 {
00109     kdDebug()<<k_funcinfo<<endl;
00110     emit modifyRelation(rel);
00111 }
00112 
00113 void PertView::print(KPrinter &printer)
00114 {
00115     Q_UNUSED(printer);
00116     kdDebug()<<k_funcinfo<<endl;
00117 
00118 }
00119 
00120 Node *PertView::currentNode()
00121 {
00122     return m_canvasview->selectedNode(); 
00123 }
00124 
00125 bool PertView::setContext(Context::Pertview &context)
00126 {
00127     Q_UNUSED(context);
00128     //kdDebug()<<k_funcinfo<<endl;
00129     return true;
00130 }
00131 
00132 void PertView::getContext(Context::Pertview &context) const
00133 {
00134     Q_UNUSED(context);
00135     //kdDebug()<<k_funcinfo<<endl;
00136 }
00137 
00138 }  //KPlato namespace
00139 
00140 #include "kptpertview.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys