kaddressbook Library API Documentation

configureviewdialog.cpp

00001 /*
00002     This file is part of KAddressBook.                                  
00003     Copyright (c) 2002 Mike Pilone <mpilone@slac.com>                   
00004                                                                         
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or   
00008     (at your option) any later version.                                 
00009                                                                         
00010     This program is distributed in the hope that it will be useful,     
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of      
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the        
00013     GNU General Public License for more details.                        
00014                                                                         
00015     You should have received a copy of the GNU General Public License   
00016     along with this program; if not, write to the Free Software         
00017     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.           
00018                                                                         
00019     As a special exception, permission is given to link this program    
00020     with any edition of Qt, and distribute the resulting executable,    
00021     without including the source code for Qt in the source distribution.
00022 */                                                                      
00023 
00024 #include <qvbox.h>
00025 
00026 #include <kconfig.h>
00027 #include <klocale.h>
00028 #include <kglobal.h>
00029 #include <kdebug.h>
00030 #include <kiconloader.h>
00031 
00032 #include "selectfieldswidget.h"
00033 #include "configureviewfilterpage.h"
00034 #include "configureviewdialog.h"
00035 
00036 ConfigureViewDialog::ConfigureViewDialog(const QString &viewName,
00037                                          KABC::AddressBook *document, 
00038                                          QWidget *parent, 
00039                                          const char *name)
00040     : KDialogBase(KDialogBase::IconList, 
00041                   QString( i18n("Modify View: ") ) + viewName,
00042                   KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
00043                   parent, name, true, true)
00044 {
00045     initGUI( document );
00046 }
00047 
00048 ConfigureViewDialog::~ConfigureViewDialog()
00049 {
00050 }
00051 
00052 void ConfigureViewDialog::readConfig(KConfig *config)
00053 {
00054   KABC::Field::List fields = KABC::Field::restoreFields( config, "KABCFields" );
00055 
00056   if ( fields.isEmpty() ) {
00057     fields = KABC::Field::defaultFields();
00058   }
00059   
00060   mSelectFieldsWidget->setSelectedFields( fields );
00061   mFilterPage->readConfig(config);
00062 }
00063 
00064 void ConfigureViewDialog::writeConfig(KConfig *config)
00065 {
00066   kdDebug() << "ConfigureViewDialog::writeConfig()" << endl;
00067 
00068   KABC::Field::List fields = mSelectFieldsWidget->selectedFields();
00069 
00070   KABC::Field::saveFields( config, "KABCFields", fields );
00071   
00072   mFilterPage->writeConfig(config);
00073 }
00074     
00075 void ConfigureViewDialog::initGUI( KABC::AddressBook *document )
00076 {
00077   // Add the first page, the attributes
00078   QVBox *page = addVBoxPage(i18n("Select Fields"), QString::null,
00079                             KGlobal::iconLoader()
00080                             ->loadIcon("view_detailed", KIcon::Desktop));
00081 
00082   // Add the select fields widget 
00083   mSelectFieldsWidget = new SelectFieldsWidget( document, page,
00084                                                 "mSelectFieldsWidget");
00085                                                 
00086   // Add the second page, the filter selection
00087   page = addVBoxPage(i18n("Default Filter"), QString::null,
00088                      KGlobal::iconLoader()
00089                      ->loadIcon("filter", KIcon::Desktop));
00090   mFilterPage = new ConfigureViewFilterPage(page, "mFilterPage");
00091 }
00092 
00093 #include "configureviewdialog.moc"
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:36 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001