kitchensync Library API Documentation

konnectorview.cpp

00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 00020 */ 00021 00022 #include <configwidget.h> 00023 #include <klocale.h> 00024 #include <konnector.h> 00025 #include <konnectorinfo.h> 00026 #include <konnectormanager.h> 00027 00028 #include <qlayout.h> 00029 #include <qlistview.h> 00030 00031 #include "konnectorview.h" 00032 00033 using namespace KSync; 00034 00035 class KonnectorCheckItem : public QCheckListItem 00036 { 00037 public: 00038 KonnectorCheckItem( Konnector *konnector, QListView *view ) 00039 : QCheckListItem( view, konnector->resourceName(), CheckBox ), 00040 mKonnector( konnector ) 00041 { 00042 } 00043 00044 Konnector *konnector() const { return mKonnector; } 00045 00046 private: 00047 Konnector *mKonnector; 00048 }; 00049 00050 00051 KonnectorView::KonnectorView( QWidget *parent, const char *name ) 00052 : QWidget( parent, name ) 00053 { 00054 QBoxLayout *topLayout = new QVBoxLayout( this ); 00055 00056 mKonnectorList = new KListView( this ); 00057 mKonnectorList->addColumn( i18n( "Konnector" ) ); 00058 mKonnectorList->setAllColumnsShowFocus( true ); 00059 mKonnectorList->setFullWidth( true ); 00060 00061 topLayout->addWidget( mKonnectorList, 1 ); 00062 00063 updateKonnectorList(); 00064 } 00065 00066 void KonnectorView::updateKonnectorList() 00067 { 00068 mKonnectorList->clear(); 00069 00070 KRES::Manager<Konnector> *manager = KonnectorManager::self(); 00071 00072 KRES::Manager<Konnector>::ActiveIterator it; 00073 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 00074 KonnectorCheckItem *item = new KonnectorCheckItem( *it, mKonnectorList ); 00075 item->setOn( true ); 00076 } 00077 } 00078 00079 Konnector::List KonnectorView::selectedKonnectors() 00080 { 00081 Konnector::List result; 00082 00083 QListViewItemIterator it( mKonnectorList ); 00084 while ( it.current() ) { 00085 KonnectorCheckItem *item = static_cast<KonnectorCheckItem *>( it.current() ); 00086 if ( item->isOn() ) { 00087 result.append( item->konnector() ); 00088 } 00089 ++it; 00090 } 00091 00092 return result; 00093 } 00094 00095 #include "konnectorview.moc"
KDE Logo
This file is part of the documentation for kitchensync Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:50:48 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003