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

kabc

  • kabc
resourceselectdialog.cpp
1 /*
2  This file is part of libkabc.
3  Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library 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 GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include <klocale.h>
22 #include <kbuttonbox.h>
23 #include <klistbox.h>
24 #include <kstdguiitem.h>
25 
26 #include <tqgroupbox.h>
27 #include <tqlayout.h>
28 
29 #include "resource.h"
30 #include "addressbook.h"
31 
32 #include "resourceselectdialog.h"
33 
34 using namespace KABC;
35 
36 ResourceSelectDialog::ResourceSelectDialog( AddressBook *ab, TQWidget *parent, const char *name )
37  : KDialog( parent, name, true )
38 {
39  setCaption( i18n( "Resource Selection" ) );
40  resize( 300, 200 );
41 
42  TQVBoxLayout *mainLayout = new TQVBoxLayout( this );
43  mainLayout->setMargin( marginHint() );
44 
45  TQGroupBox *groupBox = new TQGroupBox( 2, Qt::Horizontal, this );
46  groupBox->setTitle( i18n( "Resources" ) );
47 
48  mResourceId = new KListBox( groupBox );
49 
50  mainLayout->addWidget( groupBox );
51 
52  mainLayout->addSpacing( 10 );
53 
54  KButtonBox *buttonBox = new KButtonBox( this );
55 
56  buttonBox->addStretch();
57  buttonBox->addButton( KStdGuiItem::ok(), TQT_TQOBJECT(this), TQT_SLOT( accept() ) );
58  buttonBox->addButton( KStdGuiItem::cancel(), TQT_TQOBJECT(this), TQT_SLOT( reject() ) );
59  buttonBox->layout();
60 
61  mainLayout->addWidget( buttonBox );
62 
63  // setup listbox
64  uint counter = 0;
65  TQPtrList<Resource> list = ab->resources();
66  for ( uint i = 0; i < list.count(); ++i ) {
67  Resource *resource = list.at( i );
68  if ( resource && !resource->readOnly() ) {
69  mResourceMap.insert( counter, resource );
70  mResourceId->insertItem( resource->resourceName() );
71  counter++;
72  }
73  }
74 
75  mResourceId->setCurrentItem( 0 );
76 }
77 
78 Resource *ResourceSelectDialog::resource()
79 {
80  if ( mResourceId->currentItem() != -1 )
81  return mResourceMap[ mResourceId->currentItem() ];
82  else
83  return 0;
84 }
85 
86 Resource *ResourceSelectDialog::getResource( AddressBook *ab, TQWidget *parent )
87 {
88  TQPtrList<Resource> resources = ab->resources();
89  if ( resources.count() == 1 ) return resources.first();
90 
91  Resource *found = 0;
92  Resource *r = resources.first();
93  while( r ) {
94  if ( !r->readOnly() ) {
95  if ( found ) {
96  found = 0;
97  break;
98  } else {
99  found = r;
100  }
101  }
102  r = resources.next();
103  }
104  if ( found ) return found;
105 
106  ResourceSelectDialog dlg( ab, parent );
107  if ( dlg.exec() == KDialog::Accepted ) return dlg.resource();
108  else return 0;
109 }
110 
111 #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.8.1.2
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |