contentsRect() function, consistent with QGraphicsWidget::contentsRect()

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=851491
This commit is contained in:
Marco Martin 2008-08-23 20:36:09 +00:00
parent 053ba4f683
commit 1a321f0df1
2 changed files with 20 additions and 1 deletions

View File

@ -62,7 +62,7 @@ public:
int leftWidth;
int rightWidth;
int bottomHeight;
//margins, are equal to the measures by default
int topMargin;
int leftMargin;
@ -313,6 +313,20 @@ void PanelSvg::getMargins(qreal &left, qreal &top, qreal &right, qreal &bottom)
bottom = panel->bottomMargin;
}
QRectF PanelSvg::contentsRect() const
{
QSizeF size(panelSize());
if (size.isValid()) {
QRectF rect(QPointF(0, 0), size);
PanelData *panel = d->panels[d->prefix];
return rect.adjusted(panel->leftMargin, panel->topMargin, -panel->rightMargin, -panel->bottomMargin);
} else {
return QRectF();
}
}
QBitmap PanelSvg::mask() const
{
PanelData *panel = d->panels[d->prefix];

View File

@ -118,6 +118,11 @@ class PLASMA_EXPORT PanelSvg : public Svg
*/
void getMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const;
/**
* @return the rectangle of the center element, taking the margins into account.
*/
QRectF contentsRect() const;
/**
* Sets the prefix (@see setElementPrefix) to 'north', 'south', 'west' and 'east'
* when the location is TopEdge, BottomEdge, LeftEdge and RightEdge,