• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kabc
 

kabc

resourcedirconfig.cpp
00001 /*
00002     This file is part of libkabc.
00003     Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library 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 GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include <tqlabel.h>
00022 #include <tqlayout.h>
00023 
00024 #include <kdebug.h>
00025 #include <klocale.h>
00026 #include <kstandarddirs.h>
00027 #include <kdialog.h>
00028 
00029 #include "formatfactory.h"
00030 #include "resourcedir.h"
00031 #include "stdaddressbook.h"
00032 
00033 #include "resourcedirconfig.h"
00034 
00035 using namespace KABC;
00036 
00037 ResourceDirConfig::ResourceDirConfig( TQWidget* parent,  const char* name )
00038     : KRES::ConfigWidget( parent, name )
00039 {
00040   TQGridLayout *mainLayout = new TQGridLayout( this, 2, 2, 0, 
00041       KDialog::spacingHint() );
00042 
00043   TQLabel *label = new TQLabel( i18n( "Format:" ), this );
00044   mFormatBox = new KComboBox( this );
00045 
00046   mainLayout->addWidget( label, 0, 0 );
00047   mainLayout->addWidget( mFormatBox, 0, 1 );
00048 
00049   label = new TQLabel( i18n( "Location:" ), this );
00050   mFileNameEdit = new KURLRequester( this );
00051   mFileNameEdit->setMode( KFile::Directory );
00052 
00053   mainLayout->addWidget( label, 1, 0 );
00054   mainLayout->addWidget( mFileNameEdit, 1, 1 );
00055 
00056   FormatFactory *factory = FormatFactory::self();
00057   TQStringList formats = factory->formats();
00058   TQStringList::Iterator it;
00059   for ( it = formats.begin(); it != formats.end(); ++it ) {
00060     FormatInfo *info = factory->info( *it );
00061     if ( info ) {
00062       mFormatTypes << (*it);
00063       mFormatBox->insertItem( info->nameLabel );
00064     }
00065   }
00066 
00067   mInEditMode = false;
00068 }
00069 
00070 void ResourceDirConfig::setEditMode( bool value )
00071 {
00072   mFormatBox->setEnabled( !value );
00073   mInEditMode = value;
00074 }
00075 
00076 void ResourceDirConfig::loadSettings( KRES::Resource *res )
00077 {
00078   ResourceDir *resource = dynamic_cast<ResourceDir*>( res );
00079   
00080   if ( !resource ) {
00081     kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl;
00082     return;
00083   }
00084 
00085   mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) );
00086 
00087   mFileNameEdit->setURL( resource->path() );
00088   if ( mFileNameEdit->url().isEmpty() )
00089     mFileNameEdit->setURL( KABC::StdAddressBook::directoryName() );
00090 }
00091 
00092 void ResourceDirConfig::saveSettings( KRES::Resource *res )
00093 {
00094   ResourceDir *resource = dynamic_cast<ResourceDir*>( res );
00095   
00096   if ( !resource ) {
00097     kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl;
00098     return;
00099   }
00100 
00101   if ( mInEditMode )
00102     resource->setFormat( mFormatTypes[ mFormatBox->currentItem() ] );
00103 
00104   resource->setPath( mFileNameEdit->url() );
00105 }
00106 
00107 #include "resourcedirconfig.moc"

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kabc

Skip menu "kabc"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kabc by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |