summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorulf69 <ulf69>2004-09-03 01:20:37 (UTC)
committer ulf69 <ulf69>2004-09-03 01:20:37 (UTC)
commit7d5e6ab1868753f1f6a3b0831ba2e3c9d6ba411c (patch) (unidiff)
treecd2d7717d04533ab62cfc8435c7cafae8c82a8dc /kaddressbook
parent546841acf4cdfd83d576cdd2a5ddbcc94c3921f6 (diff)
downloadkdepimpi-7d5e6ab1868753f1f6a3b0831ba2e3c9d6ba411c.zip
kdepimpi-7d5e6ab1868753f1f6a3b0831ba2e3c9d6ba411c.tar.gz
kdepimpi-7d5e6ab1868753f1f6a3b0831ba2e3c9d6ba411c.tar.bz2
sourceforge 1014886: added configurationsettings for color and font of tableview
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/viewmanager.cpp5
-rw-r--r--kaddressbook/views/configuretableviewdialog.cpp216
-rw-r--r--kaddressbook/views/configuretableviewdialog.h21
3 files changed, 223 insertions, 19 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index bec1862..45c7b55 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -1,687 +1,692 @@
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 <qwidgetstack.h> 63#include <qwidgetstack.h>
64 64
65#include <kabc/addressbook.h> 65#include <kabc/addressbook.h>
66#include "filtereditdialog.h" 66#include "filtereditdialog.h"
67#include "addviewdialog.h" 67#include "addviewdialog.h"
68#include "kabcore.h" 68#include "kabcore.h"
69#include "kabprefs.h" 69#include "kabprefs.h"
70#include "viewmanager.h" 70#include "viewmanager.h"
71 71
72ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) 72ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name )
73 : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) 73 : QWidget( parent, name ), mCore( core ), mActiveView( 0 )
74{ 74{
75 initGUI(); 75 initGUI();
76 initActions(); 76 initActions();
77 77
78 mViewDict.setAutoDelete( true ); 78 mViewDict.setAutoDelete( true );
79 79
80 createViewFactories(); 80 createViewFactories();
81} 81}
82 82
83ViewManager::~ViewManager() 83ViewManager::~ViewManager()
84{ 84{
85 unloadViews(); 85 unloadViews();
86 mViewFactoryDict.clear(); 86 mViewFactoryDict.clear();
87} 87}
88 88
89void ViewManager::restoreSettings() 89void ViewManager::restoreSettings()
90{ 90{
91 mViewNameList = KABPrefs::instance()->mViewNames; 91 mViewNameList = KABPrefs::instance()->mViewNames;
92 QString activeViewName = KABPrefs::instance()->mCurrentView; 92 QString activeViewName = KABPrefs::instance()->mCurrentView;
93 93
94 mActionSelectView->setItems( mViewNameList ); 94 mActionSelectView->setItems( mViewNameList );
95 95
96 // Filter 96 // Filter
97 mFilterList = Filter::restore( mCore->config(), "Filter" ); 97 mFilterList = Filter::restore( mCore->config(), "Filter" );
98 mActionSelectFilter->setItems( filterNames() ); 98 mActionSelectFilter->setItems( filterNames() );
99 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); 99 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter );
100 100
101 // Tell the views to reread their config, since they may have 101 // Tell the views to reread their config, since they may have
102 // been modified by global settings 102 // been modified by global settings
103 QString _oldgroup = mCore->config()->group(); 103 QString _oldgroup = mCore->config()->group();
104 104
105 QDictIterator<KAddressBookView> it( mViewDict ); 105 QDictIterator<KAddressBookView> it( mViewDict );
106 for ( it.toFirst(); it.current(); ++it ) { 106 for ( it.toFirst(); it.current(); ++it ) {
107 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 107 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
108 it.current()->readConfig( mCore->config() ); 108 it.current()->readConfig( mCore->config() );
109 } 109 }
110 setActiveView( activeViewName ); 110 setActiveView( activeViewName );
111 111
112 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 112 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
113} 113}
114 114
115void ViewManager::saveSettings() 115void ViewManager::saveSettings()
116{ 116{
117 QString _oldgroup = mCore->config()->group(); 117 QString _oldgroup = mCore->config()->group();
118 118
119 QDictIterator<KAddressBookView> it( mViewDict ); 119 QDictIterator<KAddressBookView> it( mViewDict );
120 for ( it.toFirst(); it.current(); ++it ) { 120 for ( it.toFirst(); it.current(); ++it ) {
121 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 121 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
122#ifdef DESKTOP_VERSION 122#ifdef DESKTOP_VERSION
123 (*it)->writeConfig( mCore->config() ); 123 (*it)->writeConfig( mCore->config() );
124#else 124#else
125 (*it).writeConfig( mCore->config() ); 125 (*it).writeConfig( mCore->config() );
126#endif 126#endif
127 } 127 }
128 128
129 Filter::save( mCore->config(), "Filter", mFilterList ); 129 Filter::save( mCore->config(), "Filter", mFilterList );
130 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 130 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
131 131
132 // write the view name list 132 // write the view name list
133 KABPrefs::instance()->mViewNames = mViewNameList; 133 KABPrefs::instance()->mViewNames = mViewNameList;
134 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 134 KABPrefs::instance()->mCurrentView = mActiveView->caption();
135 135
136} 136}
137 137
138QStringList ViewManager::selectedUids() const 138QStringList ViewManager::selectedUids() const
139{ 139{
140 if ( mActiveView ) 140 if ( mActiveView )
141 return mActiveView->selectedUids(); 141 return mActiveView->selectedUids();
142 else 142 else
143 return QStringList(); 143 return QStringList();
144} 144}
145 145
146QStringList ViewManager::selectedEmails() const 146QStringList ViewManager::selectedEmails() const
147{ 147{
148 if ( mActiveView ) 148 if ( mActiveView )
149 return mActiveView->selectedEmails(); 149 return mActiveView->selectedEmails();
150 else 150 else
151 return QStringList(); 151 return QStringList();
152} 152}
153 153
154KABC::Addressee::List ViewManager::selectedAddressees() const 154KABC::Addressee::List ViewManager::selectedAddressees() const
155{ 155{
156 KABC::Addressee::List list; 156 KABC::Addressee::List list;
157 if ( mActiveView ) { 157 if ( mActiveView ) {
158 QStringList uids = mActiveView->selectedUids(); 158 QStringList uids = mActiveView->selectedUids();
159 QStringList::Iterator it; 159 QStringList::Iterator it;
160 for ( it = uids.begin(); it != uids.end(); ++it ) { 160 for ( it = uids.begin(); it != uids.end(); ++it ) {
161 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 161 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
162 if ( !addr.isEmpty() ) 162 if ( !addr.isEmpty() )
163 list.append( addr ); 163 list.append( addr );
164 } 164 }
165 } 165 }
166 166
167 return list; 167 return list;
168} 168}
169//US added another method with no parameter, since my moc compiler does not support default parameters. 169//US added another method with no parameter, since my moc compiler does not support default parameters.
170void ViewManager::setSelected() 170void ViewManager::setSelected()
171{ 171{
172 setSelected( QString::null, true ); 172 setSelected( QString::null, true );
173} 173}
174 174
175void ViewManager::setSelected( const QString &uid, bool selected ) 175void ViewManager::setSelected( const QString &uid, bool selected )
176{ 176{
177 if ( mActiveView ) 177 if ( mActiveView )
178 mActiveView->setSelected( uid, selected ); 178 mActiveView->setSelected( uid, selected );
179} 179}
180 180
181void ViewManager::unloadViews() 181void ViewManager::unloadViews()
182{ 182{
183 mViewDict.clear(); 183 mViewDict.clear();
184 mActiveView = 0; 184 mActiveView = 0;
185} 185}
186 186
187void ViewManager::setActiveView( const QString &name ) 187void ViewManager::setActiveView( const QString &name )
188{ 188{
189 KAddressBookView *view = 0; 189 KAddressBookView *view = 0;
190 190
191 // Check that this isn't the same as the current active view 191 // Check that this isn't the same as the current active view
192 if ( mActiveView && ( mActiveView->caption() == name ) ) 192 if ( mActiveView && ( mActiveView->caption() == name ) )
193 return; 193 return;
194 194
195 // At this point we know the view that should be active is not 195 // At this point we know the view that should be active is not
196 // currently active. We will try to find the new on in the list. If 196 // currently active. We will try to find the new on in the list. If
197 // we can't find it, it means it hasn't been instantiated, so we will 197 // we can't find it, it means it hasn't been instantiated, so we will
198 // create it on demand. 198 // create it on demand.
199 199
200 view = mViewDict.find( name ); 200 view = mViewDict.find( name );
201 201
202 // Check if we found the view. If we didn't, then we need to create it 202 // Check if we found the view. If we didn't, then we need to create it
203 if ( view == 0 ) { 203 if ( view == 0 ) {
204 KConfig *config = mCore->config(); 204 KConfig *config = mCore->config();
205 205
206 KConfigGroupSaver saver( config, name ); 206 KConfigGroupSaver saver( config, name );
207 207
208 QString type = config->readEntry( "Type", "Table" ); 208 QString type = config->readEntry( "Type", "Table" );
209 209
210 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; 210 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
211 211
212 ViewFactory *factory = mViewFactoryDict.find( type ); 212 ViewFactory *factory = mViewFactoryDict.find( type );
213 if ( factory ) 213 if ( factory )
214 view = factory->view( mCore->addressBook(), mViewWidgetStack ); 214 view = factory->view( mCore->addressBook(), mViewWidgetStack );
215 215
216 if ( view ) { 216 if ( view ) {
217 view->setCaption( name ); 217 view->setCaption( name );
218 mViewDict.insert( name, view ); 218 mViewDict.insert( name, view );
219//US my version needs an int as second parameter to addWidget 219//US my version needs an int as second parameter to addWidget
220 mViewWidgetStack->addWidget( view, -1 ); 220 mViewWidgetStack->addWidget( view, -1 );
221 view->readConfig( config ); 221 view->readConfig( config );
222 222
223 // The manager just relays the signals 223 // The manager just relays the signals
224 connect( view, SIGNAL( selected( const QString& ) ), 224 connect( view, SIGNAL( selected( const QString& ) ),
225 SIGNAL( selected( const QString & ) ) ); 225 SIGNAL( selected( const QString & ) ) );
226 connect( view, SIGNAL( executed( const QString& ) ), 226 connect( view, SIGNAL( executed( const QString& ) ),
227 SIGNAL( executed( const QString& ) ) ); 227 SIGNAL( executed( const QString& ) ) );
228 228
229 connect( view, SIGNAL( deleteRequest( ) ), 229 connect( view, SIGNAL( deleteRequest( ) ),
230 SIGNAL( deleteRequest( ) ) ); 230 SIGNAL( deleteRequest( ) ) );
231 231
232 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); 232 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
233 connect( view, SIGNAL( dropped( QDropEvent* ) ), 233 connect( view, SIGNAL( dropped( QDropEvent* ) ),
234 SLOT( dropped( QDropEvent* ) ) ); 234 SLOT( dropped( QDropEvent* ) ) );
235 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); 235 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
236 } 236 }
237 } 237 }
238 238
239 // If we found or created the view, raise it and refresh it 239 // If we found or created the view, raise it and refresh it
240 if ( view ) { 240 if ( view ) {
241 mActiveView = view; 241 mActiveView = view;
242 mViewWidgetStack->raiseWidget( view ); 242 mViewWidgetStack->raiseWidget( view );
243 // Set the proper filter in the view. By setting the combo 243 // Set the proper filter in the view. By setting the combo
244 // box, the activated slot will be called, which will push 244 // box, the activated slot will be called, which will push
245 // the filter to the view and refresh it. 245 // the filter to the view and refresh it.
246 246
247 if ( view->defaultFilterType() == KAddressBookView::None ) { 247 if ( view->defaultFilterType() == KAddressBookView::None ) {
248 248
249 mActionSelectFilter->setCurrentItem( 0 ); 249 mActionSelectFilter->setCurrentItem( 0 );
250 setActiveFilter( 0 ); 250 setActiveFilter( 0 );
251 } else if ( view->defaultFilterType() == KAddressBookView::Active ) { 251 } else if ( view->defaultFilterType() == KAddressBookView::Active ) {
252 setActiveFilter( mActionSelectFilter->currentItem() ); 252 setActiveFilter( mActionSelectFilter->currentItem() );
253 } else { 253 } else {
254 uint pos = filterPosition( view->defaultFilterName() ); 254 uint pos = filterPosition( view->defaultFilterName() );
255 mActionSelectFilter->setCurrentItem( pos ); 255 mActionSelectFilter->setCurrentItem( pos );
256 setActiveFilter( pos ); 256 setActiveFilter( pos );
257 } 257 }
258//US qDebug("ViewManager::setActiveView 6" ); 258//US qDebug("ViewManager::setActiveView 6" );
259 259
260 // Update the inc search widget to show the fields in the new active 260 // Update the inc search widget to show the fields in the new active
261 // view. 261 // view.
262 mCore->setSearchFields( mActiveView->fields() ); 262 mCore->setSearchFields( mActiveView->fields() );
263 263
264//US performance optimization. setActiveFilter calls also mActiveView->refresh() 264//US performance optimization. setActiveFilter calls also mActiveView->refresh()
265//US mActiveView->refresh(); 265//US mActiveView->refresh();
266 266
267 } 267 }
268 else 268 else
269 { 269 {
270 qDebug("ViewManager::setActiveView: unable to find view" ); 270 qDebug("ViewManager::setActiveView: unable to find view" );
271 kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; 271 kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n";
272 } 272 }
273} 273}
274 274
275//US added another method with no parameter, since my moc compiler does not support default parameters. 275//US added another method with no parameter, since my moc compiler does not support default parameters.
276void ViewManager::refreshView() 276void ViewManager::refreshView()
277{ 277{
278 refreshView( QString::null ); 278 refreshView( QString::null );
279} 279}
280 280
281void ViewManager::refreshView( const QString &uid ) 281void ViewManager::refreshView( const QString &uid )
282{ 282{
283 if ( mActiveView ) 283 if ( mActiveView )
284 mActiveView->refresh( uid ); 284 mActiveView->refresh( uid );
285} 285}
286 286
287void ViewManager::editView() 287void ViewManager::editView()
288{ 288{
289 if ( !mActiveView ) 289 if ( !mActiveView )
290 return; 290 return;
291 291
292 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); 292 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() );
293 ViewConfigureWidget *wdg = 0; 293 ViewConfigureWidget *wdg = 0;
294 ViewConfigureDialog* dlg = 0; 294 ViewConfigureDialog* dlg = 0;
295 if ( factory ) { 295 if ( factory ) {
296 // Save the filters so the dialog has the latest set 296 // Save the filters so the dialog has the latest set
297 Filter::save( mCore->config(), "Filter", mFilterList ); 297 Filter::save( mCore->config(), "Filter", mFilterList );
298 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); 298 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" );
299 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); 299 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" );
300 } else { 300 } else {
301 qDebug("ViewManager::editView()::cannot find viewfactory "); 301 qDebug("ViewManager::editView()::cannot find viewfactory ");
302 return; 302 return;
303 } 303 }
304 if ( wdg ) { 304 if ( wdg ) {
305 dlg->setWidget( wdg ); 305 dlg->setWidget( wdg );
306 306
307#ifndef DESKTOP_VERSION 307#ifndef DESKTOP_VERSION
308 //dlg.setMaximumSize( 640, 480 ); 308 //dlg.setMaximumSize( 640, 480 );
309 //dlg->setGeometry( 40,40, 400, 300); 309 //dlg->setGeometry( 40,40, 400, 300);
310 dlg->showMaximized(); 310 dlg->showMaximized();
311#endif 311#endif
312 312
313 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); 313 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() );
314 314
315 dlg->restoreSettings( mCore->config() ); 315 dlg->restoreSettings( mCore->config() );
316 316
317 if ( dlg->exec() ) { 317 if ( dlg->exec() ) {
318 dlg->saveSettings( mCore->config() ); 318 dlg->saveSettings( mCore->config() );
319 mActiveView->readConfig( mCore->config() ); 319 mActiveView->readConfig( mCore->config() );
320 320
321 // Set the proper filter in the view. By setting the combo 321 // Set the proper filter in the view. By setting the combo
322 // box, the activated slot will be called, which will push 322 // box, the activated slot will be called, which will push
323 // the filter to the view and refresh it. 323 // the filter to the view and refresh it.
324 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { 324 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) {
325 mActionSelectFilter->setCurrentItem( 0 ); 325 mActionSelectFilter->setCurrentItem( 0 );
326 setActiveFilter( 0 ); 326 setActiveFilter( 0 );
327 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { 327 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) {
328 setActiveFilter( mActionSelectFilter->currentItem() ); 328 setActiveFilter( mActionSelectFilter->currentItem() );
329 } else { 329 } else {
330 uint pos = filterPosition( mActiveView->defaultFilterName() ); 330 uint pos = filterPosition( mActiveView->defaultFilterName() );
331 mActionSelectFilter->setCurrentItem( pos ); 331 mActionSelectFilter->setCurrentItem( pos );
332 setActiveFilter( pos ); 332 setActiveFilter( pos );
333 } 333 }
334 mCore->setSearchFields( mActiveView->fields() ); 334 mCore->setSearchFields( mActiveView->fields() );
335//US performance optimization. setActiveFilter calls also mActiveView->refresh() 335//US performance optimization. setActiveFilter calls also mActiveView->refresh()
336//US mActiveView->refresh(); 336//US mActiveView->refresh();
337
338
339 //US this is a bugfix, that we get notified if we change a views configuration
340 emit modified();
341
337 } 342 }
338 343
339 } 344 }
340 delete dlg; 345 delete dlg;
341} 346}
342 347
343void ViewManager::deleteView() 348void ViewManager::deleteView()
344{ 349{
345 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) 350 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" )
346 .arg( mActiveView->caption() ); 351 .arg( mActiveView->caption() );
347 QString caption = i18n( "Confirm Delete" ); 352 QString caption = i18n( "Confirm Delete" );
348 353
349 354
350 if (QMessageBox::information( this, caption, 355 if (QMessageBox::information( this, caption,
351 text, 356 text,
352 i18n("Yes!"), i18n("No"), 0, 0 ) == 0) 357 i18n("Yes!"), i18n("No"), 0, 0 ) == 0)
353 { 358 {
354 mViewNameList.remove( mActiveView->caption() ); 359 mViewNameList.remove( mActiveView->caption() );
355 360
356 // remove the view from the config file 361 // remove the view from the config file
357 KConfig *config = mCore->config(); 362 KConfig *config = mCore->config();
358 config->deleteGroup( mActiveView->caption() ); 363 config->deleteGroup( mActiveView->caption() );
359 364
360 mViewDict.remove( mActiveView->caption() ); 365 mViewDict.remove( mActiveView->caption() );
361 mActiveView = 0; 366 mActiveView = 0;
362 367
363 // we are in an invalid state now, but that should be fixed after 368 // we are in an invalid state now, but that should be fixed after
364 // we emit the signal 369 // we emit the signal
365 mActionSelectView->setItems( mViewNameList ); 370 mActionSelectView->setItems( mViewNameList );
366 if ( mViewNameList.count() > 0 ) { 371 if ( mViewNameList.count() > 0 ) {
367 mActionSelectView->setCurrentItem( 0 ); 372 mActionSelectView->setCurrentItem( 0 );
368 setActiveView( mViewNameList[ 0 ] ); 373 setActiveView( mViewNameList[ 0 ] );
369 } 374 }
370 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 375 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
371 } 376 }
372} 377}
373 378
374void ViewManager::addView() 379void ViewManager::addView()
375{ 380{
376 AddViewDialog dialog( &mViewFactoryDict, this ); 381 AddViewDialog dialog( &mViewFactoryDict, this );
377 382
378 if ( dialog.exec() ) { 383 if ( dialog.exec() ) {
379 QString newName = dialog.viewName(); 384 QString newName = dialog.viewName();
380 QString type = dialog.viewType(); 385 QString type = dialog.viewType();
381 386
382 // Check for name conflicts 387 // Check for name conflicts
383 bool firstConflict = true; 388 bool firstConflict = true;
384 int numTries = 1; 389 int numTries = 1;
385 while ( mViewNameList.contains( newName ) > 0 ) { 390 while ( mViewNameList.contains( newName ) > 0 ) {
386 if ( !firstConflict ) { 391 if ( !firstConflict ) {
387 newName = newName.left( newName.length() - 4 ); 392 newName = newName.left( newName.length() - 4 );
388 firstConflict = false; 393 firstConflict = false;
389 } 394 }
390 395
391 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); 396 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries );
392 numTries++; 397 numTries++;
393 } 398 }
394 399
395 // Add the new one to the list 400 // Add the new one to the list
396 mViewNameList.append( newName ); 401 mViewNameList.append( newName );
397 402
398 // write the view to the config file, 403 // write the view to the config file,
399 KConfig *config = mCore->config(); 404 KConfig *config = mCore->config();
400 405
401 config->deleteGroup( newName ); 406 config->deleteGroup( newName );
402 407
403 KConfigGroupSaver saver( config, newName ); 408 KConfigGroupSaver saver( config, newName );
404 409
405 config->writeEntry( "Type", type ); 410 config->writeEntry( "Type", type );
406 411
407 // try to set the active view 412 // try to set the active view
408 mActionSelectView->setItems( mViewNameList ); 413 mActionSelectView->setItems( mViewNameList );
409 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); 414 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) );
410 setActiveView( newName ); 415 setActiveView( newName );
411 416
412 editView(); 417 editView();
413 418
414 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 419 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
415 } 420 }
416} 421}
417 422
418void ViewManager::createViewFactories() 423void ViewManager::createViewFactories()
419{ 424{
420#ifndef KAB_EMBEDDED 425#ifndef KAB_EMBEDDED
421 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); 426 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" );
422 KTrader::OfferList::ConstIterator it; 427 KTrader::OfferList::ConstIterator it;
423 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 428 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
424 if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) 429 if ( !(*it)->hasServiceType( "KAddressBook/View" ) )
425 continue; 430 continue;
426 431
427 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 432 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
428 433
429 if ( !factory ) { 434 if ( !factory ) {
430 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; 435 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl;
431 continue; 436 continue;
432 } 437 }
433 438
434 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); 439 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory );
435 440
436 if ( !viewFactory ) { 441 if ( !viewFactory ) {
437 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; 442 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl;
438 continue; 443 continue;
439 } 444 }
440 445
441 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 446 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
442 } 447 }
443 448
444#else //KAB_EMBEDDED 449#else //KAB_EMBEDDED
445 ViewFactory* viewFactory = new IconViewFactory(); 450 ViewFactory* viewFactory = new IconViewFactory();
446 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 451 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
447// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 452// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
448 453
449 viewFactory = new TableViewFactory(); 454 viewFactory = new TableViewFactory();
450 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 455 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
451// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 456// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
452 457
453 viewFactory = new CardViewFactory(); 458 viewFactory = new CardViewFactory();
454 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 459 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
455// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 460// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
456 461
457#endif //KAB_EMBEDDED 462#endif //KAB_EMBEDDED
458 463
459} 464}
460 465
461void ViewManager::dropped( QDropEvent *e ) 466void ViewManager::dropped( QDropEvent *e )
462{ 467{
463 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; 468 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl;
464 469
465#ifndef KAB_EMBEDDED 470#ifndef KAB_EMBEDDED
466 471
467 QString clipText, vcards; 472 QString clipText, vcards;
468 KURL::List urls; 473 KURL::List urls;
469 474
470 if ( KURLDrag::decode( e, urls) ) { 475 if ( KURLDrag::decode( e, urls) ) {
471 KURL::List::Iterator it = urls.begin(); 476 KURL::List::Iterator it = urls.begin();
472 int c = urls.count(); 477 int c = urls.count();
473 if ( c > 1 ) { 478 if ( c > 1 ) {
474 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); 479 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c );
475 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { 480 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) {
476 for ( ; it != urls.end(); ++it ) 481 for ( ; it != urls.end(); ++it )
477 emit urlDropped( *it ); 482 emit urlDropped( *it );
478 } 483 }
479 } else if ( c == 1 ) 484 } else if ( c == 1 )
480 emit urlDropped( *it ); 485 emit urlDropped( *it );
481 } else if ( KVCardDrag::decode( e, vcards ) ) { 486 } else if ( KVCardDrag::decode( e, vcards ) ) {
482 KABC::Addressee addr; 487 KABC::Addressee addr;
483 KABC::VCardConverter converter; 488 KABC::VCardConverter converter;
484 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 489 QStringList list = QStringList::split( "\r\n\r\n", vcards );
485 QStringList::Iterator it; 490 QStringList::Iterator it;
486 for ( it = list.begin(); it != list.end(); ++it ) { 491 for ( it = list.begin(); it != list.end(); ++it ) {
487 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { 492 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) {
488 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); 493 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() );
489 if ( a.isEmpty() ) { 494 if ( a.isEmpty() ) {
490 mCore->addressBook()->insertAddressee( addr ); 495 mCore->addressBook()->insertAddressee( addr );
491 emit modified(); 496 emit modified();
492 } 497 }
493 } 498 }
494 } 499 }
495 500
496 mActiveView->refresh(); 501 mActiveView->refresh();
497 } 502 }
498#else //KAB_EMBEDDED 503#else //KAB_EMBEDDED
499qDebug("ViewManager::dropped() has to be changed!!" ); 504qDebug("ViewManager::dropped() has to be changed!!" );
500#endif //KAB_EMBEDDED 505#endif //KAB_EMBEDDED
501 506
502} 507}
503 508
504void ViewManager::startDrag() 509void ViewManager::startDrag()
505{ 510{
506 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; 511 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
507 512
508#ifndef KAB_EMBEDDED 513#ifndef KAB_EMBEDDED
509 514
510 // Get the list of all the selected addressees 515 // Get the list of all the selected addressees
511 KABC::Addressee::List addrList; 516 KABC::Addressee::List addrList;
512 QStringList uidList = selectedUids(); 517 QStringList uidList = selectedUids();
513 QStringList::Iterator iter; 518 QStringList::Iterator iter;
514 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 519 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
515 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 520 addrList.append( mCore->addressBook()->findByUid( *iter ) );
516 521
517 KMultipleDrag *drag = new KMultipleDrag( this ); 522 KMultipleDrag *drag = new KMultipleDrag( this );
518 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 523 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
519 KABC::Addressee::List::Iterator it; 524 KABC::Addressee::List::Iterator it;
520 QStringList vcards; 525 QStringList vcards;
521 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 526 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
522 QString vcard = QString::null; 527 QString vcard = QString::null;
523 KABC::VCardConverter converter; 528 KABC::VCardConverter converter;
524 if ( converter.addresseeToVCard( *it, vcard ) ) 529 if ( converter.addresseeToVCard( *it, vcard ) )
525 vcards.append( vcard ); 530 vcards.append( vcard );
526 } 531 }
527 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 532 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
528 533
529 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 534 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
530 drag->dragCopy(); 535 drag->dragCopy();
531 536
532#else //KAB_EMBEDDED 537#else //KAB_EMBEDDED
533qDebug("ViewManager::startDrag() has to be changed!!" ); 538qDebug("ViewManager::startDrag() has to be changed!!" );
534#endif //KAB_EMBEDDED 539#endif //KAB_EMBEDDED
535 540
536} 541}
537 542
538void ViewManager::setActiveFilter( int index ) 543void ViewManager::setActiveFilter( int index )
539{ 544{
540 Filter currentFilter; 545 Filter currentFilter;
541 546
542 if ( ( index - 1 ) < 0 ) 547 if ( ( index - 1 ) < 0 )
543 currentFilter = Filter(); 548 currentFilter = Filter();
544 else 549 else
545 currentFilter = mFilterList[ index - 1 ]; 550 currentFilter = mFilterList[ index - 1 ];
546 551
547 // Check if we have a view. Since the filter combo is created before 552 // Check if we have a view. Since the filter combo is created before
548 // the view, this slot could be called before there is a valid view. 553 // the view, this slot could be called before there is a valid view.
549 if ( mActiveView ) { 554 if ( mActiveView ) {
550 mActiveView->setFilter( currentFilter ); 555 mActiveView->setFilter( currentFilter );
551 mActiveView->refresh(); 556 mActiveView->refresh();
552 emit selected( QString::null ); 557 emit selected( QString::null );
553 } 558 }
554} 559}
555 560
556void ViewManager::configureFilters() 561void ViewManager::configureFilters()
557{ 562{
558 FilterDialog dlg( this ); 563 FilterDialog dlg( this );
559 564
560 dlg.setFilters( mFilterList ); 565 dlg.setFilters( mFilterList );
561 566
562 if ( dlg.exec() ) 567 if ( dlg.exec() )
563 mFilterList = dlg.filters(); 568 mFilterList = dlg.filters();
564 569
565 uint pos = mActionSelectFilter->currentItem(); 570 uint pos = mActionSelectFilter->currentItem();
566 mActionSelectFilter->setItems( filterNames() ); 571 mActionSelectFilter->setItems( filterNames() );
567 mActionSelectFilter->setCurrentItem( pos ); 572 mActionSelectFilter->setCurrentItem( pos );
568 setActiveFilter( pos ); 573 setActiveFilter( pos );
569} 574}
570 575
571QStringList ViewManager::filterNames() const 576QStringList ViewManager::filterNames() const
572{ 577{
573 QStringList names( i18n( "No Filter" ) ); 578 QStringList names( i18n( "No Filter" ) );
574 579
575 Filter::List::ConstIterator it; 580 Filter::List::ConstIterator it;
576 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 581 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
577 names.append( (*it).name() ); 582 names.append( (*it).name() );
578 583
579 return names; 584 return names;
580} 585}
581 586
582int ViewManager::filterPosition( const QString &name ) const 587int ViewManager::filterPosition( const QString &name ) const
583{ 588{
584 int pos = 0; 589 int pos = 0;
585 590
586 Filter::List::ConstIterator it; 591 Filter::List::ConstIterator it;
587 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 592 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
588 if ( name == (*it).name() ) 593 if ( name == (*it).name() )
589 return pos + 1; 594 return pos + 1;
590 595
591 return 0; 596 return 0;
592} 597}
593 598
594void ViewManager::initActions() 599void ViewManager::initActions()
595{ 600{
596//US <ActionList name="view_loadedviews"/> 601//US <ActionList name="view_loadedviews"/>
597//US <Separator/> 602//US <Separator/>
598 603
599#ifdef KAB_EMBEDDED 604#ifdef KAB_EMBEDDED
600 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 605 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
601 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 606 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
602 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 607 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
603#endif //KAB_EMBEDDED 608#endif //KAB_EMBEDDED
604 609
605 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 610 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
606#if KDE_VERSION >= 309 611#if KDE_VERSION >= 309
607 mActionSelectView->setMenuAccelsEnabled( false ); 612 mActionSelectView->setMenuAccelsEnabled( false );
608#endif 613#endif
609 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 614 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
610 SLOT( setActiveView( const QString& ) ) ); 615 SLOT( setActiveView( const QString& ) ) );
611 616
612 617
613#ifdef KAB_EMBEDDED 618#ifdef KAB_EMBEDDED
614 mActionSelectView->plug(viewmenu); 619 mActionSelectView->plug(viewmenu);
615 viewmenu->insertSeparator(); 620 viewmenu->insertSeparator();
616#endif //KAB_EMBEDDED 621#endif //KAB_EMBEDDED
617 622
618 KAction *action; 623 KAction *action;
619 624
620 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 625 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
621 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 626 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
622#ifndef KAB_EMBEDDED 627#ifndef KAB_EMBEDDED
623 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." ) ); 628 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." ) );
624#else //KAB_EMBEDDED 629#else //KAB_EMBEDDED
625 action->plug(viewmenu); 630 action->plug(viewmenu);
626#endif //KAB_EMBEDDED 631#endif //KAB_EMBEDDED
627 632
628 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 633 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
629 SLOT( addView() ), mCore->actionCollection(), "view_add" ); 634 SLOT( addView() ), mCore->actionCollection(), "view_add" );
630#ifndef KAB_EMBEDDED 635#ifndef KAB_EMBEDDED
631 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." ) ); 636 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." ) );
632#else //KAB_EMBEDDED 637#else //KAB_EMBEDDED
633 action->plug(viewmenu); 638 action->plug(viewmenu);
634#endif //KAB_EMBEDDED 639#endif //KAB_EMBEDDED
635 640
636 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, 641 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0,
637 this, SLOT( deleteView() ), 642 this, SLOT( deleteView() ),
638 mCore->actionCollection(), "view_delete" ); 643 mCore->actionCollection(), "view_delete" );
639#ifndef KAB_EMBEDDED 644#ifndef KAB_EMBEDDED
640 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); 645 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) );
641#else //KAB_EMBEDDED 646#else //KAB_EMBEDDED
642 mActionDeleteView->plug(viewmenu); 647 mActionDeleteView->plug(viewmenu);
643 viewmenu->insertSeparator(); 648 viewmenu->insertSeparator();
644#endif //KAB_EMBEDDED 649#endif //KAB_EMBEDDED
645 650
646#ifndef KAB_EMBEDDED 651#ifndef KAB_EMBEDDED
647 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 652 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
648 SLOT( refreshView(const QString &) ), mCore->actionCollection(), 653 SLOT( refreshView(const QString &) ), mCore->actionCollection(),
649 "view_refresh" ); 654 "view_refresh" );
650 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); 655 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) );
651#else //KAB_EMBEDDED 656#else //KAB_EMBEDDED
652 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 657 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
653 SLOT( refreshView()), mCore->actionCollection(), 658 SLOT( refreshView()), mCore->actionCollection(),
654 "view_refresh" ); 659 "view_refresh" );
655 action->plug(viewmenu); 660 action->plug(viewmenu);
656 viewmenu->insertSeparator(); 661 viewmenu->insertSeparator();
657#endif //KAB_EMBEDDED 662#endif //KAB_EMBEDDED
658 663
659 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, 664 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this,
660 SLOT( configureFilters() ), mCore->actionCollection(), 665 SLOT( configureFilters() ), mCore->actionCollection(),
661 "options_edit_filters" ); 666 "options_edit_filters" );
662 667
663 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); 668 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" );
664 669
665#if KDE_VERSION >= 309 670#if KDE_VERSION >= 309
666 mActionSelectFilter->setMenuAccelsEnabled( false ); 671 mActionSelectFilter->setMenuAccelsEnabled( false );
667#endif 672#endif
668 connect( mActionSelectFilter, SIGNAL( activated( int ) ), 673 connect( mActionSelectFilter, SIGNAL( activated( int ) ),
669 SLOT( setActiveFilter( int ) ) ); 674 SLOT( setActiveFilter( int ) ) );
670 675
671#ifdef KAB_EMBEDDED 676#ifdef KAB_EMBEDDED
672 action->plug(settingsmenu); 677 action->plug(settingsmenu);
673 mActionSelectFilter->plug(viewmenu); 678 mActionSelectFilter->plug(viewmenu);
674#endif //KAB_EMBEDDED 679#endif //KAB_EMBEDDED
675 680
676} 681}
677 682
678void ViewManager::initGUI() 683void ViewManager::initGUI()
679{ 684{
680 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); 685 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 );
681 mViewWidgetStack = new QWidgetStack( this ); 686 mViewWidgetStack = new QWidgetStack( this );
682 layout->addWidget( mViewWidgetStack ); 687 layout->addWidget( mViewWidgetStack );
683} 688}
684 689
685#ifndef KAB_EMBEDDED 690#ifndef KAB_EMBEDDED
686#include "viewmanager.moc" 691#include "viewmanager.moc"
687#endif //KAB_EMBEDDED 692#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/configuretableviewdialog.cpp b/kaddressbook/views/configuretableviewdialog.cpp
index e1cc63e..cd09bcf 100644
--- a/kaddressbook/views/configuretableviewdialog.cpp
+++ b/kaddressbook/views/configuretableviewdialog.cpp
@@ -1,155 +1,339 @@
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#include <qstring.h> 24#include <qstring.h>
25#include <qwidget.h> 25#include <qwidget.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h>
27#include <qradiobutton.h> 28#include <qradiobutton.h>
28#include <qcheckbox.h> 29#include <qcheckbox.h>
29#include <qvbox.h> 30#include <qvbox.h>
30#include <qbuttongroup.h> 31#include <qbuttongroup.h>
32#include <qtabwidget.h>
33#include <qwhatsthis.h>
34#include <qpushbutton.h>
31 35
32#include <kglobal.h> 36#include <kglobal.h>
33#include <klocale.h> 37#include <klocale.h>
34#include <klineedit.h> 38#include <klineedit.h>
35#include <kurlrequester.h> 39#include <kurlrequester.h>
36#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kfontdialog.h>
37 42
38#ifndef KAB_EMBEDDED 43#ifndef KAB_EMBEDDED
39#include <kimageio.h> 44#include <kimageio.h>
40#else //KAB_EMBEDDED 45#else //KAB_EMBEDDED
41#endif //KAB_EMBEDDED 46#endif //KAB_EMBEDDED
42 47
43#include <kconfig.h> 48#include <kconfig.h>
44 49
50#include "colorlistbox.h"
51
45#include "configuretableviewdialog.h" 52#include "configuretableviewdialog.h"
46 53
47ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, 54ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab,
48 QWidget *parent, 55 QWidget *parent,
49 const char *name ) 56 const char *name )
50 : ViewConfigureWidget( ab, parent, name ) 57 : ViewConfigureWidget( ab, parent, name )
51{ 58{
52 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, 59 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null,
53 KGlobal::iconLoader()->loadIcon( "looknfeel", 60 KGlobal::iconLoader()->loadIcon( "looknfeel",
54 KIcon::Panel ) ); 61 KIcon::Panel ) );
55 62
56 mPage = new LookAndFeelPage( page ); 63 mPage = new LookAndFeelPage( page );
57} 64}
58 65
59ConfigureTableViewWidget::~ConfigureTableViewWidget() 66ConfigureTableViewWidget::~ConfigureTableViewWidget()
60{ 67{
61} 68}
62 69
63void ConfigureTableViewWidget::restoreSettings( KConfig *config ) 70void ConfigureTableViewWidget::restoreSettings( KConfig *config )
64{ 71{
65 ViewConfigureWidget::restoreSettings( config ); 72 ViewConfigureWidget::restoreSettings( config );
66 73
67 mPage->restoreSettings( config ); 74 mPage->restoreSettings( config );
68} 75}
69 76
70void ConfigureTableViewWidget::saveSettings( KConfig *config ) 77void ConfigureTableViewWidget::saveSettings( KConfig *config )
71{ 78{
72 ViewConfigureWidget::saveSettings( config ); 79 ViewConfigureWidget::saveSettings( config );
73 80
74 mPage->saveSettings( config ); 81 mPage->saveSettings( config );
75} 82}
76 83
77 84
78 85
79LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) 86LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name)
80 : QWidget(parent, name) 87 : QVBox(parent, name)
81{ 88{
82 initGUI(); 89 initGUI();
83 90
84 // Set initial state 91 // Set initial state
85 enableBackgroundToggled(mBackgroundBox->isChecked()); 92 enableBackgroundToggled(mBackgroundBox->isChecked());
86} 93}
87 94
88void LookAndFeelPage::restoreSettings( KConfig *config ) 95void LookAndFeelPage::restoreSettings( KConfig *config )
89{ 96{
90 mAlternateButton->setChecked(config->readBoolEntry("ABackground", true)); 97 mAlternateButton->setChecked(config->readBoolEntry("ABackground", true));
91 mLineButton->setChecked(config->readBoolEntry("SingleLine", false)); 98 mLineButton->setChecked(config->readBoolEntry("SingleLine", false));
92 mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true)); 99 mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true));
93 100
94 if (!mAlternateButton->isChecked() & !mLineButton->isChecked()) 101 if (!mAlternateButton->isChecked() & !mLineButton->isChecked())
95 mNoneButton->setChecked(true); 102 mNoneButton->setChecked(true);
96 103
97 mBackgroundBox->setChecked(config->readBoolEntry("Background", false)); 104 mBackgroundBox->setChecked(config->readBoolEntry("Background", false));
98 mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName")); 105 mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName"));
106
107 // colors
108 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) );
109 QColor c;
110qDebug("LookAndFeelPage::restoreSettings make base color configurable");
111
112#ifndef KAB_EMBEDDED
113 c = KGlobalSettings::baseColor();
114#else //KAB_EMBEDDED
115 c = QColor(0,0,0);
116#endif //KAB_EMBEDDED
117
118 lbColors->insertItem( new ColorListItem( i18n("Background Color"),
119 config->readColorEntry( "BackgroundColor", &c ) ) );
120 c = colorGroup().foreground();
121 lbColors->insertItem( new ColorListItem( i18n("Text Color"),
122 config->readColorEntry( "TextColor", &c ) ) );
123 c = colorGroup().button();
124 lbColors->insertItem( new ColorListItem( i18n("Header Background Color"),
125 config->readColorEntry( "HeaderBackgroundColor", &c ) ) );
126 c = colorGroup().buttonText();
127 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"),
128 config->readColorEntry( "HeaderTextColor", &c ) ) );
129 c = colorGroup().highlight();
130 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"),
131 config->readColorEntry( "HighlightColor", &c ) ) );
132 c = colorGroup().highlightedText();
133 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"),
134 config->readColorEntry( "HighlightedTextColor", &c ) ) );
135 c = colorGroup().background();
136 lbColors->insertItem( new ColorListItem( i18n("Alternating Background Color"),
137 config->readColorEntry( "AlternatingBackgroundColor", &c ) ) );
138
139 enableColors();
140
141 // fonts
142 QFont fnt = font();
143 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont );
144 fnt.setBold( true );
145 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont );
146 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) );
147 enableFonts();
148
99} 149}
100 150
101void LookAndFeelPage::saveSettings( KConfig *config ) 151void LookAndFeelPage::saveSettings( KConfig *config )
102{ 152{
103 config->writeEntry("ABackground", mAlternateButton->isChecked()); 153 config->writeEntry("ABackground", mAlternateButton->isChecked());
104 config->writeEntry("SingleLine", mLineButton->isChecked()); 154 config->writeEntry("SingleLine", mLineButton->isChecked());
105 config->writeEntry("ToolTips", mToolTipBox->isChecked()); 155 config->writeEntry("ToolTips", mToolTipBox->isChecked());
106 config->writeEntry("Background", mBackgroundBox->isChecked()); 156 config->writeEntry("Background", mBackgroundBox->isChecked());
107 config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text()); 157 config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text());
158
159 // colors
160 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() );
161 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm.
162 {
163 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) );
164 config->writeEntry( "TextColor", lbColors->color( 1 ) );
165 config->writeEntry( "HeaderBackgroundColor", lbColors->color( 2 ) );
166 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) );
167 config->writeEntry( "HighlightColor", lbColors->color( 4 ) );
168 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) );
169 config->writeEntry( "AlternatingBackgroundColor", lbColors->color( 6 ) );
170 }
171 // fonts
172 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() );
173 if ( cbEnableCustomFonts->isChecked() )
174 {
175 config->writeEntry( "TextFont", lTextFont->font() );
176 config->writeEntry( "HeaderFont", lHeaderFont->font() );
177 }
178
179}
180
181void LookAndFeelPage::setTextFont()
182{
183 QFont f( lTextFont->font() );
184#ifndef KAB_EMBEDDED
185 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted )
186 updateFontLabel( f, lTextFont );
187#else //KAB_EMBEDDED
188 bool ok;
189 QFont fout = KFontDialog::getFont( f, ok);
190 if ( ok )
191 updateFontLabel( fout, lTextFont );
192#endif //KAB_EMBEDDED
193}
194
195void LookAndFeelPage::setHeaderFont()
196{
197 QFont f( lHeaderFont->font() );
198#ifndef KAB_EMBEDDED
199 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted )
200 updateFontLabel( f, lHeaderFont );
201#else //KAB_EMBEDDED
202 bool ok;
203 QFont fout = KFontDialog::getFont( f, ok);
204 if ( ok )
205 updateFontLabel( fout, lHeaderFont );
206#endif //KAB_EMBEDDED
207}
208
209void LookAndFeelPage::enableFonts()
210{
211 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() );
212}
213
214void LookAndFeelPage::enableColors()
215{
216 lbColors->setEnabled( cbEnableCustomColors->isChecked() );
108} 217}
109 218
110void LookAndFeelPage::initGUI() 219void LookAndFeelPage::initGUI()
111{ 220{
112 QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialogBase::spacingHint()); 221 int spacing = KDialog::spacingHint();
113 222 int margin = KDialog::marginHint();
223
224 QTabWidget *tabs = new QTabWidget( this );
225
226 // General
227 QVBox *generalTab = new QVBox( this, "generaltab" );
228
229 generalTab->setSpacing( spacing );
230 generalTab->setMargin( margin );
231
114 QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal, 232 QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal,
115 i18n("Row Separator"), this); 233 i18n("Row Separator"), generalTab);
116 layout->addWidget(group);
117 234
118 mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"), 235 mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"),
119 group, "mAlternateButton"); 236 group, "mAlternateButton");
120 mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton"); 237 mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton");
121 mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton"); 238 mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton");
122 239
123 // Background Checkbox/Selector 240 mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab,
124 QHBoxLayout *backgroundLayout = new QHBoxLayout();
125 layout->addLayout(backgroundLayout);
126
127 mBackgroundBox = new QCheckBox(i18n("Enable background image:"), this,
128 "mBackgroundBox"); 241 "mBackgroundBox");
129 connect(mBackgroundBox, SIGNAL(toggled(bool)), 242 connect(mBackgroundBox, SIGNAL(toggled(bool)),
130 SLOT(enableBackgroundToggled(bool))); 243 SLOT(enableBackgroundToggled(bool)));
131 backgroundLayout->addWidget(mBackgroundBox);
132 244
133 mBackgroundName = new KURLRequester(this, "mBackgroundName"); 245 mBackgroundName = new KURLRequester(generalTab, "mBackgroundName");
134#ifndef KAB_EMBEDDED 246#ifndef KAB_EMBEDDED
135 mBackgroundName->setMode(KFile::File | KFile::ExistingOnly | 247 mBackgroundName->setMode(KFile::File | KFile::ExistingOnly |
136 KFile::LocalOnly); 248 KFile::LocalOnly);
137 mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading)); 249 mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading));
138#endif //KAB_EMBEDDED 250#endif //KAB_EMBEDDED
139 251
140 backgroundLayout->addWidget(mBackgroundName);
141
142 // ToolTip Checkbox 252 // ToolTip Checkbox
143 mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), this, 253 mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab,
144 "mToolTipBox"); 254 "mToolTipBox");
145 layout->addWidget(mToolTipBox); 255
256 tabs->addTab( generalTab, i18n("&General") );
257
258 // Colors
259 QVBox *colorTab = new QVBox( this, "colortab" );
260 colorTab->setSpacing( spacing );
261 colorTab->setMargin( spacing );
262 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab );
263 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) );
264 lbColors = new ColorListBox( colorTab );
265 tabs->addTab( colorTab, i18n("&Colors") );
266
267 QWhatsThis::add( cbEnableCustomColors, i18n(
268 "If custom colors are enabled, you may choose the colors for the view below. "
269 "Otherwise colors from your current KDE color scheme are used."
270 ) );
271 QWhatsThis::add( lbColors, i18n(
272 "Double click or press RETURN on a item to select a color for the related strings in the view."
273 ) );
274
275 // Fonts
276 QVBox *fntTab = new QVBox( this, "fonttab" );
277
278 fntTab->setSpacing( spacing );
279 fntTab->setMargin( spacing );
280
281 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab );
282 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) );
283
284 vbFonts = new QWidget( fntTab );
285 QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 );
286 gFnts->setSpacing( spacing );
287 gFnts->setAutoAdd( true );
288 gFnts->setColStretch( 1, 1 );
289 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts );
290 lTextFont = new QLabel( vbFonts );
291 lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken );
292#ifndef KAB_EMBEDDED
293 btnFont = new KPushButton( i18n("Choose..."), vbFonts );
294#else //KAB_EMBEDDED
295 btnFont = new QPushButton( i18n("Choose..."), vbFonts );
296#endif //KAB_EMBEDDED
297
298 lTFnt->setBuddy( btnFont );
299
300 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) );
301
302 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts );
303 lHeaderFont = new QLabel( vbFonts );
304 lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken );
305#ifndef KAB_EMBEDDED
306 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts );
307#else //KAB_EMBEDDED
308 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts );
309#endif //KAB_EMBEDDED
310 lHFnt->setBuddy( btnHeaderFont );
311 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) );
312
313 fntTab->setStretchFactor( new QWidget( fntTab ), 1 );
314
315 QWhatsThis::add( cbEnableCustomFonts, i18n(
316 "If custom fonts are enabled, you may choose which fonts to use for this view below. "
317 "Otherwise the default KDE font will be used, in bold style for the header and "
318 "normal style for the data."
319 ) );
320
321 tabs->addTab( fntTab, i18n("&Fonts") );
322
146} 323}
147 324
148void LookAndFeelPage::enableBackgroundToggled(bool enabled) 325void LookAndFeelPage::enableBackgroundToggled(bool enabled)
149{ 326{
150 mBackgroundName->setEnabled(enabled); 327 mBackgroundName->setEnabled(enabled);
151} 328}
152 329
330
331void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l )
332{
333 l->setFont( fnt );
334 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) );
335}
336
153#ifndef KAB_EMBEDDED 337#ifndef KAB_EMBEDDED
154#include "configuretableviewdialog.moc" 338#include "configuretableviewdialog.moc"
155#endif //KAB_EMBEDDED 339#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/configuretableviewdialog.h b/kaddressbook/views/configuretableviewdialog.h
index 8392710..003ccf8 100644
--- a/kaddressbook/views/configuretableviewdialog.h
+++ b/kaddressbook/views/configuretableviewdialog.h
@@ -1,88 +1,103 @@
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#ifndef CONFIGURETABLEVIEWDIALOG_H 24#ifndef CONFIGURETABLEVIEWDIALOG_H
25#define CONFIGURETABLEVIEWDIALOG_H 25#define CONFIGURETABLEVIEWDIALOG_H
26 26
27#include "viewconfigurewidget.h" 27#include "viewconfigurewidget.h"
28 28
29#include <qvbox.h>
30
29class QString; 31class QString;
30class QWidget; 32class QWidget;
31class QRadioButton; 33class QRadioButton;
32class QCheckBox; 34class QCheckBox;
33class KURLRequester; 35class KURLRequester;
34class KConfig; 36class KConfig;
37class QLabel;
35 38
36namespace KABC { class AddressBook; } 39namespace KABC { class AddressBook; }
37 40
38class LookAndFeelPage; 41class LookAndFeelPage;
39 42
40/** 43/**
41 Configure dialog for the table view. This dialog inherits from the 44 Configure dialog for the table view. This dialog inherits from the
42 standard view dialog in order to add a custom page for the table 45 standard view dialog in order to add a custom page for the table
43 view. 46 view.
44 */ 47 */
45class ConfigureTableViewWidget : public ViewConfigureWidget 48class ConfigureTableViewWidget : public ViewConfigureWidget
46{ 49{
47 public: 50 public:
48 ConfigureTableViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name ); 51 ConfigureTableViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name );
49 virtual ~ConfigureTableViewWidget(); 52 virtual ~ConfigureTableViewWidget();
50 53
51 virtual void restoreSettings( KConfig* ); 54 virtual void restoreSettings( KConfig* );
52 virtual void saveSettings( KConfig* ); 55 virtual void saveSettings( KConfig* );
53 56
54 private: 57 private:
55 void initGUI(); 58 void initGUI();
56 59
57 LookAndFeelPage *mPage; 60 LookAndFeelPage *mPage;
58}; 61};
59 62
60/** 63/**
61 Internal class. It is only defined here for moc 64 Internal class. It is only defined here for moc
62*/ 65*/
63class LookAndFeelPage : public QWidget 66class LookAndFeelPage : public QVBox
64{ 67{
65 Q_OBJECT 68 Q_OBJECT
66 69
67 public: 70 public:
68 LookAndFeelPage( QWidget *parent, const char *name = 0 ); 71 LookAndFeelPage( QWidget *parent, const char *name = 0 );
69 ~LookAndFeelPage() {} 72 ~LookAndFeelPage() {}
70 73
71 void restoreSettings( KConfig* ); 74 void restoreSettings( KConfig* );
72 void saveSettings( KConfig* ); 75 void saveSettings( KConfig* );
73 76
74 protected slots: 77 protected slots:
75 void enableBackgroundToggled( bool ); 78 void enableBackgroundToggled( bool );
76 79 void setTextFont();
80 void setHeaderFont();
81 void enableFonts();
82 void enableColors();
83
77 private: 84 private:
78 void initGUI(); 85 void initGUI();
79 86 void updateFontLabel( QFont, QLabel * );
87
88 QCheckBox *cbEnableCustomFonts,
89 *cbEnableCustomColors;
90 class ColorListBox *lbColors;
91 QLabel *lTextFont, *lHeaderFont;
92 class QPushButton *btnFont, *btnHeaderFont;
93 class QWidget* vbFonts;
94
80 QRadioButton *mAlternateButton; 95 QRadioButton *mAlternateButton;
81 QRadioButton *mLineButton; 96 QRadioButton *mLineButton;
82 QRadioButton *mNoneButton; 97 QRadioButton *mNoneButton;
83 QCheckBox *mToolTipBox; 98 QCheckBox *mToolTipBox;
84 KURLRequester *mBackgroundName; 99 KURLRequester *mBackgroundName;
85 QCheckBox *mBackgroundBox; 100 QCheckBox *mBackgroundBox;
86}; 101};
87 102
88#endif 103#endif