still experimental and to me made work better: extendergroups store items in a scrollwidget
svn path=/trunk/KDE/kdelibs/; revision=1109959
This commit is contained in:
parent
1ce5890d24
commit
7d853de323
@ -426,9 +426,9 @@ void Extender::dropEvent(QGraphicsSceneDragDropEvent *event)
|
||||
|
||||
void Extender::itemAddedEvent(ExtenderItem *item, const QPointF &pos)
|
||||
{
|
||||
if (pos == QPointF(-1, -1)) {
|
||||
//if just plain adding an item, add it at a sane position:
|
||||
if (!item->group()) {
|
||||
if (!item->group()) {
|
||||
if (pos == QPointF(-1, -1)) {
|
||||
//if just plain adding an item, add it at a sane position:
|
||||
if (appearance() == BottomUpStacked) {
|
||||
//at the top
|
||||
d->layout->insertItem(0, item);
|
||||
@ -437,11 +437,8 @@ void Extender::itemAddedEvent(ExtenderItem *item, const QPointF &pos)
|
||||
d->layout->addItem(item);
|
||||
}
|
||||
} else {
|
||||
//at the top in the group it belongs to
|
||||
d->layout->insertItem(d->insertIndexFromPos(item->group()->pos()) + 1, item);
|
||||
d->layout->insertItem(d->insertIndexFromPos(pos), item);
|
||||
}
|
||||
} else {
|
||||
d->layout->insertItem(d->insertIndexFromPos(pos), item);
|
||||
}
|
||||
|
||||
//remove the empty extender message if needed.
|
||||
|
@ -23,11 +23,13 @@
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QtGui/QGraphicsWidget>
|
||||
#include <QtGui/QGraphicsLinearLayout>
|
||||
|
||||
#include "applet.h"
|
||||
#include "extender.h"
|
||||
#include "extenderitem.h"
|
||||
#include "theme.h"
|
||||
#include "widgets/scrollwidget.h"
|
||||
|
||||
#include "private/extendergroup_p.h"
|
||||
|
||||
@ -45,6 +47,19 @@ ExtenderGroup::ExtenderGroup(Extender *parent, uint groupId)
|
||||
|
||||
config().writeEntry("isGroup", true);
|
||||
|
||||
//FIXME: this ain't pretty
|
||||
setPreferredHeight(300);
|
||||
|
||||
QGraphicsLinearLayout *lay = static_cast<QGraphicsLinearLayout *>(layout());
|
||||
d->scrollWidget = new ScrollWidget(this);
|
||||
d->scrollWidget->show();
|
||||
lay->addItem(d->scrollWidget);
|
||||
d->scrollWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
d->scrollWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
d->childsWidget = new QGraphicsWidget(d->scrollWidget);
|
||||
d->scrollWidget->setWidget(d->childsWidget);
|
||||
d->layout = new QGraphicsLinearLayout(Qt::Vertical, d->childsWidget);
|
||||
|
||||
QAction *expand = new QAction(this);
|
||||
expand->setVisible(true);
|
||||
expand->setToolTip(i18n("Show this group."));
|
||||
@ -183,6 +198,12 @@ void ExtenderGroup::collapseGroup()
|
||||
}
|
||||
}
|
||||
|
||||
void ExtenderGroup::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
ExtenderItem::resizeEvent(event);
|
||||
|
||||
d->scrollWidget->setGeometry(0, 70, size().width(), 400);
|
||||
}
|
||||
|
||||
ExtenderGroupPrivate::ExtenderGroupPrivate(ExtenderGroup *group)
|
||||
: q(group),
|
||||
@ -200,17 +221,16 @@ ExtenderGroupPrivate::~ExtenderGroupPrivate()
|
||||
void ExtenderGroupPrivate::addItemToGroup(Plasma::ExtenderItem *item)
|
||||
{
|
||||
if (item->group() == q) {
|
||||
layout->addItem(item);
|
||||
item->setParentItem(childsWidget);
|
||||
childsWidget->resize(childsWidget->size().width(),
|
||||
childsWidget->effectiveSizeHint(Qt::PreferredSize).height());
|
||||
|
||||
if (!q->isVisible() && !q->items().isEmpty()) {
|
||||
q->extender()->itemAddedEvent(q);
|
||||
q->show();
|
||||
}
|
||||
if (collapsed) {
|
||||
q->extender()->itemRemovedEvent(item);
|
||||
item->hide();
|
||||
} else {
|
||||
q->extender()->itemAddedEvent(item);
|
||||
item->show();
|
||||
}
|
||||
scrollWidget->setVisible(!q->isCollapsed());
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,6 +241,7 @@ void ExtenderGroupPrivate::removeItemFromGroup(Plasma::ExtenderItem *item)
|
||||
q->extender()->itemRemovedEvent(q);
|
||||
q->hide();
|
||||
}
|
||||
layout->removeItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,9 @@ class PLASMA_EXPORT ExtenderGroup : public ExtenderItem
|
||||
*/
|
||||
void collapseGroup();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
|
||||
private:
|
||||
ExtenderGroupPrivate * const d;
|
||||
|
||||
|
@ -203,7 +203,7 @@ void ExtenderItem::setWidget(QGraphicsItem *widget)
|
||||
if (d->widget && d->widget->isWidget()) {
|
||||
d->layout->removeItem(static_cast<QGraphicsWidget *>(d->widget));
|
||||
}
|
||||
d->layout->addItem(static_cast<QGraphicsWidget *>(widget));
|
||||
d->layout->insertItem(1, static_cast<QGraphicsWidget *>(widget));
|
||||
d->widget = widget;
|
||||
} else {
|
||||
widget->installSceneEventFilter(this);
|
||||
@ -857,6 +857,7 @@ void ExtenderItemPrivate::themeChanged()
|
||||
}
|
||||
|
||||
background->getMargins(bgLeft, bgTop, bgRight, bgBottom);
|
||||
layout->setContentsMargins(bgLeft, bgTop, bgRight, bgBottom);
|
||||
|
||||
dragger->setImagePath("widgets/extender-dragger");
|
||||
|
||||
@ -878,6 +879,7 @@ void ExtenderItemPrivate::themeChanged()
|
||||
QSizeF panelSize(QSizeF(q->size().width() - bgLeft - bgRight,
|
||||
iconSize + dragTop + dragBottom));
|
||||
|
||||
//TODO: all this stuff will die after using the layout for everything
|
||||
//resize the collapse icon.
|
||||
collapseIcon->resize(collapseIcon->sizeFromIconSize(iconSize));
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class ScrollWidget;
|
||||
class ExtenderGroup;
|
||||
class ExtenderItem;
|
||||
class Svg;
|
||||
@ -39,6 +40,9 @@ class ExtenderGroupPrivate
|
||||
|
||||
Plasma::ExtenderGroup *q;
|
||||
Plasma::Svg *svg;
|
||||
Plasma::ScrollWidget *scrollWidget;
|
||||
QGraphicsWidget *childsWidget;
|
||||
QGraphicsLinearLayout *layout;
|
||||
bool collapsed;
|
||||
bool autoHide;
|
||||
bool autoCollapse;
|
||||
|
Loading…
Reference in New Issue
Block a user