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

« back to all changes in this revision

Viewing changes to umbrello/umbrello/widgets/forkjoinwidget.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) 2005-2011                                               *
 
7
 *   copyright (C) 2005-2012                                               *
8
8
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
9
9
 ***************************************************************************/
10
10
 
19
19
/**
20
20
 * Constructs a ForkJoinWidget.
21
21
 *
22
 
 * @param scene          The parent to this widget.
23
 
 * @param drawVertical  Whether to draw the plate horizontally or vertically.
24
 
 * @param id            The ID to assign (-1 will prompt a new ID.)
 
22
 * @param scene   The parent to this widget.
 
23
 * @param ori     Whether to draw the plate horizontally or vertically.
 
24
 * @param id      The ID to assign (-1 will prompt a new ID.)
25
25
 */
26
 
ForkJoinWidget::ForkJoinWidget(UMLScene * scene, bool drawVertical, Uml::IDType id)
 
26
ForkJoinWidget::ForkJoinWidget(UMLScene * scene, Qt::Orientation ori, Uml::IDType id)
27
27
  : BoxWidget(scene, id, WidgetBase::wt_ForkJoin),
28
 
    m_drawVertical(drawVertical)
 
28
    m_orientation(ori)
29
29
{
30
30
}
31
31
 
37
37
}
38
38
 
39
39
/**
40
 
 * Get whether to draw the plate vertically.
 
40
 * Get whether to draw the plate vertically or horizontally.
41
41
 */
42
 
bool ForkJoinWidget::getDrawVertical() const {
43
 
    return m_drawVertical;
 
42
Qt::Orientation ForkJoinWidget::orientation() const
 
43
{
 
44
    return m_orientation;
44
45
}
45
46
 
46
47
/**
47
 
 * Set whether to draw the plate vertically.
 
48
 * Set whether to draw the plate vertically or horizontally.
48
49
 */
49
 
void ForkJoinWidget::setDrawVertical(bool to) {
50
 
    m_drawVertical = to;
 
50
void ForkJoinWidget::setOrientation(Qt::Orientation ori)
 
51
{
 
52
    m_orientation = ori;
51
53
    updateComponentSize();
52
 
    UMLWidget::adjustAssocs( getX(), getY() );
 
54
    UMLWidget::adjustAssocs( x(), y() );
53
55
}
54
56
 
55
57
/**
74
76
    if ( !UMLWidget::loadFromXMI(qElement) ) {
75
77
        return false;
76
78
    }
77
 
    QString drawVertical = qElement.attribute("drawvertical", "0");
78
 
    setDrawVertical( (bool)drawVertical.toInt() );
 
79
 
 
80
    QString drawVerticalStr = qElement.attribute("drawvertical", "0");
 
81
    bool drawVertical = (bool)drawVerticalStr.toInt();
 
82
    if (drawVertical) {
 
83
        setOrientation(Qt::Vertical);
 
84
    }
 
85
    else {
 
86
        setOrientation(Qt::Horizontal);
 
87
    }
 
88
 
79
89
    return true;
80
90
}
81
91
 
87
97
{
88
98
    QDomElement fjElement = qDoc.createElement("forkjoin");
89
99
    UMLWidget::saveToXMI(qDoc, fjElement);
90
 
    fjElement.setAttribute("drawvertical", m_drawVertical);
 
100
    bool drawVertical = true;
 
101
    if (m_orientation == Qt::Horizontal) {
 
102
        drawVertical = false;
 
103
    }
 
104
    fjElement.setAttribute("drawvertical", drawVertical);
91
105
    qElement.appendChild(fjElement);
92
106
}
93
107
 
100
114
    ListPopupMenu::MenuType sel = m_pMenu->getMenuType(action);
101
115
    switch (sel) {
102
116
    case ListPopupMenu::mt_Flip:
103
 
        setDrawVertical(!m_drawVertical);
 
117
        switch (m_orientation) {
 
118
        case Qt::Vertical:
 
119
            setOrientation(Qt::Horizontal);
 
120
            break;
 
121
        case Qt::Horizontal:
 
122
        default:
 
123
            setOrientation(Qt::Vertical);
 
124
            break;
 
125
        }
104
126
        break;
105
127
    default:
106
128
        break;
112
134
 */
113
135
UMLSceneSize ForkJoinWidget::minimumSize()
114
136
{
115
 
    if (m_drawVertical) {
 
137
    if (m_orientation == Qt::Vertical) {
116
138
        return UMLSceneSize(4, 40);
117
139
    } else {
118
140
        return UMLSceneSize(40, 4);
133
155
 */
134
156
void ForkJoinWidget::constrain(int& width, int& height)
135
157
{
136
 
    if (m_drawVertical) {
 
158
    if (m_orientation == Qt::Vertical) {
137
159
        if (width < 4)
138
160
            width = 4;
139
161
        else if (width > 10)