-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 { | |||
46 | QString name; | 46 | QString name; |
47 | bool active; | 47 | bool active; |
48 | bool excludeRefresh; | ||
48 | int pos; | 49 | int pos; |
49 | }; | 50 | }; |
@@ -87,5 +88,10 @@ void Today::channelReceived( const QCString &msg, const QByteArray & data ) { | |||
87 | void Today::setRefreshTimer( int interval ) { | 88 | void Today::setRefreshTimer( int interval ) { |
88 | 89 | ||
89 | if ( m_refreshTimerEnabled ) { | 90 | |
91 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | ||
92 | |||
93 | // 0 is "never" case | ||
94 | if ( !interval == 0 ) { | ||
95 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | ||
90 | m_refreshTimer->changeInterval( interval ); | 96 | m_refreshTimer->changeInterval( interval ); |
91 | } | 97 | } |
@@ -130,6 +136,5 @@ void Today::init() { | |||
130 | cfg.setGroup( "General" ); | 136 | cfg.setGroup( "General" ); |
131 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 137 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
132 | m_refreshTimer->changeInterval( cfg.readNumEntry( "checkinterval", 15000 ) ); | 138 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); |
133 | |||
134 | } | 139 | } |
135 | 140 | ||
@@ -140,10 +145,21 @@ void Today::init() { | |||
140 | void Today::loadPlugins() { | 145 | void Today::loadPlugins() { |
141 | 146 | ||
147 | // extra list for plugins that exclude themself from periodic refresh | ||
148 | QMap<QString, TodayPlugin> pluginListRefreshExclude; | ||
149 | |||
142 | QValueList<TodayPlugin>::Iterator tit; | 150 | QValueList<TodayPlugin>::Iterator tit; |
151 | if ( !pluginList.isEmpty() ) { | ||
143 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { | 152 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { |
153 | if ( (*tit).excludeRefresh ) { | ||
154 | pluginListRefreshExclude.insert( (*tit).name , (*tit) ); | ||
155 | qDebug( "Found an plug that does not want refresh feature" ); | ||
156 | } else { | ||
144 | (*tit).library->unload(); | 157 | (*tit).library->unload(); |
145 | delete (*tit).library; | 158 | delete (*tit).library; |
146 | } | 159 | } |
160 | } | ||
147 | pluginList.clear(); | 161 | pluginList.clear(); |
162 | } | ||
163 | |||
148 | 164 | ||
149 | QString path = QPEApplication::qpeDir() + "/plugins/today"; | 165 | QString path = QPEApplication::qpeDir() + "/plugins/today"; |
@@ -163,4 +179,12 @@ void Today::loadPlugins() { | |||
163 | qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); | 179 | qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); |
164 | qDebug( QString(*it) ); | 180 | qDebug( QString(*it) ); |
181 | |||
182 | // If plugin is exludes from refresh, get it in the list again here. | ||
183 | |||
184 | if ( pluginListRefreshExclude.contains( (*it) ) ) { | ||
185 | tempList.insert( pluginListRefreshExclude[(*it)].name, pluginListRefreshExclude[(*it)] ); | ||
186 | qDebug( "TEST2 " + pluginListRefreshExclude[(*it)].name ); | ||
187 | } else { | ||
188 | |||
165 | TodayPlugin plugin; | 189 | TodayPlugin plugin; |
166 | plugin.library = lib; | 190 | plugin.library = lib; |
@@ -175,4 +199,5 @@ void Today::loadPlugins() { | |||
175 | } | 199 | } |
176 | plugin.guiPart = plugin.iface->guiPart(); | 200 | plugin.guiPart = plugin.iface->guiPart(); |
201 | plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); | ||
177 | 202 | ||
178 | // package the whole thing into a qwidget so it can be shown and hidden | 203 | // package the whole thing into a qwidget so it can be shown and hidden |
@@ -208,4 +233,5 @@ void Today::loadPlugins() { | |||
208 | pluginList.append( plugin ); | 233 | pluginList.append( plugin ); |
209 | } | 234 | } |
235 | } | ||
210 | } else { | 236 | } else { |
211 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); | 237 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); |
@@ -217,4 +243,5 @@ void Today::loadPlugins() { | |||
217 | TodayPlugin tempPlugin; | 243 | TodayPlugin tempPlugin; |
218 | QStringList::Iterator stringit; | 244 | QStringList::Iterator stringit; |
245 | |||
219 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { | 246 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { |
220 | tempPlugin = ( tempList.find( *stringit ) ).data(); | 247 | tempPlugin = ( tempList.find( *stringit ) ).data(); |
@@ -269,4 +296,7 @@ void Today::draw() { | |||
269 | void Today::startConfig() { | 296 | void Today::startConfig() { |
270 | 297 | ||
298 | // disconnect timer to prevent problems while being on config dialog | ||
299 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | ||
300 | |||
271 | TodayConfig conf( this, "dialog", true ); | 301 | TodayConfig conf( this, "dialog", true ); |
272 | 302 | ||
@@ -297,4 +327,7 @@ void Today::startConfig() { | |||
297 | } | 327 | } |
298 | refresh(); | 328 | refresh(); |
329 | } else { | ||
330 | // since refresh is not called in that case , reconnect the signal | ||
331 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | ||
299 | } | 332 | } |
300 | } | 333 | } |