konnectorview.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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"
This file is part of the documentation for kitchensync Library Version 3.3.2.