00001 #include <GUIUtils.h>
00002 #include <stdio.h>
00003 #include <qlineedit.h>
00004 #include <qcombobox.h>
00005 #include <qspinbox.h>
00006 #include <qcheckbox.h>
00007 #include "cabledata.h"
00008 #include "cableedit.h"
00009
00010 static long SpeedTable[] = {
00011 2400, 9600, 19200, 38400, 57600, 115200,
00012 230400, 460800, 500000, 921600, 1000000,
00013 1152000, 1500000, 2000000, 2500000, 3000000,
00014 3500000, 4000000, -1
00015 };
00016
00017 CableEdit::CableEdit( QWidget * Parent ) : CableGUI( Parent ) {
00018 }
00019
00020 void CableEdit::showData( CableData & D ) {
00021 DeviceFile_LE->setText( D.Device );
00022 LockFile_LE->setText( D.LockFile );
00023 for( long * Run = SpeedTable; *Run != -1; *Run ++ ) {
00024 if( *Run == D.Speed ) {
00025 Speed_CB->setCurrentItem(
00026 ((long)(Run)-(long)(SpeedTable))/sizeof(long) );
00027 break;
00028 }
00029 }
00030 Parity_CB->setCurrentItem( D.Parity );
00031 DataBits_SB->setValue( D.DataBits );
00032 StopBits_CB->setCurrentItem( D.StopBits );
00033 HardwareFC_CB->setChecked( D.HardwareControl );
00034 SoftwareFC_CB->setChecked( D.SoftwareControl );
00035 }
00036
00037 QString CableEdit::acceptable( void ) {
00038 if( DeviceFile_LE->text().isEmpty() )
00039 return tr("Device filename needed");
00040 return QString();
00041 }
00042
00043 bool CableEdit::commit( CableData & D ) {
00044 bool SM = 0;
00045
00046 TXTM( D.Device, DeviceFile_LE, SM );
00047 TXTM( D.LockFile, LockFile_LE, SM );
00048
00049 for( long * Run = SpeedTable; *Run != -1; *Run ++ ) {
00050 if( *Run == D.Speed ) {
00051 if( D.Speed != Speed_CB->currentText().toLong() ) {
00052 SM = 1;
00053 D.Speed = Speed_CB->currentText().toLong();
00054 }
00055 break;
00056 }
00057 }
00058
00059 CIM(D.Parity, Parity_CB, SM );
00060
00061 SBM(D.DataBits, DataBits_SB, SM );
00062 CIM(D.StopBits, StopBits_CB, SM );
00063
00064 CBM( D.HardwareControl, HardwareFC_CB, SM );
00065 CBM( D.SoftwareControl, SoftwareFC_CB, SM );
00066
00067 return SM;
00068 }