• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kontact

kcmkontact.cpp

Go to the documentation of this file.
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 along
00017   with this program; if not, write to the Free Software Foundation, Inc.,
00018   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 <kdemacros.h>
00029 #include <kcomponentdata.h>
00030 #include <kaboutdata.h>
00031 #include <kdebug.h>
00032 #include <k3listview.h>
00033 #include <klocale.h>
00034 #include <kservicetypetrader.h>
00035 #include <kcombobox.h>
00036 
00037 #include <q3buttongroup.h>
00038 #include <QCheckBox>
00039 #include <QLabel>
00040 #include <QLayout>
00041 #include <QVBoxLayout>
00042 #include <QHBoxLayout>
00043 #include <QBoxLayout>
00044 
00045 extern "C"
00046 {
00047   KDE_EXPORT KCModule *create_kontactconfig( QWidget *parent, const char * ) {
00048     KComponentData inst( "kcmkontact" );
00049     return new KcmKontact( inst, parent );
00050   }
00051 }
00052 
00053 class PluginItem : public Q3ListViewItem
00054 {
00055   public:
00056     PluginItem( Q3ListView *parent, const KService::Ptr &ptr )
00057       : Q3ListViewItem( parent, ptr->name(), ptr->comment(), ptr->library() ),
00058         mPtr( ptr )
00059     {
00060     }
00061 
00062     KService::Ptr servicePtr() const
00063     {
00064       return mPtr;
00065     }
00066 
00067   private:
00068     KService::Ptr mPtr;
00069 };
00070 
00071 KcmKontact::KcmKontact( const KComponentData &inst, QWidget *parent )
00072   : KPrefsModule( Kontact::Prefs::self(), inst, parent )
00073 {
00074   QBoxLayout *topLayout = new QVBoxLayout( this );
00075   QBoxLayout *pluginStartupLayout = new QHBoxLayout();
00076   topLayout->addItem( pluginStartupLayout );
00077   topLayout->addStretch();
00078 
00079   KPrefsWidBool *forceStartupPlugin =
00080     addWidBool( Kontact::Prefs::self()->forceStartupPluginItem(), this );
00081   pluginStartupLayout->addWidget( forceStartupPlugin->checkBox() );
00082 
00083   PluginSelection *selection =
00084     new PluginSelection( Kontact::Prefs::self()->forcedStartupPluginItem(), this );
00085   addWid( selection );
00086 
00087   pluginStartupLayout->addWidget( selection->comboBox() );
00088   selection->comboBox()->setEnabled( false );
00089 
00090   connect( forceStartupPlugin->checkBox(), SIGNAL(toggled(bool)),
00091            selection->comboBox(), SLOT(setEnabled(bool)) );
00092   load();
00093 }
00094 
00095 const KAboutData *KcmKontact::aboutData() const
00096 {
00097   KAboutData *about = new KAboutData( I18N_NOOP( "kontactconfig" ), 0,
00098                                       ki18n( "KDE Kontact" ),
00099                                       0, KLocalizedString(), KAboutData::License_GPL,
00100                                       ki18n( "(c), 2003 Cornelius Schumacher" ) );
00101 
00102   about->addAuthor( ki18n( "Cornelius Schumacher" ), KLocalizedString(), "schumacher@kde.org" );
00103   about->addAuthor( ki18n( "Tobias Koenig" ), KLocalizedString(), "tokoe@kde.org" );
00104 
00105   return about;
00106 }
00107 
00108 PluginSelection::PluginSelection( KConfigSkeleton::ItemString *item, QWidget *parent )
00109 {
00110   mItem = item;
00111   mPluginCombo = new KComboBox( parent );
00112   connect( mPluginCombo, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
00113 }
00114 
00115 PluginSelection::~PluginSelection()
00116 {
00117 }
00118 
00119 void PluginSelection::readConfig()
00120 {
00121   const KService::List offers = KServiceTypeTrader::self()->query(
00122       QString::fromLatin1( "Kontact/Plugin" ),
00123       QString( "[X-KDE-KontactPluginVersion] == %1" ).arg( KONTACT_PLUGIN_VERSION ) );
00124 
00125   int activeComponent = 0;
00126   mPluginCombo->clear();
00127   mPluginList.clear();
00128   for ( KService::List::ConstIterator it = offers.begin(); it != offers.end(); ++it ) {
00129     KService::Ptr service = *it;
00130     // skip summary only plugins
00131     QVariant var = service->property( "X-KDE-KontactPluginHasPart" );
00132     if ( var.isValid() && var.toBool() == false ) {
00133       continue;
00134     }
00135     mPluginCombo->addItem( service->name() );
00136     mPluginList.append( service );
00137 
00138     if ( service->property( "X-KDE-PluginInfo-Name" ).toString() == mItem->value() ) {
00139       activeComponent = mPluginList.count() - 1;
00140     }
00141   }
00142 
00143   mPluginCombo->setCurrentIndex( activeComponent );
00144 }
00145 
00146 void PluginSelection::writeConfig()
00147 {
00148   KService::Ptr ptr =  mPluginList.at( mPluginCombo->currentIndex() );
00149   mItem->setValue( ptr->property( "X-KDE-PluginInfo-Name" ).toString() );
00150 }
00151 
00152 QList<QWidget *> PluginSelection::widgets() const
00153 {
00154   QList<QWidget *> widgets;
00155   widgets.append( mPluginCombo );
00156 
00157   return widgets;
00158 }
00159 
00160 #include "kcmkontact.moc"

kontact

Skip menu "kontact"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal