summaryrefslogtreecommitdiff
path: root/core/pim/today/today.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/today/today.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp54
1 files changed, 36 insertions, 18 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
@@ -105,22 +105,18 @@ 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", ',' );
}
/**
* Load the plugins
*/
@@ -130,19 +126,21 @@ void Today::loadPlugins() {
for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) {
(*tit).library->unload();
delete (*tit).library;
}
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 );
qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
@@ -161,40 +159,54 @@ void Today::loadPlugins() {
}
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( 18, 18 ), 0 );
- OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
+ 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() );
sv->setMinimumHeight( plugin.guiPart->minHeight() );
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 );
- layout->addWidget( plugin.guiBox );
+ // "prebuffer" it in one more list, to get the sorting done
+ tempList.insert( plugin.name, plugin );
- pluginList.append( 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 );
+ }
+ }
+ }
}
/**
* Repaint method. Reread all fields.
*/
@@ -224,32 +236,32 @@ void Today::draw() {
if ( count == 0 ) {
QLabel *noPluginsActive = new QLabel( this );
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);
}
/**
* The method for the configuration dialog.
*/
void Today::startConfig() {
TodayConfig conf( this, "dialog", true );
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() );
}
// set the order/activate tab
conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(),
Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) );
@@ -271,12 +283,18 @@ void Today::startConfig() {
* Refresh for the view. Reload all applets
*
*/
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;
}
layout = new QVBoxLayout( this );
layout->addWidget( Frame );
layout->addWidget( OwnerField );