Skip to content

Commit

Permalink
oops... fixed elemnts adding problems. Also now dropped elements have…
Browse files Browse the repository at this point in the history
… the same colors with elements on panel (VIP, now it's just for test). Unified formatting.
  • Loading branch information
vt4a2h committed Jan 2, 2016
1 parent f7c10bc commit 8d1d2ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gui/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ namespace gui {
QByteArray itemData;
QDataStream out(&itemData, QIODevice::WriteOnly);
QVariant type = lbl->property(Elements::elementTypePropertyName());
out << type.value<uint>();
out << type.value<QString>();

// Set mime data
QMimeData *mimeData = new QMimeData;
Expand Down
23 changes: 7 additions & 16 deletions gui/graphics/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include <QMenu>
#include <QGraphicsSceneContextMenuEvent>
#include <QGraphicsScene>
#include<QDebug>

#include <application/settings.h>

#include <gui/editentitydialog.h>

Expand All @@ -38,7 +41,8 @@
#include <entity/extendedtype.h>
#include <entity/scope.h>

#include <constants.h>
#include "constants.h"
#include "qthelpers.h"

namespace graphics {

Expand All @@ -47,19 +51,6 @@ namespace graphics {
constexpr double tmpHeight = 100.;
constexpr double tmpWidth = 100.;
const QString stub = Entity::tr( "Stub" );

// NOTE: temporary, maybe will changed to smth else
const QMap<size_t, std::function<QColor(const entity::SharedType &)>> entitiesColor = {
{ entity::Enum::staticHashType() , [](const entity::SharedType & ){ return Qt::green; } },
{ entity::Union::staticHashType(), [](const entity::SharedType & ){ return Qt::yellow; } },
{ entity::Class::staticHashType(), [](const entity::SharedType &t){
auto c = std::static_pointer_cast<entity::Class>(t);
return c->kind() == entity::Kind::ClassType ? Qt::blue : Qt::darkBlue;
} },
{ entity::Type::staticHashType() , [](const entity::SharedType &){ return Qt::red; } },
{ entity::TemplateClass::staticHashType(), [](const entity::SharedType &){ return Qt::gray; } },
{ entity::ExtendedType::staticHashType() , [](const entity::SharedType &){ return Qt::darkCyan; } },
};
}

/**
Expand Down Expand Up @@ -106,10 +97,10 @@ namespace graphics {
{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->setBrush(entitiesColor[m_Type->hashType()](m_Type));
painter->setBrush(application::settings::elementColor(G_ASSERT(m_Type)->marker()));
painter->drawRect(QRectF(-tmpWidth / 2, -tmpHeight / 2, tmpWidth, tmpHeight));
painter->setPen(Qt::white);
painter->drawText(boundingRect(), Qt::AlignCenter, m_Type ? m_Type->name() : stub);
painter->drawText(boundingRect(), Qt::AlignCenter, G_ASSERT(m_Type)->name());
}

/**
Expand Down
8 changes: 4 additions & 4 deletions gui/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ namespace gui {
std::unique_ptr<QUndoCommand> makeCmd(const QString &marker, Types &&... args)
{
if (marker == entity::ExtendedType::staticMarker())
return std::make_unique<commands::MakeAlias>(std::forward<Types >(args)...);
return std::make_unique<commands::MakeAlias>(std::forward<Types>(args)...);
else if (marker == entity::Class::staticMarker())
return std::make_unique<commands::MakeClass>(std::forward<Types >(args)...);
return std::make_unique<commands::MakeClass>(std::forward<Types>(args)...);
else if(marker == entity::Enum::staticMarker())
return std::make_unique<commands::MakeEnum>(std::forward<Types >(args)...);
return std::make_unique<commands::MakeEnum>(std::forward<Types>(args)...);
else if (marker == entity::TemplateClass::staticMarker())
return std::make_unique<commands::MakeTemplate>(std::forward<Types >(args)...);
return std::make_unique<commands::MakeTemplate>(std::forward<Types>(args)...);
else if (marker == entity::Union::staticMarker())
return std::make_unique<commands::MakeUnion>(std::forward<Types >(args)...);

Expand Down

0 comments on commit 8d1d2ba

Please sign in to comment.