• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kutils
 

kutils

componentsdialog.cpp
00001 /*  This file is part of the KDE project
00002     Copyright (C) 2003 Matthias Kretz <kretz@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License version 2 as published by the Free Software Foundation.
00007 
00008     This library is distributed in the hope that it will be useful,
00009     but WITHOUT ANY WARRANTY; without even the implied warranty of
00010     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011     Library General Public License for more details.
00012 
00013     You should have received a copy of the GNU Library General Public License
00014     along with this library; see the file COPYING.LIB.  If not, write to
00015     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016     Boston, MA 02110-1301, USA.
00017 
00018 */
00019 
00020 #include "ksettings/componentsdialog.h"
00021 #include <klocale.h>
00022 #include <tqlayout.h>
00023 #include <klistview.h>
00024 #include <tqlabel.h>
00025 #include <tqheader.h>
00026 #include <kplugininfo.h>
00027 #include <kiconloader.h>
00028 #include <kdebug.h>
00029 #include <kconfig.h>
00030 #include <kseparator.h>
00031 
00032 namespace KSettings
00033 {
00034 
00035 class ComponentsDialog::ComponentsDialogPrivate
00036 {
00037     public:
00038         KListView * listview;
00039         TQFrame * infowidget;
00040         TQLabel * iconwidget;
00041         TQLabel * commentwidget;
00042         TQLabel * descriptionwidget;
00043         TQMap<TQCheckListItem*, KPluginInfo*> plugininfomap;
00044         TQValueList<KPluginInfo*> plugininfolist;
00045 };
00046 
00047 ComponentsDialog::ComponentsDialog( TQWidget * parent, const char * name )
00048     : KDialogBase( parent, name, false, i18n( "Select Components" ) )
00049 , d( new ComponentsDialogPrivate )
00050 {
00051     TQWidget * page = new TQWidget( this );
00052     setMainWidget( page );
00053     ( new TQHBoxLayout( page, 0, KDialog::spacingHint() ) )->setAutoAdd( true );
00054     d->listview = new KListView( page );
00055     d->listview->setMinimumSize( 200, 200 );
00056     d->infowidget = new TQFrame( page );
00057     d->infowidget->setMinimumSize( 200, 200 );
00058     ( new TQVBoxLayout( d->infowidget, 0, KDialog::spacingHint() ) )->setAutoAdd( true );
00059     d->iconwidget = new TQLabel( d->infowidget );
00060     ( void )new KSeparator( d->infowidget );
00061     d->commentwidget = new TQLabel( d->infowidget );
00062     d->commentwidget->setAlignment( TQt::WordBreak );
00063     d->descriptionwidget = new TQLabel( d->infowidget );
00064     d->descriptionwidget->setAlignment( TQt::WordBreak );
00065 
00066     d->listview->addColumn( TQString::null );
00067     d->listview->header()->hide();
00068     d->listview->setRootIsDecorated( true );
00069     d->listview->setSorting( -1 );
00070     d->listview->setAcceptDrops( false );
00071     d->listview->setSelectionModeExt( KListView::Single );
00072     d->listview->setAllColumnsShowFocus( true );
00073 
00074     connect( d->listview, TQT_SIGNAL( pressed( TQListViewItem * ) ), this,
00075             TQT_SLOT( executed( TQListViewItem * ) ) );
00076     connect( d->listview, TQT_SIGNAL( spacePressed( TQListViewItem * ) ), this,
00077             TQT_SLOT( executed( TQListViewItem * ) ) );
00078     connect( d->listview, TQT_SIGNAL( returnPressed( TQListViewItem * ) ), this,
00079             TQT_SLOT( executed( TQListViewItem * ) ) );
00080     connect( d->listview, TQT_SIGNAL( selectionChanged( TQListViewItem * ) ), this,
00081             TQT_SLOT( executed( TQListViewItem * ) ) );
00082 }
00083 
00084 ComponentsDialog::~ComponentsDialog()
00085 {
00086 }
00087 
00088 void ComponentsDialog::addPluginInfo( KPluginInfo * info )
00089 {
00090     d->plugininfolist.append( info );
00091 }
00092 
00093 void ComponentsDialog::setPluginInfos( const TQMap<TQString, KPluginInfo*> &
00094         plugininfos )
00095 {
00096     for( TQMap<TQString, KPluginInfo*>::ConstIterator it = plugininfos.begin();
00097             it != plugininfos.end(); ++it )
00098     {
00099         d->plugininfolist.append( it.data() );
00100     }
00101 }
00102 
00103 void ComponentsDialog::setPluginInfos( const TQValueList<KPluginInfo *> &plugins )
00104 {
00105     d->plugininfolist = plugins;
00106 }
00107 
00108 void ComponentsDialog::show()
00109 {
00110     // clear the treelist
00111     d->listview->clear();
00112     d->plugininfomap.clear();
00113 
00114     // construct the treelist
00115     for( TQValueList<KPluginInfo*>::ConstIterator it = d->plugininfolist.begin();
00116             it != d->plugininfolist.end(); ++it )
00117     {
00118         ( *it )->load();
00119         TQCheckListItem * item = new TQCheckListItem( d->listview, ( *it )->name(),
00120                 TQCheckListItem::CheckBox );
00121         if( ! ( *it )->icon().isEmpty() )
00122             item->setPixmap( 0, SmallIcon( ( *it )->icon(), IconSize( KIcon::Small ) ) );
00123         item->setOn( ( *it )->isPluginEnabled() );
00124         d->plugininfomap[ item ] = ( *it );
00125     }
00126     KDialogBase::show();
00127 }
00128 
00129 void ComponentsDialog::executed( TQListViewItem * item )
00130 {
00131     kdDebug( 704 ) << k_funcinfo << endl;
00132     if( item == 0 )
00133         return;
00134     if( item->rtti() != 1 ) // check for QCheckListItem
00135         return;
00136 
00137     TQCheckListItem * citem = static_cast<TQCheckListItem *>( item );
00138     bool checked = citem->isOn();
00139 
00140     kdDebug( 704 ) << "it's a " << ( checked ? "checked" : "unchecked" )
00141         << " TQCheckListItem" << endl;
00142 
00143     KPluginInfo * info = d->plugininfomap[ citem ];
00144     info->setPluginEnabled( checked );
00145     //checkDependencies( info );
00146     // show info about the component on the right
00147     d->iconwidget->setPixmap( SmallIcon( info->icon(), KIcon::SizeLarge ) );
00148     d->commentwidget->setText( info->comment() );
00149     //d->descriptionwidget->setText( info->description() );
00150 }
00151 
00152 void ComponentsDialog::savePluginInfos()
00153 {
00154     for( TQValueList<KPluginInfo*>::ConstIterator it = d->plugininfolist.begin();
00155             it != d->plugininfolist.end(); ++it )
00156     {
00157         if( ( *it )->config() )
00158         {
00159             ( *it )->save();
00160             ( *it )->config()->sync();
00161         }
00162     }
00163 }
00164 
00165 void ComponentsDialog::slotOk()
00166 {
00167     savePluginInfos();
00168     KDialogBase::slotOk();
00169 }
00170 
00171 void ComponentsDialog::slotApply()
00172 {
00173     savePluginInfos();
00174     KDialogBase::slotApply();
00175 }
00176 
00177 } //namespace
00178 
00179 #include "componentsdialog.moc"
00180 // vim: sw=4 sts=4 et

kutils

Skip menu "kutils"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kutils

Skip menu "kutils"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kutils by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |