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

tdeabc

  • tdeabc
resourceselectdialog.cpp
1 /*
2  This file is part of libtdeabc.
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 <tdelocale.h>
22 #include <kbuttonbox.h>
23 #include <tdelistbox.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 TDEABC;
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 TDEListBox( 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"
TDEABC::AddressBook
Address Book.
Definition: addressbook.h:43
KButtonBox::addButton
TQPushButton * addButton(const TQString &text, bool noexpand=false)
TDEABC::ResourceSelectDialog
This class is.
Definition: resourceselectdialog.h:39
KDialog
KButtonBox
TDEABC
static data, shared by ALL addressee objects
Definition: address.h:48
KButtonBox::layout
void layout()
tdelocale.h
TDEABC::AddressBook::resources
TQPtrList< Resource > resources()
Returns a list of all resources.
Definition: addressbook.cpp:751
TDEListBox
KButtonBox::addStretch
void addStretch(int scale=1)

tdeabc

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

tdeabc

Skip menu "tdeabc"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeabc by doxygen 1.8.8
This website is maintained by Timothy Pearson.