summaryrefslogtreecommitdiffabout
path: root/kaddressbook/extensionmanager.cpp
authorzautrix <zautrix>2005-01-14 19:02:53 (UTC)
committer zautrix <zautrix>2005-01-14 19:02:53 (UTC)
commit620f8de219ee34c209960f02c8296c0568dd5d8b (patch) (unidiff)
tree772170b3b9ceaf8c204e2bdd9cbb333427de30cd /kaddressbook/extensionmanager.cpp
parent61c95ce0295f1397db6499c5b468a9fb3d32a0f4 (diff)
downloadkdepimpi-620f8de219ee34c209960f02c8296c0568dd5d8b.zip
kdepimpi-620f8de219ee34c209960f02c8296c0568dd5d8b.tar.gz
kdepimpi-620f8de219ee34c209960f02c8296c0568dd5d8b.tar.bz2
formatted name fixes
Diffstat (limited to 'kaddressbook/extensionmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/extensionmanager.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/kaddressbook/extensionmanager.cpp b/kaddressbook/extensionmanager.cpp
index 98561dc..efbdf17 100644
--- a/kaddressbook/extensionmanager.cpp
+++ b/kaddressbook/extensionmanager.cpp
@@ -29,64 +29,65 @@
29 29
30#ifndef KAB_EMBEDDED 30#ifndef KAB_EMBEDDED
31#include <ktrader.h> 31#include <ktrader.h>
32#else //KAB_EMBEDDED 32#else //KAB_EMBEDDED
33#include <features/mergewidget.h> 33#include <features/mergewidget.h>
34#include <features/distributionlistwidget.h> 34#include <features/distributionlistwidget.h>
35#endif //KAB_EMBEDDED 35#endif //KAB_EMBEDDED
36 36
37#include "addresseeeditorwidget.h" 37#include "addresseeeditorwidget.h"
38#include "kabcore.h" 38#include "kabcore.h"
39#include "kabprefs.h" 39#include "kabprefs.h"
40 40
41#include "extensionmanager.h" 41#include "extensionmanager.h"
42 42
43ExtensionManager::ExtensionManager( KABCore *core, QWidget *parent, 43ExtensionManager::ExtensionManager( KABCore *core, QWidget *parent,
44 const char *name ) 44 const char *name )
45 : QScrollView( parent, name ), mCore( core ), mCurrentExtensionWidget( 0 ) 45 : QScrollView( parent, name ), mCore( core ), mCurrentExtensionWidget( 0 )
46{ 46{
47#ifdef KAB_EMBEDDED 47#ifdef KAB_EMBEDDED
48//US QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 48//US QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
49 QWidget *settingsmenu = (QWidget*)mCore->getSettingsMenu(); 49 QWidget *settingsmenu = (QWidget*)mCore->getSettingsMenu();
50#endif //KAB_EMBEDDED 50#endif //KAB_EMBEDDED
51 51
52 mActionExtensions = new KSelectAction( i18n( "Show Extension Bar" ), 0, 52 mActionExtensions = new KSelectAction( i18n( "Show Extension Bar" ), 0,
53 mCore->actionCollection(), 53 mCore->actionCollection(),
54 "options_show_extensions" ); 54 "options_show_extensions" );
55 55
56 mActionExtensions->plug( settingsmenu ); 56 mActionExtensions->plug( settingsmenu );
57 57
58 connect( mActionExtensions, SIGNAL( activated( int ) ), 58 connect( mActionExtensions, SIGNAL( activated( int ) ),
59 SLOT( setActiveExtension( int ) ) ); 59 SLOT( setActiveExtension( int ) ) );
60 mWidgetBox = new QWidget( viewport() ); 60 mWidgetBox = new QWidget( viewport() );
61 new QHBoxLayout (mWidgetBox );
61 addChild( mWidgetBox ); 62 addChild( mWidgetBox );
62 setResizePolicy(AutoOneFit); 63 setResizePolicy(AutoOneFit);
63 createExtensionWidgets(); 64 createExtensionWidgets();
64 hide(); 65 hide();
65} 66}
66 67
67ExtensionManager::~ExtensionManager() 68ExtensionManager::~ExtensionManager()
68{ 69{
69} 70}
70 71
71void ExtensionManager::restoreSettings() 72void ExtensionManager::restoreSettings()
72{ 73{
73 mActionExtensions->setCurrentItem( KABPrefs::instance()->mCurrentExtension ); 74 mActionExtensions->setCurrentItem( KABPrefs::instance()->mCurrentExtension );
74 int i = 1; 75 int i = 1;
75 mCurrentExtensionWidget = mExtensionWidgetList.at( i-1 ); 76 mCurrentExtensionWidget = mExtensionWidgetList.at( i-1 );
76 while ( mCurrentExtensionWidget ) { 77 while ( mCurrentExtensionWidget ) {
77 if( i != KABPrefs::instance()->mCurrentExtension ) 78 if( i != KABPrefs::instance()->mCurrentExtension )
78 mCurrentExtensionWidget->hide(); 79 mCurrentExtensionWidget->hide();
79 mCurrentExtensionWidget = mExtensionWidgetList.at( ++i-1 ); 80 mCurrentExtensionWidget = mExtensionWidgetList.at( ++i-1 );
80 81
81 } 82 }
82 setActiveExtension( mActionExtensions->currentItem() ); 83 setActiveExtension( mActionExtensions->currentItem() );
83} 84}
84 85
85void ExtensionManager::saveSettings() 86void ExtensionManager::saveSettings()
86{ 87{
87 KABPrefs::instance()->mCurrentExtension = mActionExtensions->currentItem(); 88 KABPrefs::instance()->mCurrentExtension = mActionExtensions->currentItem();
88} 89}
89 90
90void ExtensionManager::reconfigure() 91void ExtensionManager::reconfigure()
91{ 92{
92 saveSettings(); 93 saveSettings();
@@ -129,94 +130,94 @@ void ExtensionManager::setActiveExtension( int id )
129#endif //KAB_EMBEDDED 130#endif //KAB_EMBEDDED
130 show(); 131 show();
131 mWidgetBox->show(); 132 mWidgetBox->show();
132 mCurrentExtensionWidget->show(); 133 mCurrentExtensionWidget->show();
133 } else { 134 } else {
134 hide(); 135 hide();
135 mCurrentExtensionWidget = 0; 136 mCurrentExtensionWidget = 0;
136#ifndef DESKTOP_VERSION 137#ifndef DESKTOP_VERSION
137//US our screen is so small, that we better hide the detailscreen, just in case. 138//US our screen is so small, that we better hide the detailscreen, just in case.
138//US mCore->setDetailsToState( ); 139//US mCore->setDetailsToState( );
139#endif //KAB_EMBEDDED 140#endif //KAB_EMBEDDED
140 } 141 }
141 } 142 }
142 143
143 emit changedActiveExtension( id ); 144 emit changedActiveExtension( id );
144} 145}
145 146
146void ExtensionManager::createExtensionWidgets() 147void ExtensionManager::createExtensionWidgets()
147{ 148{
148 // clear extension widget list 149 // clear extension widget list
149 mExtensionWidgetList.setAutoDelete( true ); 150 mExtensionWidgetList.setAutoDelete( true );
150 QPtrListIterator<ExtensionWidget> wdgIt( mExtensionWidgetList ); 151 QPtrListIterator<ExtensionWidget> wdgIt( mExtensionWidgetList );
151 ExtensionWidget *wdg = 0; 152 ExtensionWidget *wdg = 0;
152 while ( ( wdg = wdgIt.current() ) != 0 ) 153 while ( ( wdg = wdgIt.current() ) != 0 )
153 mExtensionWidgetList.remove( wdg ); 154 mExtensionWidgetList.remove( wdg );
154 155
155 mExtensionWidgetList.setAutoDelete( false ); 156 mExtensionWidgetList.setAutoDelete( false );
156 157
157 QStringList extensionNames( i18n( "None" ) ); 158 QStringList extensionNames( i18n( "None" ) );
158 159
159 // add addressee editor as default 160 // add addressee editor as default
160 161
161 QHBoxLayout *hbl = new QHBoxLayout (mWidgetBox ); 162 QHBoxLayout *hbl = (QHBoxLayout *) mWidgetBox->layout();;
162 163
163 wdg = new AddresseeEditorWidget( mCore, true, mWidgetBox ); 164 wdg = new AddresseeEditorWidget( mCore, true, mWidgetBox );
164 hbl->addWidget( wdg ); 165 hbl->addWidget( wdg );
165 //wdg->hide(); 166 //wdg->hide();
166 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 167 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
167 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 168 SIGNAL( modified( const KABC::Addressee::List& ) ) );
168 mExtensionWidgetList.append( wdg ); 169 mExtensionWidgetList.append( wdg );
169 extensionNames.append( wdg->title() ); 170 extensionNames.append( wdg->title() );
170 171
171 // load the other extensions 172 // load the other extensions
172 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 173 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
173 174
174#ifndef KAB_EMBEDDED 175#ifndef KAB_EMBEDDED
175 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 176 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
176 KTrader::OfferList::ConstIterator it; 177 KTrader::OfferList::ConstIterator it;
177 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 178 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
178 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) 179 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) )
179 continue; 180 continue;
180 181
181 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 182 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
182 if ( !factory ) { 183 if ( !factory ) {
183 kdDebug(5720) << "ExtensionManager::loadExtensions(): Factory creation failed" << endl; 184 //kdDebug(5720) << "ExtensionManager::loadExtensions(): Factory creation failed" << endl;
184 continue; 185 continue;
185 } 186 }
186 187
187 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); 188 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory );
188 189
189 if ( !extensionFactory ) { 190 if ( !extensionFactory ) {
190 kdDebug(5720) << "ExtensionManager::loadExtensions(): Cast failed" << endl; 191 //kdDebug(5720) << "ExtensionManager::loadExtensions(): Cast failed" << endl;
191 continue; 192 continue;
192 } 193 }
193 194
194 if ( !activeExtensions.contains( extensionFactory->identifier() ) ) 195 if ( !activeExtensions.contains( extensionFactory->identifier() ) )
195 continue; 196 continue;
196 197
197 wdg = extensionFactory->extension( mCore, this ); 198 wdg = extensionFactory->extension( mCore, this );
198 if ( wdg ) { 199 if ( wdg ) {
199 //wdg->hide(); 200 //wdg->hide();
200 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 201 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
201 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 202 SIGNAL( modified( const KABC::Addressee::List& ) ) );
202 mExtensionWidgetList.append( wdg ); 203 mExtensionWidgetList.append( wdg );
203 extensionNames.append( wdg->title() ); 204 extensionNames.append( wdg->title() );
204 } 205 }
205 } 206 }
206#else //KAB_EMBEDDED 207#else //KAB_EMBEDDED
207 //load Mergefactory/extension 208 //load Mergefactory/extension
208 ExtensionFactory *extensionFactory = new MergeFactory(); 209 ExtensionFactory *extensionFactory = new MergeFactory();
209 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 210 if ( activeExtensions.contains( extensionFactory->identifier() ) )
210 { 211 {
211 wdg = extensionFactory->extension( mCore, mWidgetBox ); 212 wdg = extensionFactory->extension( mCore, mWidgetBox );
212 if ( wdg ) { 213 if ( wdg ) {
213 hbl->addWidget( wdg ); 214 hbl->addWidget( wdg );
214 //wdg->hide(); 215 //wdg->hide();
215 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 216 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
216 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 217 SIGNAL( modified( const KABC::Addressee::List& ) ) );
217 mExtensionWidgetList.append( wdg ); 218 mExtensionWidgetList.append( wdg );
218 extensionNames.append( wdg->title() ); 219 extensionNames.append( wdg->title() );
219 } 220 }
220 } 221 }
221 222
222 //load DistributionListfactory/extension 223 //load DistributionListfactory/extension