summaryrefslogtreecommitdiff
path: root/noncore/applets/pcmcia/configdialog.cpp
Unidiff
Diffstat (limited to 'noncore/applets/pcmcia/configdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp52
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
@@ -46,39 +46,25 @@ using namespace Opie::Core;
46ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) 46ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
47 :ConfigDialogBase( parent, "pcmcia config dialog", true ) 47 :ConfigDialogBase( parent, "pcmcia config dialog", true )
48{ 48{
49 gbDetails->setTitle( QString( "Details for '%1'" ).arg( card->identity() ) ); 49 gbDetails->setTitle( QString( "Details for card in socket #%1" ).arg( card->number() ) );
50 txtCardName->setText( card->productIdentity().join( " " ) ); 50 txtCardName->setText( card->productIdentity().join( " " ) );
51 txtManfid->setText( card->manufacturerIdentity() ); 51 txtManfid->setText( card->manufacturerIdentity() );
52 txtFunction->setText( card->function() ); 52 txtFunction->setText( card->function() );
53 53
54 OConfig cfg( "PCMCIA" ); 54 QString action = preferredAction( card );
55 cfg.setGroup( "Global" );
56 int nCards = cfg.readNumEntry( "nCards", 0 );
57 QString insert;
58 55
59 for ( int i = 0; i < nCards; ++i ) 56 odebug << "preferred action for card '" << card->name() << "' seems to be '" << action << "'" << oendl;
60 {
61 QString cardSection = QString( "Card_%1" ).arg( i );
62 cfg.setGroup( cardSection );
63 QString name = cfg.readEntry( "name" );
64 odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl;
65 if ( card->name() == name )
66 {
67 insert = cfg.readEntry( "insert" );
68 break;
69 }
70 }
71 odebug << "preferred action for card '" << card->name() << "' seems to be '" << insert << "'" << oendl;
72 57
73 if ( !insert.isEmpty() ) 58 if ( !action.isEmpty() )
74 { 59 {
75 for ( int i; i < cbAction->count(); ++i ) 60 for ( int i; i < cbAction->count(); ++i )
76 if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); 61 if ( cbAction->text( i ) == action ) cbAction->setCurrentItem( i );
77 } 62 }
78 63
79 if ( !card->isUnsupported() ) 64 if ( !card->isUnsupported() )
80 { 65 {
81 odebug << "card is recognized - hiding bindings" << oendl; 66 odebug << "card is recognized - hiding bindings" << oendl;
67 textInfo->hide();
82 textBindTo->hide(); 68 textBindTo->hide();
83 cbBindTo->hide(); 69 cbBindTo->hide();
84 return; 70 return;
@@ -86,6 +72,7 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
86 else 72 else
87 { 73 {
88 odebug << "card is unsupported yet - showing possible bindings" << oendl; 74 odebug << "card is unsupported yet - showing possible bindings" << oendl;
75 textInfo->show();
89 textBindTo->show(); 76 textBindTo->show();
90 cbBindTo->show(); 77 cbBindTo->show();
91 } 78 }
@@ -96,7 +83,7 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
96 83
97 QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); 84 QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" );
98 85
99 for ( int i = 0; i < pcmciaconfdir.count(); ++i ) 86 for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i )
100 { 87 {
101 odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; 88 odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl;
102 QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); 89 QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] );
@@ -134,3 +121,26 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
134ConfigDialog::~ConfigDialog() 121ConfigDialog::~ConfigDialog()
135{ 122{
136} 123}
124
125QString ConfigDialog::preferredAction( const OPcmciaSocket* card )
126{
127 OConfig cfg( "PCMCIA" );
128 cfg.setGroup( "Global" );
129 int nCards = cfg.readNumEntry( "nCards", 0 );
130 QString action;
131
132 for ( int i = 0; i < nCards; ++i )
133 {
134 QString cardSection = QString( "Card_%1" ).arg( i );
135 cfg.setGroup( cardSection );
136 QString name = cfg.readEntry( "name" );
137 odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl;
138 if ( card->name() == name )
139 {
140 action = cfg.readEntry( "action" );
141 break;
142 }
143 }
144
145 return action;
146}