summaryrefslogtreecommitdiffabout
path: root/kaddressbook/extensionmanager.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kaddressbook/extensionmanager.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kaddressbook/extensionmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/extensionmanager.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/kaddressbook/extensionmanager.cpp b/kaddressbook/extensionmanager.cpp
index 46defa1..5356224 100644
--- a/kaddressbook/extensionmanager.cpp
+++ b/kaddressbook/extensionmanager.cpp
@@ -9,69 +9,71 @@
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qapplication.h> 24#include <qapplication.h>
25//Added by qt3to4:
26#include <Q3HBoxLayout>
25#include <kactionclasses.h> 27#include <kactionclasses.h>
26#include <kconfig.h> 28#include <kconfig.h>
27#include <kdebug.h> 29#include <kdebug.h>
28#include <klocale.h> 30#include <klocale.h>
29 31
30#ifndef KAB_EMBEDDED 32#ifndef KAB_EMBEDDED
31#include <ktrader.h> 33#include <ktrader.h>
32#else //KAB_EMBEDDED 34#else //KAB_EMBEDDED
33#include <features/mergewidget.h> 35#include <features/mergewidget.h>
34#include <features/distributionlistwidget.h> 36#include <features/distributionlistwidget.h>
35#endif //KAB_EMBEDDED 37#endif //KAB_EMBEDDED
36 38
37#include "addresseeeditorwidget.h" 39#include "addresseeeditorwidget.h"
38#include "kabcore.h" 40#include "kabcore.h"
39#include "kabprefs.h" 41#include "kabprefs.h"
40 42
41#include "extensionmanager.h" 43#include "extensionmanager.h"
42 44
43ExtensionManager::ExtensionManager( KABCore *core, QWidget *parent, 45ExtensionManager::ExtensionManager( KABCore *core, QWidget *parent,
44 const char *name ) 46 const char *name )
45 : QScrollView( parent, name ), mCore( core ), mCurrentExtensionWidget( 0 ) 47 : Q3ScrollView( parent, name ), mCore( core ), mCurrentExtensionWidget( 0 )
46{ 48{
47#ifdef KAB_EMBEDDED 49#ifdef KAB_EMBEDDED
48//US QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 50//US QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
49 QWidget *settingsmenu = (QWidget*)mCore->getViewMenu(); 51 QWidget *settingsmenu = (QWidget*)mCore->getViewMenu();
50#endif //KAB_EMBEDDED 52#endif //KAB_EMBEDDED
51 53
52 mActionExtensions = new KSelectAction( i18n( "Show Extension Bar" ), 0, 54 mActionExtensions = new KSelectAction( i18n( "Show Extension Bar" ), 0,
53 mCore->actionCollection(), 55 mCore->actionCollection(),
54 "options_show_extensions" ); 56 "options_show_extensions" );
55 57
56 mActionExtensions->plug( settingsmenu ,0); 58 mActionExtensions->plug( settingsmenu ,0);
57 59
58 connect( mActionExtensions, SIGNAL( activated( int ) ), 60 connect( mActionExtensions, SIGNAL( activated( int ) ),
59 SLOT( setActiveExtension( int ) ) ); 61 SLOT( setActiveExtension( int ) ) );
60 mWidgetBox = new QWidget( viewport() ); 62 mWidgetBox = new QWidget( viewport() );
61 new QHBoxLayout (mWidgetBox ); 63 new Q3HBoxLayout (mWidgetBox );
62 addChild( mWidgetBox ); 64 addChild( mWidgetBox );
63 setResizePolicy(AutoOneFit); 65 setResizePolicy(AutoOneFit);
64 createExtensionWidgets(); 66 createExtensionWidgets();
65 hide(); 67 hide();
66} 68}
67 69
68ExtensionManager::~ExtensionManager() 70ExtensionManager::~ExtensionManager()
69{ 71{
70} 72}
71 73
72void ExtensionManager::restoreSettings() 74void ExtensionManager::restoreSettings()
73{ 75{
74 mActionExtensions->setCurrentItem( KABPrefs::instance()->mCurrentExtension ); 76 mActionExtensions->setCurrentItem( KABPrefs::instance()->mCurrentExtension );
75 int i = 1; 77 int i = 1;
76 mCurrentExtensionWidget = mExtensionWidgetList.at( i-1 ); 78 mCurrentExtensionWidget = mExtensionWidgetList.at( i-1 );
77 while ( mCurrentExtensionWidget ) { 79 while ( mCurrentExtensionWidget ) {
@@ -135,44 +137,44 @@ void ExtensionManager::setActiveExtension( int id )
135 hide(); 137 hide();
136 mCurrentExtensionWidget = 0; 138 mCurrentExtensionWidget = 0;
137#ifndef DESKTOP_VERSION 139#ifndef DESKTOP_VERSION
138//US our screen is so small, that we better hide the detailscreen, just in case. 140//US our screen is so small, that we better hide the detailscreen, just in case.
139//US mCore->setDetailsToState( ); 141//US mCore->setDetailsToState( );
140#endif //KAB_EMBEDDED 142#endif //KAB_EMBEDDED
141 } 143 }
142 } 144 }
143 145
144 emit changedActiveExtension( id ); 146 emit changedActiveExtension( id );
145} 147}
146 148
147void ExtensionManager::createExtensionWidgets() 149void ExtensionManager::createExtensionWidgets()
148{ 150{
149 // clear extension widget list 151 // clear extension widget list
150 mExtensionWidgetList.setAutoDelete( true ); 152 mExtensionWidgetList.setAutoDelete( true );
151 QPtrListIterator<ExtensionWidget> wdgIt( mExtensionWidgetList ); 153 Q3PtrListIterator<ExtensionWidget> wdgIt( mExtensionWidgetList );
152 ExtensionWidget *wdg = 0; 154 ExtensionWidget *wdg = 0;
153 while ( ( wdg = wdgIt.current() ) != 0 ) 155 while ( ( wdg = wdgIt.current() ) != 0 )
154 mExtensionWidgetList.remove( wdg ); 156 mExtensionWidgetList.remove( wdg );
155 157
156 mExtensionWidgetList.setAutoDelete( false ); 158 mExtensionWidgetList.setAutoDelete( false );
157 159
158 QStringList extensionNames( i18n( "None" ) ); 160 QStringList extensionNames( i18n( "None" ) );
159 161
160 // add addressee editor as default 162 // add addressee editor as default
161 163
162 QHBoxLayout *hbl = (QHBoxLayout *) mWidgetBox->layout();; 164 Q3HBoxLayout *hbl = (Q3HBoxLayout *) mWidgetBox->layout();;
163 165
164 wdg = new AddresseeEditorWidget( mCore, true, mWidgetBox ); 166 wdg = new AddresseeEditorWidget( mCore, true, mWidgetBox );
165 hbl->addWidget( wdg ); 167 hbl->addWidget( wdg );
166 //wdg->hide(); 168 //wdg->hide();
167 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 169 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
168 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 170 SIGNAL( modified( const KABC::Addressee::List& ) ) );
169 mExtensionWidgetList.append( wdg ); 171 mExtensionWidgetList.append( wdg );
170 extensionNames.append( wdg->title() ); 172 extensionNames.append( wdg->title() );
171 173
172 // load the other extensions 174 // load the other extensions
173 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 175 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
174 176
175#ifndef KAB_EMBEDDED 177#ifndef KAB_EMBEDDED
176 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 178 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
177 KTrader::OfferList::ConstIterator it; 179 KTrader::OfferList::ConstIterator it;
178 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 180 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
@@ -231,19 +233,19 @@ void ExtensionManager::createExtensionWidgets()
231 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 233 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
232 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 234 SIGNAL( modified( const KABC::Addressee::List& ) ) );
233 mExtensionWidgetList.append( wdg ); 235 mExtensionWidgetList.append( wdg );
234 extensionNames.append( wdg->title() ); 236 extensionNames.append( wdg->title() );
235 } 237 }
236 } 238 }
237 239
238 hbl->addStretch(); 240 hbl->addStretch();
239 241
240#endif //KAB_EMBEDDED 242#endif //KAB_EMBEDDED
241 243
242 244
243 mActionExtensions->setItems( extensionNames ); 245 mActionExtensions->setItems( extensionNames );
244 mCurrentExtensionWidget = 0; 246 mCurrentExtensionWidget = 0;
245} 247}
246 248
247#ifndef KAB_EMBEDDED 249#ifndef KAB_EMBEDDED_
248#include "extensionmanager.moc" 250#include "moc_extensionmanager.cpp"
249#endif //KAB_EMBEDDED 251#endif //KAB_EMBEDDED