Diffstat (limited to 'noncore/applets/pcmcia/configdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp index 9fcf58c..f961069 100644 --- a/noncore/applets/pcmcia/configdialog.cpp +++ b/noncore/applets/pcmcia/configdialog.cpp @@ -37,75 +37,62 @@ using namespace Opie::Core; /* QT */ #include <qcombobox.h> #include <qdir.h> #include <qfile.h> #include <qgroupbox.h> #include <qlabel.h> #include <qtextstream.h> ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) :ConfigDialogBase( parent, "pcmcia config dialog", true ) { - gbDetails->setTitle( QString( "Details for '%1'" ).arg( card->identity() ) ); + gbDetails->setTitle( QString( "Details for card in socket #%1" ).arg( card->number() ) ); txtCardName->setText( card->productIdentity().join( " " ) ); txtManfid->setText( card->manufacturerIdentity() ); txtFunction->setText( card->function() ); - OConfig cfg( "PCMCIA" ); - cfg.setGroup( "Global" ); - int nCards = cfg.readNumEntry( "nCards", 0 ); - QString insert; + QString action = preferredAction( card ); - for ( int i = 0; i < nCards; ++i ) - { - QString cardSection = QString( "Card_%1" ).arg( i ); - cfg.setGroup( cardSection ); - QString name = cfg.readEntry( "name" ); - odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; - if ( card->name() == name ) - { - insert = cfg.readEntry( "insert" ); - break; - } - } - odebug << "preferred action for card '" << card->name() << "' seems to be '" << insert << "'" << oendl; + odebug << "preferred action for card '" << card->name() << "' seems to be '" << action << "'" << oendl; - if ( !insert.isEmpty() ) + if ( !action.isEmpty() ) { for ( int i; i < cbAction->count(); ++i ) - if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); + if ( cbAction->text( i ) == action ) cbAction->setCurrentItem( i ); } if ( !card->isUnsupported() ) { odebug << "card is recognized - hiding bindings" << oendl; + textInfo->hide(); textBindTo->hide(); cbBindTo->hide(); return; } else { odebug << "card is unsupported yet - showing possible bindings" << oendl; + textInfo->show(); textBindTo->show(); cbBindTo->show(); } // parse possible bind entries out of /etc/pcmcia/*.conf typedef QMap<QString,QString> StringMap; StringMap bindEntries; QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); - for ( int i = 0; i < pcmciaconfdir.count(); ++i ) + for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) { odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); QFile conffile( conffilename ); if ( conffile.open( IO_ReadOnly ) ) { QTextStream ts( &conffile ); while ( !ts.atEnd() ) { QString word; ts >> word; if ( word == "bind" ) @@ -125,12 +112,35 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) } for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) { odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; cbBindTo->insertItem( it.key() ); } } ConfigDialog::~ConfigDialog() { } + +QString ConfigDialog::preferredAction( const OPcmciaSocket* card ) +{ + OConfig cfg( "PCMCIA" ); + cfg.setGroup( "Global" ); + int nCards = cfg.readNumEntry( "nCards", 0 ); + QString action; + + for ( int i = 0; i < nCards; ++i ) + { + QString cardSection = QString( "Card_%1" ).arg( i ); + cfg.setGroup( cardSection ); + QString name = cfg.readEntry( "name" ); + odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; + if ( card->name() == name ) + { + action = cfg.readEntry( "action" ); + break; + } + } + + return action; +} |