libkdepim Library API Documentation

prefsmodule.cpp

00001 
00022 #include "prefsmodule.h"
00023 #include "prefs.h"
00024 
00025 #include <kaboutdata.h>
00026 #include <kdebug.h>
00027 #include <kcombobox.h>
00028 #include <klocale.h>
00029 #include <ktrader.h>
00030 
00031 #include <qlayout.h>
00032 #include <qlabel.h>
00033 #include <qbuttongroup.h>
00034 
00035 extern "C"
00036 {
00037   KCModule *create_komposerconfig( QWidget *parent, const char * ) {
00038     return new Komposer::PrefsModule( parent, "komposerprefs" );
00039   }
00040 }
00041 using namespace Komposer;
00042 
00043 PrefsModule::PrefsModule( QWidget *parent, const char *name )
00044   : KPrefsModule( Komposer::Prefs::self(), parent, name )
00045 {
00046   QVBoxLayout *topLayout = new QVBoxLayout( this );
00047 
00048   EditorSelection *editors = new EditorSelection( i18n( "Editors" ),
00049                                                   Komposer::Prefs::self()->m_activeEditor,
00050                                                   this );
00051   topLayout->addWidget( editors->groupBox() );
00052 
00053   addWid( editors );
00054 
00055   load();
00056 }
00057 
00058 const KAboutData*
00059 PrefsModule::aboutData() const
00060 {
00061   KAboutData *about = new KAboutData( I18N_NOOP( "komposerconfig" ),
00062                                       I18N_NOOP( "KDE Komposer" ),
00063                                       0, 0, KAboutData::License_LGPL,
00064                                       I18N_NOOP( "(c), 2003 Zack Rusin" ) );
00065 
00066   about->addAuthor( "Zack Rusin", 0, "zack@kde.org" );;
00067 
00068   return about;
00069 }
00070 
00071 
00072 EditorSelection::EditorSelection( const QString& text, QString& reference,
00073                                   QWidget *parent )
00074   : m_reference( reference )
00075 {
00076   m_box = new QGroupBox( 0, Qt::Vertical, text, parent );
00077   QVBoxLayout *boxLayout = new QVBoxLayout( m_box->layout() );
00078   boxLayout->setAlignment( Qt::AlignTop );
00079 
00080   m_editorsCombo = new KComboBox( m_box );
00081   boxLayout->addWidget( m_editorsCombo );
00082 
00083   connect( m_editorsCombo, SIGNAL(activated(const QString&)),
00084            SLOT(slotActivated(const QString&)) );
00085 }
00086 
00087 EditorSelection::~EditorSelection()
00088 {
00089 }
00090 
00091 QGroupBox*
00092 EditorSelection::groupBox()  const
00093 {
00094   return m_box;
00095 }
00096 
00097 void
00098 EditorSelection::readConfig()
00099 {
00100   m_editorsCombo->clear();
00101 
00102   KTrader::OfferList editors = KTrader::self()->query( QString::fromLatin1( "Komposer/Editor" ) );
00103   KTrader::OfferList::ConstIterator it;
00104   int i = 0;
00105   for ( it = editors.begin(); it != editors.end(); ++it, ++i ) {
00106     if ( !(*it)->hasServiceType( QString::fromLatin1( "Komposer/Editor" ) ) )
00107       continue;
00108 
00109     QString name = (*it)->property( "X-KDE-KomposerIdentifier" ).toString();
00110     m_editorsCombo->insertItem( name );
00111     if ( m_reference.contains( name ) )
00112       m_editorsCombo->setCurrentItem( i );
00113   }
00114 }
00115 
00116 void EditorSelection::writeConfig()
00117 {
00118   m_reference =  m_services[ m_editorsCombo->currentText()]->
00119                  property( "X-KDE-KomposerIdentifier" ).toString();
00120 }
00121 
00122 void
00123 EditorSelection::slotActivated( const QString& editor )
00124 {
00125   if ( !editor.isEmpty() )
00126     emit changed();
00127 }
00128 
00129 void
00130 EditorSelection::setItem( const QString& str )
00131 {
00132   for ( int i = 0; i < m_editorsCombo->count(); ++i ) {
00133     if ( m_editorsCombo->text( i ) == str ) {
00134       m_editorsCombo->setCurrentItem( i );
00135       break;
00136     }
00137   }
00138 }
00139 
00140 #include "prefsmodule.moc"
KDE Logo
This file is part of the documentation for libkdepim Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:36:31 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003