umbrello 25.04.1
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
|
#include <umldoc.h>
Classes | |
class | Private |
Public Slots | |
void | slotRemoveUMLObject (UMLObject *o) |
void | slotAutoSave () |
void | slotDiagramPopupMenu (QWidget *umlview, const QPoint &point) |
Signals | |
void | sigDiagramCreated (Uml::ID::Type id) |
void | sigDiagramRemoved (Uml::ID::Type id) |
void | sigDiagramRenamed (Uml::ID::Type t) |
void | sigDiagramChanged (Uml::DiagramType::Enum) |
void | sigObjectCreated (UMLObject *) |
void | sigObjectRemoved (UMLObject *) |
void | sigResetStatusbarProgress () |
void | sigSetStatusbarProgressSteps (int totalSteps) |
void | sigSetStatusbarProgress (int stepPosition) |
void | sigWriteToStatusBar (const QString &text) |
void | sigCurrentViewChanged () |
Static Public Member Functions | |
static bool | tagEq (const QString &tag, const QString &pattern) |
Private Types | |
typedef QMap< UMLFolder *, QList< QDomNode > > | DiagramsMap |
Private Member Functions | |
void | initSaveTimer () |
void | createDatatypeFolder () |
Private Attributes | |
Private * | m_d |
UMLFolder * | m_root [Uml::ModelType::N_MODELTYPES] |
UMLFolder * | m_datatypeRoot |
UMLStereotypeList | m_stereoList |
QString | m_Name |
name of this model as stored in the <UML:Model> tag | |
Uml::ID::Type | m_modelID |
xmi.id of this model in the <UML:Model> | |
int | m_count |
auxiliary counter for the progress bar | |
bool | m_modified |
QUrl | m_doc_url |
IDChangeLog * | m_pChangeLog |
bool | m_bLoading |
bool | m_importing |
QString | m_Doc |
QTimer * | m_pAutoSaveTimer |
Uml::ID::Type | m_nViewID |
bool | m_bTypesAreResolved |
UMLFolder * | m_pCurrentRoot |
bool | m_bClosing |
DiagramsModel * | m_diagramsModel |
ObjectsModel * | m_objectsModel |
StereotypesModel * | m_stereotypesModel |
qreal | m_resolution |
DiagramsMap | m_diagramsToLoad |
UMLDoc provides a document object for a document-view model.
The UMLDoc class provides a document object that can be used in conjunction with the classes UMLApp and UMLView to create a document-view model for standard KDE applications based on KApplication and KMainWindow. Thereby, the document object is created by the UMLApp instance and contains the document structure with the according methods for manipulation of the document data by UMLView objects. Also, UMLDoc contains the methods for serialization of the document data from and to files.
|
private |
Holds diagram xml nodes on loading
UMLDoc::UMLDoc | ( | ) |
Constructor for the fileclass of the application.
UMLDoc::~UMLDoc | ( | ) |
Destructor for the fileclass of the application.
void UMLDoc::activateAllViews | ( | ) |
Activate all the diagrams/views after loading so all their widgets keep their IDs.
void UMLDoc::addAssociation | ( | UMLAssociation * | assoc | ) |
Adds an association.
assoc | Pointer to the UMLAssociation to add. |
void UMLDoc::addDefaultDatatypes | ( | ) |
Calls the active code generator to create its default datatypes.
void UMLDoc::addDefaultStereotypes | ( | ) |
Add a stereotype if it doesn't already exist. Used by code generators, operations and attribute dialog.
void UMLDoc::addDiagramToLoad | ( | UMLFolder * | folder, |
QDomNode | node | ||
) |
Add a xml node containing a diagram to the list of diagrams to load. Helper function for loadDiagrams().
folder | pointer to UMFolder instance the diagrams belongs to |
node | xml document node containing the diagram |
void UMLDoc::addStereotype | ( | UMLStereotype * | s | ) |
Add a UMLStereotype to the application.
s | the stereotype to be added |
Adds a UMLObject that is already created but doesn't change any ids or signal. Use AddUMLObjectPaste if pasting.
object | The object to add. |
Adds an already created UMLView to the document, it gets assigned a new ID, if its name is already in use then the function appends a number to it to differentiate it from the others; this number is incremental so if number 1 is in use then it tries 2 and then 3 and so on
pView | Pointer to the UMLView to add. |
void UMLDoc::addView | ( | UMLView * | view | ) |
Adds a view to the document which represents the document contents. Usually this is your main view.
view | Pointer to the UMLView to add. |
Uml::ID::Type UMLDoc::assignNewID | ( | Uml::ID::Type | oldID | ) |
Assigns a New ID to an Object, and also logs the assignment to its internal ChangeLog.
oldID | The present ID of the object. |
UMLAssociationList UMLDoc::associations | ( | ) | const |
Returns a list of the associations in this UMLDoc.
void UMLDoc::beginPaste | ( | ) |
Opens a Paste session, deletes the old ChangeLog and creates an empty one.
void UMLDoc::changeCurrentView | ( | Uml::ID::Type | id | ) |
Changes the current view (diagram) to the view with the given ID.
id | The ID of the view to change to. |
|
virtual |
Read property of IDChangeLog* m_pChangeLog.
UMLClassifierList UMLDoc::classesAndInterfaces | ( | bool | includeNested = true | ) | const |
Returns a list of the classes, interfaces, and enumerations in this UMLDoc.
includeNested | Whether to include the concepts from nested packages (default: true.) |
void UMLDoc::closeDocument | ( | ) |
Closes the current document.
bool UMLDoc::closing | ( | ) | const |
Returns the m_bClosing flag.
UMLClassifierList UMLDoc::concepts | ( | bool | includeNested = true | ) | const |
Returns a list of the concepts in this UMLDoc.
includeNested | Whether to include the concepts from nested packages (default: true.) |
UMLDatatype * UMLDoc::createDatatype | ( | const QString & | name | ) |
Add a datatype if it doesn't already exist. Used by addDefaultDatatypes().
|
private |
Create the datatype folder and add it to the logical folder.
UMLView * UMLDoc::createDiagram | ( | UMLFolder * | folder, |
Uml::DiagramType::Enum | type, | ||
const QString & | name, | ||
Uml::ID::Type | id = Uml::ID::None |
||
) |
Creates a diagram of the given type.
folder | the folder in which tp create the diagram. |
type | the type of diagram to create |
name | the name for the diagram to create |
id | optional ID of new diagram |
QString UMLDoc::createDiagramName | ( | Uml::DiagramType::Enum | type, |
bool | askForName = true |
||
) |
Creates the name of the given diagram type.
type | The type of diagram to create. |
askForName | If true shows a dialog box asking for name, else uses a default name. |
UMLStereotype * UMLDoc::createStereotype | ( | const QString & | name | ) |
Creates a stereotype for the parent object.
name | the name of the stereotype |
UMLAssociation * UMLDoc::createUMLAssociation | ( | UMLObject * | a, |
UMLObject * | b, | ||
Uml::AssociationType::Enum | type | ||
) |
Creates AND adds an association between two UMLObjects. Used by refactoring assistant. NOTE: this method does not check if the association is valid / legal
a | The UMLObject "A" for the association (source) |
b | The UMLObject "B" for the association (destination) |
type | The association's type |
UMLFolder * UMLDoc::currentRoot | ( | ) | const |
Return the currently selected root folder. This will be an element from the m_root[] array.
UMLFolder * UMLDoc::datatypeFolder | ( | ) | const |
Returns the datatype folder.
UMLClassifierList UMLDoc::datatypes | ( | bool | includeInactive = false | ) | const |
Returns a list of the datatypes in this UMLDoc.
includeInactive | Include inactive datatypes which may have accrued by changing the active programming language. |
DiagramsModel * UMLDoc::diagramsModel | ( | ) | const |
QString UMLDoc::documentation | ( | ) | const |
Returns the documentation for the project.
qreal UMLDoc::dpiScale | ( | ) | const |
Returns scale factor for recalculation of document coordinates.
short UMLDoc::encoding | ( | QIODevice & | file | ) |
If the given XMI file has a processing instruction then extract the encoding info from the processing instruction. If that info is unrecognized then return ENC_OLD_ENC, else return the encoding found. If the file does not have a processing instruction then give a warning but return ENC_UNICODE. This is an optimistic assumption in the interest of best effort loading. The value ENC_UNKNOWN is only returned in case of a grave error.
file | The file to be checked. |
void UMLDoc::endPaste | ( | ) |
Closes a paste session, deletes the ChangeLog.
UMLEntityList UMLDoc::entities | ( | bool | includeNested = true | ) | const |
Returns a list of the entities in this UMLDoc.
includeNested | Whether to include the entities from nested packages (default: true.) |
UMLAssociation * UMLDoc::findAssociation | ( | Uml::AssociationType::Enum | assocType, |
const UMLObject * | roleAObj, | ||
const UMLObject * | roleBObj, | ||
bool * | swap = nullptr |
||
) | const |
Finds an association.
assocType | Type of the UMLAssociation to seek. |
roleAObj | Pointer to the role A UMLCanvasObject. |
roleBObj | Pointer to the role B UMLCanvasObject. |
swap | Optional pointer to boolean. The bool is set to true if the association matched with swapped roles, else it is set to false. |
UMLDatatype * UMLDoc::findDatatype | ( | QString | name, |
bool | includeInactive = false |
||
) |
Seek the datatype of the given name in the Datatypes folder.
name | Name of the datatype |
includeInactive | Include inactive datatypes in the search. |
UMLObject * UMLDoc::findObjectById | ( | Uml::ID::Type | id | ) |
UMLStereotype * UMLDoc::findOrCreateStereotype | ( | const QString & | name | ) |
Finds or creates a stereotype for the parent object.
name | the name of the stereotype |
UMLStereotype * UMLDoc::findStereotype | ( | const QString & | name | ) | const |
Finds a UMLStereotype by its name.
name | The name of the UMLStereotype to find. |
UMLStereotype * UMLDoc::findStereotypeById | ( | Uml::ID::Type | id | ) | const |
Find a UMLStereotype by its unique ID.
id | the unique ID |
UMLClassifier * UMLDoc::findUMLClassifier | ( | const QString & | name | ) |
Used to find a UMLClassifier by its name.
name | The name of the UMLObject to find. |
UMLObject * UMLDoc::findUMLObject | ( | const QString & | name, |
UMLObject::ObjectType | type = UMLObject::ot_UMLObject , |
||
UMLObject * | currentObj = nullptr |
||
) |
Used to find a UMLObject by its type and name.
name | The name of the UMLObject to find. |
type | ObjectType of the object to find (optional.) When the given type is ot_UMLObject the type is disregarded, i.e. the given name is the only search criterion. |
currentObj | Object relative to which to search (optional.) If given then the enclosing scope(s) of this object are searched before the global scope. |
UMLObject * UMLDoc::findUMLObjectRaw | ( | Uml::ModelType::Enum | modelType, |
const QString & | name, | ||
UMLObject::ObjectType | type = UMLObject::ot_UMLObject |
||
) |
UMLObject * UMLDoc::findUMLObjectRaw | ( | UMLFolder * | folder, |
const QString & | name, | ||
UMLObject::ObjectType | type = UMLObject::ot_UMLObject |
||
) |
UMLObject * UMLDoc::findUMLObjectRecursive | ( | Uml::ModelType::Enum | modelType, |
const QString & | name, | ||
UMLObject::ObjectType | type = UMLObject::ot_UMLObject |
||
) |
UMLObject * UMLDoc::findUMLObjectRecursive | ( | UMLFolder * | folder, |
const QString & | name, | ||
UMLObject::ObjectType | type = UMLObject::ot_UMLObject |
||
) |
UMLView * UMLDoc::findView | ( | Uml::DiagramType::Enum | type, |
const QString & | name, | ||
bool | searchAllScopes = false |
||
) | const |
Finds a view (diagram) by the type and name given.
type | The type of view to find. |
name | The name of the view to find. |
searchAllScopes | Search in all subfolders (default: false.) |
UMLView * UMLDoc::findView | ( | Uml::ID::Type | id | ) | const |
Finds a view (diagram) by the ID given to method.
id | The ID of the view to search for. |
bool UMLDoc::importing | ( | ) | const |
Returns true when importing file(s).
void UMLDoc::init | ( | ) |
Initialize the UMLDoc. To be called after the constructor, before anything else.
|
private |
Sets up the autosave timer.
bool UMLDoc::isModified | ( | ) | const |
Returns if the document is modified or not. Use this to determine if your document needs saving by the user on closing.
bool UMLDoc::isUnique | ( | const QString & | name | ) | const |
Returns true if the given name is unique within its scope.
name | The name to check. |
bool UMLDoc::isUnique | ( | const QString & | name, |
UMLPackage * | package | ||
) | const |
Returns true if the given name is unique within its scope of given package.
name | The name to check. |
package | The UMLPackage in which we have to determine the unique-ness |
bool UMLDoc::loadDiagrams1 | ( | ) |
Load all diagrams collected from the xmi file.
Loading diagrams is implemented as additional pass to avoid unresolved uml objects which are defined later in the xmi file.
bool UMLDoc::loadDiagramsFromXMI1 | ( | QDomNode & | node | ) |
void UMLDoc::loadExtensionsFromXMI1 | ( | QDomNode & | node | ) |
Loads umbrello specific extensions from XMI to the UMLDoc. The extension tags are: "docsettings", "diagrams", "listview", and "codegeneration".
|
virtual |
Load a given XMI model from a file. If the encoding of the file is already known it can be passed to the function. If this info isn't given, loadFromXMI will check which encoding was used.
file | The file to be loaded. |
encode | The encoding used. |
bool UMLDoc::loading | ( | ) | const |
Returns true when loading a document file.
bool UMLDoc::loadUMLObjectsFromXMI | ( | QDomElement & | element | ) |
Loads all UML objects from XMI into the current UMLDoc.
Uml::ID::Type UMLDoc::modelID | ( | ) | const |
Return the m_modelID (currently this a fixed value: Umbrello supports only a single document.)
QString UMLDoc::name | ( | ) | const |
Return the name of this model.
bool UMLDoc::newDocument | ( | ) |
Initializes the document generally.
ObjectsModel * UMLDoc::objectsModel | ( | ) | const |
bool UMLDoc::openDocument | ( | const QUrl & | url, |
const char * | format = nullptr |
||
) |
Loads the document by filename and format and emits the updateViews() signal.
url | The filename in KUrl format. |
format | The format (optional.) |
UMLPackageList UMLDoc::packages | ( | bool | includeNested = true , |
Uml::ModelType::Enum | model = Uml::ModelType::Logical |
||
) | const |
Returns a list of the packages in this UMLDoc,
void UMLDoc::print | ( | QPrinter * | pPrinter, |
DiagramPrintPage * | selectPage | ||
) |
Controls the printing of the program.
pPrinter | The printer (object) to use. |
selectPage | The DiagramPrintPage by which diagrams are selected for printing |
void UMLDoc::removeAllObjects | ( | ) |
Call to remove all objects in the current file.
void UMLDoc::removeAllViews | ( | ) |
Call to remove all the views (diagrams) in the current file.
void UMLDoc::removeAssociation | ( | UMLAssociation * | assoc, |
bool | doSetModified = true |
||
) |
Removes an association.
assoc | Pointer to the UMLAssociation to remove. |
doSetModified | Whether to mark the document as modified (default: true.) |
void UMLDoc::removeDatatype | ( | const QString & | name | ) |
Remove a datatype by name. Used when changing the active programming language.
void UMLDoc::removeDiagram | ( | Uml::ID::Type | id | ) |
Deletes a diagram from the current file.
Undo command
id | The ID of the diagram to delete. |
void UMLDoc::removeDiagramCmd | ( | Uml::ID::Type | id | ) |
Deletes a diagram from the current file.
id | The ID of the diagram to delete. |
void UMLDoc::removeStereotype | ( | UMLStereotype * | s | ) |
Remove a UMLStereotype from the application.
s | the stereotype to be removed |
Removes a view from the list of currently connected views.
view | Pointer to the UMLView to remove. |
enforceCurrentView | Switch to determine if we have a current view or not. Most of the time, we DO want this, except when exiting the program. |
void UMLDoc::renameChildUMLObject | ( | UMLObject * | o | ) |
Used to rename an operation or attribute of a classifier.
o | The attribute or operation to rename. |
void UMLDoc::renameDiagram | ( | Uml::ID::Type | id | ) |
Used to rename a document. This method takes care of everything. You just need to give the ID of the diagram to the method.
id | The ID of the diagram to rename. |
void UMLDoc::renameUMLObject | ( | UMLObject * | o | ) |
qreal UMLDoc::resolution | ( | ) | const |
Returns coordinates resolution for current document.
void UMLDoc::resolveTypes | ( | ) |
Type resolution pass.
UMLFolder * UMLDoc::rootFolder | ( | Uml::ModelType::Enum | mt | ) | const |
Return the predefined root folder of the given type.
Uml::ModelType::Enum UMLDoc::rootFolderType | ( | UMLObject * | obj | ) | const |
Return the corresponding Model_Type if the given object is one of the root folders. When the given object is not one of the root folders then return Uml::ModelType::N_MODELTYPES.
bool UMLDoc::saveDocument | ( | const QUrl & | url, |
const char * | format = nullptr |
||
) |
Saves the document using the given filename and format.
url | The filename in KUrl format. |
format | The format (optional.) |
bool UMLDoc::saveModified | ( | ) |
"save modified" - Asks the user for saving if the document is modified.
|
virtual |
This method is called for saving the given model as a XMI file. It is virtual and calls the corresponding saveToXMI() functions of the derived classes.
file | The file to be saved to. |
void UMLDoc::setCurrentRoot | ( | Uml::ModelType::Enum | rootType | ) |
Set the current root folder.
rootType | The type of the root folder to set. The element from m_root[] which is indexed by this type is selected. |
void UMLDoc::setDocumentation | ( | const QString & | doc | ) |
Sets the documentation for the project.
doc | The documentation to set for this UMLDoc. |
void UMLDoc::setImporting | ( | bool | state = true | ) |
Sets importing boolean flag to the value given.
state | value to set |
void UMLDoc::setLoading | ( | bool | state = true | ) |
Sets loading boolean flag to the value given.
state | value to set |
void UMLDoc::setLoadingError | ( | const QString & | text | ) |
void UMLDoc::setMainViewID | ( | Uml::ID::Type | viewID | ) |
Sets m_nViewID.
void UMLDoc::setModified | ( | bool | modified = true | ) |
Sets the modified flag for the document after a modifying action on the view connected to the document.
modified | The value to set the modified flag to. |
void UMLDoc::setName | ( | const QString & | name | ) |
Set the name of this model.
void UMLDoc::setResolution | ( | qreal | resolution | ) |
Set coordinates resolution for current document.
resolution | document resolution in DPI |
void UMLDoc::settingsChanged | ( | Settings::OptionState & | optionState | ) |
Sets the default settings to the given settings.
optionState | settings |
void UMLDoc::setupSignals | ( | ) |
Sets up the signals needed by the program for it to work.
void UMLDoc::setUrl | ( | const QUrl & | url | ) |
Sets the URL of the document.
url | The KUrl to set. |
void UMLDoc::setUrlUntitled | ( | ) |
Sets the URL of the document to "Untitled".
|
signal |
The diagram being displayed has changed. UMLApp uses this to keep its menu items state up to date.
|
signal |
|
signal |
|
signal |
|
signal |
void UMLDoc::signalDiagramRenamed | ( | UMLView * | view | ) |
Signal a view/diagram has been renamed.
void UMLDoc::signalUMLObjectCreated | ( | UMLObject * | o | ) |
Signal that a UMLObject has been created.
o | The object that has been created. |
|
signal |
|
signal |
|
signal |
Reset the status bar.
|
signal |
Set the progress position of the progressbar.
stepPosition | The step position to set. |
|
signal |
Set the total range of the progressbar.
totalSteps | Total range of the progressbar (0..totalSteps) |
|
signal |
Write text to the status bar.
|
slot |
Called after a specified time to autosave the document.
|
slot |
Make a popup menu for the tabs signalled from tabWidget's contextMenu().
|
slot |
Simple removal of an object.
object | the UMLObject to be removed |
const UMLStereotypeList & UMLDoc::stereotypes | ( | ) | const |
Returns a list of the stereotypes in this UMLDoc.
StereotypesModel * UMLDoc::stereotypesModel | ( | ) | const |
|
static |
Function for comparing tags in XMI files.
QString UMLDoc::uniqueViewName | ( | const Uml::DiagramType::Enum | type | ) | const |
Returns a name for the new object, appended with a number if the default name is taken e.g. class diagram, class diagram_1 etc.
type | the diagram type |
const QUrl & UMLDoc::url | ( | ) | const |
Returns the KUrl of the document.
bool UMLDoc::validateXMI1Header | ( | QDomNode & | headerNode | ) |
Ensures the XMI file is a valid UML file. Currently only checks for metamodel=UML.
headerNode | The <XMI.header> node |
UMLViewList UMLDoc::viewIterator | ( | ) | const |
Return the list of views for this document.
UMLViewList UMLDoc::views | ( | Uml::DiagramType::Enum | type = Uml::DiagramType::Undefined | ) | const |
Return a list of filtered views of this document by type.
type | diagram type to filter |
void UMLDoc::writeToStatusBar | ( | const QString & | text | ) |
Write text to the status bar.
text | the text to write |
|
private |
True while closeDocument() is executing.
|
private |
true if the we're loading a new document
|
private |
True when type resolution pass has been executed.
|
private |
auxiliary counter for the progress bar
|
private |
|
private |
Predefined root folder for datatypes, contained in m_root[Uml::mt_Logical]
|
private |
|
private |
|
private |
Documentation for the project.
|
private |
|
private |
true if the we're importing
|
private |
xmi.id of this model in the <UML:Model>
|
private |
|
private |
name of this model as stored in the <UML:Model> tag
|
private |
Auxiliary to <docsettings> processing
|
private |
|
private |
Used for autosave
|
private |
Contains all the UMLObject id changes of paste session.
|
private |
Auxiliary variable for currentRoot(): m_pCurrentRoot is only used if UMLApp::app()->currentView() returns 0.
|
private |
Holds widgets coordinates resolution. Unit is dpi.
|
private |
Array of predefined root folders.
|
private |
The UMLDoc is the sole owner of all stereotypes. UMLStereotype instances are reference counted. When a UMLStereotype is no longer referenced anywhere, its refcount drops to zero. It is then removed from the m_stereoList and it is physically deleted.
|
private |