Need to store config when changing units, if not very bad things happen
[kdepim.git] / kaddressbook / viewconfigurewidget.cpp
blobf8e883f0bf05b6bf330a0c3bad5d30125a3903e4
1 /*
2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
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
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
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
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
24 #include <qlayout.h>
25 #include <qvbox.h>
27 #include <kapplication.h>
28 #include <kconfig.h>
29 #include <kdebug.h>
30 #include <kglobal.h>
31 #include <kiconloader.h>
32 #include <klocale.h>
34 #include "viewconfigurefieldspage.h"
35 #include "viewconfigurefilterpage.h"
36 #include "viewmanager.h"
38 #include "viewconfigurewidget.h"
40 ViewConfigureWidget::ViewConfigureWidget( KABC::AddressBook *ab, QWidget *parent,
41 const char *name )
42 : KAB::ConfigureWidget( ab, parent, name )
44 QVBoxLayout *topLayout = new QVBoxLayout( this );
46 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::IconList );
47 topLayout->addWidget( mMainWidget );
49 // Add the first page, the attributes
50 QVBox *page = addPage( i18n( "Fields" ), QString::null,
51 KGlobal::iconLoader()->loadIcon( "view_detailed",
52 KIcon::Panel ) );
54 // Add the select fields page
55 mFieldsPage = new ViewConfigureFieldsPage( addressBook(), page );
57 // Add the second page, the filter selection
58 page = addPage( i18n( "Default Filter" ), QString::null,
59 KGlobal::iconLoader()->loadIcon( "filter",
60 KIcon::Panel ) );
62 mFilterPage = new ViewConfigureFilterPage( page );
65 ViewConfigureWidget::~ViewConfigureWidget()
69 void ViewConfigureWidget::restoreSettings( KConfig *config )
71 mFieldsPage->restoreSettings( config );
72 mFilterPage->restoreSettings( config );
75 void ViewConfigureWidget::saveSettings( KConfig *config )
77 mFieldsPage->saveSettings( config );
78 mFilterPage->saveSettings( config );
81 QVBox *ViewConfigureWidget::addPage( const QString &item, const QString &header,
82 const QPixmap &pixmap )
84 return mMainWidget->addVBoxPage( item, header, pixmap );
87 ViewConfigureDialog::ViewConfigureDialog( ViewConfigureWidget *wdg, const QString &viewName,
88 QWidget *parent, const char *name )
89 : KDialogBase( Swallow, i18n( "Modify View: " ) + viewName, Help | Ok | Cancel,
90 Ok, parent, name, true, true ), mConfigWidget( wdg )
92 setMainWidget( mConfigWidget );
94 resize( 600, 300 );
97 ViewConfigureDialog::~ViewConfigureDialog()
101 void ViewConfigureDialog::restoreSettings( KConfig *config )
103 mConfigWidget->restoreSettings( config );
106 void ViewConfigureDialog::saveSettings( KConfig *config )
108 mConfigWidget->saveSettings( config );
111 void ViewConfigureDialog::slotHelp()
113 kapp->invokeHelp( "using-views" );
116 #include "viewconfigurewidget.moc"