summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-06-13 20:46:02 (UTC)
committer mickeyl <mickeyl>2005-06-13 20:46:02 (UTC)
commit9e210f138184f9cc93e28dd894243fc7bfea1b0f (patch) (side-by-side diff)
treebff01f476d0b2370d7bfb8b6275677d6ee4d6580
parent8e7defdc3c1129f9e0935761ead46d9428306f7f (diff)
downloadopie-9e210f138184f9cc93e28dd894243fc7bfea1b0f.zip
opie-9e210f138184f9cc93e28dd894243fc7bfea1b0f.tar.gz
opie-9e210f138184f9cc93e28dd894243fc7bfea1b0f.tar.bz2
parse possible bindings out of /etc/pcmcia/* and list them in combobox
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp42
-rw-r--r--noncore/applets/pcmcia/configdialogbase.ui159
2 files changed, 166 insertions, 35 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp
index e7c97c1..e161d18 100644
--- a/noncore/applets/pcmcia/configdialog.cpp
+++ b/noncore/applets/pcmcia/configdialog.cpp
@@ -16,71 +16,103 @@
    =_        +     =;=|` 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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "configdialog.h"
/* OPIE */
#include <opie2/oconfig.h>
#include <opie2/odebug.h>
using namespace Opie::Core;
/* QT */
#include <qcombobox.h>
#include <qdir.h>
+#include <qfile.h>
#include <qlabel.h>
+#include <qtextstream.h>
ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent )
:ConfigDialogBase( parent, "pcmcia config dialog", true )
{
//setCaption( tr( "Configure %1" ).arg( cardname ) );
- textCardName->setText( cardname );
+ txtCardName->setText( cardname );
OConfig cfg( "PCMCIA" );
cfg.setGroup( "Global" );
int nCards = cfg.readNumEntry( "nCards", 0 );
QString insert;
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 '" << cardname << "' with known card '" << name << "'" << oendl;
if ( cardname == name )
{
insert = cfg.readEntry( "insert" );
break;
}
}
odebug << "preferred action for card '" << cardname << "' seems to be '" << insert << "'" << oendl;
if ( !insert.isEmpty() )
{
for ( int i; i < cbAction->count(); ++i )
if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i );
}
- // parse possible device and class names out of /etc/pcmcia/*.conf
- QStringList deviceNames;
- QStringList classNames;
+ // 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 )
- odebug << "found conf file '" << pcmciaconfdir[i] << "'" << oendl;
+ {
+ 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" )
+ {
+ word = ts.readLine();
+ bindEntries[ word.stripWhiteSpace() ] = conffilename;
+ continue;
+ }
+ ts.readLine();
+ }
+ }
+ else
+ {
+ owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl;
+ continue;
+ }
+ }
+ for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it )
+ {
+ odebug << "found device '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl;
+ cbBindTo->insertItem( it.key() );
+ }
}
ConfigDialog::~ConfigDialog()
{
}
diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui
index a9682c5..a0760d6 100644
--- a/noncore/applets/pcmcia/configdialogbase.ui
+++ b/noncore/applets/pcmcia/configdialogbase.ui
@@ -1,59 +1,59 @@
<!DOCTYPE UI><UI>
<class>ConfigDialogBase</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>ConfigDialogBase</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>234</width>
- <height>130</height>
+ <width>232</width>
+ <height>206</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Configure PCMCIA/CF Card</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<grid>
<property stdset="1">
<name>margin</name>
- <number>7</number>
+ <number>5</number>
</property>
<property stdset="1">
<name>spacing</name>
- <number>4</number>
+ <number>2</number>
</property>
<widget row="2" column="2" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel3</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>card</string>
</property>
</widget>
<widget row="2" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel2</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Upon insertion,</string>
</property>
</widget>
<widget row="2" column="1" >
@@ -72,79 +72,178 @@
</item>
<item>
<property>
<name>text</name>
<string>eject</string>
</property>
</item>
<item>
<property>
<name>text</name>
<string>prompt for</string>
</property>
</item>
<property stdset="1">
<name>name</name>
<cstring>cbAction</cstring>
</property>
</widget>
<widget row="3" column="1" rowspan="1" colspan="2" >
<class>QComboBox</class>
<property stdset="1">
<name>name</name>
<cstring>cbBindTo</cstring>
</property>
- </widget>
- <widget row="1" column="0" rowspan="1" colspan="3" >
- <class>Line</class>
- <property stdset="1">
- <name>name</name>
- <cstring>Line1</cstring>
- </property>
<property stdset="1">
- <name>orientation</name>
- <enum>Horizontal</enum>
+ <name>editable</name>
+ <bool>true</bool>
</property>
</widget>
<widget row="3" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>textBindTo</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Bind to:</string>
</property>
</widget>
- <widget row="4" column="0" >
- <class>QLabel</class>
+ <widget row="0" column="0" rowspan="1" colspan="3" >
+ <class>QGroupBox</class>
<property stdset="1">
<name>name</name>
- <cstring>textClassName</cstring>
+ <cstring>GroupBox1</cstring>
</property>
<property stdset="1">
- <name>text</name>
- <string>Classname:</string>
+ <name>title</name>
+ <string>Details</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
</property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>6</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>4</number>
+ </property>
+ <widget row="0" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>labelCardName</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>CardName:</string>
+ </property>
+ </widget>
+ <widget row="2" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>labelFunction</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Function:</string>
+ </property>
+ </widget>
+ <widget row="1" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>labelManufacturer</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Manufacturer:</string>
+ </property>
+ </widget>
+ <widget row="1" column="1" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>txtManfid</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>TextLabel6</string>
+ </property>
+ </widget>
+ <widget row="2" column="1" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>txtFunction</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>TextLabel7</string>
+ </property>
+ </widget>
+ <widget row="0" column="1" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>txtCardName</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>TextLabel3</string>
+ </property>
+ </widget>
+ </grid>
</widget>
- <widget row="4" column="1" rowspan="1" colspan="2" >
- <class>QComboBox</class>
- <property stdset="1">
+ <spacer row="1" column="1" >
+ <property>
<name>name</name>
- <cstring>cbClassName</cstring>
+ <cstring>Spacer1</cstring>
</property>
- </widget>
- <widget row="0" column="0" rowspan="1" colspan="3" >
- <class>QLabel</class>
<property stdset="1">
- <name>name</name>
- <cstring>textCardName</cstring>
+ <name>orientation</name>
+ <enum>Vertical</enum>
</property>
<property stdset="1">
- <name>text</name>
- <string>CardName</string>
+ <name>sizeType</name>
+ <enum>Expanding</enum>
</property>
- </widget>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
</grid>
</widget>
</UI>