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

kabc

resourceselectdialog.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 <klocale.h>
00022 #include <kbuttonbox.h>
00023 #include <klistbox.h>
00024 #include <kstdguiitem.h>
00025 
00026 #include <tqgroupbox.h>
00027 #include <tqlayout.h>
00028 
00029 #include "resource.h"
00030 #include "addressbook.h"
00031 
00032 #include "resourceselectdialog.h"
00033 
00034 using namespace KABC;
00035 
00036 ResourceSelectDialog::ResourceSelectDialog( AddressBook *ab, TQWidget *parent, const char *name )
00037     : KDialog( parent, name, true )
00038 {
00039   setCaption( i18n( "Resource Selection" ) );
00040   resize( 300, 200 );
00041 
00042   TQVBoxLayout *mainLayout = new TQVBoxLayout( this );
00043   mainLayout->setMargin( marginHint() );
00044 
00045   TQGroupBox *groupBox = new TQGroupBox( 2, Qt::Horizontal,  this );
00046   groupBox->setTitle( i18n( "Resources" ) );
00047 
00048   mResourceId = new KListBox( groupBox );
00049 
00050   mainLayout->addWidget( groupBox );
00051 
00052   mainLayout->addSpacing( 10 );
00053 
00054   KButtonBox *buttonBox = new KButtonBox( this );
00055 
00056   buttonBox->addStretch();
00057   buttonBox->addButton(  KStdGuiItem::ok(), TQT_TQOBJECT(this), TQT_SLOT( accept() ) );
00058   buttonBox->addButton(  KStdGuiItem::cancel(), TQT_TQOBJECT(this), TQT_SLOT( reject() ) );
00059   buttonBox->layout();
00060 
00061   mainLayout->addWidget( buttonBox );
00062 
00063   // setup listbox
00064   uint counter = 0;
00065   TQPtrList<Resource> list = ab->resources();
00066   for ( uint i = 0; i < list.count(); ++i ) {
00067     Resource *resource = list.at( i );
00068     if ( resource && !resource->readOnly() ) {
00069       mResourceMap.insert( counter, resource );
00070       mResourceId->insertItem( resource->resourceName() );
00071       counter++;
00072     }
00073   }
00074 
00075   mResourceId->setCurrentItem( 0 );
00076 }
00077 
00078 Resource *ResourceSelectDialog::resource()
00079 {
00080   if ( mResourceId->currentItem() != -1 )
00081     return mResourceMap[ mResourceId->currentItem() ];
00082   else
00083     return 0;
00084 }
00085 
00086 Resource *ResourceSelectDialog::getResource( AddressBook *ab, TQWidget *parent )
00087 {
00088   TQPtrList<Resource> resources = ab->resources();
00089   if ( resources.count() == 1 ) return resources.first();
00090 
00091   Resource *found = 0;
00092   Resource *r = resources.first();
00093   while( r ) {
00094     if ( !r->readOnly() ) {
00095       if ( found ) {
00096         found = 0;
00097         break;
00098       } else {
00099         found = r;
00100       }
00101     }
00102     r = resources.next();
00103   }
00104   if ( found ) return found;
00105 
00106   ResourceSelectDialog dlg( ab, parent );
00107   if ( dlg.exec() == KDialog::Accepted ) return dlg.resource();
00108   else return 0;
00109 }
00110 
00111 #include "resourceselectdialog.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. |