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.cpp42
1 files changed, 25 insertions, 17 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 91028c8..1f758f2 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -49,49 +49,50 @@ struct TodayPlugin {
bool excludeRefresh;
int pos;
};
static QValueList<TodayPlugin> pluginList;
Today::Today( QWidget* parent, const char* name, WFlags fl )
: TodayBase( parent, name, fl ) {
QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) );
QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) );
#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 );
- refresh();
+ 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;
setOwnerField( message );
}
}
void Today::setRefreshTimer( int interval ) {
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 );
}
@@ -115,48 +116,63 @@ 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;
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;
}
@@ -245,48 +261,49 @@ void Today::loadPlugins() {
// 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();
if ( !( (tempPlugin.name).isEmpty() ) ) {
layout->addWidget( tempPlugin.guiBox );
pluginList.append( tempPlugin );
}
}
}
+ draw();
}
/**
* Repaint method. Reread all fields.
*/
void Today::draw() {
if ( pluginList.count() == 0 ) {
QLabel *noPlugins = new QLabel( this );
noPlugins->setText( tr( "No plugins found" ) );
layout->addWidget( noPlugins );
return;
}
uint count = 0;
TodayPlugin plugin;
for ( uint i = 0; i < pluginList.count(); i++ ) {
plugin = pluginList[i];
if ( plugin.active ) {
// qDebug( plugin.name + " is ACTIVE " );
plugin.guiBox->show();
} else {
@@ -319,72 +336,63 @@ void Today::startConfig() {
QList<TodayConfigWidget> configWidgetList;
for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) {
plugin = pluginList[i];
// load the config widgets in the tabs
if ( plugin.guiPart->configWidget( this ) != 0l ) {
TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 );
configWidgetList.append( widget );
conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig()
, plugin.guiPart->appName() );
}
// set the order/activate tab
conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(),
Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) );
}
if ( conf.exec() == QDialog::Accepted ) {
conf.writeConfig();
TodayConfigWidget *confWidget;
for ( confWidget = configWidgetList.first(); confWidget != 0;
confWidget = configWidgetList.next() ) {
confWidget->writeConfig();
}
- refresh();
+ loadPlugins();
} 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();
- // 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;
+ QValueList<TodayPlugin>::Iterator it;
+ for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
+ if ( !(*it).excludeRefresh ) {
+ (*it).guiPart->refresh();
+ qDebug( "refresh" );
+ }
}
- layout = new QVBoxLayout( this );
- layout->addWidget( Frame );
- layout->addWidget( OwnerField );
-
- loadPlugins();
- draw();
}
void Today::startApplication() {
QCopEnvelope e( "QPE/System", "execute(QString)" );
e << QString( sender()->name() );
}
/**
* launch addressbook (personal card)
*/
void Today::editCard() {
QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" );
}
Today::~Today() {
}