20 #include "ksettings/componentsdialog.h"
23 #include <tdelistview.h>
26 #include <kplugininfo.h>
27 #include <kiconloader.h>
29 #include <tdeconfig.h>
30 #include <kseparator.h>
35 class ComponentsDialog::ComponentsDialogPrivate
41 TQLabel * commentwidget;
42 TQLabel * descriptionwidget;
43 TQMap<TQCheckListItem*, KPluginInfo*> plugininfomap;
44 TQValueList<KPluginInfo*> plugininfolist;
48 :
KDialogBase( parent, name, false, i18n(
"Select Components" ) )
49 , d( new ComponentsDialogPrivate )
51 TQWidget * page =
new TQWidget(
this );
55 d->listview->setMinimumSize( 200, 200 );
56 d->infowidget =
new TQFrame( page );
57 d->infowidget->setMinimumSize( 200, 200 );
59 d->iconwidget =
new TQLabel( d->infowidget );
61 d->commentwidget =
new TQLabel( d->infowidget );
62 d->commentwidget->setAlignment( TQt::WordBreak );
63 d->descriptionwidget =
new TQLabel( d->infowidget );
64 d->descriptionwidget->setAlignment( TQt::WordBreak );
66 d->listview->addColumn( TQString::null );
67 d->listview->header()->hide();
68 d->listview->setRootIsDecorated(
true );
69 d->listview->setSorting( -1 );
70 d->listview->setAcceptDrops(
false );
71 d->listview->setSelectionModeExt( TDEListView::Single );
72 d->listview->setAllColumnsShowFocus(
true );
74 connect( d->listview, TQ_SIGNAL( pressed( TQListViewItem * ) ),
this,
75 TQ_SLOT( executed( TQListViewItem * ) ) );
76 connect( d->listview, TQ_SIGNAL( spacePressed( TQListViewItem * ) ),
this,
77 TQ_SLOT( executed( TQListViewItem * ) ) );
78 connect( d->listview, TQ_SIGNAL( returnPressed( TQListViewItem * ) ),
this,
79 TQ_SLOT( executed( TQListViewItem * ) ) );
80 connect( d->listview, TQ_SIGNAL( selectionChanged( TQListViewItem * ) ),
this,
81 TQ_SLOT( executed( TQListViewItem * ) ) );
84 ComponentsDialog::~ComponentsDialog()
90 d->plugininfolist.append( info );
96 for( TQMap<TQString, KPluginInfo*>::ConstIterator it = plugininfos.begin();
97 it != plugininfos.end(); ++it )
99 d->plugininfolist.append( it.data() );
105 d->plugininfolist = plugins;
111 d->listview->clear();
112 d->plugininfomap.clear();
115 for( TQValueList<KPluginInfo*>::ConstIterator it = d->plugininfolist.begin();
116 it != d->plugininfolist.end(); ++it )
119 TQCheckListItem * item =
new TQCheckListItem( d->listview, ( *it )->name(),
120 TQCheckListItem::CheckBox );
121 if( ! ( *it )->icon().isEmpty() )
122 item->setPixmap( 0, SmallIcon( ( *it )->icon(), IconSize(
TDEIcon::Small ) ) );
123 item->setOn( ( *it )->isPluginEnabled() );
124 d->plugininfomap[ item ] = ( *it );
129 void ComponentsDialog::executed( TQListViewItem * item )
134 if( item->rtti() != 1 )
137 TQCheckListItem * citem =
static_cast<TQCheckListItem *
>( item );
138 bool checked = citem->isOn();
140 kdDebug( 704 ) <<
"it's a " << ( checked ?
"checked" :
"unchecked" )
141 <<
" TQCheckListItem" <<
endl;
148 d->commentwidget->setText( info->
comment() );
152 void ComponentsDialog::savePluginInfos()
154 for( TQValueList<KPluginInfo*>::ConstIterator it = d->plugininfolist.begin();
155 it != d->plugininfolist.end(); ++it )
157 if( ( *it )->config() )
160 ( *it )->config()->sync();
165 void ComponentsDialog::slotOk()
171 void ComponentsDialog::slotApply()
179 #include "componentsdialog.moc"
void setMainWidget(TQWidget *widget)
Information about a plugin.
const TQString & comment() const
const TQString & icon() const
virtual void setPluginEnabled(bool enabled)
Set whether the plugin is currently loaded.
void setPluginInfos(const TQMap< TQString, KPluginInfo * > &plugininfos)
Set list of plugins the dialog offers for selection.
ComponentsDialog(TQWidget *parent=0, const char *name=0)
Create Dialog.
void addPluginInfo(KPluginInfo *)
Add a plugin that the dialog offers for selection.
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)
A collection of classes to create configuration dialogs that work over component boundaries.