~ubuntu-branches/ubuntu/vivid/kdesdk/vivid

« back to all changes in this revision

Viewing changes to umbrello/umbrello/widgets/umlwidget.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-06-06 11:49:54 UTC
  • mfrom: (0.4.21)
  • Revision ID: package-import@ubuntu.com-20120606114954-rdls73fzlpzxglbx
Tags: 4:4.8.80-0ubuntu1
* New uptream beta release
* Update dont_export_private_classes.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
9
9
 ***************************************************************************/
10
10
 
11
 
// own header file
12
11
#include "umlwidget.h"
 
12
 
 
13
// local includes
 
14
#include "associationwidget.h"
 
15
#include "classifier.h"
 
16
#include "classpropdlg.h"
 
17
#include "cmds.h"
 
18
#include "debug_utils.h"
 
19
#include "floatingtextwidget.h"
 
20
#include "idchangelog.h"
 
21
#include "listpopupmenu.h"
 
22
#include "settingsdlg.h"
 
23
#include "uml.h"
 
24
#include "umldoc.h"
 
25
#include "umlobject.h"
 
26
#include "umlview.h"
 
27
#include "umlwidgetcontroller.h"
 
28
#include "uniqueid.h"
 
29
 
 
30
// kde includes
 
31
#include <kcolordialog.h>
 
32
#include <kfontdialog.h>
 
33
#include <klocale.h>
 
34
#include <kmessagebox.h>
 
35
 
13
36
// qt includes
14
37
#include <QtCore/QPointer>
15
38
#include <QtGui/QPainter>
16
39
#include <QtGui/QColor>
17
40
#include <QtGui/QMouseEvent>
18
 
// kde includes
19
 
#include <kcolordialog.h>
20
 
#include <kfontdialog.h>
21
 
#include <klocale.h>
22
 
#include <kmessagebox.h>
23
 
// local includes
24
 
#include "debug_utils.h"
25
 
#include "umlwidgetcontroller.h"
26
 
#include "umlobject.h"
27
 
#include "classifier.h"
28
 
#include "uniqueid.h"
29
 
#include "uml.h"
30
 
#include "umldoc.h"
31
 
#include "umlview.h"
32
 
#include "umlclassifierlistitemlist.h"
33
 
#include "listpopupmenu.h"
34
 
#include "associationwidget.h"
35
 
#include "settingsdlg.h"
36
 
#include "codedocument.h"
37
 
#include "floatingtextwidget.h"
38
 
#include "docwindow.h"
39
 
#include "classpropdlg.h"
40
 
#include "idchangelog.h"
41
 
#include "cmds.h"
42
41
 
43
42
using namespace Uml;
44
43
 
54
53
 */
55
54
UMLWidget::UMLWidget(UMLScene * scene, WidgetType type, UMLObject * o, UMLWidgetController *widgetController)
56
55
  : WidgetBase(scene, type),
57
 
    UMLSceneRectItem(scene->canvas())
 
56
    UMLSceneRectItem()
58
57
{
 
58
    setCanvas(scene->canvas());
59
59
    if (widgetController) {
60
60
        m_widgetController = widgetController;
61
61
    } else {
79
79
 */
80
80
UMLWidget::UMLWidget(UMLScene *scene, WidgetType type, Uml::IDType id, UMLWidgetController *widgetController)
81
81
  : WidgetBase(scene, type),
82
 
    UMLSceneRectItem(scene->canvas())
 
82
    UMLSceneRectItem()
83
83
{
 
84
    setCanvas(scene->canvas());
84
85
    if (widgetController) {
85
86
        m_widgetController = widgetController;
86
87
    } else {
94
95
}
95
96
 
96
97
/**
97
 
 * Standard destructor.
 
98
 * Destructor.
98
99
 */
99
100
UMLWidget::~UMLWidget()
100
101
{
125
126
    m_instanceName = other.m_instanceName;
126
127
    m_instanceName = other.m_instanceName;
127
128
    m_showStereotype = other.m_showStereotype;
128
 
    setX(other.getX());
129
 
    setY(other.getY());
 
129
    setX(other.x());
 
130
    setY(other.y());
130
131
    UMLSceneRectItem::setSize(other.width(), other.height());
131
132
 
132
133
    // assign volatile (non-saved) members
155
156
    if (this == &other)
156
157
        return true;
157
158
 
158
 
    if (m_Type != other.m_Type) {
 
159
    if (m_baseType != other.m_baseType) {
159
160
        return false;
160
161
    }
161
162
 
228
229
void UMLWidget::updateWidget()
229
230
{
230
231
    updateComponentSize();
231
 
    adjustAssocs(getX(), getY());   //adjust assoc lines.
232
 
    switch (m_Type) {
 
232
    switch (m_baseType) {
233
233
    case WidgetBase::wt_Class:
234
234
        m_scene->createAutoAttributeAssociations(this);
235
235
        break;
264
264
        width = maxSize.width();
265
265
    if (height > maxSize.height())
266
266
        height = maxSize.height();
 
267
 
 
268
    if (fixedAspectRatio()) {
 
269
        UMLSceneSize size = UMLSceneRectItem::size();
 
270
        float aspectRatio = (float)size.height()/size.width();
 
271
        height = width * aspectRatio;
 
272
    }
267
273
}
268
274
 
269
275
/**
310
316
    }
311
317
 
312
318
    m_resizable = true;
 
319
    m_fixedAspectRatio = false;
313
320
 
314
321
    m_selected = false;
315
322
    m_startMove = false;
322
329
    connect(m_scene, SIGNAL(sigRemovePopupMenu()), this, SLOT(slotRemovePopupMenu()));
323
330
    connect(m_scene, SIGNAL(sigClearAllSelected()), this, SLOT(slotClearAllSelected()));
324
331
 
325
 
    connect(m_scene, SIGNAL(sigColorChanged(Uml::IDType)), this, SLOT(slotColorChanged(Uml::IDType)));
 
332
    connect(m_scene, SIGNAL(sigFillColorChanged(Uml::IDType)), this, SLOT(slotFillColorChanged(Uml::IDType)));
 
333
    connect(m_scene, SIGNAL(sigLineColorChanged(Uml::IDType)), this, SLOT(slotLineColorChanged(Uml::IDType)));
 
334
    connect(m_scene, SIGNAL(sigTextColorChanged(Uml::IDType)), this, SLOT(slotTextColorChanged(Uml::IDType)));
326
335
    connect(m_scene, SIGNAL(sigLineWidthChanged(Uml::IDType)), this, SLOT(slotLineWidthChanged(Uml::IDType)));
327
336
 
328
337
    m_pObject = NULL;
337
346
void UMLWidget::slotMenuSelection(QAction* action)
338
347
{
339
348
    QColor newColor;
340
 
    const WidgetBase::WidgetType wt = m_Type;
 
349
    const WidgetBase::WidgetType wt = m_baseType;
341
350
    UMLWidget* widget = 0; // use for select the first object properties (fill, line color)
342
351
 
343
352
    ListPopupMenu::MenuType sel = m_pMenu->getMenuType(action);
344
353
    switch (sel) {
345
354
    case ListPopupMenu::mt_Rename:
346
355
        m_doc->renameUMLObject(m_pObject);
347
 
        // adjustAssocs( getX(), getY() );//adjust assoc lines
 
356
        // adjustAssocs( x(), y() );  // adjust assoc lines
348
357
        break;
349
358
 
350
359
    case ListPopupMenu::mt_Delete:
369
378
        } else {
370
379
            uWarning() << "making properties dialog for unknown widget type";
371
380
        }
372
 
        // adjustAssocs( getX(), getY() );//adjust assoc lines
 
381
        // adjustAssocs( x(), y() );  // adjust assoc lines
373
382
        break;
374
383
 
375
384
    case ListPopupMenu::mt_Line_Color:
428
437
    case ListPopupMenu::mt_Change_Font:
429
438
    case ListPopupMenu::mt_Change_Font_Selection: {
430
439
        QFont font = UMLWidget::font();
431
 
        if (KFontDialog::getFont(font, KFontChooser::NoDisplayFlags, m_scene)) {
 
440
        if (KFontDialog::getFont(font, KFontChooser::NoDisplayFlags, m_scene->view())) {
432
441
            UMLApp::app()->executeCommand(new CmdChangeFontSelection(m_doc, m_scene, font));
433
442
        }
434
443
    }
478
487
}
479
488
 
480
489
/**
481
 
 * Captures when another widget moves if it is link to it that signal.
 
490
 * Captures when another widget moves if this widget is linked to it.
 
491
 * @see sigWidgetMoved
482
492
 *
483
493
 * @param id The id of object behind the widget.
484
494
 */
491
501
 *
492
502
 * @param sceneID The id of the object behind the widget.
493
503
 */
494
 
void UMLWidget::slotColorChanged(Uml::IDType viewID)
 
504
void UMLWidget::slotFillColorChanged(Uml::IDType viewID)
495
505
{
496
506
    //only change if on the diagram concerned
497
 
    if (m_scene->getID() != viewID) {
 
507
    if (m_scene->ID() != viewID) {
498
508
        return;
499
509
    }
500
510
    if (m_usesDiagramFillColor) {
501
511
        m_FillColor = m_scene->fillColor();
502
512
    }
 
513
    if (m_usesDiagramUseFillColor) {
 
514
        m_useFillColor = m_scene->useFillColor();
 
515
    }
 
516
    update();
 
517
}
 
518
 
 
519
/**
 
520
 * Captures a text color change signal.
 
521
 *
 
522
 * @param sceneID The id of the object behind the widget.
 
523
 */
 
524
void UMLWidget::slotTextColorChanged(Uml::IDType viewID)
 
525
{
 
526
    //only change if on the diagram concerned
 
527
    if (m_scene->ID() != viewID)
 
528
        return;
 
529
    setTextColor( m_scene->textColor() );
 
530
    update();
 
531
}
 
532
 
 
533
 
 
534
/**
 
535
 * Captures a line color change signal.
 
536
 *
 
537
 * @param sceneID The id of the object behind the widget.
 
538
 */
 
539
void UMLWidget::slotLineColorChanged(Uml::IDType viewID)
 
540
{
 
541
    //only change if on the diagram concerned
 
542
    if (m_scene->ID() != viewID)
 
543
        return;
 
544
 
503
545
    if (m_usesDiagramLineColor) {
504
546
        m_LineColor = m_scene->lineColor();
505
 
    }
506
 
    if (m_usesDiagramUseFillColor) {
507
 
        m_useFillColor = m_scene->useFillColor();
 
547
        setLineColor( m_LineColor );
508
548
    }
509
549
    update();
510
550
}
517
557
void UMLWidget::slotLineWidthChanged(Uml::IDType viewID)
518
558
{
519
559
    //only change if on the diagram concerned
520
 
    if (m_scene->getID() != viewID) {
 
560
    if (m_scene->ID() != viewID) {
521
561
        return;
522
562
    }
523
563
    if (m_usesDiagramLineWidth) {
551
591
/**
552
592
 * Overrides the method from WidgetBase.
553
593
 */
 
594
void UMLWidget::setTextColorcmd(const QColor &color)
 
595
{
 
596
    WidgetBase::setTextColor(color);
 
597
    update();
 
598
}
 
599
 
 
600
/**
 
601
 * Overrides the method from WidgetBase.
 
602
 */
 
603
void UMLWidget::setTextColor(const QColor &color)
 
604
{
 
605
    UMLApp::app()->executeCommand(new CmdChangeTextColor(this, color));
 
606
    update();
 
607
}
 
608
 
 
609
/**
 
610
 * Overrides the method from WidgetBase.
 
611
 */
554
612
void UMLWidget::setLineColorcmd(const QColor &color)
555
613
{
556
614
    WidgetBase::setLineColor(color);
613
671
    p->fillRect(offsetX + w - s, offsetY, s, s, brush);
614
672
 
615
673
    // Draw the resize anchor in the lower right corner.
616
 
    if (m_resizable) {
 
674
    // Don't draw it if the widget is so small that the
 
675
    // resize anchor would cover up most of the widget.
 
676
    if (m_resizable && w * h > (s*3) * (s*3)) {
617
677
        brush.setColor(Qt::red);
618
678
        const int right = offsetX + w;
619
679
        const int bottom = offsetY + h;
633
693
 */
634
694
bool UMLWidget::activate(IDChangeLog* /*ChangeLog  = 0 */)
635
695
{
636
 
    if (widgetHasUMLObject(m_Type) && m_pObject == NULL) {
 
696
    if (widgetHasUMLObject(m_baseType) && m_pObject == NULL) {
637
697
        m_pObject = m_doc->findObjectById(m_nId);
638
698
        if (m_pObject == NULL) {
639
699
            uError() << "cannot find UMLObject with id=" << ID2STR(m_nId);
641
701
        }
642
702
    }
643
703
    setFont(m_Font);
644
 
    setSize(getWidth(), getHeight());
 
704
    setSize(width(), height());
645
705
    m_activated = true;
646
706
    updateComponentSize();
647
707
    if (m_scene->getPaste()) {
648
708
        FloatingTextWidget * ft = 0;
649
709
        QPoint point = m_scene->getPastePoint();
650
 
        int x = point.x() + getX();
651
 
        int y = point.y() + getY();
 
710
        int x = point.x() + this->x();
 
711
        int y = point.y() + this->y();
652
712
        x = x < 0 ? 0 : x;
653
713
        y = y < 0 ? 0 : y;
654
714
        if (m_scene->type() == Uml::DiagramType::Sequence) {
655
715
            switch (baseType()) {
656
716
            case WidgetBase::wt_Object:
657
717
            case WidgetBase::wt_Precondition :
658
 
                setY(getY());
 
718
                setY(this->y());
659
719
                setX(x);
660
720
                break;
661
721
 
662
722
            case WidgetBase::wt_Message:
663
 
                setY(getY());
 
723
                setY(this->y());
664
724
                setX(x);
665
725
                break;
666
726
 
668
728
                ft = static_cast<FloatingTextWidget *>(this);
669
729
                if (ft->textRole() == Uml::TextRole::Seq_Message) {
670
730
                    setX(x);
671
 
                    setY(getY());
 
731
                    setY(this->y());
672
732
                } else {
673
 
                    setX(getX());
674
 
                    setY(getY());
 
733
                    setX(this->x());
 
734
                    setY(this->y());
675
735
                }
676
736
                break;
677
737
 
686
746
        }
687
747
    }//end if pastepoint
688
748
    else {
689
 
        setX(getX());
690
 
        setY(getY());
 
749
        setX(this->x());
 
750
        setY(this->y());
691
751
    }
692
752
    if (m_scene->getPaste())
693
753
        m_scene->createAutoAssociations(this);
758
818
        // -> return immediately without action
759
819
        return;
760
820
    }
761
 
    AssociationWidgetListIt assoc_it(m_Assocs);
762
821
 
763
822
    foreach(AssociationWidget* assocwidget , m_Assocs) {
764
823
        assocwidget->saveIdealTextPositions();
779
838
{
780
839
    foreach(AssociationWidget* assocwidget , m_Assocs) {
781
840
 
782
 
        if (!assocwidget->getSelected())
 
841
        if (!assocwidget->isSelected())
783
842
            assocwidget->saveIdealTextPositions();
784
843
    }
785
844
 
786
845
    foreach(AssociationWidget* assocwidget , m_Assocs) {
787
 
        if (!assocwidget->getSelected())
 
846
        if (!assocwidget->isSelected())
788
847
            assocwidget->widgetMoved(this, x, y);
789
848
    }
790
849
}
796
855
{
797
856
    // will already be selected so make sure docWindow updates the doc
798
857
    // back it the widget
799
 
    DocWindow *docwindow = UMLApp::app()->docWindow();
800
 
    docwindow->updateDocumentation(false);
 
858
    umlScene()->updateDocumentation(false);
801
859
    QPointer<ClassPropDlg> dlg = new ClassPropDlg((QWidget*)UMLApp::app(), this);
802
860
 
803
861
    if (dlg->exec()) {
804
 
        docwindow->showDocumentation(umlObject() , true);
 
862
        umlScene()->showDocumentation(umlObject() , true);
805
863
        m_doc->setModified(true);
806
864
    }
807
865
    dlg->close(); //wipe from memory
830
888
    m_menuIsEmbedded = false;
831
889
    //if in a multi- selection to a specific m_pMenu for that
832
890
    // NEW: ask UMLView to count ONLY the widgets and not their floatingtextwidgets
833
 
    int count = m_scene->getSelectCount(true);
 
891
    int count = m_scene->selectedCount(true);
834
892
    //a MessageWidget when selected will select its text widget and vice versa
835
893
    //so take that into account for popup menu.
836
894
 
846
904
        unique = m_scene->checkUniqueSelection();
847
905
 
848
906
    // create the right click context menu
849
 
    m_pMenu = new ListPopupMenu(m_scene, this, multi, unique);
 
907
    m_pMenu = new ListPopupMenu(m_scene->view(), this, multi, unique);
850
908
 
851
909
    // disable the "view code" menu for simple code generators
852
910
    if (UMLApp::app()->isSimpleCodeGeneratorActive())
887
945
{
888
946
    const int w = width();
889
947
    const int h = height();
890
 
    const int left = getX();
 
948
    const int left = x();
891
949
    const int right = left + w;
892
 
    const int top = getY();
 
950
    const int top = y();
893
951
    const int bottom = top + h;
894
952
    if (p.x() < left || p.x() > right ||
895
953
            p.y() < top || p.y() > bottom)   // Qt coord.sys. origin in top left corner
903
961
 */
904
962
void UMLWidget::moveByLocal(int dx, int dy)
905
963
{
906
 
    int newX = getX() + dx;
907
 
    int newY = getY() + dy;
 
964
    int newX = x() + dx;
 
965
    int newY = y() + dy;
908
966
    setX(newX);
909
967
    setY(newY);
910
968
    // uDebug() << "********** x=" << newX << " / y=" << newY;
926
984
 */
927
985
void UMLWidget::drawShape(QPainter &p)
928
986
{
929
 
    paint(p, getX(), getY());
 
987
    paint(p, x(), y());
930
988
}
931
989
 
932
990
/**
997
1055
 */
998
1056
void UMLWidget::setSelected(bool _select)
999
1057
{
1000
 
    const WidgetBase::WidgetType wt = m_Type;
 
1058
    const WidgetBase::WidgetType wt = m_baseType;
1001
1059
    if (_select) {
1002
 
        if (m_scene->getSelectCount() == 0) {
 
1060
        if (m_scene->selectedCount() == 0) {
1003
1061
            if (widgetHasUMLObject(wt)) {
1004
1062
                m_scene->showDocumentation(m_pObject, false);
1005
1063
            } else {
1018
1076
    }
1019
1077
    m_selected = _select;
1020
1078
 
1021
 
    const QPoint pos(getX(), getY());
 
1079
    const QPoint pos(x(), y());
1022
1080
    UMLWidget *bkgnd = m_scene->widgetAt(pos);
1023
1081
    if (bkgnd && bkgnd != this && _select) {
1024
 
        uDebug() << "setting Z to " << bkgnd->getZ() + 1 << ", SelectState: " << _select;
1025
 
        setZ(bkgnd->getZ() + 1);
 
1082
        uDebug() << "setting Z to " << bkgnd->z() + 1 << ", SelectState: " << _select;
 
1083
        setZ(bkgnd->z() + 1);
1026
1084
    } else {
1027
1085
        setZ(m_origZ);
1028
1086
    }
1052
1110
    //remove signals from old view - was probably 0 anyway
1053
1111
    disconnect(m_scene, SIGNAL(sigRemovePopupMenu()), this, SLOT(slotRemovePopupMenu()));
1054
1112
    disconnect(m_scene, SIGNAL(sigClearAllSelected()), this, SLOT(slotClearAllSelected()));
1055
 
    disconnect(m_scene, SIGNAL(sigColorChanged(Uml::IDType)), this, SLOT(slotColorChanged(Uml::IDType)));
 
1113
    disconnect(m_scene, SIGNAL(sigFillColorChanged(Uml::IDType)), this, SLOT(slotFillColorChanged(Uml::IDType)));
 
1114
    disconnect(m_scene, SIGNAL(sigTextColorChanged(Uml::IDType)), this, SLOT(slotTextColorChanged(Uml::IDType)));
1056
1115
    disconnect(m_scene, SIGNAL(sigLineWidthChanged(Uml::IDType)), this, SLOT(slotLineWidthChanged(Uml::IDType)));
1057
1116
    m_scene = v;
1058
1117
    connect(m_scene, SIGNAL(sigRemovePopupMenu()), this, SLOT(slotRemovePopupMenu()));
1059
1118
    connect(m_scene, SIGNAL(sigClearAllSelected()), this, SLOT(slotClearAllSelected()));
1060
 
    connect(m_scene, SIGNAL(sigColorChanged(Uml::IDType)), this, SLOT(slotColorChanged(Uml::IDType)));
 
1119
    connect(m_scene, SIGNAL(sigFillColorChanged(Uml::IDType)), this, SLOT(slotFillColorChanged(Uml::IDType)));
 
1120
    connect(m_scene, SIGNAL(sigTextColorChanged(Uml::IDType)), this, SLOT(slotTextColorChanged(Uml::IDType)));
1061
1121
    connect(m_scene, SIGNAL(sigLineWidthChanged(Uml::IDType)), this, SLOT(slotLineWidthChanged(Uml::IDType)));
1062
1122
}
1063
1123
 
1064
1124
/**
 
1125
 * Gets the x-coordinate.
 
1126
 */
 
1127
UMLSceneValue UMLWidget::x() const {
 
1128
    return UMLSceneRectItem::x();
 
1129
}
 
1130
/**
 
1131
 * Gets the y-coordinate.
 
1132
 */
 
1133
UMLSceneValue UMLWidget::y() const {
 
1134
    return UMLSceneRectItem::y();
 
1135
}
 
1136
/**
 
1137
 * Gets the z-coordinate.
 
1138
 */
 
1139
UMLSceneValue UMLWidget::z() const {
 
1140
    return UMLSceneRectItem::z();
 
1141
}
 
1142
 
 
1143
/**
1065
1144
 * Sets the x-coordinate.
1066
1145
 * Currently, the only class that reimplements this method is
1067
1146
 * ObjectWidget.
1068
1147
 *
1069
1148
 * @param x The x-coordinate to be set.
1070
1149
 */
1071
 
void UMLWidget::setX(int x)
 
1150
void UMLWidget::setX(UMLSceneValue x)
1072
1151
{
1073
1152
    if (!m_ignoreSnapToGrid) {
1074
1153
        x = m_scene->snappedX(x);
1083
1162
 *
1084
1163
 * @param y The y-coordinate to be set.
1085
1164
 */
1086
 
void UMLWidget::setY(int y)
 
1165
void UMLWidget::setY(UMLSceneValue y)
1087
1166
{
1088
1167
    if (!m_ignoreSnapToGrid) {
1089
1168
        y = m_scene->snappedX(y);
1096
1175
 *
1097
1176
 * @param z The z-coordinate to be set.
1098
1177
 */
1099
 
void UMLWidget::setZ(int z)
 
1178
void UMLWidget::setZ(UMLSceneValue z)
1100
1179
{
1101
 
    m_origZ = getZ();
 
1180
    m_origZ = this->z();
1102
1181
    UMLSceneItem::setZ(z);
1103
1182
}
1104
1183
 
1115
1194
    else
1116
1195
        m_Text = strName;
1117
1196
    updateComponentSize();
1118
 
    adjustAssocs(getX(), getY());
1119
1197
}
1120
1198
 
1121
1199
/**
1145
1223
 */
1146
1224
void UMLWidget::slotSnapToGrid()
1147
1225
{
1148
 
    setX(getX());
1149
 
    setY(getY());
 
1226
    setX(x());
 
1227
    setY(y());
1150
1228
}
1151
1229
 
1152
1230
/**
1189
1267
 
1190
1268
/**
1191
1269
 * Sets the size.
1192
 
 * If m_scene->getSnapComponentSizeToGrid() is true, then
 
1270
 * If m_scene->snapComponentSizeToGrid() is true, then
1193
1271
 * set the next larger size that snaps to the grid.
1194
1272
 */
1195
1273
void UMLWidget::setSize(int width, int height)
1196
1274
{
1197
1275
    // snap to the next larger size that is a multiple of the grid
1198
1276
    if (!m_ignoreSnapComponentSizeToGrid
1199
 
            && m_scene->getSnapComponentSizeToGrid()) {
 
1277
            && m_scene->snapComponentSizeToGrid()) {
1200
1278
        // integer divisions
1201
 
        int numX = width / m_scene->getSnapX();
1202
 
        int numY = height / m_scene->getSnapY();
 
1279
        int numX = width / m_scene->snapX();
 
1280
        int numY = height / m_scene->snapY();
1203
1281
        // snap to the next larger valid value
1204
 
        if (width > numX * m_scene->getSnapX())
1205
 
            width = (numX + 1) * m_scene->getSnapX();
1206
 
        if (height > numY * m_scene->getSnapY())
1207
 
            height = (numY + 1) * m_scene->getSnapY();
 
1282
        if (width > numX * m_scene->snapX())
 
1283
            width = (numX + 1) * m_scene->snapX();
 
1284
        if (height > numY * m_scene->snapY())
 
1285
            height = (numY + 1) * m_scene->snapY();
1208
1286
    }
1209
1287
 
1210
1288
    UMLSceneRectItem::setSize(width, height);
1219
1297
        return;
1220
1298
    QSize size = minimumSize();
1221
1299
    setSize(size.width(), size.height());
1222
 
    adjustAssocs(getX(), getY());    // adjust assoc lines
 
1300
    adjustAssocs(x(), y());    // adjust assoc lines
1223
1301
}
1224
1302
 
1225
1303
/**
1228
1306
 */
1229
1307
void UMLWidget::clipSize()
1230
1308
{
1231
 
    int width = getWidth();
1232
 
    int height = getHeight();
1233
 
    constrain(width, height);
1234
 
    setSize(width, height);
 
1309
    int clipWidth = width();
 
1310
    int clipHeight = height();
 
1311
    constrain(clipWidth, clipHeight);
 
1312
    setSize(clipWidth, clipHeight);
1235
1313
}
1236
1314
 
 
1315
/**
 
1316
 * Template Method, override this to set the default font metric.
 
1317
 */
1237
1318
void UMLWidget::setDefaultFontMetrics(UMLWidget::FontType fontType)
1238
1319
{
1239
1320
    setupFontType(m_Font, fontType);
1287
1368
    }
1288
1369
}
1289
1370
 
 
1371
/**
 
1372
 * Template Method, override this to set the default font metric.
 
1373
 */
1290
1374
void UMLWidget::setDefaultFontMetrics(UMLWidget::FontType fontType, QPainter &painter)
1291
1375
{
1292
1376
    setupFontType(m_Font, fontType);
1294
1378
    setFontMetrics(fontType, painter.fontMetrics());
1295
1379
}
1296
1380
 
 
1381
/**
 
1382
 * Returns the font metric used by this object for Text
 
1383
 * which uses bold/italic fonts.
 
1384
 */
1297
1385
QFontMetrics &UMLWidget::getFontMetrics(UMLWidget::FontType fontType)
1298
1386
{
1299
1387
    if (m_pFontMetrics[fontType] == 0) {
1302
1390
    return *m_pFontMetrics[fontType];
1303
1391
}
1304
1392
 
 
1393
/**
 
1394
 * Set the font metric to use.
 
1395
 */
1305
1396
void UMLWidget::setFontMetrics(UMLWidget::FontType fontType, QFontMetrics fm)
1306
1397
{
1307
1398
    delete m_pFontMetrics[fontType];
1359
1450
/**
1360
1451
 * Set the status of whether to show Stereotype.
1361
1452
 *
1362
 
 * @param _status   True if stereotype shall be shown.
 
1453
 * @param flag   True if stereotype shall be shown.
1363
1454
 */
1364
 
void UMLWidget::setShowStereotype(bool _status)
 
1455
void UMLWidget::setShowStereotype(bool flag)
1365
1456
{
1366
 
    m_showStereotype = _status;
 
1457
    m_showStereotype = flag;
1367
1458
    updateComponentSize();
1368
1459
    update();
1369
1460
}
1373
1464
 *
1374
1465
 * @return  True if stereotype is shown.
1375
1466
 */
1376
 
bool UMLWidget::getShowStereotype() const
 
1467
bool UMLWidget::showStereotype() const
1377
1468
{
1378
1469
    return m_showStereotype;
1379
1470
}
1396
1487
    WidgetBase::saveToXMI(qDoc, qElement);
1397
1488
    qElement.setAttribute("xmi.id", ID2STR(id()));
1398
1489
    qElement.setAttribute("font", m_Font.toString());
1399
 
    qElement.setAttribute("x", getX());
1400
 
    qElement.setAttribute("y", getY());
1401
 
    qElement.setAttribute("width", getWidth());
1402
 
    qElement.setAttribute("height", getHeight());
 
1490
    qElement.setAttribute("x", x());
 
1491
    qElement.setAttribute("y", y());
 
1492
    qElement.setAttribute("width", width());
 
1493
    qElement.setAttribute("height", height());
1403
1494
    qElement.setAttribute("isinstance", m_isInstance);
1404
1495
    if (!m_instanceName.isEmpty())
1405
1496
        qElement.setAttribute("instancename", m_instanceName);