summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2016-09-09 05:33:57 (GMT)
committerRalf Habacker <ralf.habacker@freenet.de>2016-09-09 05:33:57 (GMT)
commit368c43e09de3cce0e2faf1ab1db0bd9e495aebcc (patch)
tree3bbbd923cc617429821d334e2020f33cb8f3f336
parent972a4253237b93dae76b18b6980eb8e8c1464ebf (diff)
Extend objects windows with additional states like 'is-saved', 'is-in-parent-list' and object pointer.
-rw-r--r--umbrello/models/objectsmodel.cpp63
-rw-r--r--umbrello/umlmodel/umlobject.cpp15
-rw-r--r--umbrello/umlmodel/umlobject.h3
-rw-r--r--umbrello/umlmodel/umlobjectprivate.h21
4 files changed, 87 insertions, 15 deletions
diff --git a/umbrello/models/objectsmodel.cpp b/umbrello/models/objectsmodel.cpp
index 1db22d8..2897700 100644
--- a/umbrello/models/objectsmodel.cpp
+++ b/umbrello/models/objectsmodel.cpp
@@ -12,11 +12,14 @@
// app includes
#include "attribute.h"
+#include "classifier.h"
#include "folder.h"
#include "operation.h"
#include "uml.h"
#include "umldoc.h"
+#include "umlobjectprivate.h"
+
// kde includes
#include <KLocalizedString>
@@ -61,7 +64,7 @@ int ObjectsModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
- return 4;
+ return 7;
}
QVariant ObjectsModel::headerData(int section, Qt::Orientation orientation, int role) const
@@ -82,6 +85,12 @@ QVariant ObjectsModel::headerData(int section, Qt::Orientation orientation, int
return QVariant(i18n("Folder"));
else if (section == 3)
return QVariant(i18n("ID"));
+ else if (section == 4)
+ return QVariant(i18n("Saved"));
+ else if (section == 5)
+ return QVariant(i18n("Parent"));
+ else if (section == 6)
+ return QVariant(i18n("Pointer"));
else return QVariant();
}
@@ -100,23 +109,55 @@ QVariant ObjectsModel::data(const QModelIndex & index, int role) const
return QVariant();
UMLObject *o = m_allObjects.at(index.row());
- if (index.column() == 0)
+
+ // each case needs to return
+ switch (index.column()) {
+ case 0:
return o->name();
- else if (index.column() == 1)
+ case 1:
return o->baseTypeStr();
- else if (index.column() == 2) {
- QVariant v;
+ case 2:
if (o->umlPackage())
- v.setValue(o->umlPackage()->name());
+ return 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 p->name();
+ } else
+ return QString();
+ case 3:
return Uml::ID::toString(o->id());
- return QVariant();
+ case 4:
+ return o->m_d->isSaved;
+ case 5:
+ if (o->umlPackage()) {
+ UMLFolder *f = o->umlPackage()->asUMLFolder();
+ if (f && f->containedObjects().contains(o))
+ return QLatin1String("package +");
+ else
+ return QLatin1String("package -");
+ } else if (o->umlParent()) {
+ if (o->isUMLAttribute()) {
+ UMLOperation *op = o->umlParent()->asUMLOperation();
+ if (op && op->getParmList().contains(o->asUMLAttribute()))
+ return QLatin1String("parent +");
+ else
+ return QLatin1String("parent -");
+ } else if (o->isUMLOperation()) {
+ UMLClassifier *c = o->umlParent()->asUMLClassifier();
+ if (c && c->getOpList().contains(o->asUMLOperation()))
+ return QLatin1String("parent +");
+ else
+ return QLatin1String("parent -");
+ }
+ return QLatin1String("not implemented");
+ } else
+ return QLatin1String("no parent");
+ case 6:
+ return QString::number((unsigned long) o, 16);
+ default:
+ return QVariant();
+ }
}
void ObjectsModel::emitDataChanged(const QModelIndex &index)
diff --git a/umbrello/umlmodel/umlobject.cpp b/umbrello/umlmodel/umlobject.cpp
index 1e2b708..8ce07b4 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 "umlobjectprivate.h"
#include "models/objectsmodel.h"
#include "package.h"
#include "folder.h"
@@ -45,7 +46,8 @@ DEBUG_REGISTER_DISABLED(UMLObject)
* @param other object to created from
*/
UMLObject::UMLObject(const UMLObject &other)
- : QObject(other.umlParent())
+ : QObject(other.umlParent()),
+ m_d(new UMLObjectPrivate)
{
other.copyInto(this);
UMLApp::app()->document()->objectsModel()->add(this);
@@ -61,7 +63,8 @@ UMLObject::UMLObject(const UMLObject &other)
UMLObject::UMLObject(UMLObject* parent, const QString& name, ID::Type id)
: QObject(parent),
m_nId(id),
- m_name(name)
+ m_name(name),
+ m_d(new UMLObjectPrivate)
{
init();
if (id == Uml::ID::None)
@@ -78,7 +81,8 @@ UMLObject::UMLObject(UMLObject* parent, const QString& name, ID::Type id)
UMLObject::UMLObject(const QString& name, ID::Type id)
: QObject(0),
m_nId(id),
- m_name(name)
+ m_name(name),
+ m_d(new UMLObjectPrivate)
{
init();
if (id == Uml::ID::None)
@@ -93,7 +97,8 @@ UMLObject::UMLObject(const QString& name, ID::Type id)
UMLObject::UMLObject(UMLObject * parent)
: QObject(parent),
m_nId(Uml::ID::None),
- m_name(QString())
+ m_name(QString()),
+ m_d(new UMLObjectPrivate)
{
init();
UMLApp::app()->document()->objectsModel()->add(this);
@@ -111,6 +116,7 @@ UMLObject::~UMLObject()
if (stereotype)
stereotype->decrRefCount();
}
+ delete m_d;
UMLApp::app()->document()->objectsModel()->remove(this);
}
@@ -837,6 +843,7 @@ void UMLObject::saveToXMI(QDomDocument &qDoc, QDomElement &qElement)
*/
QDomElement UMLObject::save(const QString &tag, QDomDocument & qDoc)
{
+ m_d->isSaved = true;
/*
Call as the first action of saveToXMI() in child class:
This creates the QDomElement with which to work.
diff --git a/umbrello/umlmodel/umlobject.h b/umbrello/umlmodel/umlobject.h
index b71bb94..d12d252 100644
--- a/umbrello/umlmodel/umlobject.h
+++ b/umbrello/umlmodel/umlobject.h
@@ -48,6 +48,7 @@ class UMLStereotype;
class UMLTemplate;
class UMLUniqueConstraint;
class UMLUseCase;
+class UMLObjectPrivate;
/**
* This class is the non-graphical version of @ref UMLWidget. These are
@@ -277,6 +278,8 @@ protected:
///< fully qualified target name of a reference.
///< In case the quidu is not found, the human readable name is
///< used which we store in m_SecondaryFallback.
+ UMLObjectPrivate *m_d; ///< private data
+ friend class ObjectsModel;
};
#endif
diff --git a/umbrello/umlmodel/umlobjectprivate.h b/umbrello/umlmodel/umlobjectprivate.h
new file mode 100644
index 0000000..b9af7ee
--- /dev/null
+++ b/umbrello/umlmodel/umlobjectprivate.h
@@ -0,0 +1,21 @@
+/***************************************************************************
+ * 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 UMLOBJECTPRIVATE_H
+#define UMLOBJECTPRIVATE_H
+
+class UMLObjectPrivate {
+public:
+ UMLObjectPrivate() : isSaved(false) { }
+ bool isSaved;
+};
+
+
+#endif // UMLOBJECTPRIVATE_H