summaryrefslogtreecommitdiffabout
path: root/kaddressbook/viewmanager.cpp
authorzautrix <zautrix>2005-03-30 17:55:57 (UTC)
committer zautrix <zautrix>2005-03-30 17:55:57 (UTC)
commit0d8be3961052dc4396aa7db1c5f50db3ec1ac194 (patch) (unidiff)
treef823a8b81413f16f861c9c91ef753d3627577cb2 /kaddressbook/viewmanager.cpp
parent95ec57b2f9df64dc40067c3a2278438029517f4c (diff)
downloadkdepimpi-0d8be3961052dc4396aa7db1c5f50db3ec1ac194.zip
kdepimpi-0d8be3961052dc4396aa7db1c5f50db3ec1ac194.tar.gz
kdepimpi-0d8be3961052dc4396aa7db1c5f50db3ec1ac194.tar.bz2
MENU CLEANUP
Diffstat (limited to 'kaddressbook/viewmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/viewmanager.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index c2b1bb0..86f0f3d 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -1,737 +1,737 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
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 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31 31
32#ifndef KAB_EMBEDDED 32#ifndef KAB_EMBEDDED
33#include <libkdepim/kvcarddrag.h> 33#include <libkdepim/kvcarddrag.h>
34#include <kabc/vcardconverter.h> 34#include <kabc/vcardconverter.h>
35#include <kconfig.h> 35#include <kconfig.h>
36#include <kdeversion.h> 36#include <kdeversion.h>
37#include <kiconloader.h> 37#include <kiconloader.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40#include <kmultipledrag.h> 40#include <kmultipledrag.h>
41#include <ktrader.h> 41#include <ktrader.h>
42#include <kurldrag.h> 42#include <kurldrag.h>
43 43
44#include "addresseeutil.h" 44#include "addresseeutil.h"
45#else //KAB_EMBEDDED 45#else //KAB_EMBEDDED
46#include "views/kaddressbookiconview.h" 46#include "views/kaddressbookiconview.h"
47#include "views/kaddressbooktableview.h" 47#include "views/kaddressbooktableview.h"
48#include "views/kaddressbookcardview.h" 48#include "views/kaddressbookcardview.h"
49#include "kaddressbookview.h" 49#include "kaddressbookview.h"
50 50
51#include <qaction.h> 51#include <qaction.h>
52#include <qmessagebox.h> 52#include <qmessagebox.h>
53#include <qpopupmenu.h> 53#include <qpopupmenu.h>
54#include <kconfigbase.h> 54#include <kconfigbase.h>
55 55
56#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
57 57
58 58
59#include <kdebug.h> 59#include <kdebug.h>
60#include <kactionclasses.h> 60#include <kactionclasses.h>
61 61
62#include <qlayout.h> 62#include <qlayout.h>
63#include <qapplication.h> 63#include <qapplication.h>
64#include <qwidgetstack.h> 64#include <qwidgetstack.h>
65 65
66#include <kabc/addressbook.h> 66#include <kabc/addressbook.h>
67#include "filtereditdialog.h" 67#include "filtereditdialog.h"
68#include "addviewdialog.h" 68#include "addviewdialog.h"
69#include "kabcore.h" 69#include "kabcore.h"
70#include "kabprefs.h" 70#include "kabprefs.h"
71#include "viewmanager.h" 71#include "viewmanager.h"
72 72
73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) 73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name )
74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) 74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 )
75{ 75{
76 initGUI(); 76 initGUI();
77 initActions(); 77 initActions();
78 78
79 mViewDict.setAutoDelete( true ); 79 mViewDict.setAutoDelete( true );
80 80
81 createViewFactories(); 81 createViewFactories();
82} 82}
83 83
84ViewManager::~ViewManager() 84ViewManager::~ViewManager()
85{ 85{
86 unloadViews(); 86 unloadViews();
87 mViewFactoryDict.clear(); 87 mViewFactoryDict.clear();
88} 88}
89void ViewManager::scrollUP() 89void ViewManager::scrollUP()
90{ 90{
91 if ( mActiveView ) 91 if ( mActiveView )
92 mActiveView->scrollUP(); 92 mActiveView->scrollUP();
93} 93}
94void ViewManager::scrollDOWN() 94void ViewManager::scrollDOWN()
95{ 95{
96 if ( mActiveView ) 96 if ( mActiveView )
97 mActiveView->scrollDOWN(); 97 mActiveView->scrollDOWN();
98} 98}
99void ViewManager::restoreSettings() 99void ViewManager::restoreSettings()
100{ 100{
101 mViewNameList = KABPrefs::instance()->mViewNames; 101 mViewNameList = KABPrefs::instance()->mViewNames;
102 QString activeViewName = KABPrefs::instance()->mCurrentView; 102 QString activeViewName = KABPrefs::instance()->mCurrentView;
103 103
104 mActionSelectView->setItems( mViewNameList ); 104 mActionSelectView->setItems( mViewNameList );
105 105
106 // Filter 106 // Filter
107 mFilterList = Filter::restore( mCore->config(), "Filter" ); 107 mFilterList = Filter::restore( mCore->config(), "Filter" );
108 mActionSelectFilter->setItems( filterNames() ); 108 mActionSelectFilter->setItems( filterNames() );
109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); 109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter );
110 int cw = 150; 110 int cw = 150;
111 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) 111 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch)
112 cw = 0; 112 cw = 0;
113 mActionSelectFilter->setComboWidth( cw ); 113 mActionSelectFilter->setComboWidth( cw );
114 // Tell the views to reread their config, since they may have 114 // Tell the views to reread their config, since they may have
115 // been modified by global settings 115 // been modified by global settings
116 QString _oldgroup = mCore->config()->group(); 116 QString _oldgroup = mCore->config()->group();
117 117
118 QDictIterator<KAddressBookView> it( mViewDict ); 118 QDictIterator<KAddressBookView> it( mViewDict );
119 for ( it.toFirst(); it.current(); ++it ) { 119 for ( it.toFirst(); it.current(); ++it ) {
120 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 120 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
121 it.current()->readConfig( mCore->config() ); 121 it.current()->readConfig( mCore->config() );
122 } 122 }
123 setActiveView( activeViewName ); 123 setActiveView( activeViewName );
124 124
125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
126} 126}
127 127
128void ViewManager::saveSettings() 128void ViewManager::saveSettings()
129{ 129{
130 QString _oldgroup = mCore->config()->group(); 130 QString _oldgroup = mCore->config()->group();
131 131
132 QDictIterator<KAddressBookView> it( mViewDict ); 132 QDictIterator<KAddressBookView> it( mViewDict );
133 for ( it.toFirst(); it.current(); ++it ) { 133 for ( it.toFirst(); it.current(); ++it ) {
134 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 134 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
135#ifdef DESKTOP_VERSION 135#ifdef DESKTOP_VERSION
136 (*it)->writeConfig( mCore->config() ); 136 (*it)->writeConfig( mCore->config() );
137#else 137#else
138 (*it).writeConfig( mCore->config() ); 138 (*it).writeConfig( mCore->config() );
139#endif 139#endif
140 } 140 }
141 141
142 Filter::save( mCore->config(), "Filter", mFilterList ); 142 Filter::save( mCore->config(), "Filter", mFilterList );
143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
144 144
145 // write the view name list 145 // write the view name list
146 KABPrefs::instance()->mViewNames = mViewNameList; 146 KABPrefs::instance()->mViewNames = mViewNameList;
147 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 147 KABPrefs::instance()->mCurrentView = mActiveView->caption();
148 148
149} 149}
150 150
151QStringList ViewManager::selectedUids() const 151QStringList ViewManager::selectedUids() const
152{ 152{
153 if ( mActiveView ) 153 if ( mActiveView )
154 return mActiveView->selectedUids(); 154 return mActiveView->selectedUids();
155 else 155 else
156 return QStringList(); 156 return QStringList();
157} 157}
158 158
159QStringList ViewManager::selectedEmails() const 159QStringList ViewManager::selectedEmails() const
160{ 160{
161 if ( mActiveView ) 161 if ( mActiveView )
162 return mActiveView->selectedEmails(); 162 return mActiveView->selectedEmails();
163 else 163 else
164 return QStringList(); 164 return QStringList();
165} 165}
166 166
167KABC::Addressee::List ViewManager::selectedAddressees() const 167KABC::Addressee::List ViewManager::selectedAddressees() const
168{ 168{
169 KABC::Addressee::List list; 169 KABC::Addressee::List list;
170 if ( mActiveView ) { 170 if ( mActiveView ) {
171 QStringList uids = mActiveView->selectedUids(); 171 QStringList uids = mActiveView->selectedUids();
172 QStringList::Iterator it; 172 QStringList::Iterator it;
173 for ( it = uids.begin(); it != uids.end(); ++it ) { 173 for ( it = uids.begin(); it != uids.end(); ++it ) {
174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
175 if ( !addr.isEmpty() ) 175 if ( !addr.isEmpty() )
176 list.append( addr ); 176 list.append( addr );
177 } 177 }
178 } 178 }
179 179
180 return list; 180 return list;
181} 181}
182//US added another method with no parameter, since my moc compiler does not support default parameters. 182//US added another method with no parameter, since my moc compiler does not support default parameters.
183void ViewManager::setSelected() 183void ViewManager::setSelected()
184{ 184{
185 setSelected( QString::null, true ); 185 setSelected( QString::null, true );
186} 186}
187 187
188void ViewManager::setSelected( const QString &uid, bool selected ) 188void ViewManager::setSelected( const QString &uid, bool selected )
189{ 189{
190 if ( mActiveView ) 190 if ( mActiveView )
191 mActiveView->setSelected( uid, selected ); 191 mActiveView->setSelected( uid, selected );
192} 192}
193 193
194void ViewManager::setListSelected(QStringList list) 194void ViewManager::setListSelected(QStringList list)
195{ 195{
196 int i, count = list.count(); 196 int i, count = list.count();
197 for ( i = 0; i < count;++i ) 197 for ( i = 0; i < count;++i )
198 setSelected( list[i], true ); 198 setSelected( list[i], true );
199 199
200} 200}
201void ViewManager::unloadViews() 201void ViewManager::unloadViews()
202{ 202{
203 mViewDict.clear(); 203 mViewDict.clear();
204 mActiveView = 0; 204 mActiveView = 0;
205} 205}
206 206
207void ViewManager::selectView( const QString &name ) 207void ViewManager::selectView( const QString &name )
208{ 208{
209 setActiveView( name ); 209 setActiveView( name );
210 mCore->saveSettings(); 210 mCore->saveSettings();
211} 211}
212void ViewManager::setActiveView( const QString &name ) 212void ViewManager::setActiveView( const QString &name )
213{ 213{
214 KAddressBookView *view = 0; 214 KAddressBookView *view = 0;
215 215
216 // Check that this isn't the same as the current active view 216 // Check that this isn't the same as the current active view
217 if ( mActiveView && ( mActiveView->caption() == name ) ) 217 if ( mActiveView && ( mActiveView->caption() == name ) )
218 return; 218 return;
219 219
220 // At this point we know the view that should be active is not 220 // At this point we know the view that should be active is not
221 // currently active. We will try to find the new on in the list. If 221 // currently active. We will try to find the new on in the list. If
222 // we can't find it, it means it hasn't been instantiated, so we will 222 // we can't find it, it means it hasn't been instantiated, so we will
223 // create it on demand. 223 // create it on demand.
224 224
225 view = mViewDict.find( name ); 225 view = mViewDict.find( name );
226 226
227 // Check if we found the view. If we didn't, then we need to create it 227 // Check if we found the view. If we didn't, then we need to create it
228 if ( view == 0 ) { 228 if ( view == 0 ) {
229 KConfig *config = mCore->config(); 229 KConfig *config = mCore->config();
230 230
231 KConfigGroupSaver saver( config, name ); 231 KConfigGroupSaver saver( config, name );
232 232
233 QString type = config->readEntry( "Type", "Table" ); 233 QString type = config->readEntry( "Type", "Table" );
234 234
235 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; 235 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
236 236
237 ViewFactory *factory = mViewFactoryDict.find( type ); 237 ViewFactory *factory = mViewFactoryDict.find( type );
238 if ( factory ) 238 if ( factory )
239 view = factory->view( mCore->addressBook(), mViewWidgetStack ); 239 view = factory->view( mCore->addressBook(), mViewWidgetStack );
240 240
241 if ( view ) { 241 if ( view ) {
242 view->setCaption( name ); 242 view->setCaption( name );
243 mViewDict.insert( name, view ); 243 mViewDict.insert( name, view );
244//US my version needs an int as second parameter to addWidget 244//US my version needs an int as second parameter to addWidget
245 mViewWidgetStack->addWidget( view, -1 ); 245 mViewWidgetStack->addWidget( view, -1 );
246 view->readConfig( config ); 246 view->readConfig( config );
247 247
248 // The manager just relays the signals 248 // The manager just relays the signals
249 connect( view, SIGNAL( selected( const QString& ) ), 249 connect( view, SIGNAL( selected( const QString& ) ),
250 SIGNAL( selected( const QString & ) ) ); 250 SIGNAL( selected( const QString & ) ) );
251 connect( view, SIGNAL( executed( const QString& ) ), 251 connect( view, SIGNAL( executed( const QString& ) ),
252 SIGNAL( executed( const QString& ) ) ); 252 SIGNAL( executed( const QString& ) ) );
253 253
254 connect( view, SIGNAL( deleteRequest( ) ), 254 connect( view, SIGNAL( deleteRequest( ) ),
255 SIGNAL( deleteRequest( ) ) ); 255 SIGNAL( deleteRequest( ) ) );
256 256
257 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); 257 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
258 connect( view, SIGNAL( dropped( QDropEvent* ) ), 258 connect( view, SIGNAL( dropped( QDropEvent* ) ),
259 SLOT( dropped( QDropEvent* ) ) ); 259 SLOT( dropped( QDropEvent* ) ) );
260 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); 260 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
261 } 261 }
262 } 262 }
263 263
264 // If we found or created the view, raise it and refresh it 264 // If we found or created the view, raise it and refresh it
265 if ( view ) { 265 if ( view ) {
266 mActiveView = view; 266 mActiveView = view;
267 mViewWidgetStack->raiseWidget( view ); 267 mViewWidgetStack->raiseWidget( view );
268 // Set the proper filter in the view. By setting the combo 268 // Set the proper filter in the view. By setting the combo
269 // box, the activated slot will be called, which will push 269 // box, the activated slot will be called, which will push
270 // the filter to the view and refresh it. 270 // the filter to the view and refresh it.
271 271
272 if ( view->defaultFilterType() == KAddressBookView::None ) { 272 if ( view->defaultFilterType() == KAddressBookView::None ) {
273 273
274 mActionSelectFilter->setCurrentItem( 0 ); 274 mActionSelectFilter->setCurrentItem( 0 );
275 setActiveFilter( 0 ); 275 setActiveFilter( 0 );
276 } else if ( view->defaultFilterType() == KAddressBookView::Active ) { 276 } else if ( view->defaultFilterType() == KAddressBookView::Active ) {
277 setActiveFilter( mActionSelectFilter->currentItem() ); 277 setActiveFilter( mActionSelectFilter->currentItem() );
278 } else { 278 } else {
279 uint pos = filterPosition( view->defaultFilterName() ); 279 uint pos = filterPosition( view->defaultFilterName() );
280 mActionSelectFilter->setCurrentItem( pos ); 280 mActionSelectFilter->setCurrentItem( pos );
281 setActiveFilter( pos ); 281 setActiveFilter( pos );
282 } 282 }
283//US qDebug("ViewManager::setActiveView 6" ); 283//US qDebug("ViewManager::setActiveView 6" );
284 284
285 // Update the inc search widget to show the fields in the new active 285 // Update the inc search widget to show the fields in the new active
286 // view. 286 // view.
287 mCore->setSearchFields( mActiveView->fields() ); 287 mCore->setSearchFields( mActiveView->fields() );
288 288
289//US performance optimization. setActiveFilter calls also mActiveView->refresh() 289//US performance optimization. setActiveFilter calls also mActiveView->refresh()
290//US mActiveView->refresh(); 290//US mActiveView->refresh();
291 } 291 }
292 else 292 else
293 { 293 {
294 qDebug("ViewManager::setActiveView: unable to find view" ); 294 qDebug("ViewManager::setActiveView: unable to find view" );
295 } 295 }
296} 296}
297 297
298//US added another method with no parameter, since my moc compiler does not support default parameters. 298//US added another method with no parameter, since my moc compiler does not support default parameters.
299void ViewManager::refreshView() 299void ViewManager::refreshView()
300{ 300{
301 refreshView( QString::null ); 301 refreshView( QString::null );
302} 302}
303 303
304void ViewManager::refreshView( const QString &uid ) 304void ViewManager::refreshView( const QString &uid )
305{ 305{
306 if ( mActiveView ) 306 if ( mActiveView )
307 mActiveView->refresh( uid ); 307 mActiveView->refresh( uid );
308} 308}
309 309
310void ViewManager::setFocusAV() 310void ViewManager::setFocusAV()
311{ 311{
312 if ( mActiveView ) 312 if ( mActiveView )
313 mActiveView->setFocusAV(); 313 mActiveView->setFocusAV();
314} 314}
315void ViewManager::editView() 315void ViewManager::editView()
316{ 316{
317 if ( !mActiveView ) 317 if ( !mActiveView )
318 return; 318 return;
319 319
320 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); 320 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() );
321 ViewConfigureWidget *wdg = 0; 321 ViewConfigureWidget *wdg = 0;
322 ViewConfigureDialog* dlg = 0; 322 ViewConfigureDialog* dlg = 0;
323 if ( factory ) { 323 if ( factory ) {
324 // Save the filters so the dialog has the latest set 324 // Save the filters so the dialog has the latest set
325 Filter::save( mCore->config(), "Filter", mFilterList ); 325 Filter::save( mCore->config(), "Filter", mFilterList );
326 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); 326 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" );
327 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); 327 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" );
328 } else { 328 } else {
329 qDebug("ViewManager::editView()::cannot find viewfactory "); 329 qDebug("ViewManager::editView()::cannot find viewfactory ");
330 return; 330 return;
331 } 331 }
332 if ( wdg ) { 332 if ( wdg ) {
333 dlg->setWidget( wdg ); 333 dlg->setWidget( wdg );
334 334
335#ifndef DESKTOP_VERSION 335#ifndef DESKTOP_VERSION
336 //dlg.setMaximumSize( 640, 480 ); 336 //dlg.setMaximumSize( 640, 480 );
337 //dlg->setGeometry( 40,40, 400, 300); 337 //dlg->setGeometry( 40,40, 400, 300);
338 dlg->showMaximized(); 338 dlg->showMaximized();
339#endif 339#endif
340 340
341 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); 341 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() );
342 342
343 dlg->restoreSettings( mCore->config() ); 343 dlg->restoreSettings( mCore->config() );
344 344
345 if ( dlg->exec() ) { 345 if ( dlg->exec() ) {
346 dlg->saveSettings( mCore->config() ); 346 dlg->saveSettings( mCore->config() );
347 mActiveView->readConfig( mCore->config() ); 347 mActiveView->readConfig( mCore->config() );
348 348
349 // Set the proper filter in the view. By setting the combo 349 // Set the proper filter in the view. By setting the combo
350 // box, the activated slot will be called, which will push 350 // box, the activated slot will be called, which will push
351 // the filter to the view and refresh it. 351 // the filter to the view and refresh it.
352 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { 352 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) {
353 mActionSelectFilter->setCurrentItem( 0 ); 353 mActionSelectFilter->setCurrentItem( 0 );
354 setActiveFilter( 0 ); 354 setActiveFilter( 0 );
355 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { 355 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) {
356 setActiveFilter( mActionSelectFilter->currentItem() ); 356 setActiveFilter( mActionSelectFilter->currentItem() );
357 } else { 357 } else {
358 uint pos = filterPosition( mActiveView->defaultFilterName() ); 358 uint pos = filterPosition( mActiveView->defaultFilterName() );
359 mActionSelectFilter->setCurrentItem( pos ); 359 mActionSelectFilter->setCurrentItem( pos );
360 setActiveFilter( pos ); 360 setActiveFilter( pos );
361 } 361 }
362 mCore->setSearchFields( mActiveView->fields() ); 362 mCore->setSearchFields( mActiveView->fields() );
363//US performance optimization. setActiveFilter calls also mActiveView->refresh() 363//US performance optimization. setActiveFilter calls also mActiveView->refresh()
364//US mActiveView->refresh(); 364//US mActiveView->refresh();
365 365
366 366
367 //US this is a bugfix, that we get notified if we change a views configuration 367 //US this is a bugfix, that we get notified if we change a views configuration
368 emit modified(); 368 emit modified();
369 369
370 } 370 }
371 371
372 } 372 }
373 delete dlg; 373 delete dlg;
374} 374}
375 375
376void ViewManager::deleteView() 376void ViewManager::deleteView()
377{ 377{
378 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) 378 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" )
379 .arg( mActiveView->caption() ); 379 .arg( mActiveView->caption() );
380 QString caption = i18n( "Confirm Delete" ); 380 QString caption = i18n( "Confirm Delete" );
381 381
382 382
383 if (QMessageBox::information( this, caption, 383 if (QMessageBox::information( this, caption,
384 text, 384 text,
385 i18n("Yes!"), i18n("No"), 0, 0 ) == 0) 385 i18n("Yes!"), i18n("No"), 0, 0 ) == 0)
386 { 386 {
387 mViewNameList.remove( mActiveView->caption() ); 387 mViewNameList.remove( mActiveView->caption() );
388 388
389 // remove the view from the config file 389 // remove the view from the config file
390 KConfig *config = mCore->config(); 390 KConfig *config = mCore->config();
391 config->deleteGroup( mActiveView->caption() ); 391 config->deleteGroup( mActiveView->caption() );
392 392
393 mViewDict.remove( mActiveView->caption() ); 393 mViewDict.remove( mActiveView->caption() );
394 mActiveView = 0; 394 mActiveView = 0;
395 395
396 // we are in an invalid state now, but that should be fixed after 396 // we are in an invalid state now, but that should be fixed after
397 // we emit the signal 397 // we emit the signal
398 mActionSelectView->setItems( mViewNameList ); 398 mActionSelectView->setItems( mViewNameList );
399 if ( mViewNameList.count() > 0 ) { 399 if ( mViewNameList.count() > 0 ) {
400 mActionSelectView->setCurrentItem( 0 ); 400 mActionSelectView->setCurrentItem( 0 );
401 setActiveView( mViewNameList[ 0 ] ); 401 setActiveView( mViewNameList[ 0 ] );
402 } 402 }
403 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 403 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
404 } 404 }
405} 405}
406 406
407void ViewManager::addView() 407void ViewManager::addView()
408{ 408{
409 AddViewDialog dialog( &mViewFactoryDict, this ); 409 AddViewDialog dialog( &mViewFactoryDict, this );
410 410
411 if ( dialog.exec() ) { 411 if ( dialog.exec() ) {
412 QString newName = dialog.viewName(); 412 QString newName = dialog.viewName();
413 QString type = dialog.viewType(); 413 QString type = dialog.viewType();
414 414
415 // Check for name conflicts 415 // Check for name conflicts
416 bool firstConflict = true; 416 bool firstConflict = true;
417 int numTries = 1; 417 int numTries = 1;
418 while ( mViewNameList.contains( newName ) > 0 ) { 418 while ( mViewNameList.contains( newName ) > 0 ) {
419 if ( !firstConflict ) { 419 if ( !firstConflict ) {
420 newName = newName.left( newName.length() - 4 ); 420 newName = newName.left( newName.length() - 4 );
421 firstConflict = false; 421 firstConflict = false;
422 } 422 }
423 423
424 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); 424 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries );
425 numTries++; 425 numTries++;
426 } 426 }
427 427
428 // Add the new one to the list 428 // Add the new one to the list
429 mViewNameList.append( newName ); 429 mViewNameList.append( newName );
430 430
431 // write the view to the config file, 431 // write the view to the config file,
432 KConfig *config = mCore->config(); 432 KConfig *config = mCore->config();
433 433
434 config->deleteGroup( newName ); 434 config->deleteGroup( newName );
435 435
436 KConfigGroupSaver saver( config, newName ); 436 KConfigGroupSaver saver( config, newName );
437 437
438 config->writeEntry( "Type", type ); 438 config->writeEntry( "Type", type );
439 439
440 // try to set the active view 440 // try to set the active view
441 mActionSelectView->setItems( mViewNameList ); 441 mActionSelectView->setItems( mViewNameList );
442 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); 442 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) );
443 setActiveView( newName ); 443 setActiveView( newName );
444 444
445 editView(); 445 editView();
446 446
447 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 447 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
448 } 448 }
449} 449}
450 450
451void ViewManager::createViewFactories() 451void ViewManager::createViewFactories()
452{ 452{
453#ifndef KAB_EMBEDDED 453#ifndef KAB_EMBEDDED
454 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); 454 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" );
455 KTrader::OfferList::ConstIterator it; 455 KTrader::OfferList::ConstIterator it;
456 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 456 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
457 if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) 457 if ( !(*it)->hasServiceType( "KAddressBook/View" ) )
458 continue; 458 continue;
459 459
460 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 460 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
461 461
462 if ( !factory ) { 462 if ( !factory ) {
463 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; 463 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl;
464 continue; 464 continue;
465 } 465 }
466 466
467 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); 467 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory );
468 468
469 if ( !viewFactory ) { 469 if ( !viewFactory ) {
470 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; 470 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl;
471 continue; 471 continue;
472 } 472 }
473 473
474 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 474 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
475 } 475 }
476 476
477#else //KAB_EMBEDDED 477#else //KAB_EMBEDDED
478 ViewFactory* viewFactory = new IconViewFactory(); 478 ViewFactory* viewFactory = new IconViewFactory();
479 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 479 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
480// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 480// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
481 481
482 viewFactory = new TableViewFactory(); 482 viewFactory = new TableViewFactory();
483 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 483 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
484// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 484// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
485 485
486 viewFactory = new CardViewFactory(); 486 viewFactory = new CardViewFactory();
487 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 487 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
488// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 488// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
489 489
490#endif //KAB_EMBEDDED 490#endif //KAB_EMBEDDED
491 491
492} 492}
493 493
494void ViewManager::dropped( QDropEvent *e ) 494void ViewManager::dropped( QDropEvent *e )
495{ 495{
496 496
497#ifndef KAB_EMBEDDED 497#ifndef KAB_EMBEDDED
498 498
499 QString clipText, vcards; 499 QString clipText, vcards;
500 KURL::List urls; 500 KURL::List urls;
501 501
502 if ( KURLDrag::decode( e, urls) ) { 502 if ( KURLDrag::decode( e, urls) ) {
503 KURL::List::Iterator it = urls.begin(); 503 KURL::List::Iterator it = urls.begin();
504 int c = urls.count(); 504 int c = urls.count();
505 if ( c > 1 ) { 505 if ( c > 1 ) {
506 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); 506 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c );
507 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { 507 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) {
508 for ( ; it != urls.end(); ++it ) 508 for ( ; it != urls.end(); ++it )
509 emit urlDropped( *it ); 509 emit urlDropped( *it );
510 } 510 }
511 } else if ( c == 1 ) 511 } else if ( c == 1 )
512 emit urlDropped( *it ); 512 emit urlDropped( *it );
513 } else if ( KVCardDrag::decode( e, vcards ) ) { 513 } else if ( KVCardDrag::decode( e, vcards ) ) {
514 KABC::Addressee addr; 514 KABC::Addressee addr;
515 KABC::VCardConverter converter; 515 KABC::VCardConverter converter;
516 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 516 QStringList list = QStringList::split( "\r\n\r\n", vcards );
517 QStringList::Iterator it; 517 QStringList::Iterator it;
518 for ( it = list.begin(); it != list.end(); ++it ) { 518 for ( it = list.begin(); it != list.end(); ++it ) {
519 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { 519 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) {
520 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); 520 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() );
521 if ( a.isEmpty() ) { 521 if ( a.isEmpty() ) {
522 mCore->addressBook()->insertAddressee( addr ); 522 mCore->addressBook()->insertAddressee( addr );
523 emit modified(); 523 emit modified();
524 } 524 }
525 } 525 }
526 } 526 }
527 527
528 mActiveView->refresh(); 528 mActiveView->refresh();
529 } 529 }
530#else //KAB_EMBEDDED 530#else //KAB_EMBEDDED
531qDebug("ViewManager::dropped() has to be changed!!" ); 531qDebug("ViewManager::dropped() has to be changed!!" );
532#endif //KAB_EMBEDDED 532#endif //KAB_EMBEDDED
533 533
534} 534}
535 535
536void ViewManager::startDrag() 536void ViewManager::startDrag()
537{ 537{
538 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; 538 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
539 539
540#ifndef KAB_EMBEDDED 540#ifndef KAB_EMBEDDED
541 541
542 // Get the list of all the selected addressees 542 // Get the list of all the selected addressees
543 KABC::Addressee::List addrList; 543 KABC::Addressee::List addrList;
544 QStringList uidList = selectedUids(); 544 QStringList uidList = selectedUids();
545 QStringList::Iterator iter; 545 QStringList::Iterator iter;
546 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 546 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
547 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 547 addrList.append( mCore->addressBook()->findByUid( *iter ) );
548 548
549 KMultipleDrag *drag = new KMultipleDrag( this ); 549 KMultipleDrag *drag = new KMultipleDrag( this );
550 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 550 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
551 KABC::Addressee::List::Iterator it; 551 KABC::Addressee::List::Iterator it;
552 QStringList vcards; 552 QStringList vcards;
553 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 553 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
554 QString vcard = QString::null; 554 QString vcard = QString::null;
555 KABC::VCardConverter converter; 555 KABC::VCardConverter converter;
556 if ( converter.addresseeToVCard( *it, vcard ) ) 556 if ( converter.addresseeToVCard( *it, vcard ) )
557 vcards.append( vcard ); 557 vcards.append( vcard );
558 } 558 }
559 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 559 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
560 560
561 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 561 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
562 drag->dragCopy(); 562 drag->dragCopy();
563 563
564#else //KAB_EMBEDDED 564#else //KAB_EMBEDDED
565qDebug("ViewManager::startDrag() has to be changed!!" ); 565qDebug("ViewManager::startDrag() has to be changed!!" );
566#endif //KAB_EMBEDDED 566#endif //KAB_EMBEDDED
567 567
568} 568}
569void ViewManager::doSearch( const QString& s,KABC::Field *field ) 569void ViewManager::doSearch( const QString& s,KABC::Field *field )
570{ 570{
571 if ( mActiveView ) 571 if ( mActiveView )
572 mActiveView->doSearch( s, field ); 572 mActiveView->doSearch( s, field );
573 573
574} 574}
575void ViewManager::setActiveFilter( int index ) 575void ViewManager::setActiveFilter( int index )
576{ 576{
577 Filter currentFilter; 577 Filter currentFilter;
578 578
579 if ( ( index - 1 ) < 0 ) 579 if ( ( index - 1 ) < 0 )
580 currentFilter = Filter(); 580 currentFilter = Filter();
581 else 581 else
582 currentFilter = mFilterList[ index - 1 ]; 582 currentFilter = mFilterList[ index - 1 ];
583 583
584 // Check if we have a view. Since the filter combo is created before 584 // Check if we have a view. Since the filter combo is created before
585 // the view, this slot could be called before there is a valid view. 585 // the view, this slot could be called before there is a valid view.
586 if ( mActiveView ) { 586 if ( mActiveView ) {
587 mActiveView->setFilter( currentFilter ); 587 mActiveView->setFilter( currentFilter );
588 mActiveView->refresh(); 588 mActiveView->refresh();
589 emit selected( QString::null ); 589 emit selected( QString::null );
590 } 590 }
591} 591}
592 592
593void ViewManager::configureFilters() 593void ViewManager::configureFilters()
594{ 594{
595 FilterDialog dlg( this ); 595 FilterDialog dlg( this );
596 596
597 dlg.setFilters( mFilterList ); 597 dlg.setFilters( mFilterList );
598 598
599 if ( dlg.exec() ) 599 if ( dlg.exec() )
600 mFilterList = dlg.filters(); 600 mFilterList = dlg.filters();
601 601
602 uint pos = mActionSelectFilter->currentItem(); 602 uint pos = mActionSelectFilter->currentItem();
603 mActionSelectFilter->setItems( filterNames() ); 603 mActionSelectFilter->setItems( filterNames() );
604 mActionSelectFilter->setCurrentItem( pos ); 604 mActionSelectFilter->setCurrentItem( pos );
605 setActiveFilter( pos ); 605 setActiveFilter( pos );
606 int cw = 150; 606 int cw = 150;
607 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) 607 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch)
608 cw = 0; 608 cw = 0;
609 mActionSelectFilter->setComboWidth( cw ); 609 mActionSelectFilter->setComboWidth( cw );
610 saveSettings(); 610 saveSettings();
611} 611}
612 612
613QStringList ViewManager::filterNames() const 613QStringList ViewManager::filterNames() const
614{ 614{
615 QStringList names( i18n( "No Filter" ) ); 615 QStringList names( i18n( "No Filter" ) );
616 616
617 Filter::List::ConstIterator it; 617 Filter::List::ConstIterator it;
618 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 618 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
619 names.append( (*it).name() ); 619 names.append( (*it).name() );
620 620
621 return names; 621 return names;
622} 622}
623Filter ViewManager::getFilterByName( const QString &name ) const 623Filter ViewManager::getFilterByName( const QString &name ) const
624{ 624{
625 Filter::List::ConstIterator it; 625 Filter::List::ConstIterator it;
626 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 626 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
627 if ( name == (*it).name() ) 627 if ( name == (*it).name() )
628 return (*it); 628 return (*it);
629 629
630 return Filter(); 630 return Filter();
631} 631}
632 632
633int ViewManager::filterPosition( const QString &name ) const 633int ViewManager::filterPosition( const QString &name ) const
634{ 634{
635 int pos = 0; 635 int pos = 0;
636 636
637 Filter::List::ConstIterator it; 637 Filter::List::ConstIterator it;
638 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 638 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
639 if ( name == (*it).name() ) 639 if ( name == (*it).name() )
640 return pos + 1; 640 return pos + 1;
641 641
642 return 0; 642 return 0;
643} 643}
644 644
645void ViewManager::initActions() 645void ViewManager::initActions()
646{ 646{
647//US <ActionList name="view_loadedviews"/> 647//US <ActionList name="view_loadedviews"/>
648//US <Separator/> 648//US <Separator/>
649 649
650#ifdef KAB_EMBEDDED 650#ifdef KAB_EMBEDDED
651 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 651 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
652 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 652 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
653 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 653 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
654#endif //KAB_EMBEDDED 654#endif //KAB_EMBEDDED
655 655
656 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 656 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
657#if KDE_VERSION >= 309 657#if KDE_VERSION >= 309
658 mActionSelectView->setMenuAccelsEnabled( false ); 658 mActionSelectView->setMenuAccelsEnabled( false );
659#endif 659#endif
660 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 660 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
661 SLOT( selectView( const QString& ) ) ); 661 SLOT( selectView( const QString& ) ) );
662 662
663 663
664#ifdef KAB_EMBEDDED 664#ifdef KAB_EMBEDDED
665 mActionSelectView->plug(viewmenu); 665 mActionSelectView->plug(viewmenu);
666 viewmenu->insertSeparator(); 666 viewmenu->insertSeparator();
667#endif //KAB_EMBEDDED 667#endif //KAB_EMBEDDED
668 668
669 KAction *action; 669 KAction *action;
670 670
671 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 671 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
672 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 672 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
673#ifndef KAB_EMBEDDED 673#ifndef KAB_EMBEDDED
674 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); 674 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) );
675#else //KAB_EMBEDDED 675#else //KAB_EMBEDDED
676 action->plug(viewmenu); 676 action->plug(viewmenu);
677#endif //KAB_EMBEDDED 677#endif //KAB_EMBEDDED
678 678
679 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 679 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
680 SLOT( addView() ), mCore->actionCollection(), "view_add" ); 680 SLOT( addView() ), mCore->actionCollection(), "view_add" );
681#ifndef KAB_EMBEDDED 681#ifndef KAB_EMBEDDED
682 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); 682 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) );
683#else //KAB_EMBEDDED 683#else //KAB_EMBEDDED
684 action->plug(viewmenu); 684 action->plug(viewmenu);
685#endif //KAB_EMBEDDED 685#endif //KAB_EMBEDDED
686 686
687 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, 687 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0,
688 this, SLOT( deleteView() ), 688 this, SLOT( deleteView() ),
689 mCore->actionCollection(), "view_delete" ); 689 mCore->actionCollection(), "view_delete" );
690#ifndef KAB_EMBEDDED 690#ifndef KAB_EMBEDDED
691 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); 691 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) );
692#else //KAB_EMBEDDED 692#else //KAB_EMBEDDED
693 mActionDeleteView->plug(viewmenu); 693 mActionDeleteView->plug(viewmenu);
694 viewmenu->insertSeparator(); 694 viewmenu->insertSeparator();
695#endif //KAB_EMBEDDED 695#endif //KAB_EMBEDDED
696 696
697#ifndef KAB_EMBEDDED 697#ifndef KAB_EMBEDDED
698 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 698 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
699 SLOT( refreshView(const QString &) ), mCore->actionCollection(), 699 SLOT( refreshView(const QString &) ), mCore->actionCollection(),
700 "view_refresh" ); 700 "view_refresh" );
701 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); 701 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) );
702#else //KAB_EMBEDDED 702#else //KAB_EMBEDDED
703 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 703 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
704 SLOT( refreshView()), mCore->actionCollection(), 704 SLOT( refreshView()), mCore->actionCollection(),
705 "view_refresh" ); 705 "view_refresh" );
706 action->plug(viewmenu); 706 action->plug(viewmenu);
707 viewmenu->insertSeparator(); 707 viewmenu->insertSeparator();
708#endif //KAB_EMBEDDED 708#endif //KAB_EMBEDDED
709 709
710 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, 710 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this,
711 SLOT( configureFilters() ), mCore->actionCollection(), 711 SLOT( configureFilters() ), mCore->actionCollection(),
712 "options_edit_filters" ); 712 "options_edit_filters" );
713 713
714 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); 714 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" );
715#if KDE_VERSION >= 309 715#if KDE_VERSION >= 309
716 mActionSelectFilter->setMenuAccelsEnabled( false ); 716 mActionSelectFilter->setMenuAccelsEnabled( false );
717#endif 717#endif
718 connect( mActionSelectFilter, SIGNAL( activated( int ) ), 718 connect( mActionSelectFilter, SIGNAL( activated( int ) ),
719 SLOT( setActiveFilter( int ) ) ); 719 SLOT( setActiveFilter( int ) ) );
720 720
721#ifdef KAB_EMBEDDED 721#ifdef KAB_EMBEDDED
722 action->plug(settingsmenu); 722 action->plug(settingsmenu);
723 mActionSelectFilter->plug(viewmenu); 723 mActionSelectFilter->plug(viewmenu,0);
724#endif //KAB_EMBEDDED 724#endif //KAB_EMBEDDED
725 725
726} 726}
727 727
728void ViewManager::initGUI() 728void ViewManager::initGUI()
729{ 729{
730 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); 730 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 );
731 mViewWidgetStack = new QWidgetStack( this ); 731 mViewWidgetStack = new QWidgetStack( this );
732 layout->addWidget( mViewWidgetStack ); 732 layout->addWidget( mViewWidgetStack );
733} 733}
734 734
735#ifndef KAB_EMBEDDED 735#ifndef KAB_EMBEDDED
736#include "viewmanager.moc" 736#include "viewmanager.moc"
737#endif //KAB_EMBEDDED 737#endif //KAB_EMBEDDED