[Uml-devel] branches/work/soc-umbrello-2011/umbrello
Camila San Martin Ayres
smayres at gmail.com
Mon Aug 22 14:41:29 UTC 2011
SVN commit 1248909 by ayres:
Fixing entity widget port.
M +1 -1 CMakeLists.txt
M +1 -1 codegenerators/d/dclassifiercodedocument.cpp
M +6 -1 codegenerators/java/javaclassifiercodedocument.cpp
M +1 -1 codegenerators/tcl/tclwriter.cpp
M +1 -1 dialogs/codeviewerdialog.cpp
M +1 -1 listpopupmenu.cpp
M +15 -5 soc-umbrello-2011/diagram.cpp
M +58 -7 soc-umbrello-2011/entitywidget.cpp
M +7 -4 soc-umbrello-2011/entitywidget.h
M +21 -2 soc-umbrello-2011/umlwidget.cpp
M +8 -3 soc-umbrello-2011/umlwidget.h
M +1 -1 soc-umbrello-2011/widgetbase.cpp
M +1 -1 soc-umbrello-2011/widgetbase.h
M +1 -0 widgets/widget_factory.cpp
--- branches/work/soc-umbrello-2011/umbrello/CMakeLists.txt #1248908:1248909
@@ -77,12 +77,12 @@
soc-umbrello-2011/umlscene.cpp
soc-umbrello-2011/diagram.cpp
soc-umbrello-2011/print.cpp
+ soc-umbrello-2011/entitywidget.cpp
soc-umbrello-2011/layoutgrid.cpp
soc-umbrello-2011/widgetbase.cpp
soc-umbrello-2011/umlwidget.cpp
soc-umbrello-2011/boxwidget.cpp
soc-umbrello-2011/objectwidget.cpp
- soc-umbrello-2011/entitywidget.cpp
)
set(libcodegenerator_SRCS
--- branches/work/soc-umbrello-2011/umbrello/codegenerators/d/dclassifiercodedocument.cpp #1248908:1248909
@@ -339,7 +339,7 @@
//
QString pkgs = getPackage();
pkgs.replace(QRegExp("::"), ".");
- QString packageText = getPackage().isEmpty() ? "" : "package "+pkgs+';'+endLine;
+ QString packageText = getPackage().isEmpty() ? "" : QString("package "+pkgs+";"+endLine);
CodeBlockWithComments * pblock = addOrUpdateTaggedCodeBlockWithComments("packages", packageText, "", 0, false);
if(packageText.isEmpty() && pblock->getContentType() == CodeBlock::AutoGenerated)
pblock->setWriteOutText(false);
--- branches/work/soc-umbrello-2011/umbrello/codegenerators/java/javaclassifiercodedocument.cpp #1248908:1248909
@@ -344,7 +344,12 @@
//
QString pkgs = getPackage();
pkgs.replace(QRegExp("::"), ".");
- QString packageText = getPackage().isEmpty() ? "" : "package "+pkgs+';'+endLine;
+ QString packageText;
+ if(getPackage().isEmpty()){
+ packageText = "";
+ }else{
+ packageText = "package "+pkgs+";"+endLine;
+ }
CodeBlockWithComments * pblock = addOrUpdateTaggedCodeBlockWithComments("packages", packageText, "", 0, false);
if(packageText.isEmpty() && pblock->getContentType() == CodeBlock::AutoGenerated)
pblock->setWriteOutText(false);
--- branches/work/soc-umbrello-2011/umbrello/codegenerators/tcl/tclwriter.cpp #1248908:1248909
@@ -409,7 +409,7 @@
myNs = "";
}
// if different package
- if (("::"+myNs) != mNamespace) {
+ if (QString("::"+myNs) != mNamespace) {
if (c->package().isEmpty()) {
writeCode("source " + findFileName(c, ".tcl"));
writeCode("namespace import ::" + cleanName(c->name()));
--- branches/work/soc-umbrello-2011/umbrello/dialogs/codeviewerdialog.cpp #1248908:1248909
@@ -104,7 +104,7 @@
void CodeViewerDialog::languageChange()
{
Uml::Programming_Language pl = UMLApp::app()->activeLanguage();
- setWindowTitle( tr2i18n( "Code Viewer - " ) + pl );
+ setWindowTitle( tr2i18n( "Code Viewer - " + pl ) );
}
#include "codeviewerdialog.moc"
--- branches/work/soc-umbrello-2011/umbrello/listpopupmenu.cpp #1248908:1248909
@@ -78,7 +78,7 @@
//make menu for logical view
if (!object)
return;
- Uml::Widget_Type type = object->type();
+ Uml::Widget_Type type = object->widget_type();
// uDebug() << "ListPopupMenu created with multi=" << multi << " , unique="
// << unique << " for Widget_Type=" << type;
--- branches/work/soc-umbrello-2011/umbrello/soc-umbrello-2011/diagram.cpp #1248908:1248909
@@ -1,3 +1,13 @@
+/***************************************************************************
+ * *
+ * 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) 2002-2007 *
+ * Umbrello UML Modeller Authors <uml-devel at uml.sf.net> *
+ ***************************************************************************/
#include "diagram.h"
#include "umlview.h"
@@ -31,15 +41,15 @@
m_view(view),
m_id(Uml::id_None),
m_localId(Uml::id_None),
- m_doc(UMLApp::app()->document())
+ m_doc(UMLApp::app()->document()),
+ m_scene(m_view->scene()),
+ m_activated(true)
{
- m_activated = true;
connect(m_doc, SIGNAL(sigObjectCreated(UMLObject *)),
this, SLOT(slotObjectCreated(UMLObject *)));
-
}
Diagram::~Diagram()
@@ -136,7 +146,7 @@
int counter = 0;
UMLWidget * temp = 0;
foreach(temp, selectedWidgets()) {
- if (temp->type() == Uml::wt_Text) {
+ if (temp->widget_type() == Uml::wt_Text) {
const FloatingTextWidget *ft = dynamic_cast<const FloatingTextWidget*>(temp);
if (ft->textRole() == Uml::tr_Floating)
counter++;
@@ -385,7 +395,7 @@
if (!pWidget) {
return false;
}
- Widget_Type type = pWidget->type();
+ Uml::Widget_Type type = pWidget->widget_type();
if (isPasteOperation) {
//if (type == Uml::wt_Message)
//m_widgetlist.append(static_cast<MessageWidget*>(pWidget));
--- branches/work/soc-umbrello-2011/umbrello/soc-umbrello-2011/entitywidget.cpp #1248908:1248909
@@ -8,21 +8,72 @@
* Umbrello UML Modeller Authors <uml-devel at uml.sf.net> *
***************************************************************************/
-#include "entitywidget.h"
+#include "soc-umbrello-2011/entitywidget.h"
#include "umlview.h"
#include "umlobject.h"
+#define ENTITY_MARGIN 5
namespace QGV {
-EntityWidget::EntityWidget(UMLView *view /* = 0 */, UMLObject* o /* = 0 */) :
-UMLWidget(view, o)
+EntityWidget::EntityWidget(UMLView* view, UMLObject* o): UMLWidget(view, o),
+m_view(view),
+m_obj(o)
{
- m_view = view;
- m_obj = o;
- qDebug() << "New Entity Widget!";
+
+ UMLWidget::setBaseType(Uml::wt_Entity);
+ setRect(qreal(cursor().pos().x()), qreal(cursor().pos().y()), 100, 30);
}
+
+
+EntityWidget::~EntityWidget(){}
+
+void EntityWidget::draw(QPainter& p, qreal offsetX, qreal offsetY)
+{
+ p.setPen(QPen(Qt::black));
+ QFont font = UMLWidget::font();
+ font.setBold(true);
+ p.setFont(font);
+
+ qreal w = rect().width();
+ qreal h = rect().height();
+
+ const QFontMetrics &fm = fontMetrics(FT_NORMAL);
+ int fontHeight = fm.lineSpacing();
+ const QString name = this->name();
+
+ p.drawRect(offsetX, offsetY, w, h);
+
+ int y = 0;
+ if ( !m_obj->stereotype().isEmpty() ) {
+ p.drawText(offsetX + ENTITY_MARGIN, offsetY,
+ w - ENTITY_MARGIN * 2,fontHeight,
+ Qt::AlignCenter, m_obj->stereotype(true));
+ font.setItalic( m_obj->isAbstract() );
+ p.setFont(font);
+ p.drawText(offsetX + ENTITY_MARGIN, offsetY + fontHeight,
+ w - ENTITY_MARGIN * 2, fontHeight, Qt::AlignCenter, name);
+ font.setBold(false);
+ font.setItalic(false);
+ p.setFont(font);
+ y = fontHeight * 2;
+ } else {
+ font.setItalic( m_obj->isAbstract() );
+ p.setFont(font);
+ p.drawText(offsetX + ENTITY_MARGIN, offsetY,
+ w - ENTITY_MARGIN * 2, fontHeight, Qt::AlignCenter, name);
+ font.setBold(false);
+ font.setItalic(false);
+ p.setFont(font);
+
+ y = fontHeight;
}
-#include "entitywidget.moc"
\ No newline at end of file
+ p.drawLine(offsetX, offsetY + 3, offsetX + w - 1, offsetY + 3);
+}
+
+
+
+}
+
--- branches/work/soc-umbrello-2011/umbrello/soc-umbrello-2011/entitywidget.h #1248908:1248909
@@ -10,15 +10,14 @@
#ifndef QGV_ENTITYWIDGET_H
#define QGV_ENTITYWIDGET_H
-#include "umlwidget.h"
+#include "soc-umbrello-2011/umlwidget.h"
class UMLObject;
-#define ENTITY_MARGIN 5
-
namespace QGV {
class UMLView;
+ class UMLWidget;
class EntityWidget : public UMLWidget {
@@ -26,14 +25,18 @@
EntityWidget(UMLView* view = 0, UMLObject* o = 0);
virtual ~EntityWidget();
+ void draw(QPainter& p, qreal offsetX, qreal offsetY);
+
+
private:
UMLView *m_view;
UMLObject *m_obj;
+ UMLWidget *m_widget;
+ };
- };
}
#endif
\ No newline at end of file
--- branches/work/soc-umbrello-2011/umbrello/soc-umbrello-2011/umlwidget.cpp #1248908:1248909
@@ -24,7 +24,7 @@
namespace QGV {
-UMLWidget::UMLWidget(UMLView* view, UMLObject* o, UMLWidgetController* widgetController): WidgetBase(view),
+UMLWidget::UMLWidget(UMLView* view, UMLObject* o, UMLWidgetController* widgetController /* = 0*/): WidgetBase(view),
m_menu(0),
m_ismenuembedded(false)
{
@@ -112,7 +112,7 @@
m_view = view;
}
-Widget_Type UMLWidget::type()
+Uml::Widget_Type UMLWidget::widget_type()
{
return m_type;
}
@@ -344,5 +344,24 @@
return QRectF(QPointF(0, 0), calculateSize());
}
+QFontMetrics &UMLWidget::fontMetrics(UMLWidget::FontType fontType)
+{
+ if (m_pFontMetrics[fontType] == 0) {
+ setDefaultFontMetrics(fontType);
+ }
+ return *m_pFontMetrics[fontType];
+}
+void UMLWidget::setDefaultFontMetrics(UMLWidget::FontType fontType)
+{
+ //setupFontType(m_Font, fontType);
+ setFontMetrics(fontType, QFontMetrics(m_Font));
+}
+
+void UMLWidget::setDefaultFontMetrics(UMLWidget::FontType fontType, QPainter& painter)
+{
+ setFontMetrics(fontType, QFontMetrics(m_Font));
+}
+
+
}
\ No newline at end of file
--- branches/work/soc-umbrello-2011/umbrello/soc-umbrello-2011/umlwidget.h #1248908:1248909
@@ -39,17 +39,22 @@
Q_OBJECT
public:
- explicit UMLWidget(UMLView * view, UMLObject * o, UMLWidgetController *widgetController = 0);
- explicit UMLWidget(UMLView * view, Uml::IDType id = Uml::id_None, UMLWidgetController *widgetController = 0);
+ UMLWidget(UMLView * view, UMLObject * o, UMLWidgetController *widgetController = 0);
+ UMLWidget(UMLView * view, Uml::IDType id = Uml::id_None, UMLWidgetController *widgetController = 0);
virtual ~UMLWidget();
void init();
void setView(UMLView *view);
- Uml::Widget_Type type();
+ Uml::Widget_Type widget_type();
void setType(Uml::Widget_Type type);
+ QFontMetrics &fontMetrics(UMLWidget::FontType fontType);
+
+ virtual void setDefaultFontMetrics(UMLWidget::FontType fontType);
+ virtual void setDefaultFontMetrics(UMLWidget::FontType fontType, QPainter &painter);
+
void setId(IDType id);
IDType id() const;
--- branches/work/soc-umbrello-2011/umbrello/soc-umbrello-2011/widgetbase.cpp #1248908:1248909
@@ -87,7 +87,7 @@
return m_view;
}
-Widget_Type WidgetBase::type()
+Uml::Widget_Type WidgetBase::widget_type()
{
return m_type;
}
--- branches/work/soc-umbrello-2011/umbrello/soc-umbrello-2011/widgetbase.h #1248908:1248909
@@ -34,7 +34,7 @@
void init(UMLView *view, Uml::Widget_Type type = Uml::wt_UMLWidget);
- Uml::Widget_Type type();
+ Uml::Widget_Type widget_type();
void setBaseType( Uml::Widget_Type type );
UMLObject* umlObject() const;
--- branches/work/soc-umbrello-2011/umbrello/widgets/widget_factory.cpp #1248908:1248909
@@ -207,6 +207,7 @@
// newWidget = new EnumWidget(view, static_cast<UMLEnum*>(o));
break;
case Uml::ot_Entity:
+ qDebug() << "creating a new Entity Widget";
newWidget = new QGV::EntityWidget(view, static_cast<UMLEntity*>(o));
break;
case Uml::ot_Interface:
More information about the umbrello-devel
mailing list