From da5c9b06fe0081050ab8165cf3d189dbc8117bf6 Mon Sep 17 00:00:00 2001 From: waspe Date: Tue, 04 Nov 2003 16:41:07 +0000 Subject: resolved merge conflict --- (limited to 'core') 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 @@ -48,6 +48,8 @@ struct TodayPlugin { static QValueList pluginList; +static QMap tempList; + Today::Today( QWidget* parent, const char* name, WFlags fl ) : TodayBase( parent, name, fl ) { @@ -66,7 +68,22 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) 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(); } @@ -132,15 +149,11 @@ void Today::init() { 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( "" + TimeString::longDateString( date ) + "" ) ); - - if ( layout ) { - delete layout; - } + DateLabel->setText( QString( "" + TimeString::longDateString( date ) + "" ) ); if ( m_hideBanner ) { Opiezilla->hide(); @@ -150,9 +163,13 @@ void Today::init() { 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 ); } /** @@ -161,6 +178,7 @@ void Today::init() { void Today::loadPlugins() { init(); + QValueList::Iterator tit; if ( !pluginList.isEmpty() ) { for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { @@ -184,9 +202,7 @@ void Today::loadPlugins() { QStringList list = dir.entryList(); QStringList::Iterator it; - qWarning("Found: %d entries !", list.count() ); - - QMap tempList; + // QMap tempList; for ( it = list.begin(); it != list.end(); ++it ) { QInterfacePtr iface; @@ -222,6 +238,7 @@ void Today::loadPlugins() { } } + // find out if plugins should be shown if ( m_excludeApplets.grep( *it ).isEmpty() ) { plugin.active = true; @@ -233,7 +250,7 @@ void Today::loadPlugins() { 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 ); @@ -242,40 +259,34 @@ void Today::loadPlugins() { 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; @@ -283,15 +294,18 @@ void Today::loadPlugins() { 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. */ @@ -324,7 +338,7 @@ void Today::draw() { noPluginsActive->setText( tr( "No plugins activated" ) ); layout->addWidget( noPluginsActive ); } - layout->addStretch(0); + repaint(); } @@ -364,32 +378,94 @@ void Today::startConfig() { 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::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( "" + TimeString::longDateString( date ) + "" ) ); + + 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::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( "" + TimeString::longDateString( QDate::currentDate() ) + "" ) ); + + updateGeometry(); + repaint(); } void Today::startApplication() { -- cgit v0.9.0.2