kplato

kptpertcanvas.h

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 #ifndef KPTPERTCANVAS_H
00021 #define KPTPERTCANVAS_H
00022 
00023 #include "kptnode.h"
00024 #include "kptproject.h"
00025 
00026 #include <qcanvas.h>
00027 #include <qmemarray.h>
00028 #include <qptrdict.h>
00029 
00030 class QTimer;
00031 class QPainter;
00032 class QPoint;
00033 class QSize;
00034 
00035 namespace KPlato
00036 {
00037 
00038 class PertNodeItem;
00039 
00040 class PertCanvas : public QCanvasView
00041 {
00042     Q_OBJECT
00043 
00044 public:
00045     PertCanvas( QWidget *parent );
00046     virtual ~PertCanvas();
00047 
00048     void draw(Project& project);
00049     void clear();
00050     QSize canvasSize();
00051 
00052     PertNodeItem *selectedItem();
00053 
00054     int verticalGap() { return m_verticalGap; }
00055     int horizontalGap() { return m_horizontalGap; }
00056     QSize itemSize() { return m_itemSize; }
00057 
00058     void setColumn(int row, int col) { m_rows.at(row)[col] = true; }
00059 
00060     void mapNode(PertNodeItem *item);
00061     void mapChildNode(PertNodeItem *parentItem, PertNodeItem *childItem, Relation::Type type);
00062     
00063     Node *selectedNode();
00064 
00065 protected:
00066     void drawRelations();
00067 
00068     void createChildItems(PertNodeItem *node);
00069     PertNodeItem *createNodeItem(Node *node);
00070 
00071     void contentsMousePressEvent ( QMouseEvent * e );
00072     void contentsMouseReleaseEvent ( QMouseEvent * e );
00073 
00074 signals:
00075     void rightButtonPressed(Node *node, const QPoint & point);
00076     void updateView(bool calculate);
00077     void addRelation(Node *par, Node *child);
00078     void modifyRelation(Relation *rel);
00079 
00080 
00081 private:
00082     QCanvas *m_canvas;
00083 
00084     QTimer *m_scrollTimer;
00085     bool m_mousePressed;
00086     bool m_printing;
00087 
00088     int m_verticalGap;
00089     int m_horizontalGap;
00090     QSize m_itemSize;
00091 
00092     QPtrDict<PertNodeItem> m_nodes;
00093     QPtrList<Relation> m_relations;
00094 
00095     QPtrList<QMemArray<bool> > m_rows;
00096 
00097 #ifndef NDEBUG
00098     void printDebug( int );
00099 #endif
00100 
00101 };
00102 
00103 }  //KPlato namespace
00104 
00105 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys