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

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-06-14 15:11:09 UTC
  • mfrom: (0.4.22)
  • Revision ID: package-import@ubuntu.com-20120614151109-t9h5vc8qga2sz5yo
Tags: 4:4.8.90-0ubuntu1
New upstream beta release

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
// own header
12
12
#include "pinwidget.h"
13
13
 
14
 
// qt includes
15
 
#include <QtGui/QPainter>
16
 
 
17
 
// kde includes
18
 
#include <klocale.h>
19
 
#include <kinputdialog.h>
20
 
 
21
14
// app includes
22
15
#include "debug_utils.h"
23
 
#include "uml.h"
24
 
#include "umldoc.h"
25
 
#include "docwindow.h"
 
16
#include "floatingtextwidget.h"
 
17
#include "listpopupmenu.h"
26
18
#include "umlscene.h"
27
19
#include "uniqueid.h"
28
 
#include "listpopupmenu.h"
29
 
#include "floatingtextwidget.h"
30
 
 
31
 
//Added by qt3to4:
 
20
 
 
21
// kde includes
 
22
#include <kinputdialog.h>
 
23
#include <klocale.h>
 
24
 
 
25
// qt includes
32
26
#include <QMouseEvent>
33
 
#include <QPolygon>
34
 
 
35
 
PinWidget::PinWidget(UMLScene * scene, UMLWidget* a, Uml::IDType id)
36
 
  : UMLWidget(scene, WidgetBase::wt_Pin, id)
 
27
#include <QPainter>
 
28
 
 
29
#define PIN_MARGIN 5
 
30
#define PIN_WIDTH 1
 
31
#define PIN_HEIGHT 1
 
32
 
 
33
/**
 
34
 * Creates a Pin widget.
 
35
 *
 
36
 * @param scene   The parent of the widget.
 
37
 * @param a       The widget to which this pin is attached.
 
38
 * @param id      The ID to assign (-1 will prompt a new ID).
 
39
 */
 
40
PinWidget::PinWidget(UMLScene* scene, UMLWidget* a, Uml::IDType id)
 
41
  : UMLWidget(scene, WidgetBase::wt_Pin, id),
 
42
    m_pOw(a)
37
43
{
38
 
    init();
 
44
    m_ignoreSnapToGrid = true;
 
45
    m_ignoreSnapComponentSizeToGrid = true;
 
46
    m_resizable = false;
39
47
    setMinimumSize(10,10);
40
48
    setMaximumSize(10,10);
41
49
    setSize(10,10);
42
 
    m_pOw = a;
43
50
    m_nY = y() < getMinY() ? getMinY() : y();
44
51
 
45
52
    m_pName = new FloatingTextWidget(scene, Uml::TextRole::Floating, "");
46
53
    scene->setupNewWidget(m_pName);
47
54
    m_pName->setX(0);
48
55
    m_pName->setY(0);
49
 
    this->activate();
 
56
 
 
57
    activate();
 
58
    setVisible(true);
50
59
}
51
60
 
 
61
/**
 
62
 * Destructor.
 
63
 */
52
64
PinWidget::~PinWidget()
53
65
{
54
66
}
55
67
 
56
 
void PinWidget::init()
57
 
{
58
 
    m_ignoreSnapToGrid = true;
59
 
    m_ignoreSnapComponentSizeToGrid = true;
60
 
    m_resizable =  false ;
61
 
    m_pOw = NULL;
62
 
    m_nY = 0;
63
 
    setVisible(true);
64
 
}
65
 
 
 
68
/**
 
69
 * Overrides the standard paint event.
 
70
 */
66
71
void PinWidget::paint(QPainter & p, int offsetX, int offsetY)
67
72
{
68
73
    int w = 10;
139
144
         drawSelected(&p, offsetX, offsetY);
140
145
}
141
146
 
 
147
/**
 
148
 * Sets the name of the pin.
 
149
 */
142
150
void PinWidget::setName(const QString &strName)
143
151
{
144
152
    m_Text = strName;
146
154
    m_pName->setText(m_Text);
147
155
}
148
156
 
 
157
/**
 
158
 * Returns the minimum height this widget should be set at on
 
159
 * a sequence diagrams.  Takes into account the widget positions
 
160
 * it is related to.
 
161
 */
149
162
int PinWidget::getMinY()
150
163
{
151
164
    if (!m_pOw) {
155
168
    return heightA;
156
169
}
157
170
 
 
171
/**
 
172
 * Overrides mouseMoveEvent.
 
173
 */
158
174
void PinWidget::mouseMoveEvent(QMouseEvent* me)
159
175
{
160
176
    UMLWidget::mouseMoveEvent(me);
166
182
    }
167
183
}
168
184
 
 
185
/**
 
186
 * Captures any popup menu signals for menus it created.
 
187
 */
169
188
void PinWidget::slotMenuSelection(QAction* action)
170
189
{
171
190
    bool ok = false;
184
203
    }
185
204
}
186
205
 
187
 
void PinWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement )
 
206
/**
 
207
 * Saves the widget to the "pinwidget" XMI element.
 
208
 */
 
209
void PinWidget::saveToXMI(QDomDocument& qDoc, QDomElement& qElement)
188
210
{
189
211
    QDomElement PinElement = qDoc.createElement( "pinwidget" );
190
212
    PinElement.setAttribute( "widgetaid", ID2STR(m_pOw->id()) );
196
218
    qElement.appendChild( PinElement );
197
219
}
198
220
 
199
 
 
200
 
bool PinWidget::loadFromXMI( QDomElement & qElement )
 
221
/**
 
222
 * Loads the widget from the "pinwidget" XMI element.
 
223
 */
 
224
bool PinWidget::loadFromXMI(QDomElement& qElement)
201
225
{
202
226
    if( !UMLWidget::loadFromXMI( qElement ) )
203
227
        return false;
228
252
        textId = UniqueID::gen();
229
253
    }
230
254
 
231
 
      //now load child elements
 
255
    //now load child elements
232
256
    QDomNode node = qElement.firstChild();
233
257
    QDomElement element = node.toElement();
234
258
    if ( !element.isNull() ) {