umbrello/umbrello
umldoc.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef UMLDOC_H
00013 #define UMLDOC_H
00014
00015
00016 #include <typeinfo>
00017
00018
00019
00020
00021 #include <kurl.h>
00022
00023
00024 #include "listpopupmenu.h"
00025 #include "umlnamespace.h"
00026 #include "optionstate.h"
00027 #include "umlobjectlist.h"
00028 #include "umlassociationlist.h"
00029 #include "umlclassifierlist.h"
00030 #include "umlentitylist.h"
00031 #include "umlviewlist.h"
00032 #include "umlstereotypelist.h"
00033 #include "umlpackagelist.h"
00034
00035 #define ENC_UNKNOWN 0
00036 #define ENC_UNICODE 1
00037 #define ENC_OLD_ENC 2
00038
00039
00040
00041 class QDomNode;
00042 class QPrinter;
00043
00044
00045 class IDChangeLog;
00046 class UMLPackage;
00047 class UMLFolder;
00048 class DiagramPrintPage;
00049
00066 class UMLDoc : public QObject {
00067 Q_OBJECT
00068 public:
00072 UMLDoc();
00073
00077 ~UMLDoc();
00078
00083 void init();
00084
00091 void addView(UMLView *view);
00092
00100 void removeView(UMLView *view , bool enforceOneView = true );
00101
00105 void setMainViewID(Uml::IDType viewID);
00106
00113 void setModified(bool _m=true);
00114
00122 bool isModified() {
00123 return m_modified;
00124 }
00125
00132 bool saveModified();
00133
00139 bool newDocument();
00140
00144 void closeDocument();
00145
00154 bool openDocument(const KUrl& url, const char *format=0);
00155
00163 bool saveDocument(const KUrl& url, const char *format=0);
00164
00170 const KUrl& url() const;
00171
00177 void setUrl(const KUrl& url);
00178
00182 void setupSignals();
00183
00190 bool isUnique(const QString &name);
00191
00199 bool isUnique(const QString &name, UMLPackage *package);
00200
00204 UMLStereotype* findOrCreateStereotype(const QString &name);
00205
00215 UMLAssociation* createUMLAssociation(UMLObject *a, UMLObject *b, Uml::Association_Type type);
00216
00222 void addAssociation(UMLAssociation *pAssoc);
00223
00230 void removeAssociation(UMLAssociation *pAssoc, bool doSetModified = true);
00231
00244 UMLAssociation * findAssociation(Uml::Association_Type assocType,
00245 const UMLObject *roleAObj,
00246 const UMLObject *roleBObj,
00247 bool *swap = NULL);
00248
00258 UMLView* createDiagram(UMLFolder *folder, Uml::Diagram_Type type, bool askForName = true);
00259
00267 void removeUMLObject(UMLObject*o);
00268
00275 void renameDiagram(Uml::IDType id);
00276
00283 void renameUMLObject(UMLObject *o);
00284
00290 void renameChildUMLObject(UMLObject *o);
00291
00292
00298 void changeCurrentView(Uml::IDType id);
00299
00305 void removeDiagram(Uml::IDType id);
00306
00313 UMLObject* findObjectById(Uml::IDType id);
00314
00328 UMLObject* findUMLObject(const QString &name,
00329 Uml::Object_Type type = Uml::ot_UMLObject,
00330 UMLObject *currentObj = NULL);
00331
00341 UMLObject* findObjectByAuxId(const QString &idStr);
00342
00348 UMLClassifier * findUMLClassifier (const QString &name);
00349
00356 UMLStereotype * findStereotype(const QString &name);
00357
00364 UMLView * findView(Uml::IDType id);
00365
00374 UMLView * findView(Uml::Diagram_Type type, const QString &name,
00375 bool searchAllScopes = false);
00376
00380 void setName(const QString& name);
00381
00385 QString getName() const;
00386
00391 Uml::IDType getModelID() const;
00392
00400 virtual void saveToXMI(QIODevice& file);
00401
00408 short getEncoding(QIODevice & file);
00409
00418 virtual bool loadFromXMI(QIODevice& file, short encode = ENC_UNKNOWN);
00419
00426 bool validateXMIHeader(QDomNode& headerNode);
00427
00433 bool loadUMLObjectsFromXMI( QDomElement & element );
00434
00440 void loadExtensionsFromXMI(QDomNode & node);
00441
00447 bool loadDiagramsFromXMI( QDomNode & node );
00448
00452 void signalDiagramRenamed(UMLView * pView );
00453
00457 void removeAllViews();
00458
00464 void signalUMLObjectCreated(UMLObject * o);
00465
00471 UMLFolder * getDatatypeFolder() {
00472 return m_datatypeRoot;
00473 }
00474
00482 UMLClassifierList getConcepts(bool includeNested = true);
00483
00491 UMLClassifierList getClasses(bool includeNested = true);
00492
00500 UMLClassifierList getClassesAndInterfaces(bool includeNested = true);
00501
00509 UMLEntityList getEntities(bool includeNested = true);
00510
00518 UMLClassifierList getInterfaces(bool includeNested = true);
00519
00525 UMLClassifierList getDatatypes();
00526
00532 UMLAssociationList getAssociations();
00533
00534
00540 UMLPackageList getPackages(bool includeNested = true);
00541
00547 void print(QPrinter * pPrinter, DiagramPrintPage * selectPage);
00548
00554 UMLViewList getViewIterator();
00555
00564 bool assignNewIDs(UMLObject* Obj);
00565
00573 bool addUMLObject(UMLObject * object);
00574
00585 bool addUMLView(UMLView * pView );
00586
00590 UMLFolder *getRootFolder(Uml::Model_Type mt);
00591
00598 Uml::Model_Type rootFolderType(UMLObject *obj);
00599
00604 UMLFolder *currentRoot();
00605
00613 void setCurrentRoot(Uml::Model_Type rootType);
00614
00620 virtual IDChangeLog* getChangeLog();
00621
00625 void endPaste();
00626
00631 void beginPaste();
00632
00640 Uml::IDType assignNewID(Uml::IDType OldID);
00641
00647 QString getDocumentation() const {
00648 return m_Doc;
00649 }
00650
00656 void setDocumentation(const QString &doc) {
00657 m_Doc = doc;
00658 }
00659
00664 void activateAllViews();
00665
00669 void settingsChanged(Settings::OptionState optionState);
00670
00671
00675 int getFileVersion(void) {return version;}
00676
00682 QString uniqViewName(const Uml::Diagram_Type type);
00683
00687 bool loading() const;
00688
00692 void setLoading(bool state = true);
00693
00697 bool closing() const;
00698
00702 void addDefaultDatatypes();
00703
00708 void createDatatype(const QString &name);
00709
00713 UMLStereotype * findStereotypeById(Uml::IDType id);
00714
00718 void addStereotype(UMLStereotype *s);
00719
00723 void removeStereotype(UMLStereotype *s);
00724
00729 void addDefaultStereotypes();
00730
00736 const UMLStereotypeList& getStereotypes();
00737
00741 void writeToStatusBar(const QString &text);
00742
00746 void resolveTypes();
00747
00752 ListPopupMenu::Menu_Type getPopupMenuSelection(QAction* action);
00753
00754 private:
00758 void initSaveTimer();
00759
00763 UMLFolder *m_root[Uml::N_MODELTYPES];
00768 UMLFolder *m_datatypeRoot;
00769
00777 UMLStereotypeList m_stereoList;
00778
00779 QString m_Name;
00780 Uml::IDType m_modelID;
00781 int m_count;
00782 bool m_modified;
00783 KUrl m_doc_url;
00784
00788 IDChangeLog* m_pChangeLog;
00789
00793 bool m_bLoading;
00794
00798 QString m_Doc;
00799
00803 QTimer * m_pAutoSaveTimer;
00804
00808 int version;
00809
00813 Uml::IDType m_nViewID;
00814
00818 bool m_bTypesAreResolved;
00819
00824 ListPopupMenu* m_pTabPopupMenu;
00825
00831 UMLFolder * m_pCurrentRoot;
00832
00836 bool m_bClosing;
00837
00838 public slots:
00839
00840 void slotRemoveUMLObject(UMLObject*o);
00841
00845 void slotAutoSave();
00846
00851 void slotDiagramPopupMenu(QWidget* umlview, const QPoint& point);
00852
00853 signals:
00854 void sigDiagramCreated(Uml::IDType id);
00855 void sigDiagramRemoved(Uml::IDType id);
00856 void sigDiagramRenamed(Uml::IDType t);
00857 void sigDiagramChanged(Uml::Diagram_Type);
00858
00859 void sigObjectCreated(UMLObject *);
00860 void sigObjectRemoved(UMLObject *);
00861
00865 void sigResetStatusbarProgress();
00866
00872 void sigSetStatusbarProgressSteps(int totalSteps);
00873
00874
00880 void sigSetStatusbarProgress(int stepPosition);
00881
00885 void sigWriteToStatusBar(const QString &text);
00886
00891 void sigCurrentViewChanged();
00892
00893
00894 };
00895
00896 #endif // UMLDOC_H