Commit 368c43e0 authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Extend objects windows with additional states like 'is-saved',...

Extend objects windows with additional states like 'is-saved', 'is-in-parent-list' and object pointer.
parent 972a4253
......@@ -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)
......
......@@ -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.
......
......@@ -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
/***************************************************************************
* 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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment