You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
194 lines
5.7 KiB
194 lines
5.7 KiB
15 years ago
|
/* This file is part of the KDE libraries
|
||
|
Copyright (C) 2000 David Faure <faure@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
|
||
12 years ago
|
#include "tdelistdebugdialog.h"
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
15 years ago
|
#include <kdebug.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
14 years ago
|
#include <tqscrollview.h>
|
||
|
#include <tqvbox.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
14 years ago
|
#include <tqpushbutton.h>
|
||
15 years ago
|
#include <klineedit.h>
|
||
|
#include <dcopclient.h>
|
||
|
|
||
12 years ago
|
TDEListDebugDialog::TDEListDebugDialog( TQStringList areaList, TQWidget *parent, const char *name, bool modal )
|
||
15 years ago
|
: KAbstractDebugDialog( parent, name, modal ),
|
||
|
m_areaList( areaList )
|
||
|
{
|
||
|
setCaption(i18n("Debug Settings"));
|
||
|
|
||
14 years ago
|
TQVBoxLayout *lay = new TQVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
|
||
15 years ago
|
|
||
|
m_incrSearch = new KLineEdit( this );
|
||
|
lay->addWidget( m_incrSearch );
|
||
14 years ago
|
connect( m_incrSearch, TQT_SIGNAL( textChanged( const TQString& ) ),
|
||
|
TQT_SLOT( generateCheckBoxes( const TQString& ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
TQScrollView * scrollView = new TQScrollView( this );
|
||
|
scrollView->setResizePolicy( TQScrollView::AutoOneFit );
|
||
15 years ago
|
lay->addWidget( scrollView );
|
||
|
|
||
14 years ago
|
m_box = new TQVBox( scrollView->viewport() );
|
||
15 years ago
|
scrollView->addChild( m_box );
|
||
|
|
||
14 years ago
|
generateCheckBoxes( TQString::null );
|
||
15 years ago
|
|
||
14 years ago
|
TQHBoxLayout* selectButs = new TQHBoxLayout( lay );
|
||
|
TQPushButton* all = new TQPushButton( i18n("&Select All"), this );
|
||
|
TQPushButton* none = new TQPushButton( i18n("&Deselect All"), this );
|
||
15 years ago
|
selectButs->addWidget( all );
|
||
|
selectButs->addWidget( none );
|
||
|
|
||
14 years ago
|
connect( all, TQT_SIGNAL( clicked() ), this, TQT_SLOT( selectAll() ) );
|
||
|
connect( none, TQT_SIGNAL( clicked() ), this, TQT_SLOT( deSelectAll() ) );
|
||
15 years ago
|
|
||
|
buildButtons( lay );
|
||
|
resize( 350, 400 );
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEListDebugDialog::generateCheckBoxes( const TQString& filter )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQPtrListIterator<TQCheckBox> cb_it ( boxes );
|
||
15 years ago
|
for( ; cb_it.current() ; ++cb_it )
|
||
|
{
|
||
14 years ago
|
if( (*cb_it)->state() != TQButton::NoChange )
|
||
15 years ago
|
m_changes.insert( (*cb_it)->name(), (*cb_it)->isChecked() ? 2 : 4 );
|
||
|
}
|
||
|
|
||
|
boxes.setAutoDelete( true );
|
||
|
boxes.clear();
|
||
|
boxes.setAutoDelete( false );
|
||
|
|
||
14 years ago
|
TQWidget* taborder = m_incrSearch;
|
||
|
TQStringList::Iterator it = m_areaList.begin();
|
||
15 years ago
|
for ( ; it != m_areaList.end() ; ++it )
|
||
|
{
|
||
14 years ago
|
TQString data = (*it).simplifyWhiteSpace();
|
||
13 years ago
|
if ( filter.isEmpty() || data.lower().contains( filter.lower() ) )
|
||
15 years ago
|
{
|
||
13 years ago
|
int space = data.find(" ");
|
||
15 years ago
|
if (space == -1)
|
||
|
kdError() << "No space:" << data << endl;
|
||
|
|
||
14 years ago
|
TQString areaNumber = data.left(space);
|
||
15 years ago
|
//kdDebug() << areaNumber << endl;
|
||
14 years ago
|
TQCheckBox * cb = new TQCheckBox( data, m_box, areaNumber.latin1() );
|
||
15 years ago
|
cb->show();
|
||
|
boxes.append( cb );
|
||
|
setTabOrder( taborder, cb );
|
||
|
taborder = cb;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
load();
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEListDebugDialog::selectAll()
|
||
15 years ago
|
{
|
||
14 years ago
|
TQPtrListIterator<TQCheckBox> it ( boxes );
|
||
15 years ago
|
for ( ; it.current() ; ++it ) {
|
||
|
(*it)->setChecked( true );
|
||
|
m_changes.insert( (*it)->name(), 2 );
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEListDebugDialog::deSelectAll()
|
||
15 years ago
|
{
|
||
14 years ago
|
TQPtrListIterator<TQCheckBox> it ( boxes );
|
||
15 years ago
|
for ( ; it.current() ; ++it ) {
|
||
|
(*it)->setChecked( false );
|
||
|
m_changes.insert( (*it)->name(), 4 );
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEListDebugDialog::load()
|
||
15 years ago
|
{
|
||
14 years ago
|
TQPtrListIterator<TQCheckBox> it ( boxes );
|
||
15 years ago
|
for ( ; it.current() ; ++it )
|
||
|
{
|
||
|
pConfig->setGroup( (*it)->name() ); // Group name = debug area code = cb's name
|
||
|
|
||
|
int setting = pConfig->readNumEntry( "InfoOutput", 2 );
|
||
|
// override setting if in m_changes
|
||
13 years ago
|
if( m_changes.find( (*it)->name() ) != m_changes.end() ) {
|
||
15 years ago
|
setting = m_changes[ (*it)->name() ];
|
||
|
}
|
||
|
|
||
|
switch (setting) {
|
||
|
case 4: // off
|
||
|
(*it)->setChecked(false);
|
||
|
break;
|
||
|
case 2: //shell
|
||
|
(*it)->setChecked(true);
|
||
|
break;
|
||
|
case 3: //syslog
|
||
|
case 1: //msgbox
|
||
|
case 0: //file
|
||
|
default:
|
||
|
(*it)->setNoChange();
|
||
|
/////// Uses the triState capability of checkboxes
|
||
|
////// Note: it seems some styles don't draw that correctly (BUG)
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEListDebugDialog::save()
|
||
15 years ago
|
{
|
||
14 years ago
|
TQPtrListIterator<TQCheckBox> it ( boxes );
|
||
15 years ago
|
for ( ; it.current() ; ++it )
|
||
|
{
|
||
|
pConfig->setGroup( (*it)->name() ); // Group name = debug area code = cb's name
|
||
14 years ago
|
if ( (*it)->state() != TQButton::NoChange )
|
||
15 years ago
|
{
|
||
|
int setting = (*it)->isChecked() ? 2 : 4;
|
||
|
pConfig->writeEntry( "InfoOutput", setting );
|
||
|
}
|
||
|
}
|
||
|
//sync done by main.cpp
|
||
|
|
||
|
// send DCOP message to all clients
|
||
14 years ago
|
TQByteArray data;
|
||
15 years ago
|
if (!kapp->dcopClient()->send("*", "KDebug", "notifyKDebugConfigChanged()", data))
|
||
|
{
|
||
|
kdError() << "Unable to send DCOP message" << endl;
|
||
|
}
|
||
|
|
||
|
m_changes.clear();
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEListDebugDialog::activateArea( TQCString area, bool activate )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQPtrListIterator<TQCheckBox> it ( boxes );
|
||
15 years ago
|
for ( ; it.current() ; ++it )
|
||
|
{
|
||
|
if ( area == (*it)->name() // debug area code = cb's name
|
||
13 years ago
|
|| (*it)->text().find( TQString::fromLatin1(area) ) != -1 ) // area name included in cb text
|
||
15 years ago
|
{
|
||
|
(*it)->setChecked( activate );
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
#include "tdelistdebugdialog.moc"
|