First commit of my work, added classes :
- LayoutItem - Layout - VBoxLayout svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=667376
This commit is contained in:
parent
bd932be569
commit
edaecc53af
75
widgets/layout.cpp
Normal file
75
widgets/layout.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "layout.h"
|
||||
|
||||
#include <QtCore/QList>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class Layout::Private
|
||||
{
|
||||
public:
|
||||
Private() : margin(10.0), spacing(10.0), parent(0) {}
|
||||
~Private() {}
|
||||
|
||||
qreal margin;
|
||||
qreal spacing;
|
||||
|
||||
LayoutItem *parent;
|
||||
};
|
||||
|
||||
|
||||
Layout::Layout(LayoutItem *parent)
|
||||
: LayoutItem(),
|
||||
d(new Private)
|
||||
{
|
||||
d->parent = parent;
|
||||
}
|
||||
|
||||
Layout::~Layout()
|
||||
{
|
||||
}
|
||||
|
||||
qreal Layout::margin() const
|
||||
{
|
||||
return d->margin;
|
||||
}
|
||||
|
||||
void Layout::setMargin(qreal m)
|
||||
{
|
||||
d->margin = m;
|
||||
}
|
||||
|
||||
qreal Layout::spacing() const
|
||||
{
|
||||
return d->spacing;
|
||||
}
|
||||
|
||||
void Layout::setSpacing(qreal s)
|
||||
{
|
||||
d->spacing = s;
|
||||
}
|
||||
|
||||
LayoutItem *Layout::parent() const
|
||||
{
|
||||
return d->parent;
|
||||
}
|
||||
|
||||
};
|
66
widgets/layout.h
Normal file
66
widgets/layout.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __LAYOUT__
|
||||
#define __LAYOUT__
|
||||
|
||||
#include <QtCore/QRectF>
|
||||
#include <QtCore/QSizeF>
|
||||
|
||||
#include <kdemacros.h>
|
||||
|
||||
#include "layoutitem.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class Widget;
|
||||
|
||||
class KDE_EXPORT Layout : public LayoutItem
|
||||
{
|
||||
public:
|
||||
Layout(LayoutItem *parent);
|
||||
virtual ~Layout();
|
||||
|
||||
qreal margin() const;
|
||||
void setMargin(qreal m);
|
||||
|
||||
qreal spacing() const;
|
||||
void setSpacing(qreal s);
|
||||
|
||||
LayoutItem *parent() const;
|
||||
|
||||
virtual int count() const = 0;
|
||||
virtual bool isEmpty() const = 0;
|
||||
|
||||
virtual void addItem(LayoutItem *l) = 0;
|
||||
|
||||
virtual void removeItem(LayoutItem *l) = 0;
|
||||
|
||||
virtual int indexOf(LayoutItem *l) const = 0;
|
||||
virtual LayoutItem *itemAt(int i) const = 0;
|
||||
virtual LayoutItem *takeAt(int i) = 0;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private *const d;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif /* __LAYOUT__ */
|
62
widgets/layoutitem.cpp
Normal file
62
widgets/layoutitem.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "layoutitem.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class LayoutItem::Private
|
||||
{
|
||||
public:
|
||||
Private() {}
|
||||
~Private() {}
|
||||
};
|
||||
|
||||
|
||||
LayoutItem::LayoutItem()
|
||||
: d(new Private)
|
||||
{
|
||||
}
|
||||
|
||||
LayoutItem::~LayoutItem()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool LayoutItem::hasHeightForWidth() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal LayoutItem::heightForWidth(qreal w) const
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool LayoutItem::hasWidthForHeight() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal LayoutItem::widthForHeight(qreal h) const
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
};
|
59
widgets/layoutitem.h
Normal file
59
widgets/layoutitem.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __LAYOUT_ITEM__
|
||||
#define __LAYOUT_ITEM__
|
||||
|
||||
#include <QtCore/QRectF>
|
||||
#include <QtCore/QSizeF>
|
||||
|
||||
#include <kdemacros.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class KDE_EXPORT LayoutItem
|
||||
{
|
||||
public:
|
||||
LayoutItem();
|
||||
virtual ~LayoutItem();
|
||||
|
||||
virtual Qt::Orientations expandingDirections() const = 0;
|
||||
|
||||
virtual QSizeF minimumSize() const = 0;
|
||||
virtual QSizeF maximumSize() const = 0;
|
||||
|
||||
virtual bool hasHeightForWidth() const;
|
||||
virtual qreal heightForWidth(qreal w) const;
|
||||
|
||||
virtual bool hasWidthForHeight() const;
|
||||
virtual qreal widthForHeight(qreal h) const;
|
||||
|
||||
virtual QRectF geometry() const = 0;
|
||||
virtual void setGeometry(const QRectF& geometry) = 0;
|
||||
|
||||
virtual QSizeF sizeHint() const = 0;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private *const d;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif /* __LAYOUT_ITEM__ */
|
191
widgets/vboxlayout.cpp
Normal file
191
widgets/vboxlayout.cpp
Normal file
@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (C) 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "vboxlayout.h"
|
||||
|
||||
#include <QtCore/QList>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class VBoxLayout::Private
|
||||
{
|
||||
public:
|
||||
Private() {}
|
||||
~Private() {}
|
||||
|
||||
QRectF geometry;
|
||||
QList<LayoutItem *> childList;
|
||||
};
|
||||
|
||||
|
||||
VBoxLayout::VBoxLayout(LayoutItem *parent)
|
||||
: Layout(parent),
|
||||
d(new Private)
|
||||
{
|
||||
}
|
||||
|
||||
VBoxLayout::~VBoxLayout()
|
||||
{
|
||||
}
|
||||
|
||||
Qt::Orientations VBoxLayout::expandingDirections() const
|
||||
{
|
||||
return Qt::Vertical;
|
||||
}
|
||||
|
||||
QSizeF VBoxLayout::minimumSize() const
|
||||
{
|
||||
}
|
||||
|
||||
QSizeF VBoxLayout::maximumSize() const
|
||||
{
|
||||
}
|
||||
|
||||
bool VBoxLayout::hasHeightForWidth() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
qreal VBoxLayout::heightForWidth(qreal w) const
|
||||
{
|
||||
}
|
||||
|
||||
QRectF VBoxLayout::geometry() const
|
||||
{
|
||||
return d->geometry;
|
||||
}
|
||||
|
||||
void VBoxLayout::setGeometry(const QRectF& geometry)
|
||||
{
|
||||
if(!geometry.isValid() || geometry.isEmpty()) {
|
||||
qDebug("Invalid Geometry!");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug("Geometry %p : %f, %f by %f, %f", this, geometry.x(), geometry.y(), geometry.width(), geometry.height());
|
||||
|
||||
QList<LayoutItem *> childs;
|
||||
QList<LayoutItem *> expandingChilds;
|
||||
QList<QSizeF> sizes;
|
||||
QSizeF available = geometry.size() - QSizeF(2 * margin(), 2 * margin());
|
||||
|
||||
foreach(LayoutItem *l, d->childList) {
|
||||
|
||||
if(l->expandingDirections() & Qt::Vertical) {
|
||||
|
||||
expandingChilds += l;
|
||||
} else {
|
||||
|
||||
childs += l;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(LayoutItem *l, childs) {
|
||||
|
||||
QSizeF hint = l->sizeHint();
|
||||
|
||||
sizes.insert(indexOf(l), QSizeF(available.width(), hint.height()));
|
||||
available -= QSizeF(0.0, hint.height() + spacing());
|
||||
}
|
||||
|
||||
qreal expandHeight = (available.height() - ((expandingChilds.count() - 1) * spacing())) / expandingChilds.count();
|
||||
|
||||
foreach(LayoutItem *l, expandingChilds) {
|
||||
|
||||
sizes.insert(indexOf(l),QSizeF(available.width(), expandHeight));
|
||||
}
|
||||
|
||||
QPointF start = geometry.topLeft();
|
||||
start += QPointF(margin(), spacing());
|
||||
|
||||
for(int i = 0; i < sizes.size(); i++) {
|
||||
|
||||
LayoutItem *l = itemAt(i);
|
||||
|
||||
l->setGeometry(QRectF(start, sizes[i]));
|
||||
start += QPointF(0.0, sizes[i].height() + spacing());
|
||||
}
|
||||
|
||||
d->geometry = geometry;
|
||||
}
|
||||
|
||||
QSizeF VBoxLayout::sizeHint() const
|
||||
{
|
||||
qreal hintHeight = 0.0;
|
||||
qreal hintWidth = 0.0;
|
||||
|
||||
foreach(LayoutItem *l, d->childList) {
|
||||
|
||||
QSizeF hint = l->sizeHint();
|
||||
|
||||
hintWidth = qMax(hint.width(), hintWidth);
|
||||
hintHeight += hint.height() + spacing();
|
||||
}
|
||||
|
||||
return QSizeF(hintWidth, hintHeight);
|
||||
}
|
||||
|
||||
int VBoxLayout::count() const
|
||||
{
|
||||
return d->childList.count();
|
||||
}
|
||||
|
||||
bool VBoxLayout::isEmpty() const
|
||||
{
|
||||
return count() == 0;
|
||||
}
|
||||
|
||||
void VBoxLayout::addItem(LayoutItem *l)
|
||||
{
|
||||
d->childList.append(l);
|
||||
|
||||
qDebug("Added Child LayoutItem : %p", l);
|
||||
|
||||
setGeometry(geometry());
|
||||
}
|
||||
|
||||
void VBoxLayout::removeItem(LayoutItem *l)
|
||||
{
|
||||
d->childList.removeAll(l);
|
||||
}
|
||||
|
||||
int VBoxLayout::indexOf(LayoutItem *l) const
|
||||
{
|
||||
return d->childList.indexOf(l);
|
||||
}
|
||||
|
||||
LayoutItem *VBoxLayout::itemAt(int i) const
|
||||
{
|
||||
return d->childList[i];
|
||||
}
|
||||
|
||||
LayoutItem *VBoxLayout::takeAt(int i)
|
||||
{
|
||||
return d->childList.takeAt(i);
|
||||
|
||||
setGeometry(geometry());
|
||||
}
|
||||
|
||||
QSizeF VBoxLayout::size() const
|
||||
{
|
||||
return geometry().size();
|
||||
}
|
||||
|
||||
};
|
74
widgets/vboxlayout.h
Normal file
74
widgets/vboxlayout.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __V_BOX_LAYOUT__
|
||||
#define __V_BOX_LAYOUT__
|
||||
|
||||
#include <QtCore/QRectF>
|
||||
#include <QtCore/QSizeF>
|
||||
|
||||
#include <kdemacros.h>
|
||||
|
||||
#include "layout.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class Widget;
|
||||
|
||||
class KDE_EXPORT VBoxLayout : public Layout
|
||||
{
|
||||
public:
|
||||
VBoxLayout(LayoutItem *parent = 0);
|
||||
virtual ~VBoxLayout();
|
||||
|
||||
Qt::Orientations expandingDirections() const;
|
||||
|
||||
QSizeF minimumSize() const;
|
||||
QSizeF maximumSize() const;
|
||||
|
||||
bool hasHeightForWidth() const;
|
||||
qreal heightForWidth(qreal w) const;
|
||||
|
||||
QRectF geometry() const;
|
||||
void setGeometry(const QRectF& geometry);
|
||||
|
||||
QSizeF sizeHint() const;
|
||||
|
||||
int count() const;
|
||||
|
||||
bool isEmpty() const;
|
||||
|
||||
void addItem(LayoutItem *l);
|
||||
|
||||
void removeItem(LayoutItem *l);
|
||||
|
||||
int indexOf(LayoutItem *l) const;
|
||||
LayoutItem *itemAt(int i) const;
|
||||
LayoutItem *takeAt(int i);
|
||||
|
||||
QSizeF size() const;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private *const d;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif /* __V_BOX_LAYOUT__ */
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2007 by Alexander Wiedenbruch <mail@wiedenbruch.de>
|
||||
* and Matias Valdenegro <mvaldenegro@informatica.utem.cl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
@ -16,7 +17,13 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <QtCore/QList>
|
||||
|
||||
#include "widget.h"
|
||||
#include "widget.moc"
|
||||
|
||||
#include "layout.h"
|
||||
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -24,16 +31,30 @@ namespace Plasma
|
||||
class Widget::Private
|
||||
{
|
||||
public:
|
||||
Private() { }
|
||||
Private() : parent(0) { }
|
||||
~Private() { }
|
||||
|
||||
QRectF geometry;
|
||||
|
||||
Widget *parent;
|
||||
Layout *layout;
|
||||
QList<Widget *> childList;
|
||||
};
|
||||
|
||||
|
||||
Widget::Widget(QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent),
|
||||
DataVisualization(),
|
||||
Widget::Widget(Widget *parent)
|
||||
: DataVisualization(),
|
||||
QGraphicsItem(parent),
|
||||
d(new Private)
|
||||
{
|
||||
d->parent = parent;
|
||||
d->layout = 0;
|
||||
|
||||
if(parent) {
|
||||
parent->addChild(this);
|
||||
|
||||
parent->setGeometry(QRectF(QPointF(0.0, 0.0), parent->size()));
|
||||
}
|
||||
}
|
||||
|
||||
Widget::~Widget()
|
||||
@ -41,5 +62,148 @@ Widget::~Widget()
|
||||
delete d;
|
||||
}
|
||||
|
||||
Qt::Orientations Widget::expandingDirections() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
QSizeF Widget::maximumSize() const
|
||||
{
|
||||
return QSizeF();
|
||||
}
|
||||
|
||||
QSizeF Widget::minimumSize() const
|
||||
{
|
||||
return QSizeF(0.0, 0.0);
|
||||
}
|
||||
|
||||
bool Widget::hasHeightForWidth() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal Widget::heightForWidth(qreal w) const
|
||||
{
|
||||
Q_UNUSED(w);
|
||||
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
bool Widget::hasWidthForHeight() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal Widget::widthForHeight(qreal h) const
|
||||
{
|
||||
Q_UNUSED(h);
|
||||
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
QRectF Widget::geometry() const
|
||||
{
|
||||
return d->geometry;
|
||||
}
|
||||
|
||||
void Widget::setGeometry(const QRectF& geometry)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
d->geometry = geometry;
|
||||
|
||||
updateGeometry();
|
||||
update();
|
||||
}
|
||||
|
||||
void Widget::updateGeometry()
|
||||
{
|
||||
if(layout()) {
|
||||
layout()->setGeometry(QRectF(QPointF(0.0, 0.0), size()));
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::invalidate()
|
||||
{
|
||||
updateGeometry();
|
||||
|
||||
if(parent()) {
|
||||
parent()->updateGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
QSizeF Widget::sizeHint() const
|
||||
{
|
||||
return QSizeF(0.0, 0.0);
|
||||
}
|
||||
|
||||
QSizeF Widget::size() const
|
||||
{
|
||||
return geometry().size();
|
||||
}
|
||||
|
||||
QRectF Widget::boundingRect() const
|
||||
{
|
||||
return geometry();
|
||||
}
|
||||
|
||||
void Widget::resize(const QSizeF& size)
|
||||
{
|
||||
setGeometry(QRectF(d->geometry.topLeft(), size));
|
||||
}
|
||||
|
||||
void Widget::resize(qreal w, qreal h)
|
||||
{
|
||||
resize(QSizeF(w, h));
|
||||
}
|
||||
|
||||
void Widget::data(const DataSource::Data& data)
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
}
|
||||
|
||||
void Widget::setLayout(Layout *l)
|
||||
{
|
||||
d->layout = l;
|
||||
}
|
||||
|
||||
Layout *Widget::layout() const
|
||||
{
|
||||
return d->layout;
|
||||
}
|
||||
|
||||
Widget *Widget::parent() const
|
||||
{
|
||||
return d->parent;
|
||||
}
|
||||
|
||||
void Widget::addChild(Widget *w)
|
||||
{
|
||||
if(!w) {
|
||||
return;
|
||||
}
|
||||
|
||||
w->reparent(this);
|
||||
w->setParentItem(this);
|
||||
|
||||
d->childList.append(w);
|
||||
|
||||
qDebug("Added Child Widget : %p", w);
|
||||
|
||||
if(layout()) {
|
||||
|
||||
layout()->addItem(w);
|
||||
|
||||
updateGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::reparent(Widget *w)
|
||||
{
|
||||
d->parent = w;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2007 by Alexander Wiedenbruch <mail@wiedenbruch.de>
|
||||
* and Matias Valdenegro <mvaldenegro@informatica.utem.cl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
@ -21,23 +22,71 @@
|
||||
|
||||
#include <QtGui/QGraphicsItem>
|
||||
|
||||
#include <QtCore/QRectF>
|
||||
#include <QtCore/QSizeF>
|
||||
|
||||
#include <kdemacros.h>
|
||||
|
||||
#include "datavisualization.h"
|
||||
#include "layoutitem.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class Layout;
|
||||
|
||||
/**
|
||||
* Class that emulates a QWidget inside plasma
|
||||
*/
|
||||
class KDE_EXPORT Widget : public QGraphicsItem,
|
||||
public DataVisualization
|
||||
class KDE_EXPORT Widget : public DataVisualization,
|
||||
public QGraphicsItem,
|
||||
public LayoutItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Widget(QGraphicsItem *parent = 0);
|
||||
Widget(Widget *parent = 0);
|
||||
virtual ~Widget();
|
||||
|
||||
virtual Qt::Orientations expandingDirections() const;
|
||||
|
||||
virtual QSizeF minimumSize() const;
|
||||
virtual QSizeF maximumSize() const;
|
||||
|
||||
virtual bool hasHeightForWidth() const;
|
||||
virtual qreal heightForWidth(qreal w) const;
|
||||
|
||||
virtual bool hasWidthForHeight() const;
|
||||
virtual qreal widthForHeight(qreal h) const;
|
||||
|
||||
QRectF geometry() const;
|
||||
void setGeometry(const QRectF& geometry);
|
||||
|
||||
void updateGeometry();
|
||||
|
||||
virtual void invalidate();
|
||||
|
||||
virtual QSizeF sizeHint() const;
|
||||
|
||||
QSizeF size() const;
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
void resize(const QSizeF& size);
|
||||
void resize(qreal w, qreal h);
|
||||
|
||||
void setLayout(Layout *l);
|
||||
Layout *layout() const;
|
||||
|
||||
Widget *parent() const;
|
||||
void reparent(Widget *w);
|
||||
|
||||
void addChild(Widget *w);
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void data(const DataSource::Data&);
|
||||
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private *const d;
|
||||
|
Loading…
Reference in New Issue
Block a user