1
/***************************************************************************
2
* This program is free software; you can redistribute it and/or modify *
3
* it under the terms of the GNU General Public License as published by *
4
* the Free Software Foundation; either version 2 of the License, or *
5
* (at your option) any later version. *
7
* copyright (C) 2009-2011 *
8
* Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
9
***************************************************************************/
12
#include "widgetlist_utils.h"
15
#include "debug_utils.h"
16
#include "umlwidget.h"
19
#include <QtCore/QVector>
21
namespace WidgetList_Utils
25
* Looks for the smallest x-value of the given UMLWidgets.
26
* @param widgetList A list with UMLWidgets.
28
qreal getSmallestX(const UMLWidgetList &widgetList)
33
foreach(UMLWidget *widget, widgetList) {
35
smallestX = widget->x();
37
if (smallestX > widget->x())
38
smallestX = widget->x();
47
* Looks for the smallest y-value of the given UMLWidgets.
48
* @param widgetList A list with UMLWidgets.
50
qreal getSmallestY(const UMLWidgetList &widgetList)
52
if (widgetList.isEmpty())
58
foreach(UMLWidget *widget, widgetList) {
60
smallestY = widget->y();
62
if (smallestY > widget->y())
63
smallestY = widget->y();
72
* Looks for the biggest x-value of the given UMLWidgets.
73
* @param widgetList A list with UMLWidgets.
75
qreal getBiggestX(const UMLWidgetList &widgetList)
77
if (widgetList.isEmpty())
83
foreach(UMLWidget *widget, widgetList) {
85
biggestX = widget->x();
86
biggestX += widget->width();
88
if (biggestX < widget->x() + widget->width())
89
biggestX = widget->x() + widget->width();
98
* Looks for the biggest y-value of the given UMLWidgets.
99
* @param widgetList A list with UMLWidgets.
101
qreal getBiggestY(const UMLWidgetList &widgetList)
103
if (widgetList.isEmpty())
109
foreach(UMLWidget *widget, widgetList) {
111
biggestY = widget->y();
112
biggestY += widget->height();
114
if (biggestY < widget->y() + widget->height())
115
biggestY = widget->y() + widget->height();
124
* Returns the sum of the heights of the given UMLWidgets
125
* @param widgetList A list with UMLWidgets.
127
qreal getHeightsSum(const UMLWidgetList &widgetList)
129
qreal heightsSum = 0;
131
foreach(UMLWidget *widget, widgetList) {
132
heightsSum += widget->height();
139
* Returns the sum of the widths of the given UMLWidgets.
140
* @param widgetList A list with UMLWidgets.
142
qreal getWidthsSum(const UMLWidgetList &widgetList)
146
foreach(UMLWidget *widget, widgetList) {
147
widthsSum += widget->width();
153
} // namespace WidgetList_Utils