summaryrefslogtreecommitdiff
path: root/core/pim/today/today.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/today/today.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/today/today.cpp39
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
@@ -42,12 +42,13 @@ struct TodayPlugin {
QLibrary *library;
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 )
@@ -83,13 +84,18 @@ void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
setOwnerField( message );
}
}
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 );
}
}
/**
@@ -126,28 +132,38 @@ void Today::init() {
cfg.setGroup( "Plugins" );
m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
m_allApplets = cfg.readListEntry( "AllApplets", ',' );
cfg.setGroup( "General" );
m_iconSize = cfg.readNumEntry( "IconSize", 18 );
- m_refreshTimer->changeInterval( cfg.readNumEntry( "checkinterval", 15000 ) );
-
+ setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
}
/**
* 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 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" );
QStringList list = dir.entryList();
QStringList::Iterator it;
@@ -159,24 +175,33 @@ void Today::loadPlugins() {
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) ) ) {
+ 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();
+ plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
// package the whole thing into a qwidget so it can be shown and hidden
plugin.guiBox = new QWidget( this );
QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
QPixmap plugPix;
plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
@@ -204,21 +229,23 @@ void Today::loadPlugins() {
// on first start the list is off course empty
if ( m_allApplets.isEmpty() ) {
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 );
}
@@ -265,12 +292,15 @@ void Today::draw() {
/**
* The method for the configuration dialog.
*/
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;
QList<TodayConfigWidget> configWidgetList;
for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) {
@@ -293,12 +323,15 @@ void Today::startConfig() {
TodayConfigWidget *confWidget;
for ( confWidget = configWidgetList.first(); confWidget != 0;
confWidget = configWidgetList.next() ) {
confWidget->writeConfig();
}
refresh();
+ } 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