Commit 39116922 authored by Thomas Zander's avatar Thomas Zander

Rename KoCanvasResourceProvider to more generic KoResourceManager

svn path=/trunk/koffice/; revision=1078992
parent bac15a51
......@@ -20,7 +20,7 @@
#ifndef KO_TABLE_INTERFACE
#define KO_TABLE_INTERFACE
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include <QHash>
#include <QtPlugin>
......
......@@ -25,7 +25,7 @@
#include <KoResource.h>
#include <KoColorSet.h>
#include <KoColorSetWidget.h>
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include <KoColorSpaceRegistry.h>
KisPaletteDocker::KisPaletteDocker()
......
......@@ -29,7 +29,7 @@
#include <KoColorSlider.h>
#include <KoColorPopupAction.h>
#include <KoColorSpaceRegistry.h>
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include <KoCanvasBase.h>
class DigitalMixerPatch : public KoColorPatch {
......
......@@ -22,7 +22,7 @@
#include <KoDockFactoryBase.h>
#include <KoDockRegistry.h>
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include "smallcolorselector_dock.h"
......
......@@ -21,7 +21,7 @@
#include <KoColorSpaceRegistry.h>
#include <KoCanvasBase.h>
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include <KoTriangleColorSelector.h>
#include <KoColor.h>
......
......@@ -25,7 +25,7 @@
#include <KoColorSpace.h>
#include <KoToolProxy.h>
#include <KoCanvasBase.h>
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include "colorspot.h"
#include "kis_ksf32_colorspace.h"
......
......@@ -23,7 +23,7 @@
#include <KLocale>
#include <KoCanvasBase.h>
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include <KoColor.h>
#include "kis_painterlymixer.h"
......
......@@ -29,7 +29,7 @@
#include <QTabletEvent>
#include <QUndoCommand>
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include <KoColorSpace.h>
#include <KoColorSpaceRegistry.h>
#include <KoShapeManager.h>
......
......@@ -55,7 +55,7 @@ KisCanvasResourceProvider::~KisCanvasResourceProvider()
{
}
void KisCanvasResourceProvider::setCanvasResourceProvider(KoCanvasResourceProvider * resourceProvider)
void KisCanvasResourceProvider::setCanvasResourceProvider(KoResourceManager * resourceProvider)
{
m_resourceProvider = resourceProvider;
......
......@@ -23,7 +23,7 @@
#include <KoColor.h>
#include <KoID.h>
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include "kis_types.h"
#include "krita_export.h"
......@@ -63,7 +63,7 @@ public:
KisCanvasResourceProvider(KisView2 * view);
~KisCanvasResourceProvider();
void setCanvasResourceProvider(KoCanvasResourceProvider * resourceProvider);
void setCanvasResourceProvider(KoResourceManager * resourceProvider);
KoCanvasBase * canvas() const;
......@@ -129,7 +129,7 @@ signals:
private:
KisView2 * m_view;
KoCanvasResourceProvider * m_resourceProvider;
KoResourceManager * m_resourceProvider;
const KoColorProfile * m_displayProfile;
};
......
......@@ -66,7 +66,7 @@ KisSelectionDecoration::KisSelectionDecoration(KisView2* view)
// current selection now (global or local).
connect(timer, SIGNAL(timeout()), this, SLOT(selectionTimerEvent()));
KoCanvasResourceProvider* resourceProvider = view->canvasBase()->resourceProvider();
KoResourceManager* resourceProvider = view->canvasBase()->resourceProvider();
connect(resourceProvider, SIGNAL(resourceChanged(int, const QVariant &)),
this, SLOT(resourceChanged(int, const QVariant&)));
}
......
......@@ -444,7 +444,7 @@ void KisTool::resetCursorStyle()
void KisTool::slotToggleFgBg()
{
KoCanvasResourceProvider* resourceProvider = canvas()->resourceProvider();
KoResourceManager* resourceProvider = canvas()->resourceProvider();
KoColor c = resourceProvider->foregroundColor();
resourceProvider->setForegroundColor(resourceProvider->backgroundColor());
resourceProvider->setBackgroundColor(c);
......@@ -452,7 +452,7 @@ void KisTool::slotToggleFgBg()
void KisTool::slotResetFgBg()
{
KoCanvasResourceProvider* resourceProvider = canvas()->resourceProvider();
KoResourceManager* resourceProvider = canvas()->resourceProvider();
resourceProvider->setForegroundColor(KoColor(Qt::black, KoColorSpaceRegistry::instance()->rgb8()));
resourceProvider->setBackgroundColor(KoColor(Qt::white, KoColorSpaceRegistry::instance()->rgb8()));
}
......
......@@ -24,7 +24,7 @@
#include <KoColor.h>
#include <KoTool.h>
#include <KoID.h>
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include <krita_export.h>
#include <kis_types.h>
......
......@@ -40,7 +40,7 @@
#include <KoPointerEvent.h>
#include <KoCanvasBase.h>
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include <KoCanvasController.h>
#include <KoViewConverter.h>
......
......@@ -43,7 +43,7 @@
#include <KoShape.h>
#include <KoShapeManager.h>
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include <KoColorSpace.h>
#include <KoPointerEvent.h>
#include <KoColor.h>
......@@ -138,7 +138,7 @@ void KisToolPaint::mouseReleaseEvent(KoPointerEvent *e)
qDebug() << "[KisToolPaint] MidButton: calling palette";
emit favoritePaletteCalled(e->pos());
// KoCanvasResourceProvider * resourceProvider = 0;
// KoResourceManager * resourceProvider = 0;
// if (canvas() && (resourceProvider = canvas()->resourceProvider())) {
// QVariant fg = resourceProvider->resource(KoCanvasResource::ForegroundColor);
// if (!fg.isValid()) return;
......
......@@ -28,7 +28,7 @@
#include <QPaintEvent>
#include <QVariant>
#include <KoCanvasResourceProvider.h>
#include <KoResourceManager.h>
#include <KoTool.h>
#include <KoAbstractGradient.h>
......
......@@ -13,7 +13,7 @@ add_subdirectory(pics)
set(flake_SRCS
KoFlake.cpp
KoCanvasBase.cpp
KoCanvasResourceProvider.cpp
KoResourceManager.cpp
KoCanvasObserverBase.cpp
KoCanvasSupervisor.cpp
KoCutController.cpp
......@@ -213,7 +213,7 @@ install(
KoCanvasController.h
KoCanvasObserverBase.h
KoCanvasSupervisor.h
KoCanvasResourceProvider.h
KoResourceManager.h
KoCopyController.h
KoCutController.h
KoDataCenter.h
......
......@@ -19,7 +19,7 @@
*/
#include "KoCanvasBase.h"
#include "KoCanvasResourceProvider.h"
#include "KoResourceManager.h"
#include "KoShapeController.h"
#include "KoCanvasController.h"
#include "KoSnapGuide.h"
......@@ -40,7 +40,7 @@ public:
delete snapGuide;
}
KoShapeController *shapeController;
KoCanvasResourceProvider * resourceProvider;
KoResourceManager * resourceProvider;
KoCanvasController *controller;
KoSnapGuide * snapGuide;
};
......@@ -48,7 +48,7 @@ public:
KoCanvasBase::KoCanvasBase(KoShapeControllerBase *shapeControllerBase)
: d(new Private())
{
d->resourceProvider = new KoCanvasResourceProvider();
d->resourceProvider = new KoResourceManager();
d->shapeController = new KoShapeController(this, shapeControllerBase);
d->snapGuide = new KoSnapGuide(this);
}
......@@ -64,7 +64,7 @@ KoShapeController *KoCanvasBase::shapeController() const
return d->shapeController;
}
KoCanvasResourceProvider *KoCanvasBase::resourceProvider() const
KoResourceManager *KoCanvasBase::resourceProvider() const
{
return d->resourceProvider;
}
......
......@@ -33,7 +33,7 @@
#include "flake_export.h"
class KoCanvasResourceProvider;
class KoResourceManager;
class QUndoCommand;
class KoShapeManager;
class KoToolProxy;
......@@ -164,7 +164,7 @@ public:
* canvas. The resource provider contains per-canvas settings such
* as current foreground and background color.
*/
KoCanvasResourceProvider *resourceProvider() const;
KoResourceManager *resourceProvider() const;
/**
* Return the shape controller for this canvas.
......
/*
Copyright (c) 2006 Boudewijn Rempt (boud@valdyas.org)
Copyright (C) 2007 Thomas Zander <zander@kde.org>
Copyright (C) 2007, 2010 Thomas Zander <zander@kde.org>
Copyright (c) 2008 Carlos Licea <carlos.licea@kdemail.net>
This library is free software; you can redistribute it and/or
......@@ -18,32 +18,32 @@
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "KoCanvasResourceProvider.h"
#include "KoResourceManager.h"
#include <QVariant>
#include "KoShape.h"
#include "KoLineBorder.h"
class KoCanvasResourceProvider::Private
class KoResourceManager::Private
{
public:
QHash<int, QVariant> resources;
};
KoCanvasResourceProvider::KoCanvasResourceProvider(QObject *parent)
KoResourceManager::KoResourceManager(QObject *parent)
: QObject(parent),
d(new Private())
{
setGrabSensitivity(3);
}
KoCanvasResourceProvider::~KoCanvasResourceProvider()
KoResourceManager::~KoResourceManager()
{
delete d;
}
void KoCanvasResourceProvider::setResource(int key, const QVariant &value)
void KoResourceManager::setResource(int key, const QVariant &value)
{
if (d->resources.contains(key)) {
if (d->resources.value(key) == value)
......@@ -55,7 +55,7 @@ void KoCanvasResourceProvider::setResource(int key, const QVariant &value)
emit resourceChanged(key, value);
}
QVariant KoCanvasResourceProvider::resource(int key)
QVariant KoResourceManager::resource(int key)
{
if (!d->resources.contains(key)) {
QVariant empty;
......@@ -64,28 +64,29 @@ QVariant KoCanvasResourceProvider::resource(int key)
return d->resources.value(key);
}
void KoCanvasResourceProvider::setResource(int key, const KoColor &color)
void KoResourceManager::setResource(int key, const KoColor &color)
{
QVariant v;
v.setValue(color);
setResource(key, v);
}
void KoCanvasResourceProvider::setResource(int key, const KoID &id)
/*
void KoResourceManager::setResource(int key, const KoID &id)
{
QVariant v;
v.setValue(id);
setResource(key, v);
}
*/
void KoCanvasResourceProvider::setResource(int key, KoShape *shape)
void KoResourceManager::setResource(int key, KoShape *shape)
{
QVariant v;
v.setValue(shape);
setResource(key, v);
}
KoColor KoCanvasResourceProvider::koColorResource(int key)
KoColor KoResourceManager::koColorResource(int key)
{
if (! d->resources.contains(key)) {
KoColor empty;
......@@ -95,33 +96,33 @@ KoColor KoCanvasResourceProvider::koColorResource(int key)
}
void KoCanvasResourceProvider::setForegroundColor(const KoColor &color)
void KoResourceManager::setForegroundColor(const KoColor &color)
{
setResource(KoCanvasResource::ForegroundColor, color);
}
KoColor KoCanvasResourceProvider::foregroundColor()
KoColor KoResourceManager::foregroundColor()
{
return koColorResource(KoCanvasResource::ForegroundColor);
}
void KoCanvasResourceProvider::setBackgroundColor(const KoColor &color)
void KoResourceManager::setBackgroundColor(const KoColor &color)
{
setResource(KoCanvasResource::BackgroundColor, color);
}
KoColor KoCanvasResourceProvider::backgroundColor()
KoColor KoResourceManager::backgroundColor()
{
return koColorResource(KoCanvasResource::BackgroundColor);
}
KoID KoCanvasResourceProvider::koIDResource(int key)
KoID KoResourceManager::koIDResource(int key)
{
return resource(key).value<KoID>();
}
KoShape * KoCanvasResourceProvider::koShapeResource(int key)
KoShape * KoResourceManager::koShapeResource(int key)
{
if (! d->resources.contains(key))
return 0;
......@@ -129,7 +130,7 @@ KoShape * KoCanvasResourceProvider::koShapeResource(int key)
return resource(key).value<KoShape *>();
}
void KoCanvasResourceProvider::setHandleRadius(int handleRadius)
void KoResourceManager::setHandleRadius(int handleRadius)
{
// do not allow arbitrary small handles
if (handleRadius < 3)
......@@ -137,14 +138,14 @@ void KoCanvasResourceProvider::setHandleRadius(int handleRadius)
setResource(KoCanvasResource::HandleRadius, QVariant(handleRadius));
}
int KoCanvasResourceProvider::handleRadius()
int KoResourceManager::handleRadius()
{
if (d->resources.contains(KoCanvasResource::HandleRadius))
return d->resources.value(KoCanvasResource::HandleRadius).toInt();
return 3; // default value.
}
void KoCanvasResourceProvider::setGrabSensitivity(int grabSensitivity)
void KoResourceManager::setGrabSensitivity(int grabSensitivity)
{
// do not allow arbitrary small handles
if (grabSensitivity < 1)
......@@ -152,19 +153,19 @@ void KoCanvasResourceProvider::setGrabSensitivity(int grabSensitivity)
setResource(KoCanvasResource::GrabSensitivity, QVariant(grabSensitivity));
}
int KoCanvasResourceProvider::grabSensitivity()
int KoResourceManager::grabSensitivity()
{
return resource(KoCanvasResource::GrabSensitivity).toInt();
}
void KoCanvasResourceProvider::setActiveBorder( const KoLineBorder &border )
void KoResourceManager::setActiveBorder( const KoLineBorder &border )
{
QVariant v;
v.setValue(border);
setResource(KoCanvasResource::ActiveBorder, v);
}
KoLineBorder KoCanvasResourceProvider::activeBorder()
KoLineBorder KoResourceManager::activeBorder()
{
if (! d->resources.contains(KoCanvasResource::ActiveBorder)) {
KoLineBorder empty;
......@@ -173,7 +174,7 @@ KoLineBorder KoCanvasResourceProvider::activeBorder()
return resource(KoCanvasResource::ActiveBorder).value<KoLineBorder>();
}
void KoCanvasResourceProvider::setUnitChanged()
void KoResourceManager::setUnitChanged()
{
// do not use setResource with a static value
// because it exits if the value does not change
......@@ -182,28 +183,28 @@ void KoCanvasResourceProvider::setUnitChanged()
emit resourceChanged(KoCanvasResource::Unit, QVariant());
}
bool KoCanvasResourceProvider::boolResource(int key) const
bool KoResourceManager::boolResource(int key) const
{
if (! d->resources.contains(key))
return false;
return d->resources[key].toBool();
}
int KoCanvasResourceProvider::intResource(int key) const
int KoResourceManager::intResource(int key) const
{
if (! d->resources.contains(key))
return 0;
return d->resources[key].toInt();
}
qreal KoCanvasResourceProvider::doubleResource(int key) const
qreal KoResourceManager::doubleResource(int key) const
{
if (! d->resources.contains(key))
return 0.;
return d->resources[key].toDouble();
}
QString KoCanvasResourceProvider::stringResource(int key)
QString KoResourceManager::stringResource(int key)
{
if (! d->resources.contains(key)) {
QString empty;
......@@ -212,7 +213,7 @@ QString KoCanvasResourceProvider::stringResource(int key)
return qvariant_cast<QString>(resource(key));
}
QSizeF KoCanvasResourceProvider::sizeResource(int key)
QSizeF KoResourceManager::sizeResource(int key)
{
if (! d->resources.contains(key)) {
QSizeF empty;
......@@ -221,12 +222,12 @@ QSizeF KoCanvasResourceProvider::sizeResource(int key)
return qvariant_cast<QSizeF>(resource(key));
}
bool KoCanvasResourceProvider::hasResource(int key)
bool KoResourceManager::hasResource(int key)
{
return d->resources.contains(key);
}
void KoCanvasResourceProvider::clearResource(int key)
void KoResourceManager::clearResource(int key)
{
if (! d->resources.contains(key))
return;
......@@ -235,4 +236,4 @@ void KoCanvasResourceProvider::clearResource(int key)
emit resourceChanged(key, empty);
}
#include <KoCanvasResourceProvider.moc>
#include <KoResourceManager.moc>
......@@ -38,7 +38,7 @@ class KoLineBorder;
* The KoCanvasResource contains a set of per-canvas
* properties, like current foreground color, current background
* color and more.
* \sa KoCanvasResourceProvider
* \sa KoResourceManager
*/
namespace KoCanvasResource
{
......@@ -71,13 +71,13 @@ enum CanvasResource {
}
/**
* The KoCanvasResourceProvider contains a set of per-canvas
* The KoResourceManager contains a set of per-canvas
* properties, like current foreground color, current background
* color and more. All tools belonging to the current canvas are
* notified when a Resource changes (is set).
* The properties come from the KoCanvasResource::CanvasResource enum.
*/
class FLAKE_EXPORT KoCanvasResourceProvider : public QObject
class FLAKE_EXPORT KoResourceManager : public QObject
{
Q_OBJECT
......@@ -87,8 +87,8 @@ public:
* Constructor.
* @param parent the parent QObject, used for memory management.
*/
explicit KoCanvasResourceProvider(QObject *parent = 0);
~KoCanvasResourceProvider();
explicit KoResourceManager(QObject *parent = 0);
~KoResourceManager();
/**
* Set a resource of any type.
......@@ -109,7 +109,8 @@ public:
* @param key the integer key, based on KoCanvasResource::CanvasResource
* @param id the new value for the key.
*/
void setResource(int key, const KoID &id);
//void setResource(int key, const KoID &id);
/**
* Set a resource of type KoShape*.
* @param key the integer key, based on KoCanvasResource::CanvasResource
......@@ -243,11 +244,11 @@ signals:
* @param key the indentifying key for the resource, based on KoCanvasResource::CanvasResource.
* @param value the variants new value.
*/
void resourceChanged(int key, const QVariant & value);
void resourceChanged(int key, const QVariant &value);
private:
KoCanvasResourceProvider(const KoCanvasResourceProvider&);
KoCanvasResourceProvider& operator=(const KoCanvasResourceProvider&);
KoResourceManager(const KoResourceManager&);
KoResourceManager& operator=(const KoResourceManager&);
class Private;
Private *const d;
......
......@@ -160,7 +160,7 @@ public:
* @param painter used for painting the shape
* @param converter to convert between internal and view coordinates.
* @param canvas the canvas that requested this paint. This can be used to retrieve canvas specific properties
* like selection and get a reference to the KoCanvasResourceProvider.
* like selection and get a reference to the KoResourceManager.
*/
virtual void paintDecorations(QPainter &painter, const KoViewConverter &converter, const KoCanvasBase *canvas);
......
......@@ -33,7 +33,7 @@ void KoShapeConfigWidgetBase::setUnit(KoUnit unit)
Q_UNUSED(unit);
}
void KoShapeConfigWidgetBase::setResourceProvider(KoCanvasResourceProvider* provider)
void KoShapeConfigWidgetBase::setResourceProvider(KoResourceManager* provider)
{
m_resourceProvider = provider;
}
......
......@@ -20,7 +20,7 @@
#ifndef KOSHAPECONFIGWIDGETBASE_H
#define KOSHAPECONFIGWIDGETBASE_H
#include "KoCanvasResourceProvider.h"
#include "KoResourceManager.h"
#include <QWidget>
......@@ -77,7 +77,7 @@ public:
virtual void setUnit(KoUnit unit);
/// called to set the canvas resource provider of the canvas the user used to insert the new shape.
void setResourceProvider(KoCanvasResourceProvider* provider);
void setResourceProvider(KoResourceManager* provider);
/// Return true if the shape config panel should be shown after the shape is created
virtual bool showOnShapeCreate();
......@@ -93,7 +93,7 @@ signals:
void propertyChanged();
protected:
KoCanvasResourceProvider *m_resourceProvider; ///< the resource provider with data for this canvas
KoResourceManager *m_resourceProvider; ///< the resource provider with data for this canvas
};
#endif
......@@ -21,7 +21,7 @@
#include "KoTool_p.h"
#include "KoCanvasBase.h"
#include "KoPointerEvent.h"
#include "KoCanvasResourceProvider.h"
#include "KoResourceManager.h"
#include "KoViewConverter.h"
#include <klocale.h>
......@@ -33,8 +33,8 @@ KoTool::KoTool(KoCanvasBase *canvas)
{
Q_D(KoTool);
if (d->canvas) { // in the case of KoToolManagers dummytool it can be zero :(
KoCanvasResourceProvider * crp = d->canvas->resourceProvider();
Q_ASSERT_X(crp, "KoTool::KoTool", "No KoCanvasResourceProvider");
KoResourceManager * crp = d->canvas->resourceProvider();
Q_ASSERT_X(crp, "KoTool::KoTool", "No KoResourceManager");
if (crp)
connect(d->canvas->resourceProvider(), SIGNAL(resourceChanged(int, const QVariant &)),
this, SLOT(resourceChanged(int, const QVariant &)));
......
......@@ -19,7 +19,7 @@
#include "TestCanvasResourceProvider.h"
#include "KoCanvasResourceProvider.h"
#include "KoResourceManager.h"
#include "KoPathShape.h"
#include <QtTest/QSignalSpy>
......@@ -28,14 +28,14 @@ void TestCanvasResourceProvider::koShapeResource()
KoPathShape * shape = new KoPathShape();
int key = 9001;
KoCanvasResourceProvider rp( 0 );
KoResourceManager rp( 0 );
rp.setResource( key, shape );
QVERIFY( shape == rp.koShapeResource( key ) );
}
void TestCanvasResourceProvider::testUnitChanged()
{
KoCanvasResourceProvider rp(0);
KoResourceManager rp(0);
QSignalSpy spy(&rp, SIGNAL(resourceChanged(int, const QVariant &)));
rp.setUnitChanged();
......
......@@ -34,7 +34,7 @@
#include "KoShapeManager.h"
#include "KoSelection.h"
#include "KoShapeController.h"
#include "KoCanvasResourceProvider.h"
#include "KoResourceManager.h"
#include "KoParameterShape.h"
#include "commands/KoPathPointMergeCommand.h"
......
......@@ -26,7 +26,7 @@
#include "KoPathToolHandle.h"
#include "KoCanvasBase.h"
#include "KoShapeManager.h"
#include "KoCanvasResourceProvider.h"
#include "KoResourceManager.h"
#include "KoViewConverter.h"