📄 propertycontainer.cpp
字号:
#include "PropertyContainer.h"
#include <eikclbd.h>
#include <AknQueryDialog.h>
#include "Test_E1122000.h"
#include <Test_E1122000.rsg>
#include "Test_E1122000.hrh"
/*
-----------------------------------------------------------------------
-----------------------------------------------------------------------
*/
CProppertyContainer* CProppertyContainer::NewL(CSensrvChannel* aSensrvSensorChannel)
{
CProppertyContainer* self = CProppertyContainer::NewLC(aSensrvSensorChannel);
CleanupStack::Pop(self);
return self;
}
/*
-----------------------------------------------------------------------
-----------------------------------------------------------------------
*/
CProppertyContainer* CProppertyContainer::NewLC(CSensrvChannel* aSensrvSensorChannel)
{
CProppertyContainer* self = new (ELeave) CProppertyContainer(aSensrvSensorChannel);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
CProppertyContainer::CProppertyContainer(CSensrvChannel* aSensrvSensorChannel)
:iSensrvSensorChannel(aSensrvSensorChannel)
{
}
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
CProppertyContainer::~CProppertyContainer()
{
delete iMyListBox;
}
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
void CProppertyContainer::ConstructL()
{
CreateWindowL();
SetRect(CEikonEnv::Static()->EikAppUi()->ClientRect());
ActivateL();
DrawNow();
}
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CProppertyContainer::HandleResourceChange(TInt aType)
{
TRect rect;
TBool SetR(EFalse);
if ( aType==KEikDynamicLayoutVariantSwitch )
{
SetR = ETrue;
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
}
if(SetR)
{
SetRect(rect);
}
CCoeControl::HandleResourceChange(aType);
}
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
void CProppertyContainer::SizeChanged()
{
MakeListBoxL();
}
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
void CProppertyContainer::MakeListBoxL()
{
TInt MySetIndex(0);
if(iMyListBox)
{
MySetIndex = iMyListBox->CurrentItemIndex();
}
delete iMyListBox;
iMyListBox = NULL;
iMyListBox = new( ELeave ) CAknDoubleStyleListBox();
iMyListBox->ConstructL(this,EAknListBoxSelectionList);
iMyListBox->Model()->SetItemTextArray(GetArrayL());
iMyListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
iMyListBox->CreateScrollBarFrameL( ETrue );
iMyListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
iMyListBox->SetRect(Rect());
iMyListBox->View()->SetListEmptyTextL(KtxNoData);
iMyListBox->ActivateL();
TInt ItemsCount = iMyListBox->Model()->ItemTextArray()->MdcaCount();
if(ItemsCount > MySetIndex && MySetIndex >= 0)
iMyListBox->SetCurrentItemIndex(MySetIndex);
else if(ItemsCount > 0)
iMyListBox->SetCurrentItemIndex(0);
UpdateScrollBar(iMyListBox);
iMyListBox->DrawNow();
}
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
CDesCArray* CProppertyContainer::GetArrayL(void)
{
CDesCArrayFlat* MyArray = new(ELeave)CDesCArrayFlat(1);
CleanupStack::PushL(MyArray);
if(iSensrvSensorChannel)
{
TBuf<255> hjelpper;
RSensrvPropertyList propChannelPropertyList;
iSensrvSensorChannel->GetAllPropertiesL(propChannelPropertyList);
for(TInt i =0; i < propChannelPropertyList.Count(); i++)
{
hjelpper.Copy(_L("\t"));
AppendName(propChannelPropertyList[i].GetPropertyId(),hjelpper);
hjelpper.Append(_L("\t"));
switch(propChannelPropertyList[i].PropertyType())
{
case ESensrvUninitializedProperty:
{
hjelpper.Append(_L("<Uninitialized>"));
}
break;
case ESensrvIntProperty:
{
TInt intVal(0);
propChannelPropertyList[i].GetValue(intVal);
hjelpper.AppendNum(intVal);
}
break;
case ESensrvRealProperty:
{
TReal realVal(0);
propChannelPropertyList[i].GetValue(realVal);
hjelpper.AppendNum((TInt)realVal);
}
break;
case ESensrvBufferProperty:
{
TBuf8<150> bufVal;
TBuf<150> hjelpBuf;
propChannelPropertyList[i].GetValue(bufVal);
hjelpBuf.Copy(bufVal);
hjelpper.Append(hjelpBuf);
}
break;
}
MyArray->AppendL(hjelpper);
}
propChannelPropertyList.Reset();
}
CleanupStack::Pop(MyArray);
return MyArray;
}
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
void CProppertyContainer::AppendName(const TUint32& aId, TDes& aName)
{
switch(aId)
{
case KSensrvPropIdAxisActive:
{
aName.Append(_L("Axis Active"));
}
break;
case KSensrvPropIdDblTapLatency:
{
aName.Append(_L("Dbl Tap Latency"));
}
break;
case KSensrvPropIdDblTapInterval:
{
aName.Append(_L("Dbl Tap Interval"));
}
break;
case KSensrvPropIdDataRate:
{
aName.Append(_L("Data Rate"));
}
break;
case KSensrvPropIdAvailability:
{
aName.Append(_L("Availability"));
}
break;
case KSensrvPropIdMeasureRange:
{
aName.Append(_L("MeasureRange"));
}
break;
case KSensrvPropIdChannelDataFormat:
{
aName.Append(_L("Channel Data Format"));
}
break;
case KSensrvPropIdScaledRange:
{
aName.Append(_L("Scaled Range"));
}
break;
case KSensrvPropIdChannelAccuracy:
{
aName.Append(_L("Channel Accuracy"));
}
break;
case KSensrvPropIdChannelScale:
{
aName.Append(_L("Channel Scale"));
}
break;
case KSensrvPropIdChannelUnit:
{
aName.Append(_L("Channel Unit"));
}
break;
case KSensrvSensorModel:
{
aName.Append(_L("Model"));
}
break;
case KSensrvSensorConnectionType:
{
aName.Append(_L("Connection Type"));
}
break;
case KSensrvSensorDescription:
{
aName.Append(_L("Description"));
}
break;
case KSensrvPropCalibrationLevel:
{
aName.Append(_L("CalibrationLevel"));
}
break;
case KSensrvPropAutoCalibrationActive:
{
aName.Append(_L("AutoCalibrationActive"));
}
break;
default:
{
aName.Append(_L("Unk: "));
aName.AppendNum(aId,EHex);
}
break;
};
}
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
void CProppertyContainer::ModifyPropertyL(void)
{
if(iSensrvSensorChannel && iMyListBox)
{
TInt pos(iMyListBox->CurrentItemIndex());
TBuf<255> hjelpper;
RSensrvPropertyList propChannelPropertyList;
iSensrvSensorChannel->GetAllPropertiesL(propChannelPropertyList);
if(pos >= 0 && pos < propChannelPropertyList.Count())
{
if(propChannelPropertyList[pos].ReadOnly())
{
hjelpper.Copy(_L("Property is Read Only"));
STATIC_CAST(CTestAppUi*,CEikonEnv::Static()->EikAppUi())->ShowDialogL(hjelpper,_L("Info"));
}
else
{
switch(propChannelPropertyList[pos].PropertyType())
{
case ESensrvUninitializedProperty:
{
hjelpper.Copy(_L("Property is Uninitialized"));
STATIC_CAST(CTestAppUi*,CEikonEnv::Static()->EikAppUi())->ShowDialogL(hjelpper,_L("Info"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -