-rw-r--r-- | core/pim/today/today.cpp | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 8184730..3eda5c0 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -45,6 +45,7 @@ struct TodayPlugin { QWidget *guiBox; QString name; bool active; + bool excludeRefresh; int pos; }; @@ -86,7 +87,12 @@ void Today::channelReceived( const QCString &msg, const QByteArray & data ) { void Today::setRefreshTimer( int interval ) { - if ( m_refreshTimerEnabled ) { + + disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); + + // 0 is "never" case + if ( !interval == 0 ) { + connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); m_refreshTimer->changeInterval( interval ); } } @@ -129,8 +135,7 @@ void Today::init() { cfg.setGroup( "General" ); m_iconSize = cfg.readNumEntry( "IconSize", 18 ); - m_refreshTimer->changeInterval( cfg.readNumEntry( "checkinterval", 15000 ) ); - + setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); } @@ -139,12 +144,23 @@ void Today::init() { */ 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 plug 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" ); @@ -162,6 +178,14 @@ void Today::loadPlugins() { 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) ) ) { + tempList.insert( pluginListRefreshExclude[(*it)].name, pluginListRefreshExclude[(*it)] ); + qDebug( "TEST2 " + pluginListRefreshExclude[(*it)].name ); + } else { + TodayPlugin plugin; plugin.library = lib; plugin.iface = iface; @@ -174,6 +198,7 @@ void Today::loadPlugins() { plugin.active = false; } plugin.guiPart = plugin.iface->guiPart(); + plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); // package the whole thing into a qwidget so it can be shown and hidden plugin.guiBox = new QWidget( this ); @@ -207,6 +232,7 @@ void Today::loadPlugins() { layout->addWidget( plugin.guiBox ); pluginList.append( plugin ); } + } } else { qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); delete lib; @@ -216,6 +242,7 @@ void Today::loadPlugins() { 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() ) ) { @@ -268,6 +295,9 @@ void Today::draw() { */ void Today::startConfig() { + // disconnect timer to prevent problems while being on config dialog + disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); + TodayConfig conf( this, "dialog", true ); TodayPlugin plugin; @@ -296,6 +326,9 @@ void Today::startConfig() { confWidget->writeConfig(); } refresh(); + } else { + // since refresh is not called in that case , reconnect the signal + connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); } } |