26 #include <tdeparts/part.h>
27 #include <tdeparts/componentfactory.h>
30 #include <tdelocale.h>
32 using namespace Kontact;
37 TQString lastErrorMessage;
40 Core::Core( TQWidget *parent,
const char *name )
41 : KParts::MainWindow( parent, name )
44 TQTimer* timer =
new TQTimer(
this );
45 mLastDate = TQDate::currentDate();
46 connect(timer, TQ_SIGNAL( timeout() ), TQ_SLOT( checkNewDay() ) );
47 timer->start( 1000*60 );
55 KParts::ReadOnlyPart *Core::createPart(
const char *libname )
57 kdDebug(5601) <<
"Core::createPart(): " << libname << endl;
59 TQMap<TQCString,KParts::ReadOnlyPart *>::ConstIterator it;
60 it = mParts.find( libname );
61 if ( it != mParts.end() )
return it.data();
63 kdDebug(5601) <<
"Creating new KPart" << endl;
66 KParts::ReadOnlyPart *part =
67 KParts::ComponentFactory::
68 createPartInstanceFromLibrary<KParts::ReadOnlyPart>
69 ( libname,
this, 0,
this,
"kontact", TQStringList(), &error );
71 KParts::ReadOnlyPart *pimPart =
dynamic_cast<KParts::ReadOnlyPart*
>( part );
73 mParts.insert( libname, pimPart );
74 TQObject::connect( pimPart, TQ_SIGNAL( destroyed( TQObject * ) ),
75 TQ_SLOT( slotPartDestroyed( TQObject * ) ) );
79 case KParts::ComponentFactory::ErrNoServiceFound:
80 d->lastErrorMessage = i18n(
"No service found" );
82 case KParts::ComponentFactory::ErrServiceProvidesNoLibrary:
83 d->lastErrorMessage = i18n(
"Program error: the .desktop file for the service does not have a Library key." );
85 case KParts::ComponentFactory::ErrNoLibrary:
86 d->lastErrorMessage = KLibLoader::self()->lastErrorMessage();
88 case KParts::ComponentFactory::ErrNoFactory:
89 d->lastErrorMessage = i18n(
"Program error: the library %1 does not provide a factory." ).arg( libname );
91 case KParts::ComponentFactory::ErrNoComponent:
92 d->lastErrorMessage = i18n(
"Program error: the library %1 does not support creating components of the specified type" ).arg( libname );
95 kdWarning(5601) << d->lastErrorMessage << endl;
101 void Core::slotPartDestroyed( TQObject * obj )
105 TQMap<TQCString, KParts::ReadOnlyPart*>::Iterator end = mParts.end();
106 TQMap<TQCString, KParts::ReadOnlyPart*>::Iterator it = mParts.begin();
107 for ( ; it != end; ++it ) {
108 if ( it.data() == obj ) {
115 void Core::checkNewDay()
117 if ( mLastDate != TQDate::currentDate() )
120 mLastDate = TQDate::currentDate();
123 TQString Core::lastErrorMessage()
const
125 return d->lastErrorMessage;
void dayChanged(const TQDate &)
Emitted when a new day starts.