-is possible to drop items at any place of an extender group

-fix build

svn path=/trunk/KDE/kdelibs/; revision=1113376
This commit is contained in:
Marco Martin 2010-04-10 16:43:56 +00:00
parent 0c989d306f
commit d29ea0a926
5 changed files with 43 additions and 6 deletions

View File

@ -276,7 +276,7 @@ void ExtenderGroup::dropEvent(QGraphicsSceneDragDropEvent *event)
qobject_cast<const ExtenderItemMimeData*>(event->mimeData());
if (mimeData) {
mimeData->extenderItem()->setGroup(this);
mimeData->extenderItem()->setGroup(this, event->pos());
QApplication::restoreOverrideCursor();
d->layout->removeItem(d->spacerWidget);
d->spacerWidget->deleteLater();
@ -307,12 +307,12 @@ ExtenderGroupPrivate::~ExtenderGroupPrivate()
{
}
void ExtenderGroupPrivate::addItemToGroup(Plasma::ExtenderItem *item)
void ExtenderGroupPrivate::addItemToGroup(Plasma::ExtenderItem *item, const QPointF &pos)
{
if (item->group() == q) {
item->setParentItem(childsWidget);
item->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
layout->insertItem(0, item);
layout->insertItem(insertIndexFromPos(pos), item);
layout->activate();
childsWidget->resize(childsWidget->size().width(),

View File

@ -366,7 +366,13 @@ Extender *ExtenderItem::extender() const
return d->extender;
}
//TODO KDE5: only one setGroup()
void ExtenderItem::setGroup(ExtenderGroup *group)
{
setGroup(group, QPointF(-1, -1));
}
void ExtenderItem::setGroup(ExtenderGroup *group, const QPointF &pos)
{
if (isGroup()) {
//nesting extender groups is just insane. I don't think we'd even want to support that.
@ -384,7 +390,7 @@ void ExtenderItem::setGroup(ExtenderGroup *group)
kDebug() << "moving to another extender because we're joining a detached group.";
setExtender(group->extender());
}
group->d->addItemToGroup(this);
group->d->addItemToGroup(this, pos);
} else {
if (oldGroup) {
oldGroup->d->removeItemFromGroup(this);

View File

@ -179,6 +179,16 @@ class PLASMA_EXPORT ExtenderItem : public QGraphicsWidget
*/
void setGroup(ExtenderGroup *group);
/**
* @param group the group you want this item to belong to. Note that you can't nest
* ExtenderGroups.
*
* @param group the new group
* @param pos position inside the extender group
* @since 4.5
*/
void setGroup(ExtenderGroup *group, const QPointF &pos);
/**
* @returns the group this item belongs to.
* @since 4.3

View File

@ -37,9 +37,27 @@ class Extender;
class ExtenderGroup;
class ExtenderItem;
class Label;
class Spacer;
class Svg;
class Spacer : public QGraphicsWidget
{
public:
Spacer(QGraphicsItem *parent);
~Spacer();
void setMargins(qreal left, qreal top, qreal right, qreal bottom);
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * widget = 0);
private:
qreal m_left;
qreal m_top;
qreal m_right;
qreal m_bottom;
};
class ExtenderPrivate
{
public:

View File

@ -27,6 +27,7 @@ class ScrollWidget;
class ExtenderGroup;
class ExtenderItem;
class Svg;
class Spacer;
class ExtenderGroupPrivate
{
@ -34,11 +35,13 @@ class ExtenderGroupPrivate
ExtenderGroupPrivate(ExtenderGroup *group);
~ExtenderGroupPrivate();
void addItemToGroup(Plasma::ExtenderItem *item);
void addItemToGroup(Plasma::ExtenderItem *item, const QPointF &pos = QPointF(-1, -1));
void removeItemFromGroup(Plasma::ExtenderItem *item);
void themeChanged();
int insertIndexFromPos(const QPointF &pos) const;
Plasma::ExtenderGroup *q;
Spacer *spacerWidget;
Plasma::Svg *svg;
Plasma::ScrollWidget *scrollWidget;
QGraphicsWidget *childsWidget;