author | harlekin <harlekin> | 2003-02-11 21:26:39 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-02-11 21:26:39 (UTC) |
commit | 39f9441dabcb094be258240f7ec3c53ed038133e (patch) (side-by-side diff) | |
tree | 7d6e7f49ce18c6c3723cbc59358c58a252011133 | |
parent | af398bd4c280e7c27754b409851fbe8189d08819 (diff) | |
download | opie-39f9441dabcb094be258240f7ec3c53ed038133e.zip opie-39f9441dabcb094be258240f7ec3c53ed038133e.tar.gz opie-39f9441dabcb094be258240f7ec3c53ed038133e.tar.bz2 |
now when coming back from the config dialog ALL plugins get restarted
-rw-r--r-- | core/pim/today/today.cpp | 35 | ||||
-rw-r--r-- | core/pim/today/today.h | 2 |
2 files changed, 6 insertions, 31 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 1f758f2..2f6907d 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -1,16 +1,16 @@ /* * today.cpp * - * copyright : (c) 2002 by Maximilian Reiß + * copyright : (c) 2002,2003 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. * * * ***************************************************************************/ @@ -61,25 +61,25 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) #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 setOwnerField(); m_refreshTimer = new QTimer( this ); connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); m_refreshTimer->start( 15000 ); - init(); + //init(); loadPlugins(); showMaximized(); } /** * Qcop receive method. */ void Today::channelReceived( const QCString &msg, const QByteArray & data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "message(QString)" ) { QString message; stream >> message; @@ -113,112 +113,87 @@ void Today::setOwnerField() { } } /** * Set the owner field with a given QString, for example per qcop. */ void Today::setOwnerField( QString &message ) { if ( !message.isEmpty() ) { OwnerField->setText( "<b>" + message + "</b>" ); } } - /** * Init stuff needed for today. Reads the config file. */ void Today::init() { // read config Config cfg( "today" ); cfg.setGroup( "Plugins" ); m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); m_allApplets = cfg.readListEntry( "AllApplets", ',' ); cfg.setGroup( "General" ); m_iconSize = cfg.readNumEntry( "IconSize", 18 ); setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); - - // qDebug(" refresh "); // set the date in top label QDate date = QDate::currentDate(); QString time = ( tr( date.toString() ) ); - DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); if ( layout ) { delete layout; } layout = new QVBoxLayout( this ); layout->addWidget( Frame ); layout->addWidget( OwnerField ); } - /** * Load the plugins */ void Today::loadPlugins() { - // extra list for plugins that exclude themself from periodic refresh - QMap<QString, TodayPlugin> pluginListRefreshExclude; - + init(); 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 a plugin that does not want refresh feature" ); - } else { (*tit).guiBox->hide(); (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); (*tit).library->unload(); delete (*tit).guiBox; 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; 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( "accepted: %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 ) ) { - layout->addWidget( pluginListRefreshExclude[(*it)].guiBox ); - pluginList.append( pluginListRefreshExclude[(*it)] ); - } else { - tempList.insert( pluginListRefreshExclude[(*it)].name, pluginListRefreshExclude[(*it)] ); - } - } 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; } @@ -230,49 +205,48 @@ void Today::loadPlugins() { QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); QPixmap plugPix; plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); plugIcon->setPixmap( plugPix ); QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); plugIcon->setName( plugin.guiPart->appName() ); connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); // 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->setMinimumHeight( 12 ); 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 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(); @@ -361,24 +335,25 @@ void Today::startConfig() { } else { // since refresh is not called in that case , reconnect the signal connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); } } /** * Refresh for the view. Reload all applets * */ void Today::refresh() { + init(); QValueList<TodayPlugin>::Iterator it; for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { if ( !(*it).excludeRefresh ) { (*it).guiPart->refresh(); qDebug( "refresh" ); } } } void Today::startApplication() { diff --git a/core/pim/today/today.h b/core/pim/today/today.h index 35b7ee3..24f5611 100644 --- a/core/pim/today/today.h +++ b/core/pim/today/today.h @@ -1,16 +1,16 @@ /* * today.h * - * copyright : (c) 2002 by Maximilian Reiß + * copyright : (c) 2002,2003 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. * * * ***************************************************************************/ |