-rw-r--r-- | core/pim/today/plugins/datebook/datebookpluginimpl.cpp | 1 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 10 |
2 files changed, 6 insertions, 5 deletions
diff --git a/core/pim/today/plugins/datebook/datebookpluginimpl.cpp b/core/pim/today/plugins/datebook/datebookpluginimpl.cpp index 4159b49..45736bb 100644 --- a/core/pim/today/plugins/datebook/datebookpluginimpl.cpp +++ b/core/pim/today/plugins/datebook/datebookpluginimpl.cpp @@ -1,42 +1,43 @@ /* * datebookpluginimpl.cpp * * copyright : (c) 2002 by Maximilian Reiß * email : harlekin@handhelds.org * */ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "datebookplugin.h" #include "datebookpluginimpl.h" DatebookPluginImpl::DatebookPluginImpl() { datebookPlugin = new DatebookPlugin(); } DatebookPluginImpl::~DatebookPluginImpl() { + delete datebookPlugin; } TodayPluginObject* DatebookPluginImpl::guiPart() { return datebookPlugin; } QRESULT DatebookPluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) { *iface = 0; if ( ( uuid == IID_QUnknown ) || ( uuid == IID_TodayPluginInterface ) ) { *iface = this, (*iface)->addRef(); } return QS_OK; } Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( DatebookPluginImpl ); } diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 01ef02d..1b31cfd 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -18,50 +18,51 @@ #include "today.h" #include <opie/todayconfigwidget.h> #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/resource.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qpe/contact.h> #include <qdir.h> #include <qfile.h> #include <qpushbutton.h> #include <qlabel.h> #include <qtimer.h> #include <qpixmap.h> #include <qlayout.h> #include <qhbox.h> #include <opie/otabwidget.h> #include <qdialog.h> #include <qwhatsthis.h> struct TodayPlugin { + TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} QLibrary *library; - TodayPluginInterface *iface; + QInterfacePtr<TodayPluginInterface> iface; TodayPluginObject *guiPart; QWidget *guiBox; QString name; bool active; bool excludeRefresh; int pos; }; static QValueList<TodayPlugin> pluginList; Today::Today( QWidget* parent, const char* name, WFlags fl ) : TodayBase( parent, name, fl ) { QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); #if defined(Q_WS_QWS) #if !defined(QT_NO_COP) QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); #endif #endif @@ -140,70 +141,69 @@ void Today::init() { /** * Load the plugins */ void Today::loadPlugins() { // extra list for plugins that exclude themself from periodic refresh QMap<QString, TodayPlugin> pluginListRefreshExclude; QValueList<TodayPlugin>::Iterator tit; if ( !pluginList.isEmpty() ) { for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { if ( (*tit).excludeRefresh ) { pluginListRefreshExclude.insert( (*tit).name , (*tit) ); qDebug( "Found an plugin that does not want refresh feature" ); } else { (*tit).library->unload(); delete (*tit).library; } } pluginList.clear(); } - QString path = QPEApplication::qpeDir() + "/plugins/today"; QDir dir( path, "lib*.so" ); QStringList list = dir.entryList(); QStringList::Iterator it; QMap<QString, TodayPlugin> tempList; for ( it = list.begin(); it != list.end(); ++it ) { - TodayPluginInterface *iface = 0; +// TodayPluginInterface *iface = 0; + QInterfacePtr<TodayPluginInterface> iface; QLibrary *lib = new QLibrary( path + "/" + *it ); qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); qDebug( QString(*it) ); // If plugin is exludes from refresh, get it in the list again here. if ( pluginListRefreshExclude.contains( (*it) ) ) { - // if its not in allApplets list, add it to a layout if ( !m_allApplets.contains( pluginListRefreshExclude[(*it)].name ) ) { qDebug( "NUGASDA" ); layout->addWidget( pluginListRefreshExclude[(*it)].guiBox ); pluginList.append( pluginListRefreshExclude[(*it)] ); } else { tempList.insert( pluginListRefreshExclude[(*it)].name, pluginListRefreshExclude[(*it)] ); qDebug( "TEST2 " + pluginListRefreshExclude[(*it)].name ); } } else { TodayPlugin plugin; plugin.library = lib; plugin.iface = iface; plugin.name = QString(*it); // find out if plugins should be shown if ( m_excludeApplets.grep( *it ).isEmpty() ) { plugin.active = true; } else { plugin.active = false; } plugin.guiPart = plugin.iface->guiPart(); @@ -222,49 +222,49 @@ void Today::loadPlugins() { // a scrollview for each plugin QScrollView* sv = new QScrollView( plugin.guiBox ); QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); // not sure if that is good .-) sv->setMinimumHeight( 10 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setHScrollBarMode( QScrollView::AlwaysOff ); sv->setFrameShape( QFrame::NoFrame ); sv->addChild( plugWidget ); // make sure the icon is on the top alligned boxLayout->addWidget( plugIcon, 0, AlignTop ); boxLayout->addWidget( sv, 0, AlignTop ); boxLayout->setStretchFactor( plugIcon, 1 ); boxLayout->setStretchFactor( sv, 9 ); // "prebuffer" it in one more list, to get the sorting done tempList.insert( plugin.name, plugin ); // on first start the list is off course empty if ( m_allApplets.isEmpty() ) { layout->addWidget( plugin.guiBox ); pluginList.append( plugin ); } // if plugin is not yet in the list, add it to the layout too - if ( !m_allApplets.contains( plugin.name ) ) { + else if ( !m_allApplets.contains( plugin.name ) ) { layout->addWidget( plugin.guiBox ); pluginList.append( plugin ); } } } else { qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); delete lib; } } if ( !m_allApplets.isEmpty() ) { TodayPlugin tempPlugin; QStringList::Iterator stringit; for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { tempPlugin = ( tempList.find( *stringit ) ).data(); if ( !( (tempPlugin.name).isEmpty() ) ) { layout->addWidget( tempPlugin.guiBox ); pluginList.append( tempPlugin ); } } } } |