author | harlekin <harlekin> | 2002-09-20 20:19:14 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-09-20 20:19:14 (UTC) |
commit | d2d73b6391fbc7f743199f48387d13e887bbac1e (patch) (side-by-side diff) | |
tree | 7f289628796ee4bf0bf1f32d952b5455a42b17bd /core/pim/today/today.cpp | |
parent | 681e6e75efaa5577d376d0bb191afdf323cb4e75 (diff) | |
download | opie-d2d73b6391fbc7f743199f48387d13e887bbac1e.zip opie-d2d73b6391fbc7f743199f48387d13e887bbac1e.tar.gz opie-d2d73b6391fbc7f743199f48387d13e887bbac1e.tar.bz2 |
fixed the crash when closing config dialog and also sorting of the plugins is working now
-rw-r--r-- | core/pim/today/today.cpp | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 7537631..d8b427d 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -108,16 +108,12 @@ void Today::setOwnerField( QString &message ) { * Init stuff needed for today. Reads the config file. */ void Today::init() { - - QDate date = QDate::currentDate(); - QString time = ( tr( date.toString() ) ); - - DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); - // read config Config cfg( "today" ); - cfg.setGroup( "Applets" ); + cfg.setGroup( "Plugins" ); + m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); + m_allApplets = cfg.readListEntry( "AllApplets", ',' ); } @@ -133,13 +129,15 @@ void Today::loadPlugins() { } pluginList.clear(); - QString path = QPEApplication::qpeDir() + "/plugins/today"; QDir dir( path, "lib*.so" ); QStringList list = dir.entryList(); QStringList::Iterator it; + + QMap<QString, TodayPlugin> tempList; + for ( it = list.begin(); it != list.end(); ++it ) { TodayPluginInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); @@ -164,12 +162,10 @@ void Today::loadPlugins() { // 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( 18, 18 ), 0 ); OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); plugIcon->setPixmap( plugPix ); - // a scrollview for each plugin QScrollView* sv = new QScrollView( plugin.guiBox ); QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); @@ -178,20 +174,36 @@ void Today::loadPlugins() { 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 ); - layout->addWidget( plugin.guiBox ); + // "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 { 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 ); + } + } + } } @@ -227,8 +239,7 @@ void Today::draw() { noPluginsActive->setText( tr( "No plugins activated" ) ); layout->addWidget( noPluginsActive ); } - //layout->addStretch(0); - //layout->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); + layout->addStretch(0); } @@ -241,12 +252,13 @@ void Today::startConfig() { TodayPlugin plugin; QList<ConfigWidget> configWidgetList; - for ( uint i = 0; i < pluginList.count(); i++ ) { + + 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 ) { - ConfigWidget* widget = plugin.guiPart->configWidget( this ); + ConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); configWidgetList.append( widget ); conf.TabWidget3->insertTab( widget, plugin.guiPart->appName() ); } @@ -274,6 +286,12 @@ void Today::startConfig() { void Today::refresh() { init(); + // 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; } |