22 #include <QtGui/QLayout>
23 #include <QtGui/QLabel>
30 #include <QtCore/QList>
31 #include <QtGui/QTreeWidget>
36 class ComponentsDialog::ComponentsDialogPrivate
43 QLabel * descriptionwidget;
49 :
KDialog( parent ), d( new ComponentsDialogPrivate )
51 setObjectName( name );
53 setCaption(
i18n(
"Select Components" ) );
56 setMainWidget( page );
57 QHBoxLayout *hbox =
new QHBoxLayout( page );
61 d->listview->setMinimumSize( 200, 200 );
62 d->infowidget =
new QFrame( page );
63 d->infowidget->setMinimumSize( 200, 200 );
65 QVBoxLayout *vbox =
new QVBoxLayout( d->infowidget );
68 d->iconwidget =
new QLabel( d->infowidget );
69 vbox->addWidget( d->iconwidget );
70 vbox->addWidget(
new KSeparator( d->infowidget ) );
71 d->commentwidget =
new QLabel( d->infowidget );
72 d->commentwidget->setWordWrap(
true );
73 vbox->addWidget( d->commentwidget );
74 d->descriptionwidget =
new QLabel( d->infowidget );
75 d->descriptionwidget->setWordWrap(
true );
76 vbox->addWidget( d->descriptionwidget );
78 d->listview->setAcceptDrops(
false );
80 connect( d->listview, SIGNAL(itemPressed(QTreeWidgetItem*,
int)),
this,
81 SLOT(executed(QTreeWidgetItem*,
int)) );
82 connect( d->listview, SIGNAL(itemActivated(QTreeWidgetItem*,
int)),
this,
83 SLOT(executed(QTreeWidgetItem*,
int)) );
84 connect( d->listview, SIGNAL(itemSelectionChanged(QTreeWidgetItem*,
int)),
this,
85 SLOT(executed(QTreeWidgetItem*,
int)) );
95 d->plugininfolist.append( info );
102 it != plugininfos.end(); ++it )
104 d->plugininfolist.append( it.value() );
110 d->plugininfolist = plugins;
116 d->listview->clear();
117 d->plugininfomap.clear();
121 it != d->plugininfolist.constEnd(); ++it )
124 QTreeWidgetItem * item =
new QTreeWidgetItem( d->listview,
QStringList( ( *it )->name() ) );
125 if( ! ( *it )->icon().isEmpty() )
127 item->setCheckState( 0, ( *it )->isPluginEnabled() ? Qt::Checked : Qt::Unchecked );
128 d->plugininfomap[ item ] = ( *it );
133 void ComponentsDialog::executed( QTreeWidgetItem * item,
int )
139 bool checked = ( item->checkState(0) == Qt::Checked );
141 kDebug( 704 ) <<
"it's a " << ( checked ?
"checked" :
"unchecked" )
142 <<
" QCheckListItem" << endl;
149 d->commentwidget->setText( info->
comment() );
153 void ComponentsDialog::savePluginInfos()
156 it != d->plugininfolist.constEnd(); ++it )
158 if ((*it)->config().isValid()) {
160 (*it)->config().sync();
168 KDialog::slotButtonClicked(
Ok );
174 KDialog::slotButtonClicked(
Apply );
179 #include "componentsdialog_p.moc"
QString i18n(const char *text)
void setPluginInfos(const QMap< QString, KPluginInfo * > &plugininfos)
Set list of plugins the dialog offers for selection.
int IconSize(KIconLoader::Group group)
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
void addPluginInfo(KPluginInfo *)
Add a plugin that the dialog offers for selection.
ComponentsDialog(QWidget *parent=0, const char *name=0)
Create Dialog.
void setPluginEnabled(bool enabled)
QPixmap SmallIcon(const QString &name, int force_size, int state, const QStringList &overlays)