F:/KPlato/koffice/libs/flake/KoCanvasResourceProvider.cpp

Aller à la documentation de ce fichier.
00001 /*
00002  *  Copyright (c) 2006 Boudewijn Rempt
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018  */
00019 #include "KoCanvasResourceProvider.h"
00020 
00021 #include <QVariant>
00022 #include <KoColor.h> // Zut, do we want this? It's convenient, but
00023                      // also makes flake dependent on pigment. (BSAR)
00024 
00025 KoCanvasResourceProvider::KoCanvasResourceProvider(QObject * parent)
00026     : QObject( parent )
00027 {
00028 }
00029 
00030 void KoCanvasResourceProvider::setResource( KoCanvasResource::EnumCanvasResource key, const QVariant & value )
00031 {
00032     if ( m_resources.contains( key ) ) {
00033         m_resources[key] = value;
00034     }
00035     else {
00036         m_resources.insert( key, value );
00037     }
00038     emit sigResourceChanged( key, value );
00039 }
00040 
00041 QVariant KoCanvasResourceProvider::resource(KoCanvasResource::EnumCanvasResource key)
00042 {
00043     if ( !m_resources.contains( key ) )
00044         return m_empty;
00045     else
00046         return m_resources.value( key );
00047 }
00048 
00049 void KoCanvasResourceProvider::setKoColor( KoCanvasResource::EnumCanvasResource key, const KoColor & color )
00050 {
00051     QVariant v;
00052     v.setValue( color );
00053     setResource( key, v );
00054 }
00055 
00056 KoColor KoCanvasResourceProvider::koColor( KoCanvasResource::EnumCanvasResource key )
00057 {
00058     return resource( key ).value<KoColor>();
00059 }
00060 
00061 
00062 void KoCanvasResourceProvider::setForegroundColor( const KoColor & color )
00063 {
00064     QVariant v;
00065     v.setValue( color );
00066     setResource( KoCanvasResource::ForegroundColor, v );
00067 
00068 }
00069 
00070 KoColor KoCanvasResourceProvider::foregroundColor()
00071 {
00072     return resource( KoCanvasResource::ForegroundColor ).value<KoColor>();
00073 }
00074 
00075 
00076 void KoCanvasResourceProvider::setBackgroundColor( const KoColor & color )
00077 {
00078     QVariant v;
00079     v.setValue( color );
00080     setResource( KoCanvasResource::BackgroundColor, v );
00081 
00082 }
00083 
00084 KoColor KoCanvasResourceProvider::backgroundColor()
00085 {
00086     return resource( KoCanvasResource::BackgroundColor ).value<KoColor>();
00087 }
00088 
00089 
00090 void KoCanvasResourceProvider::setKoID( KoCanvasResource::EnumCanvasResource key, const KoID & id )
00091 {
00092     QVariant  v;
00093     v.setValue( id );
00094     setResource( key, v );
00095 
00096 }
00097 
00098 KoID KoCanvasResourceProvider::koID(KoCanvasResource::EnumCanvasResource key)
00099 {
00100     return resource( key ).value<KoID>();
00101 }
00102 
00103 
00104 #include "KoCanvasResourceProvider.moc"

Généré le Wed Nov 22 23:40:59 2006 pour KPlato par  doxygen 1.5.1-p1