00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#include "actionpartservice.h"
00024
00025
#include <kdebug.h>
00026
#include <ktrader.h>
00027
00028
using namespace KSync;
00029
00030
bool ActionPartService::mAvailablePartsRead =
false;
00031
ActionPartService::List ActionPartService::mAvailableParts;
00032
00033
const ActionPartService::List &ActionPartService::availableParts()
00034 {
00035
if ( !mAvailablePartsRead ) {
00036 KTrader::OfferList offers = KTrader::self()->query(
00037 QString::fromLatin1(
"KitchenSync/ActionPart"), QString::null );
00038
00039 KTrader::OfferList::ConstIterator it;
00040
for ( it = offers.begin(); it != offers.end(); ++it ) {
00041 kdDebug() <<
"DESKTOP: " << (*it)->desktopEntryName() << endl;
00042
ActionPartService ser( *it );
00043 mAvailableParts.append( ser );
00044 }
00045
00046 mAvailablePartsRead =
true;
00047 }
00048
00049
return mAvailableParts;
00050 }
00051
00052
ActionPartService ActionPartService::partForId(
const QString &
id )
00053 {
00054 availableParts();
00055
00056 ActionPartService::List::ConstIterator it;
00057
for( it = mAvailableParts.begin(); it != mAvailableParts.end(); ++it ) {
00058 kdDebug() <<
"id: " << (*it).id() << endl;
00059
00060
if ( (*it).id() ==
id )
return *it;
00061 }
00062
00063 kdDebug() <<
"ActionPartService: No part for name '" <<
id <<
"'" << endl;
00064
00065
return ActionPartService();
00066 }
00067
00068 ActionPartService::ActionPartService()
00069 {
00070 }
00071
00072
ActionPartService::ActionPartService(
const KService::Ptr &service )
00073 : m_id( service->desktopEntryName() ), m_name( service->name() ),
00074 m_comment( service->comment() ),
00075 m_icon( service->icon() ), m_lib( service->library() )
00076 {
00077 kdDebug() <<
"xx: " << m_id << endl;
00078 }
00079
00080 ActionPartService::~ActionPartService()
00081 {
00082 }
00083
00084
QString ActionPartService::name()
const
00085
{
00086
return m_name;
00087 }
00088
00089
QString ActionPartService::id()
const
00090
{
00091
return m_id;
00092 }
00093
00094
QString ActionPartService::comment()
const
00095
{
00096
return m_comment;
00097 }
00098
00099
QString ActionPartService::libname()
const
00100
{
00101
return m_lib;
00102 }
00103
00104
QString ActionPartService::icon()
const
00105
{
00106
return m_icon;
00107 }
00108
00109
void ActionPartService::setId(
const QString &
id )
00110 {
00111 m_id =
id;
00112 }
00113
00114
void ActionPartService::setName(
const QString &name )
00115 {
00116 m_name = name;
00117 }
00118
00119
void ActionPartService::setComment(
const QString &comment )
00120 {
00121 m_comment = comment;
00122 }
00123
00124
void ActionPartService::setLibname(
const QString &libName )
00125 {
00126 m_lib = libName;
00127 }
00128
00129
void ActionPartService::setIcon(
const QString &icon )
00130 {
00131 m_icon = icon;
00132 }
00133
00134
ActionPartService &ActionPartService::operator=(
const ActionPartService &man1 )
00135 {
00136 m_name = man1.
m_name;
00137 m_comment = man1.
m_comment;
00138 m_icon = man1.
m_icon;
00139 m_lib = man1.
m_lib;
00140
return *
this;
00141 }
00142
00143
bool ActionPartService::operator== (
const ActionPartService &par2 )
00144 {
00145
return name() == par2.
name();
00146 }
00147
00148
bool ActionPartService::operator== (
const ActionPartService &par2 )
const
00149
{
00150
return name() == par2.
name();
00151 }