author | waspe <waspe> | 2003-11-04 16:41:07 (UTC) |
---|---|---|
committer | waspe <waspe> | 2003-11-04 16:41:07 (UTC) |
commit | da5c9b06fe0081050ab8165cf3d189dbc8117bf6 (patch) (side-by-side diff) | |
tree | 30dd36ad48413c39aa348ff5a49e130ef6ee2e4e | |
parent | efcd8d6a743261194b55df3afeec956fde9886d4 (diff) | |
download | opie-da5c9b06fe0081050ab8165cf3d189dbc8117bf6.zip opie-da5c9b06fe0081050ab8165cf3d189dbc8117bf6.tar.gz opie-da5c9b06fe0081050ab8165cf3d189dbc8117bf6.tar.bz2 |
resolved merge conflict
-rw-r--r-- | core/pim/today/today.cpp | 152 |
1 files changed, 114 insertions, 38 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index cb18c1c..dd8d59b 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -43,16 +43,18 @@ struct TodayPlugin { QString name; bool active; bool excludeRefresh; int pos; }; static QValueList<TodayPlugin> pluginList; +static QMap<QString, TodayPlugin> tempList; + 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) @@ -61,17 +63,32 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) 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 ); - //init(); + m_big_box = 0L; + + + layout = new QVBoxLayout( this ); + layout->addWidget( Frame ); + layout->addWidget( OwnerField ); + + m_sv = new QScrollView( this ); + m_sv->setResizePolicy( QScrollView::AutoOneFit ); + m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); + m_sv->setFrameShape( QFrame::NoFrame ); + + layout->addWidget( m_sv ); + layout->setStretchFactor( m_sv,4 ); + + qApp->processEvents(); loadPlugins(); showMaximized(); } /** * Qcop receive method. */ void Today::channelReceived( const QCString &msg, const QByteArray & data ) { @@ -127,45 +144,46 @@ 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_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); - setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); + setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); // set the date in top label QDate date = QDate::currentDate(); - DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); - - if ( layout ) { - delete layout; - } + DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); if ( m_hideBanner ) { Opiezilla->hide(); TodayLabel->hide(); } else { Opiezilla->show(); TodayLabel->show(); } - layout = new QVBoxLayout( this ); - layout->addWidget( Frame ); - layout->addWidget( OwnerField ); + if ( m_big_box ) { + delete m_big_box; + } + + m_big_box = new QWidget( m_sv->viewport() ); + m_sv->addChild( m_big_box ); + m_bblayout = new QVBoxLayout ( m_big_box ); } /** * Load the plugins */ void Today::loadPlugins() { init(); + QValueList<TodayPlugin>::Iterator tit; if ( !pluginList.isEmpty() ) { for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { (*tit).guiBox->hide(); (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); delete (*tit).guiBox; (*tit).library->unload(); delete (*tit).library; @@ -179,19 +197,17 @@ void Today::loadPlugins() { QDir dir( path, "lib*.dylib" ); #else QDir dir( path, "lib*.so" ); #endif QStringList list = dir.entryList(); QStringList::Iterator it; - qWarning("Found: %d entries !", list.count() ); - - QMap<QString, TodayPlugin> tempList; + // QMap<QString, TodayPlugin> tempList; for ( it = list.begin(); it != list.end(); ++it ) { QInterfacePtr<TodayPluginInterface> iface; QLibrary *lib = new QLibrary( path + "/" + *it ); qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); @@ -217,86 +233,84 @@ void Today::loadPlugins() { QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; if ( trans->load( tfn ) ) { qApp->installTranslator( trans ); } else { delete trans; } } + // 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 ); + plugin.guiBox = new QWidget( m_big_box ); 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( 12 ); - sv->setResizePolicy( QScrollView::AutoOneFit ); - sv->setHScrollBarMode( QScrollView::AlwaysOff ); - sv->setFrameShape( QFrame::NoFrame ); - sv->addChild( plugWidget ); - // make sure the icon is on the top alligned + + QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox ); boxLayout->addWidget( plugIcon, 0, AlignTop ); - boxLayout->addWidget( sv, 0, AlignTop ); + boxLayout->addWidget( plugWidget, 0, AlignTop ); boxLayout->setStretchFactor( plugIcon, 1 ); - boxLayout->setStretchFactor( sv, 9 ); - // "prebuffer" it in one more list, to get the sorting done + boxLayout->setStretchFactor( plugWidget, 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 ); + m_bblayout->addWidget( plugin.guiBox ); } // 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 ); + m_bblayout->addWidget( tempPlugin.guiBox ); } } } + m_bblayout->addStretch( 2 ); draw(); } + + /** * Repaint method. Reread all fields. */ void Today::draw() { if ( pluginList.count() == 0 ) { QLabel *noPlugins = new QLabel( this ); noPlugins->setText( tr( "No plugins found" ) ); @@ -319,17 +333,17 @@ void Today::draw() { count++; } if ( count == 0 ) { QLabel *noPluginsActive = new QLabel( this ); noPluginsActive->setText( tr( "No plugins activated" ) ); layout->addWidget( noPluginsActive ); } - layout->addStretch(0); + repaint(); } /** * The method for the configuration dialog. */ void Today::startConfig() { @@ -359,42 +373,104 @@ void Today::startConfig() { if ( conf.exec() == QDialog::Accepted ) { conf.writeConfig(); TodayConfigWidget *confWidget; for ( confWidget = configWidgetList.first(); confWidget != 0; confWidget = configWidgetList.next() ) { confWidget->writeConfig(); } - loadPlugins(); + + // make the plugins to reinitialize ( reread its configs ) + reinitialize(); + draw(); + } else { // since refresh is not called in that case , reconnect the signal - m_refreshTimer->start( 15000 ); // get the config value in here later - connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); + m_refreshTimer->start( 15000 ); // get the config value in here later + connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); } } + +void Today::reinitialize() { + + Config cfg( "today" ); + cfg.setGroup( "Plugins" ); + m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); + m_allApplets = cfg.readListEntry( "AllApplets", ',' ); + + /* reinitialize all plugins */ + QValueList<TodayPlugin>::Iterator it; + for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { + if ( !(*it).excludeRefresh ) { + (*it).guiPart->reinitialize(); + qDebug( "reinit" ); + } + + /* check if plugins is still to be shown */ + if ( m_excludeApplets.grep( (*it).name ).isEmpty() ) { + (*it).active = true; + } else { + (*it).active = false; + } + + } + + cfg.setGroup( "General" ); + m_iconSize = cfg.readNumEntry( "IconSize", 18 ); + m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); + setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); + + // set the date in top label + QDate date = QDate::currentDate(); + DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); + + if ( m_hideBanner ) { + Opiezilla->hide(); + TodayLabel->hide(); + } else { + Opiezilla->show(); + TodayLabel->show(); + } + + delete m_bblayout; + m_bblayout = new QVBoxLayout( m_big_box ); + TodayPlugin tempPlugin; + QStringList::Iterator stringit; + + for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { + tempPlugin = ( tempList.find( *stringit ) ).data(); + if ( !( (tempPlugin.name).isEmpty() ) ) { + m_bblayout->addWidget( tempPlugin.guiBox ); + } + } + m_bblayout->addStretch( 2 ); + +} + /** * Refresh for the view. Reload all applets * */ void Today::refresh() { - init(); - QValueList<TodayPlugin>::Iterator it; for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { if ( !(*it).excludeRefresh ) { (*it).guiPart->refresh(); - layout->addWidget( (*it).guiBox ); qDebug( "refresh" ); } } - layout->addStretch(0); + + DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); + + updateGeometry(); + repaint(); } void Today::startApplication() { QCopEnvelope e( "QPE/System", "execute(QString)" ); e << QString( sender()->name() ); } /** |