27 #include <kparts/part.h>
28 #include <kparts/componentfactory.h>
33 using namespace KontactInterface;
36 class KontactInterface::Core::Private
41 explicit Private(
Core *qq );
43 void slotPartDestroyed( QObject * );
46 QString lastErrorMessage;
48 QMap<QByteArray,KParts::ReadOnlyPart *> mParts;
51 Core::Private::Private(
Core *qq )
52 : q( qq ), mLastDate( QDate::currentDate() )
57 Core::Core( QWidget *parent, Qt::WindowFlags f )
58 : KParts::MainWindow( parent, f ), d( new Private( this ) )
60 QTimer *timer =
new QTimer(
this );
61 connect( timer, SIGNAL(timeout()), SLOT(checkNewDay()) );
62 timer->start( 1000 * 60 );
74 QMap<QByteArray,KParts::ReadOnlyPart *>::ConstIterator it;
75 it = d->mParts.constFind( libname );
76 if ( it != d->mParts.constEnd() ) {
80 kDebug() <<
"Creating new KPart";
82 KPluginLoader loader( libname );
83 kDebug() << loader.fileName();
84 KPluginFactory *factory = loader.factory();
85 KParts::ReadOnlyPart *part = 0;
87 part = factory->create<KParts::ReadOnlyPart>( this );
91 d->mParts.insert( libname, part );
92 QObject::connect( part, SIGNAL(destroyed(QObject*)),
93 SLOT(slotPartDestroyed(QObject*)) );
95 d->lastErrorMessage = loader.errorString();
96 kWarning() << d->lastErrorMessage;
103 void Core::Private::slotPartDestroyed( QObject *obj )
107 QMap<QByteArray, KParts::ReadOnlyPart*>::Iterator end = mParts.end();
108 QMap<QByteArray, KParts::ReadOnlyPart*>::Iterator it = mParts.begin();
109 for ( ; it != end; ++it ) {
110 if ( it.value() == obj ) {
117 void Core::Private::checkNewDay()
119 if ( mLastDate != QDate::currentDate() ) {
120 emit q->dayChanged( QDate::currentDate() );
123 mLastDate = QDate::currentDate();
129 return d->lastErrorMessage;
132 #include "moc_core.cpp"