move all the prive code into private/; makes it much clearer with the division lines are

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=839792
This commit is contained in:
Aaron J. Seigo 2008-07-30 20:35:42 +00:00
parent 8febce6910
commit 63bce9d1b4
30 changed files with 296 additions and 245 deletions

View File

@ -27,7 +27,6 @@ set(plasma_LIB_SRCS
appletbrowser/kcategorizeditemsviewmodels.cpp
appletbrowser/openwidgetassistant.cpp
appletbrowser/plasmaappletitemmodel.cpp
applethandle.cpp
configxml.cpp
containment.cpp
corona.cpp
@ -35,16 +34,20 @@ set(plasma_LIB_SRCS
dataengine.cpp
dataenginemanager.cpp
delegate.cpp
desktoptoolbox.cpp
dialog.cpp
#FOR FUTURE
#layouts/borderlayout.cpp
packages.cpp
paintutils.cpp
panelsvg.cpp
paneltoolbox.cpp
plasma.cpp
popupapplet.cpp
private/applethandle.cpp
private/datacontainer_p.cpp
private/desktoptoolbox.cpp
private/packages.cpp
private/paneltoolbox.cpp
private/toolbox.cpp
private/tooltip.cpp
querymatch.cpp
runnercontext.cpp
runnermanager.cpp
@ -56,9 +59,7 @@ set(plasma_LIB_SRCS
servicejob.cpp
svg.cpp
theme.cpp
toolbox.cpp
tooltipmanager.cpp
tooltip.cpp
uiloader.cpp
version.cpp
view.cpp

View File

@ -20,7 +20,7 @@
*/
#include "applet.h"
#include "applet_p.h"
#include "private/applet_p.h"
#include <cmath>
#include <limits>
@ -59,23 +59,24 @@
#include <Solid/PowerManagement>
#include "plasma/configxml.h"
#include "plasma/containment.h"
#include "plasma/containment_p.h"
#include "plasma/corona.h"
#include "plasma/dataenginemanager.h"
#include "plasma/package.h"
#include "plasma/packages_p.h"
#include "plasma/plasma.h"
#include "plasma/scripting/appletscript.h"
#include "plasma/svg.h"
#include "plasma/panelsvg.h"
#include "plasma/theme.h"
#include "plasma/toolbox_p.h"
#include "plasma/view.h"
#include "plasma/widgets/label.h"
#include "plasma/widgets/pushbutton.h"
#include "plasma/tooltipmanager.h"
#include "configxml.h"
#include "containment.h"
#include "corona.h"
#include "dataenginemanager.h"
#include "package.h"
#include "plasma.h"
#include "scripting/appletscript.h"
#include "svg.h"
#include "panelsvg.h"
#include "theme.h"
#include "view.h"
#include "widgets/label.h"
#include "widgets/pushbutton.h"
#include "tooltipmanager.h"
#include "private/containment_p.h"
#include "private/packages_p.h"
#include "private/toolbox_p.h"
//#define DYNAMIC_SHADOWS
namespace Plasma

View File

@ -19,7 +19,7 @@
*/
#include "containment.h"
#include "containment_p.h"
#include "private/containment_p.h"
#include <QAction>
#include <QDesktopWidget>
@ -44,14 +44,15 @@
#include <KStandardDirs>
#include <KWindowSystem>
#include "applet_p.h"
#include "applethandle_p.h"
#include "corona.h"
#include "animator.h"
#include "desktoptoolbox_p.h"
#include "paneltoolbox_p.h"
#include "corona.h"
#include "svg.h"
#include "private/applet_p.h"
#include "private/applethandle_p.h"
#include "private/desktoptoolbox_p.h"
#include "private/paneltoolbox_p.h"
namespace Plasma
{

View File

@ -18,7 +18,7 @@
*/
#include "datacontainer.h"
#include "datacontainer_p.h"
#include "private/datacontainer_p.h"
#include <QVariant>
@ -192,5 +192,4 @@ void DataContainer::checkUsage()
} // Plasma namespace
#include "datacontainer.moc"
#include "datacontainer_p.moc"

View File

@ -1,194 +0,0 @@
/*
* Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* 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 PLASMA_DATACONTAINER_P_H
#define PLASMA_DATACONTAINER_P_H
#include <QtCore/QTimerEvent>
#include <QtCore/QTime>
namespace Plasma
{
class SignalRelay;
class DataContainerPrivate
{
public:
DataContainerPrivate()
: dirty(false), cached(false)
{}
SignalRelay* signalRelay(const DataContainer* dc, QObject *visualization,
uint pollingInterval, Plasma::IntervalAlignment align);
bool hasUpdates();
DataEngine::Data data;
QMap<QObject *, SignalRelay *> relayObjects;
QMap<uint, SignalRelay *> relays;
QTime updateTs;
bool dirty : 1;
bool cached : 1;
};
class SignalRelay : public QObject
{
Q_OBJECT
public:
SignalRelay(DataContainer* parent, DataContainerPrivate *data, uint ival, Plasma::IntervalAlignment align)
: QObject(parent),
dc(parent),
d(data),
m_interval(ival),
m_align(align),
m_resetTimer(true),
m_queued(false)
{
//kDebug() << "signal relay with time of" << m_timerId << "being set up";
m_timerId = startTimer(0);
if (m_align != Plasma::NoAlignment) {
checkAlignment();
}
}
int receiverCount() const
{
return receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)));
}
bool isUnused()
{
return receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data))) < 1;
}
void checkAlignment()
{
int newTime = 0;
QTime t = QTime::currentTime();
if (m_align == Plasma::AlignToMinute) {
int seconds = t.second();
if (seconds > 2) {
newTime = ((60 - seconds) * 1000) + 500;
}
} else if (m_align == Plasma::AlignToHour) {
int minutes = t.minute();
int seconds = t.second();
if (minutes > 1 || seconds > 10) {
newTime = ((60 - minutes) * 1000 * 60) +
((60 - seconds) * 1000) + 500;
}
}
if (newTime) {
killTimer(m_timerId);
m_timerId = startTimer(newTime);
m_resetTimer = true;
}
}
void checkQueueing() {
if (m_queued) {
emit dataUpdated(dc->objectName(), d->data);
m_queued = false;
//TODO: should we re-align our timer at this point, to avoid
// constant queueing due to more-or-less constant time
// async update time? this might make sense for
// staggered accesses to the same source by multiple
// visualizations causing a minimumPollingInterval violation.
// it may not make sense for purely async-and-takes-a-while
// type operations (e.g. network fetching).
// we need more real world data before making such a change
// change
//
// killTimer(m_timerId);
// m_timerId = startTime(m_interval);
}
}
DataContainer *dc;
DataContainerPrivate *d;
uint m_interval;
Plasma::IntervalAlignment m_align;
int m_timerId;
bool m_resetTimer;
bool m_queued;
signals:
void dataUpdated(const QString&, const Plasma::DataEngine::Data&);
protected:
void timerEvent(QTimerEvent *event)
{
if (m_resetTimer) {
killTimer(m_timerId);
m_timerId = startTimer(m_interval);
m_resetTimer = false;
}
if (m_align != Plasma::NoAlignment) {
checkAlignment();
}
emit dc->updateRequested(dc);
if (d->hasUpdates()) {
//kDebug() << "emitting data updated directly" << d->data;
emit dataUpdated(dc->objectName(), d->data);
} else {
// the source wasn't actually updated; so let's put ourselves in the queue
// so we get an dataUpdated() when the data does arrive
//kDebug() << "queued";
m_queued = true;
}
event->accept();
}
};
SignalRelay* DataContainerPrivate::signalRelay(const DataContainer* dc, QObject *visualization, uint pollingInterval, Plasma::IntervalAlignment align)
{
QMap<uint, SignalRelay *>::const_iterator relayIt = relays.find(pollingInterval);
SignalRelay *relay = 0;
//FIXME what if we have two applets with the same interval and different alignment?
if (relayIt == relays.end()) {
relay = new SignalRelay(const_cast<DataContainer*>(dc), this, pollingInterval, align);
relays[pollingInterval] = relay;
} else {
relay = relayIt.value();
}
relayObjects[visualization] = relay;
return relay;
}
bool DataContainerPrivate::hasUpdates()
{
if (cached) {
//some signalrelay needs us to pretend we did an update
cached = false;
return true;
}
return dirty;
}
}
#endif // multiple inclusion guard

View File

@ -18,7 +18,7 @@
*/
#include "dataengine.h"
#include "dataengine_p.h"
#include "private/dataengine_p.h"
#include <QQueue>
#include <QTimer>
@ -34,9 +34,10 @@
#include "datacontainer.h"
#include "package.h"
#include "service.h"
#include "service_p.h"
#include "scripting/dataenginescript.h"
#include "private/service_p.h"
namespace Plasma
{

View File

@ -22,7 +22,7 @@
#include <KDebug>
#include <KServiceTypeTrader>
#include "dataengine_p.h"
#include "private/dataengine_p.h"
#include "scripting/scriptengine.h"
namespace Plasma

View File

@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "applethandle_p.h"
#include "private/applethandle_p.h"
#include <QApplication>
#include <QBitmap>
@ -892,3 +892,4 @@ void AppletHandle::calculateSize()
} // Plasma Namespace
#include "applethandle_p.moc"

128
private/datacontainer_p.cpp Normal file
View File

@ -0,0 +1,128 @@
/*
* Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* 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 "datacontainer.h"
#include "datacontainer_p.h"
namespace Plasma
{
SignalRelay* DataContainerPrivate::signalRelay(const DataContainer* dc, QObject *visualization, uint pollingInterval, Plasma::IntervalAlignment align)
{
QMap<uint, SignalRelay *>::const_iterator relayIt = relays.find(pollingInterval);
SignalRelay *relay = 0;
//FIXME what if we have two applets with the same interval and different alignment?
if (relayIt == relays.end()) {
relay = new SignalRelay(const_cast<DataContainer*>(dc), this, pollingInterval, align);
relays[pollingInterval] = relay;
} else {
relay = relayIt.value();
}
relayObjects[visualization] = relay;
return relay;
}
bool DataContainerPrivate::hasUpdates()
{
if (cached) {
// SignalRelay needs us to pretend we did an update
cached = false;
return true;
}
return dirty;
}
void SignalRelay::checkAlignment()
{
int newTime = 0;
QTime t = QTime::currentTime();
if (m_align == Plasma::AlignToMinute) {
int seconds = t.second();
if (seconds > 2) {
newTime = ((60 - seconds) * 1000) + 500;
}
} else if (m_align == Plasma::AlignToHour) {
int minutes = t.minute();
int seconds = t.second();
if (minutes > 1 || seconds > 10) {
newTime = ((60 - minutes) * 1000 * 60) +
((60 - seconds) * 1000) + 500;
}
}
if (newTime) {
killTimer(m_timerId);
m_timerId = startTimer(newTime);
m_resetTimer = true;
}
}
void SignalRelay::checkQueueing()
{
if (m_queued) {
emit dataUpdated(dc->objectName(), d->data);
m_queued = false;
//TODO: should we re-align our timer at this point, to avoid
// constant queueing due to more-or-less constant time
// async update time? this might make sense for
// staggered accesses to the same source by multiple
// visualizations causing a minimumPollingInterval violation.
// it may not make sense for purely async-and-takes-a-while
// type operations (e.g. network fetching).
// we need more real world data before making such a change
// change
//
// killTimer(m_timerId);
// m_timerId = startTime(m_interval);
}
}
void SignalRelay::timerEvent(QTimerEvent *event)
{
if (m_resetTimer) {
killTimer(m_timerId);
m_timerId = startTimer(m_interval);
m_resetTimer = false;
}
if (m_align != Plasma::NoAlignment) {
checkAlignment();
}
emit dc->updateRequested(dc);
if (d->hasUpdates()) {
//kDebug() << "emitting data updated directly" << d->data;
emit dataUpdated(dc->objectName(), d->data);
} else {
// the source wasn't actually updated; so let's put ourselves in the queue
// so we get an dataUpdated() when the data does arrive
//kDebug() << "queued";
m_queued = true;
}
event->accept();
}
} // Plasma namespace
#include "datacontainer_p.moc"

103
private/datacontainer_p.h Normal file
View File

@ -0,0 +1,103 @@
/*
* Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* 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 PLASMA_DATACONTAINER_P_H
#define PLASMA_DATACONTAINER_P_H
#include <QtCore/QTimerEvent>
#include <QtCore/QTime>
namespace Plasma
{
class SignalRelay;
class DataContainerPrivate
{
public:
DataContainerPrivate()
: dirty(false), cached(false)
{}
SignalRelay* signalRelay(const DataContainer* dc, QObject *visualization,
uint pollingInterval, Plasma::IntervalAlignment align);
bool hasUpdates();
DataEngine::Data data;
QMap<QObject *, SignalRelay *> relayObjects;
QMap<uint, SignalRelay *> relays;
QTime updateTs;
bool dirty : 1;
bool cached : 1;
};
class SignalRelay : public QObject
{
Q_OBJECT
public:
SignalRelay(DataContainer* parent, DataContainerPrivate *data, uint ival, Plasma::IntervalAlignment align)
: QObject(parent),
dc(parent),
d(data),
m_interval(ival),
m_align(align),
m_resetTimer(true),
m_queued(false)
{
//kDebug() << "signal relay with time of" << m_timerId << "being set up";
m_timerId = startTimer(0);
if (m_align != Plasma::NoAlignment) {
checkAlignment();
}
}
int receiverCount() const
{
return receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)));
}
bool isUnused()
{
return receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data))) < 1;
}
void checkAlignment();
void checkQueueing();
DataContainer *dc;
DataContainerPrivate *d;
uint m_interval;
Plasma::IntervalAlignment m_align;
int m_timerId;
bool m_resetTimer;
bool m_queued;
signals:
void dataUpdated(const QString&, const Plasma::DataEngine::Data&);
protected:
void timerEvent(QTimerEvent *event);
};
} // Plasma namespace
#endif // multiple inclusion guard

View File

@ -27,7 +27,7 @@
#include <KIcon>
#include <plasma/toolbox_p.h>
#include <private/toolbox_p.h>
#include "animator.h"

View File

@ -17,7 +17,7 @@
* Boston, MA 02110-1301, USA. *
*******************************************************************************/
#include "packages_p.h"
#include "private/packages_p.h"
#include <KConfigGroup>
#include <KDesktopFile>

View File

@ -27,7 +27,7 @@
#include <KIcon>
#include <plasma/toolbox_p.h>
#include <private/toolbox_p.h>
#include "animator.h"

View File

@ -17,9 +17,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SERVICE_P_H
#define SERVICE_P_H
#include "servicejob.h"
#include <KTemporaryFile>
namespace Plasma
{
@ -83,4 +87,5 @@ public:
} // namespace Plasma
#endif

View File

@ -19,7 +19,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "toolbox_p.h"
#include "private/toolbox_p.h"
#include <QAction>
#include <QGraphicsSceneHoverEvent>
@ -76,7 +76,10 @@ void ToolBox::addTool(QAction *action)
tool->setAction(action);
tool->setDrawBackground(true);
tool->setOrientation(Qt::Horizontal);
tool->resize(tool->sizeFromIconSize(22));
QSizeF iconSize = tool->sizeFromIconSize(22);
tool->setMinimumSize(iconSize);
tool->setMaximumSize(iconSize);
tool->resize(tool->size());
tool->hide();
const int height = static_cast<int>(tool->boundingRect().height());

View File

@ -18,7 +18,8 @@
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "tooltip_p.h"
#include "private/tooltip_p.h"
#include <QBitmap>
#include <QHBoxLayout>

View File

@ -27,11 +27,12 @@
#include "applet.h"
#include "dataengine.h"
#include "package.h"
#include "packages_p.h"
#include "scripting/appletscript.h"
#include "scripting/dataenginescript.h"
#include "scripting/runnerscript.h"
#include "private/packages_p.h"
namespace Plasma
{

View File

@ -18,7 +18,7 @@
*/
#include "service.h"
#include "service_p.h"
#include "private/service_p.h"
#include <QFile>

View File

@ -35,7 +35,7 @@
#include <KStandardDirs>
#include <KGlobalSettings>
#include "plasma/packages_p.h"
#include "private/packages_p.h"
namespace Plasma
{

View File

@ -40,12 +40,12 @@
//Plasma
#include <plasma/applet.h>
#include <plasma/containment.h>
#include <plasma/panelsvg.h>
#include <plasma/theme.h>
#include <plasma/tooltip_p.h>
#include <plasma/view.h>
#include <applet.h>
#include <containment.h>
#include <panelsvg.h>
#include <theme.h>
#include <view.h>
#include <private/tooltip_p.h>
namespace Plasma
{