kaddressbook Library API Documentation

kaddressbookmain.cpp

00001 /*
00002  * kaddressbookmain.cpp
00003  *
00004  * Copyright (C) 1999 Don Sanders <dsanders@kde.org>
00005  */
00006 
00007 #include <qclipboard.h>
00008 
00009 #include <kiconloader.h>
00010 #include <klocale.h>
00011 #include <kglobal.h>
00012 #include <kmenubar.h>
00013 #include <kconfig.h>
00014 #include <kaccel.h>
00015 #include <kdebug.h>
00016 #include <kaction.h>
00017 #include <kstdaction.h>
00018 #include <kstatusbar.h>
00019 #include <kstandarddirs.h>
00020 #include <kmessagebox.h>
00021 #include <kprocess.h>
00022 #include <kprotocolinfo.h>
00023 #include <kedittoolbar.h>
00024 #include <kkeydialog.h>
00025 
00026 #include "kaddressbook.h"
00027 #include "actionmanager.h"
00028 #include "incsearchwidget.h"
00029 #include "kaddressbookmain.h"
00030 #include "kaddressbookmain.moc"
00031 
00032 KAddressBookMain::KAddressBookMain()
00033   : KMainWindow(0), DCOPObject("KAddressBookIface")
00034 {
00035     setCaption( i18n( "Address Book Browser" ));
00036 
00037     mWidget = new KAddressBook( this, "KAddressBook" );
00038 
00039     mActionManager = new ActionManager(this, mWidget, true, this);
00040 
00041     initActions();
00042 
00043     // tell the KMainWindow that this is indeed the main widget
00044     setCentralWidget(mWidget);
00045 
00046     // we do want a status bar
00047     statusBar()->show();
00048 
00049     // Tell the central widget to read its config
00050     mWidget->readConfig();
00051 
00052     // Finally create the GUI
00053     createGUI( "kaddressbookui.rc", false );
00054     // <HACK reason="there is no line edit action">
00055     // create the incremental search line edit manually:
00056     const int IncSearch=1; //the ID of the widget - just to be clear :-)
00057     KToolBar *isToolBar=toolBar("incSearchToolBar");
00058     IncSearchWidget *incSearchWidget=new IncSearchWidget(isToolBar);
00059     isToolBar->insertWidget(IncSearch, 0,  incSearchWidget, 0);
00060     isToolBar->setItemAutoSized(IncSearch);
00061     mWidget->setIncSearchWidget(incSearchWidget);
00062     // </HACK>
00063     mActionManager->initActionViewList();
00064 
00065     setAutoSaveSettings();
00066 }
00067 
00068 KAddressBookMain::~KAddressBookMain()
00069 {
00070     mWidget->writeConfig();
00071 }
00072 
00073 void KAddressBookMain::saveProperties(KConfig *)
00074 {
00075   // the 'config' object points to the session managed
00076   // config file.  anything you write here will be available
00077   // later when this app is restored
00078 
00079   //what I want to save
00080   //windowsize
00081   //background image/underlining color/alternating color1,2
00082   //chosen fields
00083   //chosen fieldsWidths
00084 
00085   // e.g., config->writeEntry("key", var);
00086 }
00087 
00088 void KAddressBookMain::readProperties(KConfig *)
00089 {
00090   // the 'config' object points to the session managed
00091   // config file.  this function is automatically called whenever
00092   // the app is being restored.  read in here whatever you wrote
00093   // in 'saveProperties'
00094 
00095   // e.g., var = config->readEntry("key");
00096 }
00097 
00098 void KAddressBookMain::initActions()
00099 {
00100   KStdAction::quit( this, SLOT(close()), actionCollection() );
00101 
00102   KStdAction::preferences( mWidget, SLOT( configure() ), actionCollection() );
00103   KStdAction::configureToolbars( this, SLOT( configureToolbars() ),
00104                                  actionCollection() );
00105   KStdAction::keyBindings(this, SLOT( configureKeys()), actionCollection() );
00106 }
00107 
00108 void KAddressBookMain::configureToolbars()
00109 {
00110   saveMainWindowSettings( KGlobal::config(), "MainWindow" );
00111 
00112   KEditToolbar dlg(factory());
00113   connect(&dlg,SIGNAL(newToolbarConfig()),this,SLOT(slotNewToolbarConfig()));
00114 
00115   dlg.exec();
00116 }
00117 
00118 void KAddressBookMain::slotNewToolbarConfig()
00119 {
00120   mActionManager->initActionViewList();
00121 
00122   applyMainWindowSettings( KGlobal::config(), "MainWindow" );
00123 }
00124 
00125 void KAddressBookMain::configureKeys()
00126 {
00127   KKeyDialog::configureKeys(actionCollection(),xmlFile(),true,this);
00128 }
00129 
00130 bool KAddressBookMain::queryClose()
00131 {
00132   if ( mActionManager->isModified() ) {
00133     QString text = i18n( "The address book was modified. Do you want to save your changes?" );
00134     int ret = KMessageBox::warningYesNoCancel( this, text, "",
00135                                               KStdGuiItem::yes(),
00136                                               KStdGuiItem::no(), "AskForSave" );
00137     switch ( ret ) {
00138       case KMessageBox::Yes:
00139         mWidget->save();
00140         break;
00141       case KMessageBox::No:
00142         return true;
00143         break;
00144       default: //cancel
00145         return false;
00146         break;
00147     }
00148   }
00149 
00150   return true;
00151 }
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:37 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001