Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SDK
Umbrello
Commits
19e25728
Commit
19e25728
authored
May 24, 2014
by
Ralf Habacker
Browse files
Add zargo file import support (reading of embedded xmi file).
CCBUG:56184
parent
d22ed2f5
Changes
5
Hide whitespace changes
Inline
Side-by-side
umbrello/CMakeLists.txt
View file @
19e25728
...
...
@@ -404,6 +404,7 @@ set(libumbrello_SRCS
folder.cpp
foreignkeyconstraint.cpp
icon_utils.cpp
import_argo.cpp
import_rose.cpp
layoutgenerator.cpp
listpopupmenu.cpp
...
...
umbrello/import_argo.cpp
0 → 100644
View file @
19e25728
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2006-2014 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
// own header
#include "import_argo.h"
// app includes
#include "debug_utils.h"
#include "uml.h"
#include "umldoc.h"
// kde includes
#include <klocale.h>
#include <KTempDir>
#include <KZip>
// qt includes
#include <QFile>
#include <QStringList>
#include <QXmlStreamReader>
static
void
reportError
(
const
QXmlStreamReader
&
xml
,
const
KZip
&
zipFile
,
const
QString
&
fileName
)
{
uError
()
<<
xml
.
name
()
<<
"in file"
<<
zipFile
.
fileName
()
<<
":"
<<
fileName
;
}
bool
Import_Argo
::
loadFromArgoFile
(
const
KZip
&
zipFile
,
const
QString
&
fileName
)
{
const
KArchiveFile
*
file
=
static_cast
<
const
KArchiveFile
*>
(
zipFile
.
directory
()
->
entry
(
fileName
));
if
(
!
file
)
return
false
;
QXmlStreamReader
xml
;
xml
.
addData
(
file
->
data
());
while
(
!
xml
.
atEnd
())
{
xml
.
readNext
();
if
(
xml
.
name
()
==
"member"
)
{
QXmlStreamAttributes
attributes
=
xml
.
attributes
();
QString
type
=
attributes
.
value
(
"type"
).
toString
();
QString
name
=
attributes
.
value
(
"name"
).
toString
();
if
(
type
==
"xmi"
)
loadFromXMIFile
(
zipFile
,
name
);
else
if
(
type
==
"pgml"
)
loadFromPGMLFile
(
zipFile
,
name
);
else
if
(
type
==
"todo"
)
loadFromTodoFile
(
zipFile
,
name
);
else
uError
()
<<
"unknown file type"
<<
type
<<
"in file"
<<
zipFile
.
fileName
()
<<
":"
<<
fileName
;
}
}
if
(
xml
.
hasError
())
{
reportError
(
xml
,
zipFile
,
fileName
);
return
false
;
}
return
true
;
}
bool
Import_Argo
::
loadFromPGMLFile
(
const
KZip
&
zipFile
,
const
QString
&
fileName
)
{
const
KArchiveFile
*
file
=
static_cast
<
const
KArchiveFile
*>
(
zipFile
.
directory
()
->
entry
(
fileName
));
if
(
!
file
)
return
false
;
QXmlStreamReader
xml
;
xml
.
addData
(
file
->
data
());
while
(
!
xml
.
atEnd
())
{
xml
.
readNext
();
uDebug
()
<<
"unhandled tag"
<<
xml
.
name
()
<<
"in file"
<<
zipFile
.
fileName
()
<<
":"
<<
fileName
;
}
if
(
xml
.
hasError
())
{
reportError
(
xml
,
zipFile
,
fileName
);
return
false
;
}
return
true
;
}
bool
Import_Argo
::
loadFromTodoFile
(
const
KZip
&
zipFile
,
const
QString
&
fileName
)
{
const
KArchiveFile
*
file
=
static_cast
<
const
KArchiveFile
*>
(
zipFile
.
directory
()
->
entry
(
fileName
));
if
(
!
file
)
return
false
;
QXmlStreamReader
xml
;
xml
.
addData
(
file
->
data
());
while
(
!
xml
.
atEnd
())
{
xml
.
readNext
();
uDebug
()
<<
"unhandled tag"
<<
xml
.
name
()
<<
"in file"
<<
zipFile
.
fileName
()
<<
":"
<<
fileName
;
}
if
(
xml
.
hasError
())
{
reportError
(
xml
,
zipFile
,
fileName
);
return
false
;
}
return
true
;
}
bool
Import_Argo
::
loadFromXMIFile
(
const
KZip
&
zipFile
,
const
QString
&
fileName
)
{
const
KArchiveFile
*
file
=
static_cast
<
const
KArchiveFile
*>
(
zipFile
.
directory
()
->
entry
(
fileName
));
if
(
!
file
)
return
false
;
KTempDir
tmpDir
;
tmpDir
.
setAutoRemove
(
true
);
file
->
copyTo
(
tmpDir
.
name
());
QFile
xmiFile
(
tmpDir
.
name
()
+
file
->
name
());
if
(
!
xmiFile
.
open
(
QIODevice
::
ReadOnly
))
{
return
false
;
}
return
UMLApp
::
app
()
->
document
()
->
loadFromXMI
(
xmiFile
,
0
);
}
bool
Import_Argo
::
loadFromZArgoFile
(
QIODevice
&
file
,
UMLPackage
*
parentPkg
)
{
Q_UNUSED
(
parentPkg
);
KZip
zipFile
(
&
file
);
if
(
!
zipFile
.
open
(
QIODevice
::
ReadOnly
))
return
false
;
const
KArchiveDirectory
*
directory
=
zipFile
.
directory
();
bool
result
=
true
;
foreach
(
const
QString
&
name
,
directory
->
entries
())
{
const
KArchiveEntry
*
entry
=
directory
->
entry
(
name
);
if
(
entry
->
isFile
())
{
const
KArchiveFile
*
file
=
static_cast
<
const
KArchiveFile
*>
(
entry
);
if
(
file
==
0
)
{
uError
()
<<
"Could not read file from"
<<
file
;
continue
;
}
if
(
name
.
endsWith
(
".argo"
))
result
=
loadFromArgoFile
(
zipFile
,
name
);
}
}
return
result
;
}
umbrello/import_argo.h
0 → 100644
View file @
19e25728
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2006-2014 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
#ifndef IMPORT_ARGO_H
#define IMPORT_ARGO_H
#include <qiodevice.h>
class
UMLPackage
;
class
KZip
;
/**
* Argo model import
*
* @author Ralf Habacker
* Bugs and comments to umbrello-devel@kde.org or http://bugs.kde.org
*/
class
Import_Argo
{
public:
static
bool
loadFromZArgoFile
(
QIODevice
&
file
,
UMLPackage
*
parentPkg
=
0
);
protected:
static
bool
loadFromArgoFile
(
const
KZip
&
zipFile
,
const
QString
&
fileName
);
static
bool
loadFromPGMLFile
(
const
KZip
&
zipFile
,
const
QString
&
fileName
);
static
bool
loadFromTodoFile
(
const
KZip
&
zipFile
,
const
QString
&
fileName
);
static
bool
loadFromXMIFile
(
const
KZip
&
zipFile
,
const
QString
&
fileName
);
};
#endif
umbrello/uml.cpp
View file @
19e25728
...
...
@@ -1205,11 +1205,13 @@ void UMLApp::slotFileOpen()
}
else
{
KUrl
url
=
KFileDialog
::
getOpenUrl
(
KUrl
(),
i18n
(
"*.xmi *.xmi.tgz *.xmi.tar.bz2 *.mdl|All Supported Files (*.xmi, *.xmi.tgz, *.xmi.tar.bz2, *.mdl)
\n
"
i18n
(
"*.xmi *.xmi.tgz *.xmi.tar.bz2 *.mdl
*.zargo
|All Supported Files (*.xmi, *.xmi.tgz, *.xmi.tar.bz2, *.mdl
, *.zargo
)
\n
"
"*.xmi|Uncompressed XMI Files (*.xmi)
\n
"
"*.xmi.tgz|Gzip Compressed XMI Files (*.xmi.tgz)
\n
"
"*.xmi.tar.bz2|Bzip2 Compressed XMI Files (*.xmi.tar.bz2)
\n
"
"*.mdl|Rose model files"
),
this
,
i18n
(
"Open File"
));
"*.mdl|Rose model files (*.mdl)
\n
"
"*.zargo|Compressed argo Files(*.zargo)
\n
"
),
this
,
i18n
(
"Open File"
));
if
(
!
url
.
isEmpty
())
{
m_listView
->
setSortingEnabled
(
false
);
if
(
m_doc
->
openDocument
(
url
))
{
...
...
umbrello/umldoc.cpp
View file @
19e25728
...
...
@@ -29,6 +29,7 @@
#include "stereotype.h"
#include "classifierlistitem.h"
#include "object_factory.h"
#include "import_argo.h"
#include "import_rose.h"
#include "model_utils.h"
#include "uml.h"
...
...
@@ -545,6 +546,14 @@ bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
else
newDocument
();
}
else
if
(
filetype
.
endsWith
(
QLatin1String
(
".zargo"
)))
{
status
=
Import_Argo
::
loadFromZArgoFile
(
file
);
if
(
status
)
{
m_doc_url
.
setFileName
(
i18n
(
"Untitled"
));
}
else
newDocument
();
}
else
{
status
=
loadFromXMI
(
file
,
ENC_UNKNOWN
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment