umbrello API Documentation

umldoc.h

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2002-2007                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 #ifndef UMLDOC_H
00013 #define UMLDOC_H
00014 
00015 #ifdef HAVE_CONFIG_H
00016 #include <config.h>
00017 #endif
00018 
00019 // system includes
00020 #include <typeinfo>
00021 
00022 // qt includes
00023 #include <qdatastream.h>
00024 #include <qmap.h>
00025 #include <qdict.h>
00026 #include <qptrstack.h>
00027 
00028 // kde includes
00029 #include <kurl.h>
00030 #include <kdockwidget.h>
00031 #include <kpopupmenu.h>
00032 
00033 // app includes
00034 #include "umlnamespace.h"
00035 #include "optionstate.h"
00036 #include "umlobjectlist.h"
00037 #include "umlassociationlist.h"
00038 #include "umlclassifierlist.h"
00039 #include "umlviewlist.h"
00040 #include "umlstereotypelist.h"
00041 
00042 #define ENC_UNKNOWN 0
00043 #define ENC_UNICODE 1
00044 #define ENC_OLD_ENC 2
00045 
00046 
00047 // forward declarations
00048 class QDomNode;
00049 class QFile;
00050 class QSplitter;
00051 
00052 class KPrinter;
00053 
00054 class DocWindow;
00055 class IDChangeLog;
00056 class ObjectWidget;
00057 class UMLWidget;
00058 class UMLPackage;
00059 class UMLFolder;
00060 
00077 class UMLDoc : public QObject {
00078     Q_OBJECT
00079 public:
00083     UMLDoc();
00084 
00088     ~UMLDoc();
00089 
00094     void init();
00095 
00102     void addView(UMLView *view);
00103 
00111     void removeView(UMLView *view , bool enforceOneView = true );
00112 
00116     void setMainViewID(Uml::IDType viewID);
00117 
00126     void setModified(bool _m=true, bool addToUndo=true);
00127 
00135     bool isModified() {
00136         return m_modified;
00137     }
00138 
00145     bool saveModified();
00146 
00152     bool newDocument();
00153 
00157     void closeDocument();
00158 
00167     bool openDocument(const KURL& url, const char *format=0);
00168 
00176     bool saveDocument(const KURL& url, const char *format=0);
00177 
00183     const KURL& URL() const;
00184 
00190     void setURL(const KURL& url);
00191 
00195     void setupSignals();
00196 
00203     bool isUnique(const QString &name);
00204 
00211     bool isUnique(const QString &name, UMLPackage *package);
00212 
00216     UMLStereotype* findOrCreateStereotype(const QString &name);
00217 
00227     UMLAssociation* createUMLAssociation(UMLObject *a, UMLObject *b, Uml::Association_Type type);
00228 
00234     void addAssociation(UMLAssociation *pAssoc);
00235 
00242     void removeAssociation(UMLAssociation *pAssoc, bool doSetModified = true);
00243 
00256     UMLAssociation * findAssociation(Uml::Association_Type assocType,
00257                                      const UMLObject *roleAObj,
00258                                      const UMLObject *roleBObj,
00259                                      bool *swap = NULL);
00260 
00269     void createDiagram(UMLFolder *folder, Uml::Diagram_Type type, bool askForName = true);
00270 
00278     void removeUMLObject(UMLObject*o);
00279 
00286     void renameDiagram(Uml::IDType id);
00287 
00294     void renameUMLObject(UMLObject *o);
00295 
00301     void renameChildUMLObject(UMLObject *o);
00302 
00303 
00309     void  changeCurrentView(Uml::IDType id);
00310 
00316     void removeDiagram(Uml::IDType id);
00317 
00324     UMLObject* findObjectById(Uml::IDType id);
00325 
00339     UMLObject* findUMLObject(const QString &name,
00340                              Uml::Object_Type type = Uml::ot_UMLObject,
00341                              UMLObject *currentObj = NULL);
00342 
00352     UMLObject* findObjectByAuxId(const QString &idStr);
00353 
00359     UMLClassifier * findUMLClassifier (const QString &name);
00360 
00367     UMLStereotype * findStereotype(const QString &name);
00368 
00375     UMLView * findView(Uml::IDType id);
00376 
00385     UMLView * findView(Uml::Diagram_Type type, const QString &name,
00386                        bool searchAllScopes = false);
00387 
00391     void setName(const QString& name);
00392 
00396     QString getName() const;
00397 
00402     Uml::IDType getModelID() const;
00403 
00411     virtual void saveToXMI(QIODevice& file);
00412 
00419     short getEncoding(QIODevice & file);
00420 
00429     virtual bool loadFromXMI(QIODevice& file, short encode = ENC_UNKNOWN);
00430 
00437     bool validateXMIHeader(QDomNode& headerNode);
00438 
00444     bool loadUMLObjectsFromXMI( QDomElement & element );
00445 
00451     void loadExtensionsFromXMI(QDomNode & node);
00452 
00458     bool loadDiagramsFromXMI( QDomNode & node );
00459 
00463     void signalDiagramRenamed(UMLView * pView );
00464 
00468     void removeAllViews();
00469 
00475     void signalUMLObjectCreated(UMLObject * o);
00476 
00482     UMLFolder * getDatatypeFolder() {
00483         return m_datatypeRoot;
00484     }
00485 
00493     UMLClassifierList getConcepts(bool includeNested = true);
00494 
00502     UMLClassifierList getClasses(bool includeNested = true);
00503 
00511     UMLClassifierList getClassesAndInterfaces(bool includeNested = true);
00512 
00520     UMLClassifierList getInterfaces(bool includeNested = true);
00521 
00527     UMLClassifierList getDatatypes();
00528 
00534     UMLAssociationList getAssociations();
00535 
00541     void print(KPrinter * pPrinter);
00542 
00548     UMLViewList getViewIterator();
00549 
00558     bool assignNewIDs(UMLObject* Obj);
00559 
00567     bool addUMLObject(UMLObject * object);
00568 
00579     bool addUMLView(UMLView * pView );
00580 
00584     UMLFolder *getRootFolder(Uml::Model_Type mt);
00585 
00592     Uml::Model_Type rootFolderType(UMLObject *obj);
00593 
00598     UMLFolder *currentRoot();
00599 
00607     void setCurrentRoot(Uml::Model_Type rootType);
00608 
00614     virtual IDChangeLog* getChangeLog();
00615 
00619     void endPaste();
00620 
00625     void beginPaste();
00626 
00634     Uml::IDType assignNewID(Uml::IDType OldID);
00635 
00641     QString getDocumentation() const {
00642         return m_Doc;
00643     }
00644 
00650     void setDocumentation(const QString &doc) {
00651         m_Doc = doc;
00652     }
00653 
00658     void activateAllViews();
00659 
00663     void settingsChanged(Settings::OptionState optionState);
00664 
00665 
00669     int getFileVersion(void) {return version;}
00670 
00675     void loadUndoData();
00676 
00681     void loadRedoData();
00682 
00687     void addToUndoStack();
00688 
00693     void clearUndoStack();
00694 
00699     void clearRedoStack();
00700 
00706     QString uniqViewName(const Uml::Diagram_Type type);
00707 
00711     bool loading() const;
00712 
00716     void setLoading(bool state = true);
00717 
00721     void addDefaultDatatypes();
00722 
00727     void createDatatype(const QString &name);
00728 
00732     UMLStereotype * findStereotypeById(Uml::IDType id);
00733 
00737     void addStereotype(const UMLStereotype *s);
00738 
00742     void removeStereotype(const UMLStereotype *s);
00743 
00748     void addDefaultStereotypes();
00749 
00755     const UMLStereotypeList& getStereotypes();
00756 
00760     void writeToStatusBar(const QString &text);
00761 
00765     void resolveTypes();
00766 
00767 private:
00771     void initSaveTimer();
00772 
00776     UMLFolder *m_root[Uml::N_MODELTYPES];
00781     UMLFolder *m_datatypeRoot;
00782 
00790     UMLStereotypeList m_stereoList;
00791 
00792     QString m_Name; 
00793     Uml::IDType m_modelID; 
00794     int m_count;   
00795     bool m_modified;
00796     KURL m_doc_url;
00797 
00801     IDChangeLog* m_pChangeLog;
00802 
00806     bool m_bLoading;
00807 
00811     QString m_Doc;
00812 
00816     QTimer * m_pAutoSaveTimer;
00817 
00821     int version;
00822 
00829     QPtrList<QDataStream> undoStack;
00830 
00835     QPtrList<QDataStream> redoStack;
00836 
00840     Uml::IDType m_nViewID;
00841 
00845     bool m_bTypesAreResolved;
00846 
00851     KPopupMenu* m_pTabPopupMenu;
00852 
00858     UMLFolder * m_pCurrentRoot;
00859 
00860 public slots:
00861 
00862     void slotRemoveUMLObject(UMLObject*o);
00863 
00867     void slotAutoSave();
00868 
00873     void slotDiagramPopupMenu(QWidget* umlview, const QPoint& point);
00874 
00875 signals:
00876     void sigDiagramCreated(Uml::IDType id);
00877     void sigDiagramRemoved(Uml::IDType id);
00878     void sigDiagramRenamed(Uml::IDType t);
00879     void sigDiagramChanged(Uml::Diagram_Type);
00880 
00881     void sigObjectCreated(UMLObject *);
00882     void sigObjectRemoved(UMLObject *);
00883 
00887     void sigResetStatusbarProgress();
00888 
00894     void sigSetStatusbarProgressSteps(int totalSteps);
00895 
00896 
00902     void sigSetStatusbarProgress(int stepPosition);
00903 
00907     void sigWriteToStatusBar(const QString &text);
00908 
00913     void sigCurrentViewChanged();
00914 
00915 
00916 };
00917 
00918 #endif // UMLDOC_H
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:00 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003