~ubuntu-branches/ubuntu/intrepid/kdesdk/intrepid-updates

« back to all changes in this revision

Viewing changes to umbrello/umbrello/umlwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-28 10:11:43 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: james.westby@ubuntu.com-20080528101143-gzc3styjz1b70zxu
Tags: upstream-4.0.80
ImportĀ upstreamĀ versionĀ 4.0.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *   the Free Software Foundation; either version 2 of the License, or     *
6
6
 *   (at your option) any later version.                                   *
7
7
 *                                                                         *
8
 
 *   copyright (C) 2002-2007                                               *
 
8
 *   copyright (C) 2002-2008                                               *
9
9
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
10
10
 ***************************************************************************/
11
11
 
14
14
// system includes
15
15
#include <qpainter.h>
16
16
#include <qcolor.h>
 
17
//Added by qt3to4:
 
18
#include <QMouseEvent>
17
19
#include <kdebug.h>
18
20
#include <kcolordialog.h>
19
21
#include <kfontdialog.h>
38
40
#include "dialogs/classpropdlg.h"
39
41
#include "clipboard/idchangelog.h"
40
42
 
 
43
#include "cmds.h"
 
44
 
41
45
using namespace Uml;
42
46
 
43
 
 
44
 
UMLWidget::UMLWidget( UMLView * view, UMLObject * o, UMLWidgetController *widgetController /* = 0*/ )
45
 
        : WidgetBase(view), QCanvasRectangle( view->canvas() ),
 
47
UMLWidget::UMLWidget(UMLView * view, UMLObject * o, UMLWidgetController *widgetController /* = 0*/)
 
48
        : WidgetBase(view), Q3CanvasRectangle(view->canvas()),
46
49
        m_pMenu(0)
47
50
{
48
51
    if (widgetController) {
52
55
    }
53
56
    init();
54
57
    m_pObject = o;
55
 
    if(m_pObject) {
56
 
        connect( m_pObject, SIGNAL(modified()), this, SLOT(updateWidget()) );
 
58
    if (m_pObject) {
 
59
        connect(m_pObject, SIGNAL(modified()), this, SLOT(updateWidget()));
57
60
        m_nId = m_pObject->getID();
58
61
    }
59
62
}
60
63
 
61
64
UMLWidget::UMLWidget(UMLView * view, Uml::IDType id /* = Uml::id_None */, UMLWidgetController *widgetController /* = 0*/)
62
 
        : WidgetBase(view), QCanvasRectangle( view->canvas() ),
 
65
        : WidgetBase(view), Q3CanvasRectangle(view->canvas()),
63
66
        m_pMenu(0)
64
67
{
65
68
    if (widgetController) {
74
77
        m_nId = id;
75
78
}
76
79
 
77
 
UMLWidget::~UMLWidget() {
 
80
UMLWidget::~UMLWidget()
 
81
{
78
82
    //slotRemovePopupMenu();
79
83
    delete m_widgetController;
80
84
    cleanup();
81
85
}
82
86
 
83
 
UMLWidget& UMLWidget::operator=(const UMLWidget& other) {
 
87
UMLWidget& UMLWidget::operator=(const UMLWidget & other)
 
88
{
84
89
    if (this == &other)
85
90
        return *this;
86
91
 
88
93
    m_bUseFillColour = other.m_bUseFillColour;
89
94
    m_nId = other.m_nId;
90
95
    m_Type = other.m_Type;
91
 
    setX( other.getX() );
92
 
    setY( other.getY() );
 
96
    setX(other.getX());
 
97
    setY(other.getY());
93
98
    m_Assocs = other.m_Assocs;
94
99
    m_Font = other.m_Font;
95
 
    QCanvasRectangle::setSize( other.width(), other.height() );
 
100
    Q3CanvasRectangle::setSize(other.width(), other.height());
96
101
    m_bUsesDiagramFillColour = other.m_bUsesDiagramFillColour;
97
102
    m_bUsesDiagramLineColour = other.m_bUsesDiagramLineColour;
98
103
    m_bUsesDiagramLineWidth  = other.m_bUsesDiagramLineWidth;
119
124
    return *this;
120
125
}
121
126
 
122
 
bool UMLWidget::operator==(const UMLWidget& other) {
123
 
    if( this == &other )
 
127
bool UMLWidget::operator==(const UMLWidget& other)
 
128
{
 
129
    if (this == &other)
124
130
        return true;
125
131
 
126
 
    if(m_Type != other.m_Type) {
 
132
    if (m_Type != other.m_Type) {
127
133
        return false;
128
134
    }
129
135
 
139
145
 
140
146
    // if(getBaseType() != wt_Text) // DON'T do this for floatingtext widgets, an infinite loop will result
141
147
    // {
142
 
    AssociationWidgetListIt assoc_it( m_Assocs );
143
 
    AssociationWidgetListIt assoc_it2( other.m_Assocs );
 
148
    AssociationWidgetListIt assoc_it(m_Assocs);
 
149
    AssociationWidgetListIt assoc_it2(other.m_Assocs);
144
150
    AssociationWidget * assoc = 0, *assoc2 = 0;
145
 
    while ( ((assoc=assoc_it.current()) != 0) &&  ((assoc2=assoc_it2.current()) != 0)) {
146
 
        ++assoc_it;
147
 
        ++assoc_it2;
148
 
        if(!(*assoc == *assoc2)) {
 
151
    while (assoc_it.hasNext() &&  assoc_it2.hasNext()) {
 
152
        assoc = assoc_it.next();
 
153
        assoc2 = assoc_it2.next();
 
154
 
 
155
        if (!(*assoc == *assoc2)) {
149
156
            return false;
150
157
        }
151
158
    }
167
174
     */
168
175
}
169
176
 
170
 
void UMLWidget::mouseMoveEvent(QMouseEvent* me) {
 
177
void UMLWidget::mouseMoveEvent(QMouseEvent* me)
 
178
{
171
179
    m_widgetController->mouseMoveEvent(me);
172
180
}
173
181
 
174
 
void UMLWidget::mousePressEvent(QMouseEvent *me) {
 
182
void UMLWidget::mousePressEvent(QMouseEvent *me)
 
183
{
175
184
    m_widgetController->mousePressEvent(me);
176
185
}
177
186
 
178
187
void UMLWidget::updateWidget()
179
188
{
180
189
    updateComponentSize();
181
 
    adjustAssocs( getX(), getY() ); //adjust assoc lines.
182
 
    if (m_Type == Uml::wt_Class) {
 
190
    adjustAssocs(getX(), getY());   //adjust assoc lines.
 
191
    switch (m_Type) {
 
192
    case Uml::wt_Class:
183
193
        m_pView->createAutoAttributeAssociations(this);
 
194
        break;
 
195
    case Uml::wt_Entity:
 
196
        m_pView->createAutoConstraintAssociations(this);
 
197
        break;
 
198
    default:
 
199
        break;
184
200
    }
185
 
    if(isVisible())
 
201
 
 
202
    if (isVisible())
186
203
        update();
187
204
}
188
205
 
189
 
QSize UMLWidget::calculateSize() {
 
206
QSize UMLWidget::calculateSize()
 
207
{
190
208
    return QSize(20, 20);
191
209
}
192
210
 
193
 
void UMLWidget::constrain(int& width, int& height) {
 
211
void UMLWidget::constrain(int& width, int& height)
 
212
{
194
213
    const QSize minSize = calculateSize();
195
214
    if (width < minSize.width())
196
215
        width = minSize.width();
198
217
        height = minSize.height();
199
218
}
200
219
 
201
 
void UMLWidget::mouseReleaseEvent(QMouseEvent *me) {
 
220
void UMLWidget::mouseReleaseEvent(QMouseEvent *me)
 
221
{
202
222
    m_widgetController->mouseReleaseEvent(me);
203
223
}
204
224
 
205
 
void UMLWidget::init() {
 
225
void UMLWidget::init()
 
226
{
206
227
    m_nId = Uml::id_None;
207
228
    m_bIsInstance = false;
208
229
    if (m_pView) {
214
235
        m_Font       = optionState.uiState.font;
215
236
        m_bShowStereotype = optionState.classState.showStereoType;
216
237
    } else {
217
 
        kError() << "UMLWidget::init: SERIOUS PROBLEM - m_pView is NULL" << endl;
 
238
        uError() << "SERIOUS PROBLEM - m_pView is NULL" << endl;
218
239
        m_bUseFillColour = false;
219
240
        m_bUsesDiagramFillColour = false;
220
241
        m_bUsesDiagramUseFillColour = false;
234
255
    m_pMenu = 0;
235
256
    m_pDoc = UMLApp::app()->getDocument();
236
257
    m_nPosX = 0;
237
 
    connect( m_pView, SIGNAL( sigRemovePopupMenu() ), this, SLOT( slotRemovePopupMenu() ) );
238
 
    connect( m_pView, SIGNAL( sigClearAllSelected() ), this, SLOT( slotClearAllSelected() ) );
 
258
    connect(m_pView, SIGNAL(sigRemovePopupMenu()), this, SLOT(slotRemovePopupMenu()));
 
259
    connect(m_pView, SIGNAL(sigClearAllSelected()), this, SLOT(slotClearAllSelected()));
239
260
 
240
 
    connect( m_pView, SIGNAL(sigColorChanged(Uml::IDType)), this, SLOT(slotColorChanged(Uml::IDType)));
241
 
    connect( m_pView, SIGNAL(sigLineWidthChanged(Uml::IDType)), this, SLOT(slotLineWidthChanged(Uml::IDType)));
 
261
    connect(m_pView, SIGNAL(sigColorChanged(Uml::IDType)), this, SLOT(slotColorChanged(Uml::IDType)));
 
262
    connect(m_pView, SIGNAL(sigLineWidthChanged(Uml::IDType)), this, SLOT(slotLineWidthChanged(Uml::IDType)));
242
263
 
243
264
 
244
265
    // connect( m_pView, SIGNAL(sigColorChanged(int)), this, SLOT(slotColorChanged(int)));
246
267
    setZ(m_origZ = 2);  // default for most widgets
247
268
}
248
269
 
249
 
void UMLWidget::slotMenuSelection(int sel) {
250
 
    QFont font;
 
270
void UMLWidget::slotMenuSelection(QAction* action)
 
271
{
251
272
    QColor newColour;
252
273
    const Uml::Widget_Type wt = m_Type;
253
274
    UMLWidget* widget = 0; // use for select the first object properties (fill, line color)
254
275
 
255
 
    switch(sel) {
 
276
    ListPopupMenu::Menu_Type sel = m_pMenu->getMenuType(action);
 
277
    switch (sel) {
256
278
    case ListPopupMenu::mt_Rename:
257
279
        m_pDoc -> renameUMLObject(m_pObject);
258
280
        // adjustAssocs( getX(), getY() );//adjust assoc lines
263
285
        m_pView -> removeWidget(this);
264
286
        break;
265
287
 
266
 
    //UMLWidgetController::doMouseDoubleClick relies on this implementation
 
288
        //UMLWidgetController::doMouseDoubleClick relies on this implementation
267
289
    case ListPopupMenu::mt_Properties:
268
290
        if (wt == wt_Actor || wt == wt_UseCase ||
269
291
                wt == wt_Package || wt == wt_Interface || wt == wt_Datatype ||
270
292
                wt == wt_Component || wt == wt_Artifact ||
271
293
                wt == wt_Node || wt == wt_Enum || wt == wt_Entity ||
272
294
                (wt == wt_Class && m_pView -> getType() == dt_Class)) {
 
295
            UMLApp::app()->BeginMacro("Change Properties");
273
296
            showProperties();
 
297
            UMLApp::app()->EndMacro();
274
298
        } else if (wt == wt_Object) {
 
299
            UMLApp::app()->BeginMacro("Change Properties");
275
300
            m_pObject->showProperties();
 
301
            UMLApp::app()->EndMacro();
276
302
        } else {
277
 
            kWarning() << "making properties dialog for unknown widget type" << endl;
 
303
            uWarning() << "making properties dialog for unknown widget type";
278
304
        }
279
305
        // adjustAssocs( getX(), getY() );//adjust assoc lines
280
306
        break;
281
307
 
282
308
    case ListPopupMenu::mt_Line_Color:
283
 
    case ListPopupMenu::mt_Line_Color_Selection:
284
309
        widget = m_pView->getFirstMultiSelectedWidget();
285
 
        if (widget) { newColour = widget->getLineColor(); }
286
 
        if( KColorDialog::getColor(newColour) ) {
287
 
            m_pView -> selectionSetLineColor( newColour );
 
310
        if (widget) {
 
311
            newColour = widget->getLineColor();
 
312
        }
 
313
        if (KColorDialog::getColor(newColour)) {
 
314
            m_pView -> selectionSetLineColor(newColour);
288
315
            m_pDoc -> setModified(true);
 
316
 
289
317
        }
290
318
        break;
291
319
 
292
320
    case ListPopupMenu::mt_Fill_Color:
293
 
    case ListPopupMenu::mt_Fill_Color_Selection:
294
321
        widget = m_pView->getFirstMultiSelectedWidget();
295
 
        if (widget) { newColour = widget->getFillColour(); }
296
 
        if ( KColorDialog::getColor(newColour) ) {
297
 
            m_pView -> selectionSetFillColor( newColour );
 
322
        if (widget) {
 
323
            newColour = widget->getFillColour();
 
324
        }
 
325
        if (KColorDialog::getColor(newColour)) {
 
326
            m_pView -> selectionSetFillColor(newColour);
298
327
            m_pDoc -> setModified(true);
299
328
        }
300
329
        break;
302
331
    case ListPopupMenu::mt_Use_Fill_Color:
303
332
        m_bUseFillColour = !m_bUseFillColour;
304
333
        m_bUsesDiagramUseFillColour = false;
305
 
        m_pView->selectionUseFillColor( m_bUseFillColour );
 
334
        m_pView->selectionUseFillColor(m_bUseFillColour);
306
335
        break;
307
336
    case ListPopupMenu::mt_Show_Attributes_Selection:
308
337
    case ListPopupMenu::mt_Show_Operations_Selection:
318
347
        break;
319
348
 
320
349
    case ListPopupMenu::mt_ViewCode: {
321
 
            UMLClassifier *c = dynamic_cast<UMLClassifier*>(m_pObject);
322
 
            if(c)
323
 
            {
324
 
                UMLApp::app()->viewCodeDocument(c);
325
 
            }
326
 
            break;
 
350
        UMLClassifier *c = dynamic_cast<UMLClassifier*>(m_pObject);
 
351
        if (c) {
 
352
            UMLApp::app()->viewCodeDocument(c);
327
353
        }
 
354
        break;
 
355
    }
328
356
 
329
357
    case ListPopupMenu::mt_Delete_Selection:
330
358
        m_pView -> deleteSelection();
331
359
        break;
332
360
 
333
361
    case ListPopupMenu::mt_Change_Font:
334
 
        font = getFont();
335
 
        if( KFontDialog::getFont( font, false, m_pView ) )
336
 
        {
337
 
            setFont( font );
338
 
            m_pDoc->setModified(true);
339
 
        }
340
 
        break;
341
 
 
342
 
    case ListPopupMenu::mt_Change_Font_Selection:
343
 
        font = getFont();
344
 
        if( KFontDialog::getFont( font, false, m_pView ) )
345
 
        {
346
 
            m_pView -> selectionSetFont( font );
347
 
            m_pDoc->setModified(true);
348
 
        }
349
 
        break;
 
362
    case ListPopupMenu::mt_Change_Font_Selection: {
 
363
        QFont font = getFont();
 
364
        if (KFontDialog::getFont(font, false, m_pView)) {
 
365
            UMLApp::app()->executeCommand(new cmdChangeFontSelection(m_pDoc, m_pView, font));
 
366
        }
 
367
    }
 
368
    break;
350
369
 
351
370
    case ListPopupMenu::mt_Cut:
352
371
        m_pView -> setStartedCut();
363
382
 
364
383
    case ListPopupMenu::mt_Refactoring:
365
384
        //check if we are operating on a classifier, or some other kind of UMLObject
366
 
        if(dynamic_cast<UMLClassifier*>(m_pObject))
367
 
        {
 
385
        if (dynamic_cast<UMLClassifier*>(m_pObject)) {
368
386
            UMLApp::app()->refactor(static_cast<UMLClassifier*>(m_pObject));
369
387
        }
370
388
        break;
371
389
 
372
390
    case ListPopupMenu::mt_Clone:
373
391
        // In principle we clone all the uml objects.
374
 
        {
375
 
            UMLObject *pClone = m_pObject->clone();
376
 
            m_pView->addObject(pClone);
377
 
        }
378
 
        break;
 
392
    {
 
393
        UMLObject *pClone = m_pObject->clone();
 
394
        m_pView->addObject(pClone);
 
395
    }
 
396
    break;
379
397
 
380
398
    case ListPopupMenu::mt_Rename_MultiA:
381
399
    case ListPopupMenu::mt_Rename_MultiB:
382
400
    case ListPopupMenu::mt_Rename_Name:
383
401
    case ListPopupMenu::mt_Rename_RoleAName:
384
 
    case ListPopupMenu::mt_Rename_RoleBName:
385
 
        {
386
 
            FloatingTextWidget *ft = static_cast<FloatingTextWidget*>(this);
387
 
            ft->handleRename();
388
 
            break;
389
 
        }
 
402
    case ListPopupMenu::mt_Rename_RoleBName: {
 
403
        FloatingTextWidget *ft = static_cast<FloatingTextWidget*>(this);
 
404
        ft->handleRename();
 
405
        break;
 
406
    }
 
407
 
 
408
    default:
 
409
        uDebug() << "Menu_Type " << sel << " not implemented" << endl;
390
410
    }
391
411
}
392
412
 
393
413
void UMLWidget::slotWidgetMoved(Uml::IDType /*id*/) {}
394
414
 
395
 
void UMLWidget::slotColorChanged(Uml::IDType viewID) {
 
415
void UMLWidget::slotColorChanged(Uml::IDType viewID)
 
416
{
396
417
    //only change if on the diagram concerned
397
 
    if(m_pView->getID() != viewID) {
 
418
    if (m_pView->getID() != viewID) {
398
419
        return;
399
420
    }
400
 
    if ( m_bUsesDiagramFillColour ) {
 
421
    if (m_bUsesDiagramFillColour) {
401
422
        m_FillColour = m_pView->getFillColor();
402
423
    }
403
 
    if ( m_bUsesDiagramLineColour ) {
 
424
    if (m_bUsesDiagramLineColour) {
404
425
        m_LineColour = m_pView->getLineColor();
405
426
    }
406
 
    if ( m_bUsesDiagramUseFillColour ) {
 
427
    if (m_bUsesDiagramUseFillColour) {
407
428
        m_bUseFillColour = m_pView->getUseFillColor();
408
429
    }
409
430
    update();
410
431
}
411
432
 
412
 
void UMLWidget::slotLineWidthChanged(Uml::IDType viewID) {
 
433
void UMLWidget::slotLineWidthChanged(Uml::IDType viewID)
 
434
{
413
435
    //only change if on the diagram concerned
414
 
    if(m_pView->getID() != viewID) {
 
436
    if (m_pView->getID() != viewID) {
415
437
        return;
416
438
    }
417
 
    if ( m_bUsesDiagramLineWidth ) {
 
439
    if (m_bUsesDiagramLineWidth) {
418
440
        m_LineWidth = m_pView->getLineWidth();
419
441
    }
420
442
    update();
421
443
}
422
444
 
423
 
void UMLWidget::mouseDoubleClickEvent( QMouseEvent * me ) {
 
445
void UMLWidget::mouseDoubleClickEvent(QMouseEvent * me)
 
446
{
424
447
    m_widgetController->mouseDoubleClickEvent(me);
425
448
}
426
449
 
427
 
void UMLWidget::setUseFillColour(bool fc) {
 
450
void UMLWidget::setUseFillColour(bool fc)
 
451
{
428
452
    m_bUseFillColour = fc;
429
453
    m_bUsesDiagramUseFillColour = false;
430
454
    update();
431
455
}
432
456
 
433
 
void UMLWidget::setLineColor(const QColor &colour) {
 
457
void UMLWidget::setLineColorcmd(const QColor &colour)
 
458
{
434
459
    WidgetBase::setLineColor(colour);
435
460
    update();
436
461
}
437
462
 
438
 
void UMLWidget::setLineWidth(uint width) {
 
463
void UMLWidget::setLineColor(const QColor &colour)
 
464
{
 
465
    UMLApp::app()->executeCommand(new cmdChangeLineColor(this, colour));
 
466
}
 
467
 
 
468
void UMLWidget::setLineWidth(uint width)
 
469
{
439
470
    WidgetBase::setLineWidth(width);
440
471
    update();
441
472
}
442
473
 
443
 
void UMLWidget::setFillColour(const QColor &colour) {
 
474
void UMLWidget::setFillColour(const QColor &colour)
 
475
{
 
476
    UMLApp::app()->executeCommand(new cmdChangeFillColor(this, colour));
 
477
}
 
478
 
 
479
void UMLWidget::setFillColourcmd(const QColor &colour)
 
480
{
444
481
    m_FillColour = colour;
445
482
    m_bUsesDiagramFillColour = false;
446
483
    update();
447
484
}
448
485
 
449
 
void UMLWidget::drawSelected(QPainter * p, int offsetX, int offsetY) {
 
486
QColor UMLWidget::getFillColor()
 
487
{
 
488
    return  m_FillColour;
 
489
}
 
490
 
 
491
void UMLWidget::drawSelected(QPainter * p, int offsetX, int offsetY)
 
492
{
450
493
    int w = width();
451
494
    int h = height();
452
495
    int s = 4;
461
504
        const int right = offsetX + w;
462
505
        const int bottom = offsetY + h;
463
506
        p->drawLine(right - s, offsetY + h - 1, offsetX + w - 1, offsetY + h - s);
464
 
        p->drawLine(right - (s*2), bottom - 1, right - 1, bottom - (s*2) );
465
 
        p->drawLine(right - (s*3), bottom - 1, right - 1, bottom - (s*3) );
466
 
     } else {
467
 
         p->fillRect(offsetX + w - s, offsetY + h - s, s, s, brush);
468
 
     }
 
507
        p->drawLine(right - (s*2), bottom - 1, right - 1, bottom - (s*2));
 
508
        p->drawLine(right - (s*3), bottom - 1, right - 1, bottom - (s*3));
 
509
    } else {
 
510
        p->fillRect(offsetX + w - s, offsetY + h - s, s, s, brush);
 
511
    }
469
512
}
470
513
 
471
 
bool UMLWidget::activate(IDChangeLog* /*ChangeLog  = 0 */) {
 
514
bool UMLWidget::activate(IDChangeLog* /*ChangeLog  = 0 */)
 
515
{
472
516
    if (widgetHasUMLObject(m_Type) && m_pObject == NULL) {
473
517
        m_pObject = m_pDoc->findObjectById(m_nId);
474
518
        if (m_pObject == NULL) {
475
 
            kError() << "UMLWidget::activate: cannot find UMLObject with id="
476
 
                << ID2STR(m_nId) << endl;
 
519
            uError() << "cannot find UMLObject with id=" << ID2STR(m_nId) << endl;
477
520
            return false;
478
521
        }
479
522
    }
486
529
        QPoint point = m_pView -> getPastePoint();
487
530
        int x = point.x() + getX();
488
531
        int y = point.y() + getY();
489
 
        x = x < 0?0:x;
490
 
        y = y < 0?0:y;
491
 
        if( m_pView -> getType() == dt_Sequence ) {
492
 
            switch( getBaseType() ) {
 
532
        x = x < 0 ? 0 : x;
 
533
        y = y < 0 ? 0 : y;
 
534
        if (m_pView -> getType() == dt_Sequence) {
 
535
            switch (getBaseType()) {
493
536
            case wt_Object:
 
537
            case wt_Precondition :
 
538
                setY(getY());
 
539
                setX(x);
 
540
                break;
 
541
 
494
542
            case wt_Message:
495
 
                setY( getY() );
496
 
                setX( x );
 
543
                setY(getY());
 
544
                setX(x);
497
545
                break;
498
546
 
499
547
            case wt_Text:
500
 
                ft = static_cast<FloatingTextWidget *>( this );
 
548
                ft = static_cast<FloatingTextWidget *>(this);
501
549
                if (ft->getRole() == tr_Seq_Message) {
502
 
                    setX( x );
503
 
                    setY( getY() );
 
550
                    setX(x);
 
551
                    setY(getY());
504
552
                } else {
505
 
                    setX( getX() );
506
 
                    setY( getY() );
 
553
                    setX(getX());
 
554
                    setY(getY());
507
555
                }
508
556
                break;
509
557
 
510
558
            default:
511
 
                setY( y );
 
559
                setY(y);
512
560
                break;
513
561
            }//end switch base type
514
562
        }//end if sequence
515
563
        else {
516
 
            setX( x );
517
 
            setY( y );
 
564
            setX(x);
 
565
            setY(y);
518
566
        }
519
567
    }//end if pastepoint
520
568
    else {
521
 
        setX( getX() );
522
 
        setY( getY() );
 
569
        setX(getX());
 
570
        setY(getY());
523
571
    }
524
 
    if ( m_pView -> getPaste() )
525
 
        m_pView -> createAutoAssociations( this );
 
572
    if (m_pView -> getPaste())
 
573
        m_pView -> createAutoAssociations(this);
526
574
    updateComponentSize();
527
575
    return true;
528
576
}
529
577
 
530
578
/** Read property of bool m_bActivated. */
531
 
bool UMLWidget::isActivated() {
 
579
bool UMLWidget::isActivated()
 
580
{
532
581
    return m_bActivated;
533
582
}
534
583
 
535
 
void UMLWidget::setActivated(bool Active /*=true*/) {
 
584
void UMLWidget::setActivated(bool Active /*=true*/)
 
585
{
536
586
    m_bActivated = Active;
537
587
}
538
588
 
539
 
void UMLWidget::addAssoc(AssociationWidget* pAssoc) {
 
589
void UMLWidget::addAssoc(AssociationWidget* pAssoc)
 
590
{
540
591
    if (pAssoc && !m_Assocs.contains(pAssoc)) {
541
592
        m_Assocs.append(pAssoc);
542
593
    }
543
594
}
544
595
 
545
 
void UMLWidget::removeAssoc(AssociationWidget* pAssoc) {
546
 
    if(pAssoc) {
547
 
        m_Assocs.remove(pAssoc);
 
596
void UMLWidget::removeAssoc(AssociationWidget* pAssoc)
 
597
{
 
598
    if (pAssoc) {
 
599
        m_Assocs.removeAll(pAssoc);
548
600
    }
549
601
}
550
602
 
558
610
    //   as file is only partly loaded -> reposition
559
611
    //   could be misguided )
560
612
    /// @todo avoid trigger of this event during load
561
 
    if ( m_pDoc->loading() ) {
 
613
    if (m_pDoc->loading()) {
562
614
        // don't recalculate the assocs during load of XMI
563
615
        // -> return immediately without action
564
616
        return;
565
617
    }
566
618
    AssociationWidgetListIt assoc_it(m_Assocs);
567
 
    AssociationWidget* assocwidget = 0;
568
 
    while ((assocwidget = assoc_it.current())) {
569
 
        ++assoc_it;
 
619
 
 
620
    foreach(AssociationWidget* assocwidget , m_Assocs) {
570
621
        assocwidget->saveIdealTextPositions();
571
622
    }
572
 
    assoc_it.toFirst();
573
 
    while ((assocwidget = assoc_it.current())) {
574
 
        ++assoc_it;
 
623
 
 
624
    foreach(AssociationWidget* assocwidget , m_Assocs) {
575
625
        assocwidget->widgetMoved(this, x, y);
576
626
    }
577
627
}
578
628
 
579
629
void UMLWidget::adjustUnselectedAssocs(int x, int y)
580
630
{
581
 
    AssociationWidgetListIt assoc_it(m_Assocs);
582
 
    AssociationWidget* assocwidget = 0;
583
 
    while ((assocwidget = assoc_it.current())) {
584
 
        ++assoc_it;
585
 
        if(!assocwidget->getSelected())
 
631
 
 
632
    foreach(AssociationWidget* assocwidget , m_Assocs) {
 
633
 
 
634
        if (!assocwidget->getSelected())
586
635
            assocwidget->saveIdealTextPositions();
587
636
    }
588
 
    assoc_it.toFirst();
589
 
    while ((assocwidget = assoc_it.current())) {
590
 
        ++assoc_it;
591
 
        if(!assocwidget->getSelected())
 
637
 
 
638
    foreach(AssociationWidget* assocwidget , m_Assocs) {
 
639
        if (!assocwidget->getSelected())
592
640
            assocwidget->widgetMoved(this, x, y);
593
641
    }
594
642
}
595
643
 
596
 
void UMLWidget::showProperties() {
 
644
void UMLWidget::showProperties()
 
645
{
597
646
    // will already be selected so make sure docWindow updates the doc
598
647
    // back it the widget
599
648
    DocWindow *docwindow = UMLApp::app()->getDocWindow();
600
 
    docwindow->updateDocumentation( false );
 
649
    docwindow->updateDocumentation(false);
601
650
    ClassPropDlg *dlg = new ClassPropDlg((QWidget*)UMLApp::app(), this);
602
651
 
603
652
    if (dlg->exec()) {
604
 
        docwindow->showDocumentation( getUMLObject() , true );
 
653
        docwindow->showDocumentation(getUMLObject() , true);
605
654
        m_pDoc->setModified(true);
606
655
    }
607
 
    dlg->close(true); //wipe from memory
 
656
    dlg->close(); //wipe from memory
608
657
}
609
658
 
610
 
void UMLWidget::startPopupMenu( const QPoint &At) {
 
659
ListPopupMenu*  UMLWidget::setupPopupMenu()
 
660
{
611
661
    slotRemovePopupMenu();
612
662
 
613
663
    //if in a multi- selection to a specific m_pMenu for that
632
682
 
633
683
    // disable the "view code" menu for simple code generators
634
684
    CodeGenerator * currentCG = UMLApp::app()->getGenerator();
635
 
    if(currentCG && dynamic_cast<SimpleCodeGenerator*>(currentCG))
636
 
        m_pMenu->setItemEnabled(ListPopupMenu::mt_ViewCode, false);
637
 
 
638
 
    m_pMenu->popup(At);
639
 
 
640
 
    connect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotMenuSelection(int)));
 
685
    if (currentCG && dynamic_cast<SimpleCodeGenerator*>(currentCG))
 
686
        m_pMenu->setActionEnabled(ListPopupMenu::mt_ViewCode, false);
 
687
 
 
688
    connect(m_pMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotMenuSelection(QAction*)));
 
689
 
 
690
    return m_pMenu;
641
691
}
642
692
 
643
 
void UMLWidget::slotRemovePopupMenu() {
644
 
    if(m_pMenu) {
645
 
        disconnect(m_pMenu, SIGNAL(activated(int)), this, SLOT(slotMenuSelection(int)));
 
693
void UMLWidget::slotRemovePopupMenu()
 
694
{
 
695
    if (m_pMenu) {
 
696
        disconnect(m_pMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotMenuSelection(QAction*)));
646
697
        delete m_pMenu;
647
698
        m_pMenu = 0;
648
699
    }
649
700
}
650
701
 
651
 
int UMLWidget::onWidget(const QPoint & p) {
 
702
int UMLWidget::onWidget(const QPoint & p)
 
703
{
652
704
    const int w = width();
653
705
    const int h = height();
654
706
    const int left = getX();
656
708
    const int top = getY();
657
709
    const int bottom = top + h;
658
710
    if (p.x() < left || p.x() > right ||
659
 
        p.y() < top || p.y() > bottom)   // Qt coord.sys. origin in top left corner
 
711
            p.y() < top || p.y() > bottom)   // Qt coord.sys. origin in top left corner
660
712
        return 0;
661
713
    return (w + h) / 2;
662
714
}
663
715
 
664
 
void UMLWidget::moveBy(int dx, int dy) {
 
716
void UMLWidget::moveByLocal(int dx, int dy)
 
717
{
665
718
    int newX = getX() + dx;
666
719
    int newY = getY() + dy;
667
720
    setX(newX);
668
721
    setY(newY);
 
722
    // uDebug() << "********** x=" << newX << " / y=" << newY;
669
723
    adjustAssocs(newX, newY);
670
724
}
671
725
 
672
 
void UMLWidget::setPen(QPainter & p) {
673
 
    p.setPen( QPen(m_LineColour, m_LineWidth) );
674
 
}
675
 
 
676
 
void UMLWidget::drawShape(QPainter &p ) {
677
 
    draw( p, getX(), getY() );
678
 
}
679
 
 
680
 
void UMLWidget::setSelected(bool _select) {
 
726
void UMLWidget::setPenFromSettings(QPainter & p)
 
727
{
 
728
    p.setPen(QPen(m_LineColour, m_LineWidth));
 
729
}
 
730
 
 
731
void UMLWidget::drawShape(QPainter &p)
 
732
{
 
733
    draw(p, getX(), getY());
 
734
}
 
735
 
 
736
void UMLWidget::setSelected(bool _select)
 
737
{
681
738
    const Uml::Widget_Type wt = m_Type;
682
 
    if( _select ) {
683
 
        if( m_pView -> getSelectCount() == 0 ) {
684
 
            if ( widgetHasUMLObject(wt) ) {
 
739
    if (_select) {
 
740
        if (m_pView -> getSelectCount() == 0) {
 
741
            if (widgetHasUMLObject(wt)) {
685
742
                m_pView->showDocumentation(m_pObject, false);
686
743
            } else {
687
744
                m_pView->showDocumentation(this, false);
694
751
        /* if (wt != wt_Text && wt != wt_Box) {
695
752
            setZ(m_origZ);
696
753
        } */
697
 
        if( m_bSelected )
698
 
            m_pView -> updateDocumentation( true );
 
754
        if (m_bSelected)
 
755
            m_pView -> updateDocumentation(true);
699
756
    }
700
757
    m_bSelected = _select;
701
758
 
702
759
    const QPoint pos(getX(), getY());
703
760
    UMLWidget *bkgnd = m_pView->getWidgetAt(pos);
704
761
    if (bkgnd && bkgnd != this && _select) {
705
 
        kDebug() << "UMLWidget::setSelected: setting Z to "
706
 
            << bkgnd->getZ() + 1 << ", SelectState: " << _select << endl;
707
 
        setZ( bkgnd->getZ() + 1 );
 
762
        uDebug() << "setting Z to " << bkgnd->getZ() + 1 << ", SelectState: " << _select << endl;
 
763
        setZ(bkgnd->getZ() + 1);
708
764
    } else {
709
 
        setZ( m_origZ );
 
765
        setZ(m_origZ);
710
766
    }
711
767
 
712
768
    update();
718
774
 
719
775
void UMLWidget::slotClearAllSelected()
720
776
{
721
 
    setSelected( false );
 
777
    setSelected(false);
722
778
}
723
779
 
724
 
void UMLWidget::setView(UMLView * v) {
 
780
void UMLWidget::setView(UMLView * v)
 
781
{
725
782
    //remove signals from old view - was probably 0 anyway
726
 
    disconnect( m_pView, SIGNAL( sigRemovePopupMenu() ), this, SLOT( slotRemovePopupMenu() ) );
727
 
    disconnect( m_pView, SIGNAL( sigClearAllSelected() ), this, SLOT( slotClearAllSelected() ) );
728
 
    disconnect( m_pView, SIGNAL(sigColorChanged(Uml::IDType)), this, SLOT(slotColorChanged(Uml::IDType)));
729
 
    disconnect( m_pView, SIGNAL(sigLineWidthChanged(Uml::IDType)), this, SLOT(slotLineWidthChanged(Uml::IDType)));
 
783
    disconnect(m_pView, SIGNAL(sigRemovePopupMenu()), this, SLOT(slotRemovePopupMenu()));
 
784
    disconnect(m_pView, SIGNAL(sigClearAllSelected()), this, SLOT(slotClearAllSelected()));
 
785
    disconnect(m_pView, SIGNAL(sigColorChanged(Uml::IDType)), this, SLOT(slotColorChanged(Uml::IDType)));
 
786
    disconnect(m_pView, SIGNAL(sigLineWidthChanged(Uml::IDType)), this, SLOT(slotLineWidthChanged(Uml::IDType)));
730
787
    m_pView = v;
731
 
    connect( m_pView, SIGNAL( sigRemovePopupMenu() ), this, SLOT( slotRemovePopupMenu() ) );
732
 
    connect( m_pView, SIGNAL( sigClearAllSelected() ), this, SLOT( slotClearAllSelected() ) );
733
 
    connect( m_pView, SIGNAL(sigColorChanged(Uml::IDType)), this, SLOT(slotColorChanged(Uml::IDType)));
734
 
    connect( m_pView, SIGNAL(sigLineWidthChanged(Uml::IDType)), this, SLOT(slotLineWidthChanged(Uml::IDType)));
 
788
    connect(m_pView, SIGNAL(sigRemovePopupMenu()), this, SLOT(slotRemovePopupMenu()));
 
789
    connect(m_pView, SIGNAL(sigClearAllSelected()), this, SLOT(slotClearAllSelected()));
 
790
    connect(m_pView, SIGNAL(sigColorChanged(Uml::IDType)), this, SLOT(slotColorChanged(Uml::IDType)));
 
791
    connect(m_pView, SIGNAL(sigLineWidthChanged(Uml::IDType)), this, SLOT(slotLineWidthChanged(Uml::IDType)));
735
792
}
736
793
 
737
 
void UMLWidget::setX( int x ) {
 
794
void UMLWidget::setX(int x)
 
795
{
738
796
    if (!m_bIgnoreSnapToGrid) {
739
797
        x = m_pView->snappedX(x);
740
798
    }
741
 
    QCanvasItem::setX( (double)x );
 
799
    Q3CanvasItem::setX(x);
742
800
}
743
801
 
744
 
void UMLWidget::setY( int y ) {
745
 
    if (!m_bIgnoreSnapToGrid){
 
802
void UMLWidget::setY(int y)
 
803
{
 
804
    if (!m_bIgnoreSnapToGrid) {
746
805
        y = m_pView->snappedX(y);
747
806
    }
748
 
    QCanvasItem::setY( (double)y );
 
807
    Q3CanvasItem::setY(y);
749
808
}
750
809
 
751
 
void UMLWidget::setZ(int z) {
 
810
void UMLWidget::setZ(int z)
 
811
{
752
812
    m_origZ = getZ();
753
 
    QCanvasItem::setZ(z);
 
813
    Q3CanvasItem::setZ(z);
754
814
}
755
815
 
756
 
void UMLWidget::setName(const QString &strName) {
 
816
void UMLWidget::setName(const QString &strName)
 
817
{
757
818
    if (m_pObject)
758
819
        m_pObject->setName(strName);
759
820
    else
760
821
        m_Text = strName;
761
822
    updateComponentSize();
762
 
    adjustAssocs( getX(), getY() );
 
823
    adjustAssocs(getX(), getY());
763
824
}
764
825
 
765
 
QString UMLWidget::getName() const {
 
826
QString UMLWidget::getName() const
 
827
{
766
828
    if (m_pObject)
767
829
        return m_pObject->getName();
768
830
    return m_Text;
769
831
}
770
832
 
771
 
void UMLWidget::cleanup() {
772
 
}
773
 
 
774
 
void UMLWidget::slotSnapToGrid( ) {
775
 
    setX( getX() );
776
 
    setY( getY() );
777
 
}
778
 
 
779
 
bool UMLWidget::widgetHasUMLObject(Uml::Widget_Type type) {
 
833
void UMLWidget::cleanup()
 
834
{
 
835
}
 
836
 
 
837
void UMLWidget::slotSnapToGrid()
 
838
{
 
839
    setX(getX());
 
840
    setY(getY());
 
841
}
 
842
 
 
843
bool UMLWidget::widgetHasUMLObject(Uml::Widget_Type type)
 
844
{
780
845
    if (type == wt_Actor ||
781
846
            type == wt_UseCase ||
782
847
            type == wt_Class ||
794
859
    }
795
860
}
796
861
 
797
 
void UMLWidget::setIgnoreSnapToGrid(bool to) {
 
862
void UMLWidget::setIgnoreSnapToGrid(bool to)
 
863
{
798
864
    m_bIgnoreSnapToGrid = to;
799
865
}
800
866
 
801
 
bool UMLWidget::getIgnoreSnapToGrid() const {
 
867
bool UMLWidget::getIgnoreSnapToGrid() const
 
868
{
802
869
    return m_bIgnoreSnapToGrid;
803
870
}
804
871
 
805
 
void UMLWidget::setSize(int width,int height) {
 
872
void UMLWidget::setSize(int width, int height)
 
873
{
806
874
    // snap to the next larger size that is a multiple of the grid
807
875
    if (!m_bIgnoreSnapComponentSizeToGrid
808
 
            && m_pView -> getSnapComponentSizeToGrid() )
809
 
    {
 
876
            && m_pView -> getSnapComponentSizeToGrid()) {
810
877
        // integer divisions
811
878
        int numX = width / m_pView->getSnapX();
812
879
        int numY = height / m_pView->getSnapY();
817
884
            height = (numY + 1) * m_pView->getSnapY();
818
885
    }
819
886
 
820
 
    QCanvasRectangle::setSize(width,height);
 
887
    Q3CanvasRectangle::setSize(width, height);
821
888
}
822
889
 
823
 
void UMLWidget::updateComponentSize() {
 
890
void UMLWidget::updateComponentSize()
 
891
{
824
892
    if (m_pDoc->loading())
825
893
        return;
826
894
    const QSize minSize = calculateSize();
827
895
    const int w = minSize.width();
828
896
    const int h = minSize.height();
829
897
    setSize(w, h);
830
 
    adjustAssocs( getX(), getY() );  // adjust assoc lines
 
898
    adjustAssocs(getX(), getY());    // adjust assoc lines
831
899
}
832
900
 
833
 
void UMLWidget::setDefaultFontMetrics(UMLWidget::FontType fontType) {
 
901
void UMLWidget::setDefaultFontMetrics(UMLWidget::FontType fontType)
 
902
{
834
903
    setupFontType(m_Font, fontType);
835
904
    setFontMetrics(fontType, QFontMetrics(m_Font));
836
905
}
837
906
 
838
 
void UMLWidget::setupFontType(QFont &font, UMLWidget::FontType fontType) {
839
 
    switch(fontType){
 
907
void UMLWidget::setupFontType(QFont &font, UMLWidget::FontType fontType)
 
908
{
 
909
    switch (fontType) {
840
910
    case FT_NORMAL:
841
911
        font.setBold(false);
842
912
        font.setItalic(false);
881
951
    }
882
952
}
883
953
 
884
 
void UMLWidget::setDefaultFontMetrics(UMLWidget::FontType fontType, QPainter &painter) {
 
954
void UMLWidget::setDefaultFontMetrics(UMLWidget::FontType fontType, QPainter &painter)
 
955
{
885
956
    setupFontType(m_Font, fontType);
886
957
    painter.setFont(m_Font);
887
958
    setFontMetrics(fontType, painter.fontMetrics());
888
959
}
889
960
 
890
961
//FIXME this is probably the source of problems with widgets not being wide enough
891
 
QFontMetrics &UMLWidget::getFontMetrics(UMLWidget::FontType fontType) {
 
962
QFontMetrics &UMLWidget::getFontMetrics(UMLWidget::FontType fontType)
 
963
{
892
964
    if (m_pFontMetrics[fontType] == 0) {
893
965
        setDefaultFontMetrics(fontType);
894
966
    }
895
967
    return *m_pFontMetrics[fontType];
896
968
}
897
969
 
898
 
void UMLWidget::setFontMetrics(UMLWidget::FontType fontType, QFontMetrics fm) {
 
970
void UMLWidget::setFontMetrics(UMLWidget::FontType fontType, QFontMetrics fm)
 
971
{
899
972
    delete m_pFontMetrics[fontType];
900
973
    m_pFontMetrics[fontType] = new QFontMetrics(fm);
901
974
}
902
975
 
903
 
QFont UMLWidget::getFont() const {
 
976
QFont UMLWidget::getFont() const
 
977
{
904
978
    return m_Font;
905
979
}
906
980
 
907
 
void UMLWidget::setFont( QFont font ) {
 
981
void UMLWidget::setFont(QFont font)
 
982
{
908
983
    m_Font = font;
909
984
    forceUpdateFontMetrics(0);
910
985
    if (m_pDoc->loading())
912
987
    update();
913
988
}
914
989
 
915
 
void UMLWidget::forceUpdateFontMetrics(QPainter *painter) {
 
990
void UMLWidget::forceUpdateFontMetrics(QPainter *painter)
 
991
{
916
992
    if (painter == 0) {
917
993
        for (int i = 0; i < (int)UMLWidget::FT_INVALID; ++i) {
918
 
            if (m_pFontMetrics[(UMLWidget::FontType)i]!=0)
 
994
            if (m_pFontMetrics[(UMLWidget::FontType)i] != 0)
919
995
                setDefaultFontMetrics((UMLWidget::FontType)i);
920
996
        }
921
997
    } else {
922
998
        for (int i2 = 0; i2 < (int)UMLWidget::FT_INVALID; ++i2) {
923
 
            if (m_pFontMetrics[(UMLWidget::FontType)i2]!=0)
924
 
                setDefaultFontMetrics((UMLWidget::FontType)i2,*painter);
 
999
            if (m_pFontMetrics[(UMLWidget::FontType)i2] != 0)
 
1000
                setDefaultFontMetrics((UMLWidget::FontType)i2, *painter);
925
1001
        }
926
1002
    }
927
1003
    // calculate the size, based on the new font metric
928
1004
    updateComponentSize();
929
1005
}
930
1006
 
931
 
void UMLWidget::setShowStereotype(bool _status) {
 
1007
void UMLWidget::setShowStereotype(bool _status)
 
1008
{
932
1009
    m_bShowStereotype = _status;
933
1010
    updateComponentSize();
934
1011
    update();
935
1012
}
936
1013
 
937
 
bool UMLWidget::getShowStereotype() const {
 
1014
bool UMLWidget::getShowStereotype() const
 
1015
{
938
1016
    return m_bShowStereotype;
939
1017
}
940
1018
 
941
 
void UMLWidget::moveEvent(QMoveEvent* /*me*/) {
 
1019
void UMLWidget::moveEvent(QMoveEvent* /*me*/)
 
1020
{
942
1021
}
943
1022
 
944
 
void UMLWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
 
1023
void UMLWidget::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
 
1024
{
945
1025
    /*
946
1026
      Call after required actions in child class.
947
1027
      Type must be set in the child class.
948
1028
    */
949
1029
    WidgetBase::saveToXMI(qDoc, qElement);
950
 
    qElement.setAttribute( "xmi.id", ID2STR(getID()) );
951
 
    qElement.setAttribute( "font", m_Font.toString() );
952
 
    qElement.setAttribute( "usefillcolor", m_bUseFillColour );
953
 
    qElement.setAttribute( "x", getX() );
954
 
    qElement.setAttribute( "y", getY() );
955
 
    qElement.setAttribute( "width", getWidth() );
956
 
    qElement.setAttribute( "height", getHeight() );
 
1030
    qElement.setAttribute("xmi.id", ID2STR(getID()));
 
1031
    qElement.setAttribute("font", m_Font.toString());
 
1032
    qElement.setAttribute("usefillcolor", m_bUseFillColour);
 
1033
    qElement.setAttribute("x", getX());
 
1034
    qElement.setAttribute("y", getY());
 
1035
    qElement.setAttribute("width", getWidth());
 
1036
    qElement.setAttribute("height", getHeight());
957
1037
    // for consistency the following attributes now use american spelling for "color"
958
 
    qElement.setAttribute( "usesdiagramfillcolor", m_bUsesDiagramFillColour );
959
 
    qElement.setAttribute( "usesdiagramusefillcolor", m_bUsesDiagramUseFillColour );
 
1038
    qElement.setAttribute("usesdiagramfillcolor", m_bUsesDiagramFillColour);
 
1039
    qElement.setAttribute("usesdiagramusefillcolor", m_bUsesDiagramUseFillColour);
960
1040
    if (m_bUsesDiagramFillColour) {
961
 
        qElement.setAttribute( "fillcolor", "none" );
 
1041
        qElement.setAttribute("fillcolor", "none");
962
1042
    } else {
963
 
        qElement.setAttribute( "fillcolor", m_FillColour.name() );
 
1043
        qElement.setAttribute("fillcolor", m_FillColour.name());
964
1044
    }
965
1045
    qElement.setAttribute("isinstance", m_bIsInstance);
966
1046
    if (!m_instanceName.isEmpty())
969
1049
        qElement.setAttribute("showstereotype", m_bShowStereotype);
970
1050
}
971
1051
 
972
 
bool UMLWidget::loadFromXMI( QDomElement & qElement ) {
 
1052
bool UMLWidget::loadFromXMI(QDomElement & qElement)
 
1053
{
973
1054
    WidgetBase::loadFromXMI(qElement);
974
 
    QString id = qElement.attribute( "xmi.id", "-1" );
975
 
    QString font = qElement.attribute( "font", "" );
976
 
    QString usefillcolor = qElement.attribute( "usefillcolor", "1" );
977
 
    QString x = qElement.attribute( "x", "0" );
978
 
    QString y = qElement.attribute( "y", "0" );
979
 
    QString h = qElement.attribute( "height", "0" );
980
 
    QString w = qElement.attribute( "width", "0" );
 
1055
    QString id = qElement.attribute("xmi.id", "-1");
 
1056
    QString font = qElement.attribute("font", "");
 
1057
    QString usefillcolor = qElement.attribute("usefillcolor", "1");
 
1058
    QString x = qElement.attribute("x", "0");
 
1059
    QString y = qElement.attribute("y", "0");
 
1060
    QString h = qElement.attribute("height", "0");
 
1061
    QString w = qElement.attribute("width", "0");
981
1062
    /*
982
1063
      For the next three *color attributes, there was a mixup of american and english spelling for "color".
983
1064
      So first we need to keep backward compatibility and try to retrieve the *colour attribute.
984
1065
      Next we overwrite this value if we find a *color, otherwise the former *colour is kept.
985
1066
    */
986
 
    QString fillColour = qElement.attribute( "fillcolour", "none" );
987
 
    fillColour = qElement.attribute( "fillcolor", fillColour );
988
 
    QString usesDiagramFillColour = qElement.attribute( "usesdiagramfillcolour", "1" );
989
 
    usesDiagramFillColour = qElement.attribute( "usesdiagramfillcolor", usesDiagramFillColour );
990
 
    QString usesDiagramUseFillColour = qElement.attribute( "usesdiagramusefillcolour", "1" );
991
 
    usesDiagramUseFillColour = qElement.attribute( "usesdiagramusefillcolor", usesDiagramUseFillColour );
 
1067
    QString fillColour = qElement.attribute("fillcolour", "none");
 
1068
    fillColour = qElement.attribute("fillcolor", fillColour);
 
1069
    QString usesDiagramFillColour = qElement.attribute("usesdiagramfillcolour", "1");
 
1070
    usesDiagramFillColour = qElement.attribute("usesdiagramfillcolor", usesDiagramFillColour);
 
1071
    QString usesDiagramUseFillColour = qElement.attribute("usesdiagramusefillcolour", "1");
 
1072
    usesDiagramUseFillColour = qElement.attribute("usesdiagramusefillcolor", usesDiagramUseFillColour);
992
1073
 
993
1074
    m_nId = STR2ID(id);
994
1075
 
995
 
    if( !font.isEmpty() ) {
 
1076
    if (!font.isEmpty()) {
996
1077
        //QFont newFont;
997
1078
        m_Font.fromString(font);
998
1079
        //setFont(newFont);
999
1080
    } else {
1000
 
        kWarning() << "Using default font " << m_Font.toString()
 
1081
        uWarning() << "Using default font " << m_Font.toString()
1001
1082
        << " for widget with xmi.id " << ID2STR(m_nId) << endl;
1002
1083
        //setFont( m_Font );
1003
1084
    }
1004
1085
    m_bUseFillColour = (bool)usefillcolor.toInt();
1005
1086
    m_bUsesDiagramFillColour = (bool)usesDiagramFillColour.toInt();
1006
1087
    m_bUsesDiagramUseFillColour = (bool)usesDiagramUseFillColour.toInt();
1007
 
    setSize( w.toInt(), h.toInt() );
1008
 
    setX( x.toInt() );
1009
 
    setY( y.toInt() );
 
1088
    setSize(w.toInt(), h.toInt());
 
1089
    setX(x.toInt());
 
1090
    setY(y.toInt());
1010
1091
    if (fillColour != "none") {
1011
1092
        m_FillColour = QColor(fillColour);
1012
1093
    }
1018
1099
    return true;
1019
1100
}
1020
1101
 
1021
 
UMLWidgetController* UMLWidget::getWidgetController() {
 
1102
UMLWidgetController* UMLWidget::getWidgetController()
 
1103
{
1022
1104
    return m_widgetController;
1023
1105
}
1024
1106