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

« back to all changes in this revision

Viewing changes to umbrello/umbrello/widgets/combinedfragmentwidget.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:
4
4
 *   the Free Software Foundation; either version 2 of the License, or     *
5
5
 *   (at your option) any later version.                                   *
6
6
 *                                                                         *
7
 
 *   copyright (C) 2002-2011                                               *
 
7
 *   copyright (C) 2002-2012                                               *
8
8
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
9
9
 ***************************************************************************/
10
10
 
28
28
#include "listpopupmenu.h"
29
29
#include "dialog_utils.h"
30
30
 
 
31
/**
 
32
 * Creates a Combined Fragment widget.
 
33
 *
 
34
 * @param scene              The parent of the widget.
 
35
 * @param combinedfragmentType      The type of combined fragment.
 
36
 * @param id                The ID to assign (-1 will prompt a new ID.)
 
37
 */
31
38
CombinedFragmentWidget::CombinedFragmentWidget(UMLScene * scene, CombinedFragmentType combinedfragmentType, Uml::IDType id )
32
39
  : UMLWidget(scene, WidgetBase::wt_CombinedFragment, id)
33
40
{
34
41
    setCombinedFragmentType( combinedfragmentType );
35
42
}
36
43
 
 
44
/**
 
45
 *  Destructor.
 
46
 */
37
47
CombinedFragmentWidget::~CombinedFragmentWidget()
38
48
{
39
49
    for(QList<FloatingDashLineWidget*>::iterator it=m_dashLines.begin() ; it!=m_dashLines.end() ; ++it) {
41
51
    }
42
52
}
43
53
 
 
54
/**
 
55
 * Overrides the standard paint event.
 
56
 */
44
57
void CombinedFragmentWidget::paint(QPainter & p, int offsetX, int offsetY)
45
58
{
46
59
    int w = width();
61
74
    int textStartY = (h / 2) - (fontHeight / 2);
62
75
    p.drawRect(offsetX, offsetY, w, h );
63
76
 
64
 
    p.setPen(Qt::black);
 
77
    p.setPen(textColor());
65
78
    p.setFont( UMLWidget::font() );
66
79
        QString temp = "loop";
67
80
 
113
126
                {
114
127
                     temp = '[' + combined_fragment_value + ']';
115
128
            p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY + 20,w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, temp);
116
 
                    if (m_dashLines.size() == 1 && m_dashLines.first()->getY() < offsetY + 20 + fontHeight )
 
129
                    if (m_dashLines.size() == 1 && m_dashLines.first()->y() < offsetY + 20 + fontHeight )
117
130
                        m_dashLines.first()->setY(offsetY + h/2);
118
131
                }
119
132
                p.drawText(offsetX + COMBINED_FRAGMENT_MARGIN, offsetY ,
120
133
            w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "alt");
121
134
                // dash lines
122
 
                m_dashLines.first()->paint(p,getX(),getY());
 
135
                m_dashLines.first()->paint(p,x(),y());
123
136
                for(QList<FloatingDashLineWidget*>::iterator it=m_dashLines.begin() ; it!=m_dashLines.end() ; ++it) {
124
 
                    (*it)->setX(getX());
 
137
                    (*it)->setX(x());
125
138
                    old_Y = (*it)->getYMin();
126
 
                    (*it)->setYMin(getY());
127
 
                    (*it)->setYMax(getY() + getHeight());
128
 
                    (*it)->setY(getY() + (*it)->getY() - old_Y);
 
139
                    (*it)->setYMin(y());
 
140
                    (*it)->setYMax(y() + height());
 
141
                    (*it)->setY(y() + (*it)->y() - old_Y);
129
142
                    (*it)->setSize(w, 0);
130
143
                }
131
144
 
136
149
            w - COMBINED_FRAGMENT_MARGIN * 2, fontHeight, Qt::AlignLeft, "parallel");
137
150
                // dash lines
138
151
                if (m_dashLines.size() != 0) {
139
 
                    m_dashLines.first()->paint(p,getX(),getY());
 
152
                    m_dashLines.first()->paint(p,x(),y());
140
153
                    for(QList<FloatingDashLineWidget*>::iterator it=m_dashLines.begin() ; it!=m_dashLines.end() ; ++it) {
141
 
                        (*it)->setX(getX());
 
154
                        (*it)->setX(x());
142
155
                        old_Y = (*it)->getYMin();
143
 
                        (*it)->setYMin(getY());
144
 
                        (*it)->setYMax(getY() + getHeight());
145
 
                        (*it)->setY(getY() + (*it)->getY() - old_Y);
 
156
                        (*it)->setYMin(y());
 
157
                        (*it)->setYMax(y() + height());
 
158
                        (*it)->setY(y() + (*it)->y() - old_Y);
146
159
                        (*it)->setSize(w, 0);
147
160
                    }
148
161
                }
160
173
        drawSelected(&p, offsetX, offsetY);
161
174
}
162
175
 
 
176
/**
 
177
 * Overrides method from UMLWidget.
 
178
 */
163
179
UMLSceneSize CombinedFragmentWidget::minimumSize()
164
180
{
165
181
    int width = 10, height = 10;
179
195
    return UMLSceneSize(width, height);
180
196
}
181
197
 
 
198
/**
 
199
 * Returns the type of combined fragment.
 
200
 */
182
201
CombinedFragmentWidget::CombinedFragmentType CombinedFragmentWidget::combinedFragmentType() const
183
202
{
184
203
    return m_CombinedFragment;
185
204
}
186
205
 
 
206
/**
 
207
 * Sets the type of combined fragment.
 
208
 */
187
209
void CombinedFragmentWidget::setCombinedFragmentType( CombinedFragmentType combinedfragmentType )
188
210
{
189
211
    m_CombinedFragment = combinedfragmentType;
196
218
        {
197
219
            m_dashLines.back()->setText("else");
198
220
        }
199
 
        m_dashLines.back()->setX(getX());
200
 
        m_dashLines.back()->setYMin(getY());
201
 
        m_dashLines.back()->setYMax(getY() + getHeight());
202
 
        m_dashLines.back()->setY(getY() + height()/2);
203
 
        m_dashLines.back()->setSize(getWidth(), 0);
 
221
        m_dashLines.back()->setX(x());
 
222
        m_dashLines.back()->setYMin(y());
 
223
        m_dashLines.back()->setYMax(y() + height());
 
224
        m_dashLines.back()->setY(y() + height()/2);
 
225
        m_dashLines.back()->setSize(width(), 0);
204
226
        m_scene->setupNewWidget(m_dashLines.back());
205
227
    }
206
228
}
207
229
 
 
230
/**
 
231
 * Returns the type of combined fragment.
 
232
 */
208
233
CombinedFragmentWidget::CombinedFragmentType CombinedFragmentWidget::combinedFragmentType(const QString& type) const
209
234
{
210
235
    if(type == "Reference")
230
255
    return (CombinedFragmentWidget::Ref);
231
256
}
232
257
 
 
258
/**
 
259
 * Sets the type of combined fragment.
 
260
 */
233
261
void CombinedFragmentWidget::setCombinedFragmentType( const QString& combinedfragmentType )
234
262
{
235
263
    setCombinedFragmentType(combinedFragmentType(combinedfragmentType) );
236
264
}
237
265
 
 
266
/**
 
267
 * ...
 
268
 */
238
269
void CombinedFragmentWidget::askNameForWidgetType(UMLWidget* &targetWidget, const QString& dialogTitle,
239
270
    const QString& dialogPrompt, const QString& defaultName)
240
271
{
260
291
    }
261
292
}
262
293
 
 
294
/**
 
295
 * Saves the widget to the "combinedFragmentwidget" XMI element.
 
296
 */
263
297
void CombinedFragmentWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement )
264
298
{
265
299
    QDomElement combinedFragmentElement = qDoc.createElement( "combinedFragmentwidget" );
276
310
    qElement.appendChild( combinedFragmentElement );
277
311
}
278
312
 
 
313
/**
 
314
 * Loads the widget from the "CombinedFragmentwidget" XMI element.
 
315
 */
279
316
bool CombinedFragmentWidget::loadFromXMI( QDomElement & qElement )
280
317
{
281
318
    if( !UMLWidget::loadFromXMI( qElement ) )
314
351
    return true;
315
352
}
316
353
 
 
354
/**
 
355
 * Overrides the function from UMLWidget.
 
356
 *
 
357
 * @param action  The command to be executed.
 
358
 */
317
359
void CombinedFragmentWidget::slotMenuSelection(QAction* action)
318
360
{
319
361
    bool ok = false;
327
369
        {
328
370
            m_dashLines.back()->setText("else");
329
371
        }
330
 
        m_dashLines.back()->setX(getX());
331
 
        m_dashLines.back()->setYMin(getY());
332
 
        m_dashLines.back()->setYMax(getY() + getHeight());
333
 
        m_dashLines.back()->setY(getY() + getHeight() / 2);
334
 
        m_dashLines.back()->setSize(getWidth(), 0);
 
372
        m_dashLines.back()->setX(x());
 
373
        m_dashLines.back()->setYMin(y());
 
374
        m_dashLines.back()->setYMax(y() + height());
 
375
        m_dashLines.back()->setY(y() + height() / 2);
 
376
        m_dashLines.back()->setSize(width(), 0);
335
377
        m_scene->setupNewWidget(m_dashLines.back());
336
378
        break;
337
379
 
355
397
}
356
398
 
357
399
#include "combinedfragmentwidget.moc"
358