flowpart.h

00001 /***************************************************************************
00002  *   Copyright (C) 2003-2005 by David Saxton                               *
00003  *   david@bluehaze.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 
00011 #ifndef FLOWPART_H
00012 #define FLOWPART_H
00013 
00014 #include "cnitem.h"
00015 
00016 class ICNDocument;
00017 class Node;
00018 class FlowCode;
00019 class FlowCodeDocument;
00020 class FlowPart;
00021 class FPNode;
00022 class QPixmap;
00023 class QSize;
00024 
00025 typedef QValueList<FlowPart*> FlowPartList;
00026 
00034 class FlowPart : public CNItem
00035 {
00036 Q_OBJECT
00037 public:
00038         enum FlowSymbol
00039         {
00040                 ps_process, // Process - Plain rectangular box
00041                 ps_call, // Call - Rectangular box with double vertical lines at either end
00042                 ps_io, // I/O - Slanter rectangular box
00043                 ps_round, // Start/End - Rounded rectangular box
00044                 ps_decision, // Decision - Diamond shape
00045                 ps_other // Custom shape, which is ignored by FlowPart
00046         };
00047         FlowPart( ICNDocument *icnDocument, bool newItem, const QString &id );
00048         virtual ~FlowPart();
00049         
00050         virtual void generateMicrobe( FlowCode */*code*/ ) = 0;
00054         void setOrientation( uint orientation );
00055         uint orientation() const { return m_orientation; }
00059         uint allowedOrientations() const;
00060         virtual ItemData itemData() const;
00061         virtual void restoreFromItemData( const ItemData &itemData );
00065         virtual void setCaption( const QString &caption );
00076         FlowPart* endPart( QStringList ids, FlowPartList *previousParts = 0 );
00087         void handleIfElse( FlowCode *code, const QString &case1Statement, const QString &case2Statement,
00088                                            const QString &case1, const QString &case2 );
00093         FlowPart* outputPart( const QString& internalNodeId );
00098         FlowPartList inputParts( const QString& id );
00102         FlowPartList inputParts();
00108         FlowPartList outputParts();
00112         void orientationPixmap( uint orientation, QPixmap & pm ) const;
00113         virtual Variant * createProperty( const QString & id, Variant::Type::Value type );
00114         
00115 public slots:
00120         void updateVarNames();
00124         void varNameChanged( QVariant newValue, QVariant oldValue );
00130         void slotUpdateFlowPartVariables();
00131 
00132 protected:
00133         virtual void updateAttachedPositioning();
00137         virtual void filterEndPartIDs( QStringList *ids ) { Q_UNUSED(ids); }
00143         virtual void drawShape( QPainter &p );
00149         QString gotoCode( const QString& internalNodeId );
00155         void createStdInput();
00161         void createStdOutput();
00167         void createAltOutput();
00171         void initSymbol( FlowPart::FlowSymbol symbol, int width = 48 );
00172         
00173         void initProcessSymbol() { initSymbol( FlowPart::ps_process ); }
00174         void initCallSymbol() { initSymbol( FlowPart::ps_call ); }
00175         void initIOSymbol() { initSymbol( FlowPart::ps_io ); }
00176         void initRoundedRectSymbol() { initSymbol( FlowPart::ps_round ); }
00177         void initDecisionSymbol() { initSymbol( FlowPart::ps_decision ); }
00178 
00179         QString m_caption;
00180         uint m_orientation;
00181         FPNode *m_stdInput;
00182         FPNode *m_stdOutput;
00183         FPNode *m_altOutput;
00184         QGuardedPtr<FlowCodeDocument> m_pFlowCodeDocument;
00185         
00186         virtual void postResize();
00187         void updateNodePositions();
00188         
00189 private:
00190         FlowSymbol m_flowSymbol;
00191 };
00192 typedef QValueList<FlowPart*> FlowPartList;
00193 
00194 #endif
00195 
00196 
00197 

Generated on Tue May 8 17:05:30 2007 for KTechLab by  doxygen 1.5.1