Move ExtenderGroupPrivate to a seperate header file, so we can call addItemToGroup in setGroup.
svn path=/trunk/KDE/kdelibs/; revision=944336
This commit is contained in:
parent
acaa4108df
commit
0bfbed06ae
@ -27,55 +27,11 @@
|
||||
#include "extendergroup.h"
|
||||
#include "extenderitem.h"
|
||||
|
||||
#include "private/extendergroup_p.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class ExtenderGroupPrivate
|
||||
{
|
||||
public:
|
||||
ExtenderGroupPrivate(ExtenderGroup *group)
|
||||
: collapsed(true),
|
||||
hideIfEmpty(true)
|
||||
{
|
||||
q = group;
|
||||
}
|
||||
|
||||
~ExtenderGroupPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
void addItemToGroup(Plasma::ExtenderItem *item)
|
||||
{
|
||||
if (item->group() == q) {
|
||||
if (collapsed) {
|
||||
q->extender()->itemRemovedEvent(item);
|
||||
item->hide();
|
||||
}
|
||||
if (!q->isVisible()) {
|
||||
q->extender()->itemAddedEvent(q);
|
||||
q->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void removeItemFromGroup(Plasma::ExtenderItem *item)
|
||||
{
|
||||
if (item->group() == q) {
|
||||
if (q->items().isEmpty()) {
|
||||
q->extender()->itemRemovedEvent(q);
|
||||
q->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExtenderGroup *q;
|
||||
bool collapsed;
|
||||
bool hideIfEmpty;
|
||||
};
|
||||
|
||||
class ExtenderItem;
|
||||
class Applet;
|
||||
|
||||
ExtenderGroup::ExtenderGroup(Extender *parent, uint groupId)
|
||||
: ExtenderItem(parent, groupId),
|
||||
d(new ExtenderGroupPrivate(this))
|
||||
@ -172,6 +128,42 @@ void ExtenderGroup::collapseGroup()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ExtenderGroupPrivate::ExtenderGroupPrivate(ExtenderGroup *group)
|
||||
: collapsed(true),
|
||||
hideIfEmpty(true)
|
||||
{
|
||||
q = group;
|
||||
}
|
||||
|
||||
ExtenderGroupPrivate::~ExtenderGroupPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
void ExtenderGroupPrivate::addItemToGroup(Plasma::ExtenderItem *item)
|
||||
{
|
||||
if (item->group() == q) {
|
||||
if (collapsed) {
|
||||
q->extender()->itemRemovedEvent(item);
|
||||
item->hide();
|
||||
}
|
||||
if (!q->isVisible()) {
|
||||
q->extender()->itemAddedEvent(q);
|
||||
q->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExtenderGroupPrivate::removeItemFromGroup(Plasma::ExtenderItem *item)
|
||||
{
|
||||
if (item->group() == q) {
|
||||
if (q->items().isEmpty()) {
|
||||
q->extender()->itemRemovedEvent(q);
|
||||
q->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#include "extendergroup.moc"
|
||||
|
@ -93,6 +93,8 @@ class PLASMA_EXPORT ExtenderGroup : public ExtenderItem
|
||||
|
||||
Q_PRIVATE_SLOT(d, void addItemToGroup(Plasma::ExtenderItem *item))
|
||||
Q_PRIVATE_SLOT(d, void removeItemFromGroup(Plasma::ExtenderItem *item))
|
||||
|
||||
friend class ExtenderItem;
|
||||
};
|
||||
} // Plasma namespace
|
||||
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "private/applethandle_p.h"
|
||||
#include "private/extender_p.h"
|
||||
#include "private/extenderapplet_p.h"
|
||||
#include "private/extendergroup_p.h"
|
||||
#include "private/extenderitem_p.h"
|
||||
#include "private/extenderitemmimedata_p.h"
|
||||
|
||||
@ -286,6 +287,7 @@ void ExtenderItem::setGroup(ExtenderGroup *group)
|
||||
{
|
||||
d->group = group;
|
||||
config().writeEntry("group", group->name());
|
||||
group->d->addItemToGroup(this);
|
||||
}
|
||||
|
||||
ExtenderGroup *ExtenderItem::group() const
|
||||
|
44
private/extendergroup_p.h
Normal file
44
private/extendergroup_p.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2009 by Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_EXTENDERGROUPPRIVATE_H
|
||||
#define PLASMA_EXTENDERGROUPPRIVATE_H
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class ExtenderGroup;
|
||||
class ExtenderItem;
|
||||
|
||||
class ExtenderGroupPrivate
|
||||
{
|
||||
public:
|
||||
ExtenderGroupPrivate(ExtenderGroup *group);
|
||||
~ExtenderGroupPrivate();
|
||||
|
||||
void addItemToGroup(Plasma::ExtenderItem *item);
|
||||
void removeItemFromGroup(Plasma::ExtenderItem *item);
|
||||
|
||||
Plasma::ExtenderGroup *q;
|
||||
bool collapsed;
|
||||
bool hideIfEmpty;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user