author | harlekin <harlekin> | 2004-06-03 20:36:44 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-06-03 20:36:44 (UTC) |
commit | 52f849d3031f9d2fad2272ad069e7a1456c0ee54 (patch) (unidiff) | |
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) (ignore whitespace changes)
-rw-r--r-- | core/pim/today/todayconfig.cpp | 137 |
1 files changed, 78 insertions, 59 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 @@ | |||
18 | 18 | ||
19 | #include <qpe/config.h> | 19 | #include <opie2/oconfig.h> |
20 | #include <opie2/opluginloader.h> | ||
21 | #include <opie2/todayplugininterface.h> | ||
22 | |||
20 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
@@ -33,2 +36,7 @@ | |||
33 | using namespace Opie::Ui; | 36 | using namespace Opie::Ui; |
37 | using Opie::Core::OConfig; | ||
38 | using Opie::Core::OPluginManager; | ||
39 | using Opie::Core::OPluginLoader; | ||
40 | using Opie::Core::OPluginItem; | ||
41 | |||
34 | class ToolButton : public QToolButton { | 42 | class ToolButton : public QToolButton { |
@@ -37,3 +45,3 @@ public: | |||
37 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 45 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
38 | : QToolButton( parent, name ) { | 46 | : QToolButton( parent, name ) { |
39 | setPixmap( Resource::loadPixmap( icon ) ); | 47 | setPixmap( Resource::loadPixmap( icon ) ); |
@@ -53,3 +61,3 @@ public: | |||
53 | TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) | 61 | TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) |
54 | : QDialog( parent, name, modal, WStyle_ContextHelp ) { | 62 | : QDialog( parent, name, modal, WStyle_ContextHelp ) { |
55 | 63 | ||
@@ -70,3 +78,4 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) | |||
70 | m_appletListView->setSorting( -1 ); | 78 | m_appletListView->setSorting( -1 ); |
71 | 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" ) ); | 79 | QWhatsThis::add |
80 | ( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); | ||
72 | QVBox *vbox1 = new QVBox( hbox1 ); | 81 | QVBox *vbox1 = new QVBox( hbox1 ); |
@@ -86,6 +95,4 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) | |||
86 | 95 | ||
87 | m_applets_changed = false; | ||
88 | |||
89 | connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) ); | 96 | connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) ); |
90 | 97 | previousItem = 0l; | |
91 | readConfig(); | 98 | readConfig(); |
@@ -95,2 +102,30 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) | |||
95 | 102 | ||
103 | void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plugLoader ) { | ||
104 | |||
105 | |||
106 | m_pluginManager = plugManager; | ||
107 | m_pluginLoader = plugLoader; | ||
108 | |||
109 | OPluginItem::List inLst = m_pluginLoader->allAvailable( true ); | ||
110 | |||
111 | OPluginItem::List lst; | ||
112 | for ( OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { | ||
113 | lst.prepend((*it)); | ||
114 | |||
115 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); | ||
116 | |||
117 | if ( iface->guiPart()->configWidget(this) != 0l ) { | ||
118 | TodayConfigWidget* widget = iface->guiPart()->configWidget( TabWidget3 ); | ||
119 | TabWidget3->addTab( widget, iface->guiPart()->pixmapNameConfig() | ||
120 | , iface->guiPart()->appName() ); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | ||
125 | pluginManagement( (*it) ); | ||
126 | } | ||
127 | |||
128 | TabWidget3->setCurrentTab( tab_2 ); | ||
129 | } | ||
130 | |||
96 | /** | 131 | /** |
@@ -100,3 +135,3 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) | |||
100 | void TodayConfig::setAutoStart() { | 135 | void TodayConfig::setAutoStart() { |
101 | Config cfg( "today" ); | 136 | OConfig cfg( "today" ); |
102 | cfg.setGroup( "Autostart" ); | 137 | cfg.setGroup( "Autostart" ); |
@@ -118,3 +153,3 @@ void TodayConfig::setAutoStart() { | |||
118 | void TodayConfig::readConfig() { | 153 | void TodayConfig::readConfig() { |
119 | Config cfg( "today" ); | 154 | OConfig cfg( "today" ); |
120 | cfg.setGroup( "Autostart" ); | 155 | cfg.setGroup( "Autostart" ); |
@@ -130,6 +165,2 @@ void TodayConfig::readConfig() { | |||
130 | m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); | 165 | m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); |
131 | |||
132 | |||
133 | cfg.setGroup( "Plugins" ); | ||
134 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | ||
135 | } | 166 | } |
@@ -140,33 +171,24 @@ void TodayConfig::readConfig() { | |||
140 | void TodayConfig::writeConfig() { | 171 | void TodayConfig::writeConfig() { |
141 | Config cfg( "today" ); | 172 | OConfig cfg( "today" ); |
142 | cfg.setGroup( "Plugins" ); | 173 | |
143 | if ( m_applets_changed ) { | 174 | int position = m_appletListView->childCount(); |
144 | QStringList exclude; | 175 | |
145 | QStringList include; | 176 | QListViewItemIterator list_it( m_appletListView ); |
146 | QStringList all_applets; | 177 | // |
147 | 178 | // this makes sure the names get saved in the order selected | |
148 | QListViewItemIterator list_it( m_appletListView ); | 179 | for ( ; list_it.current(); ++list_it ) { |
149 | 180 | OPluginItem::List lst = m_pluginLoader->allAvailable( true ); | |
150 | // this makes sure the names get saved in the order selected | 181 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
151 | for ( ; list_it.current(); ++list_it ) { | 182 | if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) { |
152 | QMap <QString, QCheckListItem *>::Iterator it; | 183 | (*it).setPosition(position--); |
153 | for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { | 184 | m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() ); |
154 | if ( list_it.current() == (*it) && !(*it)-> isOn () ) { | ||
155 | exclude << it.key(); | ||
156 | } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ | ||
157 | include << it.key(); | ||
158 | } | ||
159 | if ( list_it.current() == (*it) ) { | ||
160 | all_applets << it.key(); | ||
161 | } | ||
162 | } | 185 | } |
163 | } | 186 | } |
164 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | ||
165 | cfg.writeEntry( "IncludeApplets", include, ',' ); | ||
166 | cfg.writeEntry( "AllApplets", all_applets, ',' ); | ||
167 | } | 187 | } |
168 | 188 | ||
189 | m_pluginManager->save(); | ||
190 | |||
169 | cfg.setGroup( "Autostart" ); | 191 | cfg.setGroup( "Autostart" ); |
170 | m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); | 192 | m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); |
171 | cfg.writeEntry( "autostart", m_autoStart ); | 193 | cfg.writeEntry( "autostart", m_autoStart ); |
172 | m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); | 194 | m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); |
@@ -182,2 +204,10 @@ void TodayConfig::writeConfig() { | |||
182 | setAutoStart(); | 204 | setAutoStart(); |
205 | |||
206 | OPluginItem::List lst = m_pluginManager->managedPlugins(); | ||
207 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | ||
208 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); | ||
209 | if ( iface->guiPart()->configWidget(this) != 0l ) { | ||
210 | iface->guiPart()->configWidget(this)->writeConfig(); | ||
211 | } | ||
212 | } | ||
183 | } | 213 | } |
@@ -204,23 +234,13 @@ void TodayConfig::moveSelectedDown() { | |||
204 | */ | 234 | */ |
205 | void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { | 235 | void TodayConfig::pluginManagement( OPluginItem plugItem ) { |
206 | |||
207 | QCheckListItem *item; | ||
208 | item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox ); | ||
209 | 236 | ||
210 | if ( !icon.isNull() ) { | 237 | QCheckListItem *item = new QCheckListItem( m_appletListView, plugItem.name(), QCheckListItem::CheckBox ); |
211 | item->setPixmap( 0, icon ); | ||
212 | } | ||
213 | |||
214 | if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { | ||
215 | item->setOn( TRUE ); | ||
216 | } | ||
217 | |||
218 | m_applets[libName] = item; | ||
219 | 238 | ||
220 | // kind of hack to get the first tab as default. | 239 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( plugItem, IID_TodayPluginInterface ); |
221 | TabWidget3->setCurrentTab( tab_2 ); | 240 | QPixmap icon = Resource::loadPixmap( iface->guiPart()->pixmapNameWidget() ); |
222 | } | 241 | if ( !icon.isNull() ) { |
223 | 242 | item->setPixmap( 0, icon ); | |
224 | void TodayConfig::appletChanged() { | 243 | } |
225 | m_applets_changed = true; | 244 | item->setOn( plugItem.isEnabled() ); |
245 | previousItem = item; | ||
226 | } | 246 | } |
@@ -228,4 +248,3 @@ void TodayConfig::appletChanged() { | |||
228 | 248 | ||
229 | TodayConfig::~TodayConfig() { | ||
230 | } | ||
231 | 249 | ||
250 | TodayConfig::~TodayConfig() {} | ||