small change

This commit is contained in:
Volker Fischer 2008-01-27 14:41:12 +00:00
parent d6c95888c5
commit 58cb051a14
3 changed files with 32 additions and 24 deletions

View file

@ -286,6 +286,14 @@
</item> </item>
<item> <item>
<widget class="CMultiColorLED" native="1" name="LEDOverallStatus" > <widget class="CMultiColorLED" native="1" name="LEDOverallStatus" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" > <property name="minimumSize" >
<size> <size>
<width>13</width> <width>13</width>

View file

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2006 * Copyright (c) 2004-2008
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
@ -37,23 +37,23 @@ CMultiColorLEDbase::CMultiColorLEDbase ( QWidget* parent, Qt::WindowFlags f )
BitmCubeGrey ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ), BitmCubeGrey ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ),
BitmCubeYellow ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ) BitmCubeYellow ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL )
{ {
/* Create bitmaps */ // create bitmaps
BitmCubeGreen.fill ( QColor ( 0, 255, 0 ) ); BitmCubeGreen.fill ( QColor ( 0, 255, 0 ) );
BitmCubeRed.fill ( QColor ( 255, 0, 0 ) ); BitmCubeRed.fill ( QColor ( 255, 0, 0 ) );
BitmCubeGrey.fill ( QColor ( 192, 192, 192 ) ); BitmCubeGrey.fill ( QColor ( 192, 192, 192 ) );
BitmCubeYellow.fill ( QColor ( 255, 255, 0 ) ); BitmCubeYellow.fill ( QColor ( 255, 255, 0 ) );
/* Init color flags */ // init color flags
Reset(); Reset();
/* Set init-bitmap */ // set init bitmap
SetPixmap ( BitmCubeGrey ); SetPixmap ( BitmCubeGrey );
eColorFlag = RL_GREY; eColorFlag = RL_GREY;
/* Init update time */ // init update time
iUpdateTime = DEFAULT_UPDATE_TIME; iUpdateTime = DEFAULT_UPDATE_TIME;
/* Connect timer events to the desired slots */ // connect timer events to the desired slots
connect ( &TimerRedLight, SIGNAL ( timeout() ), connect ( &TimerRedLight, SIGNAL ( timeout() ),
this, SLOT ( OnTimerRedLight() ) ); this, SLOT ( OnTimerRedLight() ) );
connect ( &TimerGreenLight, SIGNAL ( timeout() ), connect ( &TimerGreenLight, SIGNAL ( timeout() ),
@ -64,7 +64,7 @@ CMultiColorLEDbase::CMultiColorLEDbase ( QWidget* parent, Qt::WindowFlags f )
void CMultiColorLEDbase::Reset() void CMultiColorLEDbase::Reset()
{ {
/* Reset color flags */ // reset color flags
bFlagRedLi = false; bFlagRedLi = false;
bFlagGreenLi = false; bFlagGreenLi = false;
bFlagYellowLi = false; bFlagYellowLi = false;
@ -125,7 +125,7 @@ void CMultiColorLEDbase::UpdateColor()
return; return;
} }
/* If no color is active, set control to grey light */ // if no color is active, set control to grey light
if ( eColorFlag != RL_GREY ) if ( eColorFlag != RL_GREY )
{ {
SetPixmap ( BitmCubeGrey ); SetPixmap ( BitmCubeGrey );
@ -133,24 +133,24 @@ void CMultiColorLEDbase::UpdateColor()
} }
} }
void CMultiColorLEDbase::SetLight ( int iNewStatus ) void CMultiColorLEDbase::SetLight ( const int iNewStatus )
{ {
switch ( iNewStatus ) switch ( iNewStatus )
{ {
case MUL_COL_LED_GREEN: case MUL_COL_LED_GREEN:
// Green light // green light
bFlagGreenLi = true; bFlagGreenLi = true;
TimerGreenLight.setInterval ( iUpdateTime ); TimerGreenLight.setInterval ( iUpdateTime );
break; break;
case MUL_COL_LED_YELLOW: case MUL_COL_LED_YELLOW:
// Yellow light // yellow light
bFlagYellowLi = true; bFlagYellowLi = true;
TimerYellowLight.setInterval ( iUpdateTime ); TimerYellowLight.setInterval ( iUpdateTime );
break; break;
case MUL_COL_LED_RED: case MUL_COL_LED_RED:
// Red light // red light
bFlagRedLi = true; bFlagRedLi = true;
TimerRedLight.setInterval ( iUpdateTime ); TimerRedLight.setInterval ( iUpdateTime );
break; break;
@ -159,9 +159,9 @@ void CMultiColorLEDbase::SetLight ( int iNewStatus )
UpdateColor(); UpdateColor();
} }
void CMultiColorLEDbase::SetUpdateTime ( int iNUTi ) void CMultiColorLEDbase::SetUpdateTime ( const int iNUTi )
{ {
/* Avoid too short intervals */ // avoid too short intervals
if ( iNUTi < MIN_TIME_FOR_RED_LIGHT ) if ( iNUTi < MIN_TIME_FOR_RED_LIGHT )
{ {
iUpdateTime = MIN_TIME_FOR_RED_LIGHT; iUpdateTime = MIN_TIME_FOR_RED_LIGHT;

View file

@ -57,14 +57,14 @@ public:
CMultiColorLEDbase ( QWidget* parent = 0, Qt::WindowFlags f = 0 ); CMultiColorLEDbase ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
void Reset(); void Reset();
void SetUpdateTime ( int iNUTi ); void SetUpdateTime ( const int iNUTi );
void SetLight ( int iNewStatus ); void SetLight ( const int iNewStatus );
protected: protected:
enum ELightColor { RL_GREY, RL_RED, RL_GREEN, RL_YELLOW }; enum ELightColor { RL_GREY, RL_RED, RL_GREEN, RL_YELLOW };
ELightColor eColorFlag; ELightColor eColorFlag;
virtual void SetPixmap ( QPixmap& NewBitmap ) {} // must be implemented in derived class! virtual void SetPixmap ( QPixmap& NewBitmap ) {} // must be implemented in derived class
void UpdateColor(); void UpdateColor();
QPixmap BitmCubeGreen; QPixmap BitmCubeGreen;