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

tdeutils

  • tdeutils
  • ksettings
componentsdialog.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2003 Matthias Kretz <kretz@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17
18*/
19
20#include "ksettings/componentsdialog.h"
21#include <tdelocale.h>
22#include <tqlayout.h>
23#include <tdelistview.h>
24#include <tqlabel.h>
25#include <tqheader.h>
26#include <kplugininfo.h>
27#include <kiconloader.h>
28#include <kdebug.h>
29#include <tdeconfig.h>
30#include <kseparator.h>
31
32namespace KSettings
33{
34
35class ComponentsDialog::ComponentsDialogPrivate
36{
37 public:
38 TDEListView * listview;
39 TQFrame * infowidget;
40 TQLabel * iconwidget;
41 TQLabel * commentwidget;
42 TQLabel * descriptionwidget;
43 TQMap<TQCheckListItem*, KPluginInfo*> plugininfomap;
44 TQValueList<KPluginInfo*> plugininfolist;
45};
46
47ComponentsDialog::ComponentsDialog( TQWidget * parent, const char * name )
48 : KDialogBase( parent, name, false, i18n( "Select Components" ) )
49, d( new ComponentsDialogPrivate )
50{
51 TQWidget * page = new TQWidget( this );
52 setMainWidget( page );
53 ( new TQHBoxLayout( page, 0, KDialog::spacingHint() ) )->setAutoAdd( true );
54 d->listview = new TDEListView( page );
55 d->listview->setMinimumSize( 200, 200 );
56 d->infowidget = new TQFrame( page );
57 d->infowidget->setMinimumSize( 200, 200 );
58 ( new TQVBoxLayout( d->infowidget, 0, KDialog::spacingHint() ) )->setAutoAdd( true );
59 d->iconwidget = new TQLabel( d->infowidget );
60 ( void )new KSeparator( 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 );
65
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 );
73
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 * ) ) );
82}
83
84ComponentsDialog::~ComponentsDialog()
85{
86}
87
88void ComponentsDialog::addPluginInfo( KPluginInfo * info )
89{
90 d->plugininfolist.append( info );
91}
92
93void ComponentsDialog::setPluginInfos( const TQMap<TQString, KPluginInfo*> &
94 plugininfos )
95{
96 for( TQMap<TQString, KPluginInfo*>::ConstIterator it = plugininfos.begin();
97 it != plugininfos.end(); ++it )
98 {
99 d->plugininfolist.append( it.data() );
100 }
101}
102
103void ComponentsDialog::setPluginInfos( const TQValueList<KPluginInfo *> &plugins )
104{
105 d->plugininfolist = plugins;
106}
107
108void ComponentsDialog::show()
109{
110 // clear the treelist
111 d->listview->clear();
112 d->plugininfomap.clear();
113
114 // construct the treelist
115 for( TQValueList<KPluginInfo*>::ConstIterator it = d->plugininfolist.begin();
116 it != d->plugininfolist.end(); ++it )
117 {
118 ( *it )->load();
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 );
125 }
126 KDialogBase::show();
127}
128
129void ComponentsDialog::executed( TQListViewItem * item )
130{
131 kdDebug( 704 ) << k_funcinfo << endl;
132 if( item == 0 )
133 return;
134 if( item->rtti() != 1 ) // check for QCheckListItem
135 return;
136
137 TQCheckListItem * citem = static_cast<TQCheckListItem *>( item );
138 bool checked = citem->isOn();
139
140 kdDebug( 704 ) << "it's a " << ( checked ? "checked" : "unchecked" )
141 << " TQCheckListItem" << endl;
142
143 KPluginInfo * info = d->plugininfomap[ citem ];
144 info->setPluginEnabled( checked );
145 //checkDependencies( info );
146 // show info about the component on the right
147 d->iconwidget->setPixmap( SmallIcon( info->icon(), TDEIcon::SizeLarge ) );
148 d->commentwidget->setText( info->comment() );
149 //d->descriptionwidget->setText( info->description() );
150}
151
152void ComponentsDialog::savePluginInfos()
153{
154 for( TQValueList<KPluginInfo*>::ConstIterator it = d->plugininfolist.begin();
155 it != d->plugininfolist.end(); ++it )
156 {
157 if( ( *it )->config() )
158 {
159 ( *it )->save();
160 ( *it )->config()->sync();
161 }
162 }
163}
164
165void ComponentsDialog::slotOk()
166{
167 savePluginInfos();
168 KDialogBase::slotOk();
169}
170
171void ComponentsDialog::slotApply()
172{
173 savePluginInfos();
174 KDialogBase::slotApply();
175}
176
177} //namespace
178
179#include "componentsdialog.moc"
KDialogBase
KDialogBase::slotApply
virtual void slotApply()
KDialogBase::setMainWidget
void setMainWidget(TQWidget *widget)
KDialogBase::slotOk
virtual void slotOk()
KDialog::spacingHint
static int spacingHint()
KPluginInfo
Information about a plugin.
Definition: kplugininfo.h:43
KPluginInfo::comment
const TQString & comment() const
Definition: kplugininfo.cpp:215
KPluginInfo::icon
const TQString & icon() const
Definition: kplugininfo.cpp:220
KPluginInfo::setPluginEnabled
virtual void setPluginEnabled(bool enabled)
Set whether the plugin is currently loaded.
Definition: kplugininfo.cpp:192
KSeparator
KSettings::ComponentsDialog::setPluginInfos
void setPluginInfos(const TQMap< TQString, KPluginInfo * > &plugininfos)
Set list of plugins the dialog offers for selection.
Definition: componentsdialog.cpp:93
KSettings::ComponentsDialog::show
void show()
reimplemented
Definition: componentsdialog.cpp:108
KSettings::ComponentsDialog::ComponentsDialog
ComponentsDialog(TQWidget *parent=0, const char *name=0)
Create Dialog.
Definition: componentsdialog.cpp:47
KSettings::ComponentsDialog::addPluginInfo
void addPluginInfo(KPluginInfo *)
Add a plugin that the dialog offers for selection.
Definition: componentsdialog.cpp:88
TDEIcon::Small
Small
TDEIcon::SizeLarge
SizeLarge
TDEListView
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
KSettings
A collection of classes to create configuration dialogs that work over component boundaries.
Definition: componentsdialog.cpp:33
tdelocale.h

tdeutils

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

tdeutils

Skip menu "tdeutils"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeutils by doxygen 1.9.4
This website is maintained by Timothy Pearson.