kaddressbook

viewconfigurewidget.cpp
1 /*
2  This file is part of KAddressBook.
3  Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 
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.
9 
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.
14 
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.
18 
19  As a special exception, permission is given to link this program
20  with any edition of TQt, and distribute the resulting executable,
21  without including the source code for TQt in the source distribution.
22 */
23 
24 #include <tqlayout.h>
25 #include <tqvbox.h>
26 
27 #include <tdeapplication.h>
28 #include <tdeconfig.h>
29 #include <kdebug.h>
30 #include <tdeglobal.h>
31 #include <kiconloader.h>
32 #include <tdelocale.h>
33 
34 #include "viewconfigurefieldspage.h"
35 #include "viewconfigurefilterpage.h"
36 #include "viewmanager.h"
37 
38 #include "viewconfigurewidget.h"
39 
40 ViewConfigureWidget::ViewConfigureWidget( TDEABC::AddressBook *ab, TQWidget *parent,
41  const char *name )
42  : KAB::ConfigureWidget( ab, parent, name )
43 {
44  TQVBoxLayout *topLayout = new TQVBoxLayout( this );
45 
46  mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::IconList );
47  topLayout->addWidget( mMainWidget );
48 
49  // Add the first page, the attributes
50  TQVBox *page = addPage( i18n( "Fields" ), TQString(),
51  TDEGlobal::iconLoader()->loadIcon( "view_detailed",
52  TDEIcon::Panel ) );
53 
54  // Add the select fields page
55  mFieldsPage = new ViewConfigureFieldsPage( addressBook(), page );
56 
57  // Add the second page, the filter selection
58  page = addPage( i18n( "Default Filter" ), TQString(),
59  TDEGlobal::iconLoader()->loadIcon( "filter",
60  TDEIcon::Panel ) );
61 
62  mFilterPage = new ViewConfigureFilterPage( page );
63 }
64 
65 ViewConfigureWidget::~ViewConfigureWidget()
66 {
67 }
68 
69 void ViewConfigureWidget::restoreSettings( TDEConfig *config )
70 {
71  mFieldsPage->restoreSettings( config );
72  mFilterPage->restoreSettings( config );
73 }
74 
75 void ViewConfigureWidget::saveSettings( TDEConfig *config )
76 {
77  mFieldsPage->saveSettings( config );
78  mFilterPage->saveSettings( config );
79 }
80 
81 TQVBox *ViewConfigureWidget::addPage( const TQString &item, const TQString &header,
82  const TQPixmap &pixmap )
83 {
84  return mMainWidget->addVBoxPage( item, header, pixmap );
85 }
86 
87 ViewConfigureDialog::ViewConfigureDialog( ViewConfigureWidget *wdg, const TQString &viewName,
88  TQWidget *parent, const char *name )
89  : KDialogBase( Swallow, i18n( "Modify View: " ) + viewName, Help | Ok | Cancel,
90  Ok, parent, name, true, true ), mConfigWidget( wdg )
91 {
92  setMainWidget( mConfigWidget );
93 
94  resize( 600, 300 );
95 }
96 
97 ViewConfigureDialog::~ViewConfigureDialog()
98 {
99 }
100 
101 void ViewConfigureDialog::restoreSettings( TDEConfig *config )
102 {
103  mConfigWidget->restoreSettings( config );
104 }
105 
106 void ViewConfigureDialog::saveSettings( TDEConfig *config )
107 {
108  mConfigWidget->saveSettings( config );
109 }
110 
111 void ViewConfigureDialog::slotHelp()
112 {
113  kapp->invokeHelp( "using-views" );
114 }
115 
116 #include "viewconfigurewidget.moc"
This widget is the base class for all view configuration widgets.
virtual void restoreSettings(TDEConfig *config)
Reads the configuration from the config object and sets the values in the GUI.
virtual void saveSettings(TDEConfig *config)
Writes the configuration from the GUI to the config object.
TQVBox * addPage(const TQString &item, const TQString &header=TQString(), const TQPixmap &pixmap=TQPixmap())
Use this method to add new pages to the widget.