summaryrefslogtreecommitdiffstats
path: root/examples/uml
diff options
context:
space:
mode:
authorLuis Paulo Torres de Oliveira <luis.paulo.tdo@gmail.com>2013-11-25 09:36:33 -0300
committerSandro S. Andrade <sandroandrade@kde.org>2013-11-26 02:25:35 +0100
commit9cc11ffbb66d74ce0776ecd1647e412f9c64eac4 (patch)
treef0757799bed2c8447c963ce1acbaa8d5aa97488a /examples/uml
parentdcaf2e6be08d1b0b208e4b31b93696139ade9239 (diff)
Fix revision issues of gcc-xml architecture recovery backend plugin.
Change-Id: Iddb9e6ba56323f12ecb251c0d14e0dff24806195 Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'examples/uml')
-rw-r--r--examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.cpp32
-rw-r--r--examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.h16
2 files changed, 34 insertions, 14 deletions
diff --git a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.cpp b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.cpp
index f9ee53f3..3a700b87 100644
--- a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.cpp
+++ b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.cpp
@@ -40,6 +40,12 @@
****************************************************************************/
#include "gccxmlarchitecturerecoverybackendplugin.h"
+#include <QtWidgets/QAction>
+#include <QtWidgets/QFileDialog>
+#include <QtCore/QProcess>
+
+#include <duseinterfaces/iuicontroller.h>
+
GccXmlArchitectureRecoveryBackendPlugin::GccXmlArchitectureRecoveryBackendPlugin(QObject *parent) :
DuSE::IPlugin(parent)
{
@@ -47,7 +53,9 @@ GccXmlArchitectureRecoveryBackendPlugin::GccXmlArchitectureRecoveryBackendPlugin
bool GccXmlArchitectureRecoveryBackendPlugin::initialize(DuSE::ICore *core)
{
- Q_UNUSED(core);
+ QAction *newArchitectureRecoveryProcessAction = new QAction(QIcon(), tr("New architecture recovery process"), this);
+ connect(newArchitectureRecoveryProcessAction, SIGNAL(triggered()), this, SLOT(newArchitectureRecoveryProcess()));
+ core->uiController()->addAction(newArchitectureRecoveryProcessAction, tr("menu_File"));
return true;
}
@@ -56,6 +64,13 @@ void GccXmlArchitectureRecoveryBackendPlugin::setRootProjectDir(const QDir &root
_rootProjectDir = rootProjectDir;
}
+void GccXmlArchitectureRecoveryBackendPlugin::newArchitectureRecoveryProcess()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, tr("Open xml file"), "/home", tr("Xml files (*.xml)"));
+ _rootProjectDir = new QDir(fileName);
+ components();
+}
+
QObjectList GccXmlArchitectureRecoveryBackendPlugin::components()
{
QObjectList components;
@@ -63,7 +78,6 @@ QObjectList GccXmlArchitectureRecoveryBackendPlugin::components()
QStringList headers = _rootProjectDir.entryList(QStringList("*.h"), QDir::Files | QDir::NoSymLinks);
QStringList xmlFiles = generateXmlFiles(headers);
int xmlFilesSize = xmlFiles.size();
-
for (int i = 0; i < xmlFilesSize; ++i) {
QString xmlFile = xmlFiles.at(i).toLocal8Bit().constData();
@@ -100,20 +114,22 @@ QStringList GccXmlArchitectureRecoveryBackendPlugin::generateXmlFiles(const QStr
bool GccXmlArchitectureRecoveryBackendPlugin::openXmlFile(const QString &filePath)
{
- QFile file(filePath);
- _xmlReader = new QXmlStreamReader(&file);
+ _xmlFile.setFileName(filePath);
+ _xmlReader = new QXmlStreamReader(&_xmlFile);
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ if (!_xmlFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
return false;
}
return true;
}
-QStringList GccXmlArchitectureRecoveryBackendPlugin::findConstructorsFromXml(const QString &className)
+QStringList GccXmlArchitectureRecoveryBackendPlugin::findConstructorsFromXml(QString xmlFile)
{
QStringList constructors;
+ openXmlFile(_rootProjectDir.absolutePath() + "/" + xmlFile);
+ QString className = xmlFile.replace(".xml", "");
while (!_xmlReader->atEnd() && !_xmlReader->hasError()) {
QXmlStreamReader::TokenType token = _xmlReader->readNext();
@@ -134,11 +150,11 @@ QStringList GccXmlArchitectureRecoveryBackendPlugin::findConstructorsFromXml(con
QObject *GccXmlArchitectureRecoveryBackendPlugin::extractComponent(QString xmlFile)
{
- QStringList constructors = findConstructorsFromXml(xmlFile.replace(".xml", ""));
+ QStringList constructors = findConstructorsFromXml(xmlFile);
QString expression = constructors.last();
QStringList elements = expression.split("::");
- QString className = elements.at(1);
+ QString className = elements.at(0) + "::" + elements.at(1);
QObject *component = new QObject;
component->setObjectName(className);
diff --git a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.h b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.h
index eae3a635..db3409ea 100644
--- a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.h
+++ b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.h
@@ -44,11 +44,11 @@
#include <duseinterfaces/iplugin.h>
#include <architecturerecoverycore/iarchitecturerecoverybackend.h>
-#include <QDir>
-#include <QProcess>
-#include <QObjectList>
-#include <QStringList>
-#include <QXmlStreamReader>
+#include <QtCore/QDir>
+#include <QtCore/QObjectList>
+#include <QtCore/QStringList>
+
+class QXmlStreamReader;
class GccXmlArchitectureRecoveryBackendPlugin : public DuSE::IPlugin, public IArchitectureRecoveryBackend
{
@@ -65,13 +65,17 @@ public:
virtual QObjectList components();
virtual QObjectList connectors();
+private Q_SLOTS:
+ void newArchitectureRecoveryProcess();
+
private:
QStringList generateXmlFiles(const QStringList &codeFiles) const;
bool openXmlFile(const QString &filePath);
- QStringList findConstructorsFromXml(const QString &className);
+ QStringList findConstructorsFromXml(QString xmlFile);
QObject *extractComponent(QString xmlFile);
QDir _rootProjectDir;
+ QFile _xmlFile;
QXmlStreamReader *_xmlReader;
};