core.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "core.h"
00025
00026 #include <kparts/part.h>
00027 #include <kparts/componentfactory.h>
00028 #include <kdebug.h>
00029 #include <qtimer.h>
00030
00031 using namespace Kontact;
00032
00033 Core::Core( QWidget *parent, const char *name )
00034 : KParts::MainWindow( parent, name )
00035 {
00036 QTimer* timer = new QTimer( this );
00037 mLastDate = QDate::currentDate();
00038 connect(timer, SIGNAL( timeout() ), SLOT( checkNewDay() ) );
00039 timer->start( 1000*60 );
00040 }
00041
00042 Core::~Core()
00043 {
00044 }
00045
00046 KParts::ReadOnlyPart *Core::createPart( const char *libname )
00047 {
00048 kdDebug() << "Core:createPart(): " << libname << endl;
00049
00050 QMap<QCString,KParts::ReadOnlyPart *>::ConstIterator it;
00051 it = mParts.find( libname );
00052 if ( it != mParts.end() ) return it.data();
00053
00054 kdDebug() << "Creating new KPart" << endl;
00055
00056 KParts::ReadOnlyPart *part =
00057 KParts::ComponentFactory::
00058 createPartInstanceFromLibrary<KParts::ReadOnlyPart>
00059 ( libname, this, 0, this, "kontact" );
00060
00061 if ( part ) {
00062 mParts.insert( libname, part );
00063 QObject::connect( part, SIGNAL( destroyed( QObject * ) ),
00064 SLOT( slotPartDestroyed( QObject * ) ) );
00065 }
00066
00067 return part;
00068 }
00069
00070 void Core::slotPartDestroyed( QObject * obj )
00071 {
00072
00073
00074 QMap<QCString, KParts::ReadOnlyPart*>::Iterator end = mParts.end();
00075 QMap<QCString, KParts::ReadOnlyPart*>::Iterator it = mParts.begin();
00076 for ( ; it != end; ++it ) {
00077 if ( it.data() == obj ) {
00078 mParts.remove( it );
00079 return;
00080 }
00081 }
00082 }
00083
00084 void Core::checkNewDay()
00085 {
00086 if ( mLastDate != QDate::currentDate() )
00087 emit dayChanged( QDate::currentDate() );
00088
00089 mLastDate = QDate::currentDate();
00090 }
00091
00092 #include "core.moc"
00093
This file is part of the documentation for kontact Library Version 3.2.2.