summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2016-09-07 18:53:39 (GMT)
committerRalf Habacker <ralf.habacker@freenet.de>2016-09-07 19:01:38 (GMT)
commitd02e8a7e4d53e8ed2aac2de425c5ce554474e757 (patch)
treed16154f5907218852dc82d8a4ae76d91e570906a
parent37ba24a224b8e94d7e9f3ba06d20b13ab4d92f39 (diff)
Add dock window showing all uml objects for further debugging.
-rw-r--r--CMakeLists.txt1
-rw-r--r--umbrello/CMakeLists.txt2
-rw-r--r--umbrello/models/objectsmodel.cpp143
-rw-r--r--umbrello/models/objectsmodel.h45
-rw-r--r--umbrello/objectswindow.cpp85
-rw-r--r--umbrello/objectswindow.h39
-rw-r--r--umbrello/uml.cpp3
-rw-r--r--umbrello/umlappprivate.h13
-rw-r--r--umbrello/umldoc.cpp7
-rw-r--r--umbrello/umldoc.h3
-rw-r--r--umbrello/umlmodel/umlobject.cpp6
11 files changed, 347 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e9604a1..8f62d48 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -235,6 +235,7 @@ endmacro(add_unstable_feature)
add_unstable_feature(WIDGET_SHOW_DOC) # show documentation in classes ticket xxx
add_unstable_feature(NEW_CODE_GENERATORS) # new c++ code generator
+add_unstable_feature(UML_OBJECTS_WINDOW) # objects dock window
if(LIBXSLT_FOUND AND LIBXML2_FOUND)
add_subdirectory(umbrello)
diff --git a/umbrello/CMakeLists.txt b/umbrello/CMakeLists.txt
index 08462a0..ac3ca48 100644
--- a/umbrello/CMakeLists.txt
+++ b/umbrello/CMakeLists.txt
@@ -439,6 +439,7 @@ set(umbrellobase_SRCS
birdview.cpp
cmdlineexportallviewsevent.cpp
diagramswindow.cpp
+ objectswindow.cpp
docwindow.cpp
dotgenerator.cpp
icon_utils.cpp
@@ -475,6 +476,7 @@ set(umbrellobase_SRCS
set(umbrellomodels_SRCS
models/diagramsmodel.cpp
+ models/objectsmodel.cpp
models/stereotypesmodel.cpp
)
diff --git a/umbrello/models/objectsmodel.cpp b/umbrello/models/objectsmodel.cpp
new file mode 100644
index 0000000..1db22d8
--- /dev/null
+++ b/umbrello/models/objectsmodel.cpp
@@ -0,0 +1,143 @@
+/***************************************************************************
+ * 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) 2016 *
+ * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
+ ***************************************************************************/
+
+#include "objectsmodel.h"
+
+// app includes
+#include "attribute.h"
+#include "folder.h"
+#include "operation.h"
+#include "uml.h"
+#include "umldoc.h"
+
+// kde includes
+#include <KLocalizedString>
+
+// qt includes
+#include <QtDebug>
+
+ObjectsModel::ObjectsModel()
+{
+}
+
+bool ObjectsModel::add(UMLObject *o)
+{
+ if (m_allObjects.contains(o))
+ return false;
+ int index = m_allObjects.size();
+ beginInsertRows(QModelIndex(), index, index);
+ m_allObjects.append(o);
+ endInsertRows();
+ return true;
+}
+
+bool ObjectsModel::remove(UMLObject *o)
+{
+ int index = m_allObjects.indexOf(o);
+ if (index == -1)
+ return false;
+ beginRemoveRows(QModelIndex(), index, index);
+ m_allObjects.removeAll(o);
+ endRemoveRows();
+ return true;
+}
+
+int ObjectsModel::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent);
+
+ int count = m_allObjects.size();
+ return count;
+}
+
+int ObjectsModel::columnCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent);
+
+ return 4;
+}
+
+QVariant ObjectsModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (section < 0)
+ return QVariant();
+
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Vertical)
+ return section + 1;
+ if (section == 0)
+ return QVariant(i18n("Name"));
+ else if (section == 1)
+ return QVariant(i18n("Type"));
+ else if (section == 2)
+ return QVariant(i18n("Folder"));
+ else if (section == 3)
+ return QVariant(i18n("ID"));
+ else return QVariant();
+}
+
+QVariant ObjectsModel::data(const QModelIndex & index, int role) const
+{
+ if (role == Qt::UserRole && index.column() == 0) {
+ QVariant v;
+ v.setValue(m_allObjects.at(index.row()).data());
+ return v;
+ }
+ else if (role != Qt::DisplayRole)
+ return QVariant();
+
+ int cCount = columnCount(index);
+ if (index.column() >= cCount)
+ return QVariant();
+
+ UMLObject *o = m_allObjects.at(index.row());
+ if (index.column() == 0)
+ return o->name();
+ else if (index.column() == 1)
+ return o->baseTypeStr();
+ else if (index.column() == 2) {
+ QVariant v;
+ if (o->umlPackage())
+ v.setValue(o->umlPackage()->name());
+ else if (o->parent()) {
+ UMLObject *p = dynamic_cast<UMLObject*>(o->parent());
+ if (p)
+ v.setValue(p->name());
+ }
+ return v;
+ } else if (index.column() == 3)
+ return Uml::ID::toString(o->id());
+ return QVariant();
+}
+
+void ObjectsModel::emitDataChanged(const QModelIndex &index)
+{
+ emit dataChanged(index, index);
+}
+
+void ObjectsModel::emitDataChanged(int index)
+{
+ QModelIndex mi = createIndex(index,0);
+ emit dataChanged(mi, mi);
+}
+
+void ObjectsModel::emitDataChanged(UMLObject *o)
+{
+#if QT_VERSION < 0x050000
+ emit layoutAboutToBeChanged();
+#endif
+ int index = m_allObjects.indexOf(o);
+ emitDataChanged(index);
+#if QT_VERSION < 0x050000
+ emit layoutChanged();
+#endif
+}
diff --git a/umbrello/models/objectsmodel.h b/umbrello/models/objectsmodel.h
new file mode 100644
index 0000000..db017be
--- /dev/null
+++ b/umbrello/models/objectsmodel.h
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * 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) 2016 *
+ * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
+ ***************************************************************************/
+
+#ifndef OBJECTSMODEL_H
+#define OBJECTSMODEL_H
+
+// qt includes
+#include <QAbstractTableModel>
+#include <QPointer>
+
+class UMLObject;
+
+Q_DECLARE_METATYPE(UMLObject*);
+
+class ObjectsModel : public QAbstractTableModel
+{
+ Q_OBJECT
+public:
+ explicit ObjectsModel();
+
+ bool add(UMLObject *o);
+ bool remove(UMLObject *o);
+
+ int rowCount(const QModelIndex &parent) const;
+ int columnCount(const QModelIndex &parent) const;
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
+
+ void emitDataChanged(const QModelIndex &index);
+ void emitDataChanged(int index);
+ void emitDataChanged(UMLObject *o);
+
+protected:
+ QList<QPointer<UMLObject>> m_allObjects;
+};
+
+#endif // OBJECTSMODEL_H
diff --git a/umbrello/objectswindow.cpp b/umbrello/objectswindow.cpp
new file mode 100644
index 0000000..1334f46
--- /dev/null
+++ b/umbrello/objectswindow.cpp
@@ -0,0 +1,85 @@
+/***************************************************************************
+ * 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) 2016 *
+ * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
+ ***************************************************************************/
+
+#include "objectswindow.h"
+
+// app includes
+#include "models/objectsmodel.h"
+#include "uml.h"
+#include "umldoc.h"
+#include "umlview.h"
+
+// kde includes
+#include <KLocalizedString>
+
+// qt includes
+#include <QHeaderView>
+#include <QTableView>
+#include <QSortFilterProxyModel>
+#include <QtDebug>
+
+ObjectsWindow::ObjectsWindow(const QString &title, QWidget *parent)
+ : QDockWidget(title, parent)
+{
+ setObjectName(QLatin1String("ObjectsWindow"));
+
+ QSortFilterProxyModel *proxy = new QSortFilterProxyModel;
+ proxy->setSourceModel(UMLApp::app()->document()->objectsModel());
+ proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
+ m_objectsTree = new QTableView;
+ m_objectsTree->setModel(proxy);
+ m_objectsTree->setSortingEnabled(true);
+ m_objectsTree->verticalHeader()->setDefaultSectionSize(20);
+ m_objectsTree->verticalHeader()->setVisible(false);
+#if QT_VERSION >= 0x050000
+ m_diagramsTree->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+#else
+ m_objectsTree->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
+#endif
+ setWidget(m_objectsTree);
+
+ connect(m_objectsTree, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotObjectsDoubleClicked(QModelIndex)));
+ connect(m_objectsTree, SIGNAL(clicked(QModelIndex)), this, SLOT(slotObjectsClicked(QModelIndex)));
+}
+
+ObjectsWindow::~ObjectsWindow()
+{
+ delete m_objectsTree;
+}
+
+void ObjectsWindow::modified()
+{
+ UMLObject *o = dynamic_cast<UMLObject*>(QObject::sender());
+ if (!o)
+ return;
+ UMLApp::app()->document()->objectsModel()->emitDataChanged(o);
+}
+
+void ObjectsWindow::slotObjectsDoubleClicked(QModelIndex index)
+{
+ QVariant v = m_objectsTree->model()->data(index, Qt::UserRole);
+ if (v.canConvert<UMLObject*>()) {
+ UMLObject *o = v.value<UMLObject*>();
+ o->showPropertiesDialog(this);
+ }
+}
+
+void ObjectsWindow::slotObjectsClicked(QModelIndex index)
+{
+#if 1
+ Q_UNUSED(index)
+#else
+ QVariant v = m_objectsTree->model()->data(index, Qt::UserRole);
+ if (v.canConvert<UMLObject*>()) {
+ UMLObject *o = v.value<UMLObject*>();
+ //o->showPropertiesDialog(this);
+ }
+#endif
+}
diff --git a/umbrello/objectswindow.h b/umbrello/objectswindow.h
new file mode 100644
index 0000000..9f7947d
--- /dev/null
+++ b/umbrello/objectswindow.h
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * 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) 2016 *
+ * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
+ ***************************************************************************/
+
+#ifndef ObjectsWindow_H
+#define ObjectsWindow_H
+
+#include <QDockWidget>
+#include <QModelIndex>
+
+class QTableView;
+
+class ObjectsWindow : public QDockWidget
+{
+ Q_OBJECT
+public:
+ explicit ObjectsWindow(const QString &title, QWidget *parent = 0);
+ ~ObjectsWindow();
+
+signals:
+
+public slots:
+ void modified();
+
+protected slots:
+ void slotObjectsDoubleClicked(QModelIndex index);
+ void slotObjectsClicked(QModelIndex index);
+
+protected:
+ QTableView *m_objectsTree;
+};
+
+#endif // ObjectsWindow_H
diff --git a/umbrello/uml.cpp b/umbrello/uml.cpp
index 72f3018..59b3c07 100644
--- a/umbrello/uml.cpp
+++ b/umbrello/uml.cpp
@@ -932,6 +932,9 @@ void UMLApp::initView()
setCentralWidget(widget);
m_d->createDiagramsWindow();
+#ifdef ENABLE_UML_OBJECTS_WINDOW
+ m_d->createObjectsWindow();
+#endif
m_d->createStereotypesWindow();
// create the tree viewer
diff --git a/umbrello/umlappprivate.h b/umbrello/umlappprivate.h
index 90e4fdd..6275f79 100644
--- a/umbrello/umlappprivate.h
+++ b/umbrello/umlappprivate.h
@@ -16,6 +16,7 @@
#include "findresults.h"
#include "uml.h"
#include "diagramswindow.h"
+#include "objectswindow.h"
#include "stereotypeswindow.h"
// kde includes
@@ -52,8 +53,10 @@ public:
FindResults findResults;
QListWidget *logWindow; ///< Logging window.
KToggleAction *viewDiagramsWindow;
+ KToggleAction *viewObjectsWindow;
KToggleAction *viewStereotypesWindow;
DiagramsWindow *diagramsWindow;
+ ObjectsWindow *objectsWindow;
StereotypesWindow *stereotypesWindow;
KTextEditor::Editor *editor;
@@ -125,6 +128,16 @@ public slots:
connect(viewDiagramsWindow, SIGNAL(triggered(bool)), diagramsWindow, SLOT(setVisible(bool)));
}
+ void createObjectsWindow()
+ {
+ // create the object window
+ objectsWindow = new ObjectsWindow(i18n("&UML Objects"), parent);
+ parent->addDockWidget(Qt::RightDockWidgetArea, objectsWindow);
+
+ viewObjectsWindow = parent->actionCollection()->add<KToggleAction>(QLatin1String("view_objects_window"));
+ connect(viewObjectsWindow, SIGNAL(triggered(bool)), objectsWindow, SLOT(setVisible(bool)));
+ }
+
void createStereotypesWindow()
{
// create the tree viewer
diff --git a/umbrello/umldoc.cpp b/umbrello/umldoc.cpp
index 1e95e06..ce5c1e8 100644
--- a/umbrello/umldoc.cpp
+++ b/umbrello/umldoc.cpp
@@ -45,6 +45,7 @@
#include "version.h"
#include "worktoolbar.h"
#include "models/diagramsmodel.h"
+#include "models/objectsmodel.h"
#include "models/stereotypesmodel.h"
// kde includes
@@ -117,6 +118,7 @@ UMLDoc::UMLDoc()
m_pCurrentRoot(0),
m_bClosing(false),
m_diagramsModel(new DiagramsModel),
+ m_objectsModel(new ObjectsModel),
m_stereotypesModel(new StereotypesModel(&m_stereoList))
{
for (int i = 0; i < Uml::ModelType::N_MODELTYPES; ++i)
@@ -2457,6 +2459,11 @@ DiagramsModel *UMLDoc::diagramsModel()
return m_diagramsModel;
}
+ObjectsModel *UMLDoc::objectsModel()
+{
+ return m_objectsModel;
+}
+
StereotypesModel *UMLDoc::stereotypesModel()
{
return m_stereotypesModel;
diff --git a/umbrello/umldoc.h b/umbrello/umldoc.h
index bda9d97..84b54e7 100644
--- a/umbrello/umldoc.h
+++ b/umbrello/umldoc.h
@@ -49,6 +49,7 @@ class QPrinter;
class IDChangeLog;
class DiagramsModel;
+class ObjectsModel;
class StereotypesModel;
class UMLPackage;
class UMLFolder;
@@ -237,6 +238,7 @@ public:
DiagramsModel *diagramsModel();
StereotypesModel *stereotypesModel();
+ ObjectsModel *objectsModel();
private:
void initSaveTimer();
@@ -314,6 +316,7 @@ private:
bool m_bClosing;
DiagramsModel *m_diagramsModel;
+ ObjectsModel *m_objectsModel;
StereotypesModel *m_stereotypesModel;
public slots:
diff --git a/umbrello/umlmodel/umlobject.cpp b/umbrello/umlmodel/umlobject.cpp
index 1cf0c1c..1e2b708 100644
--- a/umbrello/umlmodel/umlobject.cpp
+++ b/umbrello/umlmodel/umlobject.cpp
@@ -19,6 +19,7 @@
#include "uml.h"
#include "umldoc.h"
#include "umllistview.h"
+#include "models/objectsmodel.h"
#include "package.h"
#include "folder.h"
#include "stereotype.h"
@@ -47,6 +48,7 @@ UMLObject::UMLObject(const UMLObject &other)
: QObject(other.umlParent())
{
other.copyInto(this);
+ UMLApp::app()->document()->objectsModel()->add(this);
}
/**
@@ -64,6 +66,7 @@ UMLObject::UMLObject(UMLObject* parent, const QString& name, ID::Type id)
init();
if (id == Uml::ID::None)
m_nId = UniqueID::gen();
+ UMLApp::app()->document()->objectsModel()->add(this);
}
/**
@@ -80,6 +83,7 @@ UMLObject::UMLObject(const QString& name, ID::Type id)
init();
if (id == Uml::ID::None)
m_nId = UniqueID::gen();
+ UMLApp::app()->document()->objectsModel()->add(this);
}
/**
@@ -92,6 +96,7 @@ UMLObject::UMLObject(UMLObject * parent)
m_name(QString())
{
init();
+ UMLApp::app()->document()->objectsModel()->add(this);
}
/**
@@ -106,6 +111,7 @@ UMLObject::~UMLObject()
if (stereotype)
stereotype->decrRefCount();
}
+ UMLApp::app()->document()->objectsModel()->remove(this);
}
/**