-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 @@ -46,4 +46,5 @@ struct TodayPlugin { QString name; bool active; + bool excludeRefresh; int pos; }; @@ -87,5 +88,10 @@ 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 ); } @@ -130,6 +136,5 @@ void Today::init() { cfg.setGroup( "General" ); m_iconSize = cfg.readNumEntry( "IconSize", 18 ); - m_refreshTimer->changeInterval( cfg.readNumEntry( "checkinterval", 15000 ) ); - + setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); } @@ -140,10 +145,21 @@ 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"; @@ -163,4 +179,12 @@ void Today::loadPlugins() { 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; @@ -175,4 +199,5 @@ void Today::loadPlugins() { } plugin.guiPart = plugin.iface->guiPart(); + plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); // package the whole thing into a qwidget so it can be shown and hidden @@ -208,4 +233,5 @@ void Today::loadPlugins() { pluginList.append( plugin ); } + } } else { qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); @@ -217,4 +243,5 @@ void Today::loadPlugins() { TodayPlugin tempPlugin; QStringList::Iterator stringit; + for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { tempPlugin = ( tempList.find( *stringit ) ).data(); @@ -269,4 +296,7 @@ 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 ); @@ -297,4 +327,7 @@ void Today::startConfig() { } refresh(); + } else { + // since refresh is not called in that case , reconnect the signal + connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); } } |