kontact Library API Documentation

kcmkontact.cpp

00001 /*
00002     This file is part of KDE Kontact.
00003 
00004     Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program 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
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #include "kcmkontact.h"
00026 #include "prefs.h"
00027 
00028 #include <kaboutdata.h>
00029 #include <kdebug.h>
00030 #include <klistview.h>
00031 #include <klocale.h>
00032 #include <ktrader.h>
00033 
00034 #include <qlayout.h>
00035 #include <qlabel.h>
00036 #include <qbuttongroup.h>
00037 
00038 extern "C"
00039 {
00040   KCModule *create_kontactconfig( QWidget *parent, const char * ) {
00041     return new KcmKontact( parent, "kcmkontact" );
00042   }
00043 }
00044 
00045 class PluginItem : public QCheckListItem
00046 {
00047   public:
00048     PluginItem( const KService::Ptr &ptr, QListView *parent,
00049                 const QString &text )
00050       : QCheckListItem( parent, text, QCheckListItem::CheckBox ),
00051         mPtr( ptr )
00052     {
00053     }
00054 
00055     KService::Ptr servicePtr() const
00056     {
00057       return mPtr;
00058     }
00059 
00060     virtual QString text( int column ) const
00061     {
00062       if ( column == 0 )
00063         return mPtr->name();
00064       else if ( column == 1 )
00065         return mPtr->comment();
00066       else
00067         return QString::null;
00068     }
00069 
00070   private:
00071     KService::Ptr mPtr;
00072 };
00073 
00074 KcmKontact::KcmKontact( QWidget *parent, const char *name )
00075   : KPrefsModule( Kontact::Prefs::self(), parent, name )
00076 {
00077   QVBoxLayout *topLayout = new QVBoxLayout( this );
00078 
00079 #if 0
00080   KPrefsWidRadios *radios = addWidRadios( Kontact::Prefs::self()->sidePaneTypeItem(),
00081                                           this );
00082   topLayout->addWidget( radios->groupBox() );
00083 #endif
00084 
00085   load();
00086 }
00087 
00088 const KAboutData* KcmKontact::aboutData() const
00089 {
00090   KAboutData *about = new KAboutData( I18N_NOOP( "kontactconfig" ),
00091                                       I18N_NOOP( "KDE Kontact" ),
00092                                       0, 0, KAboutData::License_GPL,
00093                                       I18N_NOOP( "(c), 2003 Cornelius Schumacher" ) );
00094 
00095   about->addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" );
00096   about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" );
00097 
00098   return about;
00099 }
00100 
00101 
00102 PluginSelection::PluginSelection( const QString &text, QStringList &reference,
00103                                   QWidget *parent )
00104   : mReference( reference )
00105 {
00106   mBox = new QGroupBox( 0, Qt::Vertical, text, parent );
00107   QVBoxLayout *boxLayout = new QVBoxLayout( mBox->layout() );
00108   boxLayout->setAlignment( Qt::AlignTop );
00109 
00110   mPluginView = new KListView( mBox );
00111   mPluginView->setAllColumnsShowFocus( true );
00112   mPluginView->addColumn( i18n( "Name" ) );
00113   mPluginView->addColumn( i18n( "Description" ) );
00114   boxLayout->addWidget( mPluginView );
00115 
00116   connect( mPluginView, SIGNAL( clicked( QListViewItem* ) ),
00117            SLOT( itemClicked( QListViewItem* ) ) );
00118 }
00119 
00120 PluginSelection::~PluginSelection()
00121 {
00122 }
00123 
00124 QGroupBox *PluginSelection::groupBox()  const
00125 {
00126   return mBox;
00127 }
00128 
00129 void PluginSelection::readConfig()
00130 {
00131   mPluginView->clear();
00132 }
00133 
00134 void PluginSelection::writeConfig()
00135 {
00136   mReference.clear();
00137 
00138   QPtrList<QListViewItem> list;
00139   QListViewItemIterator it( mPluginView );
00140   while ( it.current() ) {
00141     PluginItem *item = static_cast<PluginItem*>( it.current() );
00142     if ( item ) {
00143       if ( item->isOn() )
00144         mReference.append( item->servicePtr()->
00145                            property( "X-KDE-KontactIdentifier" ).toString() );
00146     }
00147     ++it;
00148   }
00149 }
00150 
00151 void PluginSelection::itemClicked( QListViewItem *item )
00152 {
00153   if ( item != 0 )
00154     emit changed();
00155 }
00156 
00157 #include "kcmkontact.moc"
KDE Logo
This file is part of the documentation for kontact Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:39:00 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003