author | harlekin <harlekin> | 2002-10-31 17:09:01 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-31 17:09:01 (UTC) |
commit | 16fcb285f9ba7c514fc3f2695768a82feeb7182b (patch) (side-by-side diff) | |
tree | 4b1b09287dd339e7138608464c309f938f89e257 | |
parent | ba60ce32edbad5e743494c0de33534258ee5d80c (diff) | |
download | opie-16fcb285f9ba7c514fc3f2695768a82feeb7182b.zip opie-16fcb285f9ba7c514fc3f2695768a82feeb7182b.tar.gz opie-16fcb285f9ba7c514fc3f2695768a82feeb7182b.tar.bz2 |
started support for plugins without refresh, not finished yet
-rw-r--r-- | core/pim/today/changelog | 5 | ||||
-rw-r--r-- | core/pim/today/opie-today.control | 2 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookplugin.cpp | 3 | ||||
-rw-r--r-- | core/pim/today/plugins/datebook/datebookplugin.h | 2 | ||||
-rw-r--r-- | core/pim/today/plugins/mail/mailplugin.cpp | 4 | ||||
-rw-r--r-- | core/pim/today/plugins/mail/mailplugin.h | 3 | ||||
-rw-r--r-- | core/pim/today/plugins/todolist/todoplugin.cpp | 3 | ||||
-rw-r--r-- | core/pim/today/plugins/todolist/todoplugin.h | 2 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 159 | ||||
-rw-r--r-- | core/pim/today/todayconfig.cpp | 6 |
10 files changed, 119 insertions, 70 deletions
diff --git a/core/pim/today/changelog b/core/pim/today/changelog index 93abdcb..ba3cdbc 100644 --- a/core/pim/today/changelog +++ b/core/pim/today/changelog @@ -1,2 +1,7 @@ +0.6 + +* longer refresh intervals possible +* plugins can decide now if they want to take part in refresh cycles + 0.5.2 diff --git a/core/pim/today/opie-today.control b/core/pim/today/opie-today.control index 267a195..acdcf8e 100644 --- a/core/pim/today/opie-today.control +++ b/core/pim/today/opie-today.control @@ -4,5 +4,5 @@ Section: opie/applications Maintainer: Maximilian Reiß <harlekin@handhelds.org> Architecture: arm -Version: 0.5.2-$SUB_VERSION +Version: 0.6-$SUB_VERSION Depends: opie-base ($QPE_VERSION), libopie ($QPE_VERSION) License: GPL diff --git a/core/pim/today/plugins/datebook/datebookplugin.cpp b/core/pim/today/plugins/datebook/datebookplugin.cpp index cacdb65..eda84be 100644 --- a/core/pim/today/plugins/datebook/datebookplugin.cpp +++ b/core/pim/today/plugins/datebook/datebookplugin.cpp @@ -58,2 +58,5 @@ QString DatebookPlugin::appName() const { } +bool DatebookPlugin::excludeFromRefresh() const { + return false; +} diff --git a/core/pim/today/plugins/datebook/datebookplugin.h b/core/pim/today/plugins/datebook/datebookplugin.h index 4d0f8e6..13c62a9 100644 --- a/core/pim/today/plugins/datebook/datebookplugin.h +++ b/core/pim/today/plugins/datebook/datebookplugin.h @@ -37,5 +37,5 @@ public: TodayConfigWidget* configWidget( QWidget *); QString appName() const; - + bool excludeFromRefresh() const; }; diff --git a/core/pim/today/plugins/mail/mailplugin.cpp b/core/pim/today/plugins/mail/mailplugin.cpp index 1c90df4..d497970 100644 --- a/core/pim/today/plugins/mail/mailplugin.cpp +++ b/core/pim/today/plugins/mail/mailplugin.cpp @@ -55,2 +55,6 @@ QString MailPlugin::appName() const { +bool MailPlugin::excludeFromRefresh() const { + return false; +} + diff --git a/core/pim/today/plugins/mail/mailplugin.h b/core/pim/today/plugins/mail/mailplugin.h index d2a3dcb..c937b9e 100644 --- a/core/pim/today/plugins/mail/mailplugin.h +++ b/core/pim/today/plugins/mail/mailplugin.h @@ -41,6 +41,5 @@ public: TodayConfigWidget* configWidget(QWidget *); QString appName() const; - - + bool excludeFromRefresh() const; }; diff --git a/core/pim/today/plugins/todolist/todoplugin.cpp b/core/pim/today/plugins/todolist/todoplugin.cpp index 09b54af..e10b414 100644 --- a/core/pim/today/plugins/todolist/todoplugin.cpp +++ b/core/pim/today/plugins/todolist/todoplugin.cpp @@ -57,2 +57,5 @@ QString TodolistPlugin::appName() const { +bool TodolistPlugin::excludeFromRefresh() const { + return false; +} diff --git a/core/pim/today/plugins/todolist/todoplugin.h b/core/pim/today/plugins/todolist/todoplugin.h index 0a6669f..f98afdb 100644 --- a/core/pim/today/plugins/todolist/todoplugin.h +++ b/core/pim/today/plugins/todolist/todoplugin.h @@ -38,5 +38,5 @@ public: TodayConfigWidget* configWidget(QWidget *); QString appName() const; - + bool excludeFromRefresh() const; }; 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; }; @@ -77,15 +78,20 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) */ void Today::channelReceived( const QCString &msg, const QByteArray & data ) { - QDataStream stream( data, IO_ReadOnly ); - if ( msg == "message(QString)" ) { - QString message; - stream >> message; - setOwnerField( message ); - } + QDataStream stream( data, IO_ReadOnly ); + if ( msg == "message(QString)" ) { + QString message; + stream >> message; + 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 ); } @@ -99,10 +105,10 @@ void Today::setOwnerField() { QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); if ( QFile::exists( file ) ) { - Contact cont = Contact::readVCard( file )[0]; - QString returnString = cont.fullName(); - OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); - } else { - OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); - } + Contact cont = Contact::readVCard( file )[0]; + QString returnString = cont.fullName(); + OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); + } else { + OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); + } } @@ -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; - for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { - (*tit).library->unload(); - delete (*tit).library; + 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(); } - pluginList.clear(); + QString path = QPEApplication::qpeDir() + "/plugins/today"; @@ -163,48 +179,58 @@ void Today::loadPlugins() { qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); qDebug( QString(*it) ); - 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; + + // 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 { - plugin.active = false; - } - plugin.guiPart = plugin.iface->guiPart(); - - // 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 ); - OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); - plugIcon->setPixmap( plugPix ); - QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); - plugIcon->setName( plugin.guiPart->appName() ); - connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); - // a scrollview for each plugin - QScrollView* sv = new QScrollView( plugin.guiBox ); - QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); - // not sure if that is good .-) - sv->setMinimumHeight( 10 ); - sv->setResizePolicy( QScrollView::AutoOneFit ); - sv->setHScrollBarMode( QScrollView::AlwaysOff ); - sv->setFrameShape( QFrame::NoFrame ); - sv->addChild( plugWidget ); - // make sure the icon is on the top alligned - boxLayout->addWidget( plugIcon, 0, AlignTop ); - boxLayout->addWidget( sv, 0, AlignTop ); - boxLayout->setStretchFactor( plugIcon, 1 ); - boxLayout->setStretchFactor( sv, 9 ); - // "prebuffer" it in one more list, to get the sorting done - tempList.insert( plugin.name, plugin ); - - // on first start the list is off course empty - if ( m_allApplets.isEmpty() ) { - layout->addWidget( plugin.guiBox ); - pluginList.append( plugin ); + + 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 ); + OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); + plugIcon->setPixmap( plugPix ); + QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); + plugIcon->setName( plugin.guiPart->appName() ); + connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); + // a scrollview for each plugin + QScrollView* sv = new QScrollView( plugin.guiBox ); + QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); + // not sure if that is good .-) + sv->setMinimumHeight( 10 ); + sv->setResizePolicy( QScrollView::AutoOneFit ); + sv->setHScrollBarMode( QScrollView::AlwaysOff ); + sv->setFrameShape( QFrame::NoFrame ); + sv->addChild( plugWidget ); + // make sure the icon is on the top alligned + boxLayout->addWidget( plugIcon, 0, AlignTop ); + boxLayout->addWidget( sv, 0, AlignTop ); + boxLayout->setStretchFactor( plugIcon, 1 ); + boxLayout->setStretchFactor( sv, 9 ); + // "prebuffer" it in one more list, to get the sorting done + tempList.insert( plugin.name, plugin ); + + // on first start the list is off course empty + if ( m_allApplets.isEmpty() ) { + layout->addWidget( plugin.guiBox ); + pluginList.append( plugin ); + } } } else { @@ -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,7 +296,10 @@ 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; + TodayPlugin plugin; QList<TodayConfigWidget> configWidgetList; @@ -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() ) ); } } diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index db1141a..8d0b069 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp @@ -105,6 +105,8 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) QWhatsThis::add( refreshLabel, tr( "How often should Today refresh itself" ) ); SpinRefresh = new QSpinBox( hbox_refresh ); - SpinRefresh->setMinValue( 2 ); - SpinRefresh->setSuffix( tr( " seconds" ) ); + SpinRefresh->setMinValue( 0 ); + SpinRefresh->setSuffix( tr( " sec" ) ); + SpinRefresh->setMaxValue ( 7200 ); + SpinRefresh->setSpecialValueText ( tr("never") ); QWhatsThis::add( SpinRefresh, tr( "How often should Today refresh itself" ) ); |