kplato
kptpertcanvas.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 }
00104
00105 #endif
|