fix for multicolor LED, still not solved: LED in list view not working

This commit is contained in:
Volker Fischer 2008-02-01 08:27:09 +00:00
parent 58cb051a14
commit cfa6891b5b
2 changed files with 26 additions and 38 deletions

View file

@ -30,7 +30,7 @@
/* Implementation *************************************************************/
CMultiColorLEDbase::CMultiColorLEDbase ( QWidget* parent, Qt::WindowFlags f )
CMultiColorLED::CMultiColorLED ( QWidget* parent, Qt::WindowFlags f )
: QLabel ( parent, f ),
BitmCubeGreen ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ),
BitmCubeRed ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ),
@ -46,8 +46,13 @@ CMultiColorLEDbase::CMultiColorLEDbase ( QWidget* parent, Qt::WindowFlags f )
// init color flags
Reset();
// set modified style of label
setFrameShape ( QFrame::Panel );
setFrameShadow ( QFrame::Sunken );
setIndent ( 0 );
// set init bitmap
SetPixmap ( BitmCubeGrey );
setPixmap ( BitmCubeGrey );
eColorFlag = RL_GREY;
// init update time
@ -62,7 +67,7 @@ CMultiColorLEDbase::CMultiColorLEDbase ( QWidget* parent, Qt::WindowFlags f )
this, SLOT ( OnTimerYellowLight() ) );
}
void CMultiColorLEDbase::Reset()
void CMultiColorLED::Reset()
{
// reset color flags
bFlagRedLi = false;
@ -72,25 +77,25 @@ void CMultiColorLEDbase::Reset()
UpdateColor();
}
void CMultiColorLEDbase::OnTimerRedLight()
void CMultiColorLED::OnTimerRedLight()
{
bFlagRedLi = false;
UpdateColor();
}
void CMultiColorLEDbase::OnTimerGreenLight()
void CMultiColorLED::OnTimerGreenLight()
{
bFlagGreenLi = false;
UpdateColor();
}
void CMultiColorLEDbase::OnTimerYellowLight()
void CMultiColorLED::OnTimerYellowLight()
{
bFlagYellowLi = false;
UpdateColor();
}
void CMultiColorLEDbase::UpdateColor()
void CMultiColorLED::UpdateColor()
{
/* Red light has highest priority, then comes yellow and at the end, we
decide to set green light. Allways check the current color of the
@ -99,7 +104,7 @@ void CMultiColorLEDbase::UpdateColor()
{
if ( eColorFlag != RL_RED )
{
SetPixmap ( BitmCubeRed );
setPixmap ( BitmCubeRed );
eColorFlag = RL_RED;
}
return;
@ -109,7 +114,7 @@ void CMultiColorLEDbase::UpdateColor()
{
if ( eColorFlag != RL_YELLOW )
{
SetPixmap ( BitmCubeYellow );
setPixmap ( BitmCubeYellow );
eColorFlag = RL_YELLOW;
}
return;
@ -119,7 +124,7 @@ void CMultiColorLEDbase::UpdateColor()
{
if ( eColorFlag != RL_GREEN )
{
SetPixmap ( BitmCubeGreen );
setPixmap ( BitmCubeGreen );
eColorFlag = RL_GREEN;
}
return;
@ -128,12 +133,12 @@ void CMultiColorLEDbase::UpdateColor()
// if no color is active, set control to grey light
if ( eColorFlag != RL_GREY )
{
SetPixmap ( BitmCubeGrey );
setPixmap ( BitmCubeGrey );
eColorFlag = RL_GREY;
}
}
void CMultiColorLEDbase::SetLight ( const int iNewStatus )
void CMultiColorLED::SetLight ( const int iNewStatus )
{
switch ( iNewStatus )
{
@ -159,7 +164,7 @@ void CMultiColorLEDbase::SetLight ( const int iNewStatus )
UpdateColor();
}
void CMultiColorLEDbase::SetUpdateTime ( const int iNUTi )
void CMultiColorLED::SetUpdateTime ( const int iNUTi )
{
// avoid too short intervals
if ( iNUTi < MIN_TIME_FOR_RED_LIGHT )
@ -171,13 +176,3 @@ void CMultiColorLEDbase::SetUpdateTime ( const int iNUTi )
iUpdateTime = iNUTi;
}
}
CMultiColorLED::CMultiColorLED ( QWidget* parent, Qt::WindowFlags f )
: CMultiColorLEDbase ( parent, f )
{
// set modified style
setFrameShape ( QFrame::Panel );
setFrameShadow ( QFrame::Sunken );
setIndent ( 0 );
}

View file

@ -1,5 +1,5 @@
/******************************************************************************\
* Copyright (c) 2004-2006
* Copyright (c) 2004-2008
*
* Author(s):
* Volker Fischer
@ -49,12 +49,12 @@
/* Classes ********************************************************************/
class CMultiColorLEDbase : public QLabel
class CMultiColorLED : public QLabel
{
Q_OBJECT
public:
CMultiColorLEDbase ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
CMultiColorLED ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
void Reset();
void SetUpdateTime ( const int iNUTi );
@ -64,7 +64,6 @@ protected:
enum ELightColor { RL_GREY, RL_RED, RL_GREEN, RL_YELLOW };
ELightColor eColorFlag;
virtual void SetPixmap ( QPixmap& NewBitmap ) {} // must be implemented in derived class
void UpdateColor();
QPixmap BitmCubeGreen;
@ -89,17 +88,11 @@ protected slots:
};
class CMultiColorLED : public CMultiColorLEDbase
{
public:
CMultiColorLED ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
protected:
virtual void SetPixmap ( QPixmap& NewBitmap ) { setPixmap ( NewBitmap ); }
};
class CMultColLEDListViewItem : public CMultiColorLEDbase
// TODO list view item LED does not work anymore
class CMultColLEDListViewItem : public CMultiColorLED
{
public:
CMultColLEDListViewItem ( const int iNewCol ) : iColumn ( iNewCol ),