Commit db95a3ec authored by Jochen Becher's avatar Jochen Becher

ModelEditor: Fix use of conditional code and preprocessor macros

Remove some dead code, debugging code and use of QMT_CHECK.

Change-Id: I04939484fbfa02ca6a816777c355f7db7d7f8077
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent a4415135
......@@ -67,10 +67,6 @@
#include <QtSvg/QSvgGenerator>
#endif
#ifdef USE_EMF_CLIPBOARD
// TODO implement emf clipboard
#endif
#include <QDebug>
......@@ -371,10 +367,6 @@ void DiagramSceneModel::copyToClipboard()
}
#endif
#ifdef USE_EMF_CLIPBOARD
// TODO implement emf clipboard
#endif
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
addExtraSceneItems();
......
......@@ -243,22 +243,6 @@ QList<ILatchable::Latch> ComponentItem::verticalLatches(ILatchable::Action actio
return ObjectItem::verticalLatches(action, grabbedItem);
}
#if 0
QList<qreal> ComponentItem::horizontalLatches() const
{
QRectF rect = object()->rect();
rect.translate(object()->pos());
return QList<qreal>() << (rect.left() - RECT_WIDTH * 0.5) << rect.left() << rect.right();
}
QList<qreal> ComponentItem::verticalLatches() const
{
QRectF rect = object()->rect();
rect.translate(object()->pos());
return QList<qreal>() << rect.top() << rect.bottom();
}
#endif
QPointF ComponentItem::relationStartPos() const
{
return pos();
......
......@@ -212,23 +212,6 @@ QList<ILatchable::Latch> PackageItem::verticalLatches(ILatchable::Action action,
return ObjectItem::verticalLatches(action, grabbedItem);
}
#if 0
QList<qreal> PackageItem::horizontalLatches() const
{
QRectF rect = object()->rect();
rect.translate(object()->pos());
return QList<qreal>() << rect.left() << rect.center().x() << rect.right();
}
QList<qreal> PackageItem::verticalLatches() const
{
QRectF rect = object()->rect();
rect.translate(object()->pos());
ShapeGeometry shape = calcMinimumGeometry();
return QList<qreal>() << rect.topLeft().y() << (rect.topLeft() + QPointF(0.0, shape.m_minimumTabSize.height())).y() << rect.center().y() << rect.bottomRight().y();
}
#endif
QPointF PackageItem::relationStartPos() const
{
return pos();
......
......@@ -209,7 +209,7 @@ void RelationItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
Q_UNUSED(option);
Q_UNUSED(widget);
#ifdef DEBUG_PAINT_SELECTION_SHAPE
#ifdef DEBUG_PAINT_SHAPE
painter->save();
painter->setPen(Qt::red);
painter->setBrush(Qt::blue);
......
......@@ -118,7 +118,7 @@ public:
Q_UNUSED(option);
Q_UNUSED(widget);
#if 0
#ifdef DEBUG_PAINT_SHAPE
painter->setPen(QPen(Qt::blue));
painter->drawRect(boundingRect());
painter->setPen(QPen(Qt::red));
......@@ -373,7 +373,7 @@ void ArrowItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
Q_UNUSED(option);
Q_UNUSED(widget);
#if DEBUG_PAINT_ARROW_SHAPE
#ifdef DEBUG_PAINT_SHAPE
painter->setPen(QPen(Qt::blue));
painter->drawRect(boundingRect());
painter->setPen(QPen(Qt::red));
......
......@@ -40,9 +40,6 @@
#include <QLineF>
#include <QPainter>
//#define DEBUG_PAINT_SHAPE
namespace qmt {
static const double MAX_SELECTION_DISTANCE_FROM_PATH = 4.0;
......
#ifndef QMT_QMTASSERT_H
#define QMT_QMTASSERT_H
// TODO implement with QTC_ASSERT when lib is translated into QtCreator style
#include "utils/qtcassert.h"
// implement with Q_ASSERT and Q_ASSERT_X locally during debugging but do not submit!
#define QMT_CHECK(condition)
#define QMT_CHECK_X(condition, where, what)
// TODO extend with parameter action
#define QMT_CHECK(condition) QTC_CHECK(condition)
// TODO implement logging of where and what
#define QMT_CHECK_X(condition, where, what) QTC_CHECK(condition)
#endif // QMT_QMTASSERT_H
......@@ -1260,40 +1260,38 @@ MReferences ModelController::simplify(const MSelection &modelSelection)
void ModelController::verifyModelIntegrity() const
{
#if 0
#ifndef QT_NO_DEBUG
QMT_CHECK(m_rootPackage);
QHash<Uid, const MObject *> objectsMap;
QHash<Uid, const MRelation *> relationsMap;
QMultiHash<Uid, MRelation *> objectRelationsMap;
verifyModelIntegrity(m_rootPackage, &objectsMap, &relationsMap, &objectRelationsMap);
QMT_CHECK(objectsMap.size() == m_objectsMap.size());
foreach (const MObject *object, m_objectsMap) {
QMT_CHECK(object);
QMT_CHECK(m_objectsMap.contains(object->uid()));
QMT_CHECK(objectsMap.contains(object->uid()));
}
QMT_CHECK(relationsMap.size() == m_relationsMap.size());
foreach (const MRelation *relation, m_relationsMap) {
QMT_CHECK(relation);
QMT_CHECK(m_relationsMap.contains(relation->uid()));
QMT_CHECK(relationsMap.contains(relation->uid()));
}
QMT_CHECK(objectRelationsMap.size() == m_objectRelationsMap.size());
for (QMultiHash<Uid, MRelation *>::const_iterator it = m_objectRelationsMap.cbegin(); it != m_objectRelationsMap.cend(); ++it) {
QMT_CHECK(objectRelationsMap.contains(it.key(), it.value()));
static const bool debugModelIntegrity = false;
if (debugModelIntegrity) {
QMT_CHECK(m_rootPackage);
QHash<Uid, const MObject *> objectsMap;
QHash<Uid, const MRelation *> relationsMap;
QMultiHash<Uid, MRelation *> objectRelationsMap;
verifyModelIntegrity(m_rootPackage, &objectsMap, &relationsMap, &objectRelationsMap);
QMT_CHECK(objectsMap.size() == m_objectsMap.size());
foreach (const MObject *object, m_objectsMap) {
QMT_CHECK(object);
QMT_CHECK(m_objectsMap.contains(object->uid()));
QMT_CHECK(objectsMap.contains(object->uid()));
}
QMT_CHECK(relationsMap.size() == m_relationsMap.size());
foreach (const MRelation *relation, m_relationsMap) {
QMT_CHECK(relation);
QMT_CHECK(m_relationsMap.contains(relation->uid()));
QMT_CHECK(relationsMap.contains(relation->uid()));
}
QMT_CHECK(objectRelationsMap.size() == m_objectRelationsMap.size());
for (QMultiHash<Uid, MRelation *>::const_iterator it = m_objectRelationsMap.cbegin(); it != m_objectRelationsMap.cend(); ++it) {
QMT_CHECK(objectRelationsMap.contains(it.key(), it.value()));
}
}
#endif
#endif
}
void ModelController::verifyModelIntegrity(const MObject *object, QHash<Uid, const MObject *> *objectsMap,
QHash<Uid, const MRelation *> *relationsMap,
QMultiHash<Uid, MRelation *> *objectRelationsMap) const
{
#ifndef QT_NO_DEBUG
QMT_CHECK(object);
QMT_CHECK(!objectsMap->contains(object->uid()));
objectsMap->insert(object->uid(), object);
......@@ -1316,12 +1314,6 @@ void ModelController::verifyModelIntegrity(const MObject *object, QHash<Uid, con
verifyModelIntegrity(childObject, objectsMap, relationsMap, objectRelationsMap);
}
}
#else
Q_UNUSED(object);
Q_UNUSED(objectsMap);
Q_UNUSED(relationsMap);
Q_UNUSED(objectRelationsMap);
#endif
}
}
......@@ -30,8 +30,6 @@
#include "projectserializer.h"
//#define USE_COMPRESSED_FILES
#include "infrastructureserializer.h"
#include "qmt/project/project.h"
......
......@@ -37,7 +37,7 @@
namespace qark {
#if 0 // ambigous with default implementation in access.h
#if 0 // TODO this is ambigous with default implementation in access.h
template<class Archive, typename T>
inline typename std::enable_if<std::is_enum<T>::value, void>::type save(Archive &archive, const T &value, const Parameters &)
......
Markdown is supported
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