author | harlekin <harlekin> | 2004-06-03 20:36:44 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-06-03 20:36:44 (UTC) |
commit | 52f849d3031f9d2fad2272ad069e7a1456c0ee54 (patch) (side-by-side diff) | |
tree | 7d03d229363b81c40d180ee99d168e99c4f6c06e /core/pim/today/todayconfig.cpp | |
parent | 74109985fd9ebdffd6cf0416207a69b17b563fd6 (diff) | |
download | opie-52f849d3031f9d2fad2272ad069e7a1456c0ee54.zip opie-52f849d3031f9d2fad2272ad069e7a1456c0ee54.tar.gz opie-52f849d3031f9d2fad2272ad069e7a1456c0ee54.tar.bz2 |
updated today to use the new opluginloader, migration not finished yet but mostly working
Diffstat (limited to 'core/pim/today/todayconfig.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/today/todayconfig.cpp | 117 |
1 files changed, 68 insertions, 49 deletions
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index 4f0877c..c9823d4 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp @@ -18,3 +18,6 @@ -#include <qpe/config.h> +#include <opie2/oconfig.h> +#include <opie2/opluginloader.h> +#include <opie2/todayplugininterface.h> + #include <qpe/resource.h> @@ -33,2 +36,7 @@ using namespace Opie::Ui; +using Opie::Core::OConfig; +using Opie::Core::OPluginManager; +using Opie::Core::OPluginLoader; +using Opie::Core::OPluginItem; + class ToolButton : public QToolButton { @@ -70,3 +78,4 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) m_appletListView->setSorting( -1 ); - QWhatsThis::add( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); + QWhatsThis::add + ( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); QVBox *vbox1 = new QVBox( hbox1 ); @@ -86,6 +95,4 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) - m_applets_changed = false; - connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) ); - + previousItem = 0l; readConfig(); @@ -95,2 +102,30 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) +void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plugLoader ) { + + + m_pluginManager = plugManager; + m_pluginLoader = plugLoader; + + OPluginItem::List inLst = m_pluginLoader->allAvailable( true ); + + OPluginItem::List lst; + for ( OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { + lst.prepend((*it)); + + TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); + + if ( iface->guiPart()->configWidget(this) != 0l ) { + TodayConfigWidget* widget = iface->guiPart()->configWidget( TabWidget3 ); + TabWidget3->addTab( widget, iface->guiPart()->pixmapNameConfig() + , iface->guiPart()->appName() ); + } + } + + for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { + pluginManagement( (*it) ); + } + + TabWidget3->setCurrentTab( tab_2 ); +} + /** @@ -100,3 +135,3 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) void TodayConfig::setAutoStart() { - Config cfg( "today" ); + OConfig cfg( "today" ); cfg.setGroup( "Autostart" ); @@ -118,3 +153,3 @@ void TodayConfig::setAutoStart() { void TodayConfig::readConfig() { - Config cfg( "today" ); + OConfig cfg( "today" ); cfg.setGroup( "Autostart" ); @@ -130,6 +165,2 @@ void TodayConfig::readConfig() { m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); - - - cfg.setGroup( "Plugins" ); - m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); } @@ -140,22 +171,15 @@ void TodayConfig::readConfig() { void TodayConfig::writeConfig() { - Config cfg( "today" ); - cfg.setGroup( "Plugins" ); - if ( m_applets_changed ) { - QStringList exclude; - QStringList include; - QStringList all_applets; + OConfig cfg( "today" ); - QListViewItemIterator list_it( m_appletListView ); + int position = m_appletListView->childCount(); + QListViewItemIterator list_it( m_appletListView ); + // // this makes sure the names get saved in the order selected for ( ; list_it.current(); ++list_it ) { - QMap <QString, QCheckListItem *>::Iterator it; - for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { - if ( list_it.current() == (*it) && !(*it)-> isOn () ) { - exclude << it.key(); - } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ - include << it.key(); - } - if ( list_it.current() == (*it) ) { - all_applets << it.key(); + OPluginItem::List lst = m_pluginLoader->allAvailable( true ); + for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { + if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) { + (*it).setPosition(position--); + m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() ); } @@ -163,6 +187,4 @@ void TodayConfig::writeConfig() { } - cfg.writeEntry( "ExcludeApplets", exclude, ',' ); - cfg.writeEntry( "IncludeApplets", include, ',' ); - cfg.writeEntry( "AllApplets", all_applets, ',' ); - } + + m_pluginManager->save(); @@ -182,2 +204,10 @@ void TodayConfig::writeConfig() { setAutoStart(); + + OPluginItem::List lst = m_pluginManager->managedPlugins(); + for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { + TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); + if ( iface->guiPart()->configWidget(this) != 0l ) { + iface->guiPart()->configWidget(this)->writeConfig(); + } + } } @@ -204,7 +234,8 @@ void TodayConfig::moveSelectedDown() { */ -void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { +void TodayConfig::pluginManagement( OPluginItem plugItem ) { - QCheckListItem *item; - item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox ); + QCheckListItem *item = new QCheckListItem( m_appletListView, plugItem.name(), QCheckListItem::CheckBox ); + TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( plugItem, IID_TodayPluginInterface ); + QPixmap icon = Resource::loadPixmap( iface->guiPart()->pixmapNameWidget() ); if ( !icon.isNull() ) { @@ -212,20 +243,8 @@ void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon } - - if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { - item->setOn( TRUE ); + item->setOn( plugItem.isEnabled() ); + previousItem = item; } - m_applets[libName] = item; - - // kind of hack to get the first tab as default. - TabWidget3->setCurrentTab( tab_2 ); -} -void TodayConfig::appletChanged() { - m_applets_changed = true; -} - - -TodayConfig::~TodayConfig() { -} +TodayConfig::~TodayConfig() {} |