40
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cxutils.h"
|
|
19 |
#include "cxuieventlog.h"
|
|
20 |
|
|
21 |
/*!
|
|
22 |
* Event log item constructor.
|
|
23 |
* @param type Event type description
|
|
24 |
* @param id Event id description
|
|
25 |
*/
|
|
26 |
CxuiEventLog::CxuiEvent::CxuiEvent(const QString &type, const QString &value)
|
|
27 |
: mTime(QTime::currentTime()), mType(type), mValue(value)
|
|
28 |
{
|
|
29 |
}
|
|
30 |
|
|
31 |
|
|
32 |
/*!
|
|
33 |
* Event log constructor.
|
|
34 |
* @param name Event log name.
|
|
35 |
* @param size Maximum number of events stored to log. After maximum size is encountered,
|
|
36 |
* old events are discarded as new ones are added.
|
|
37 |
*/
|
|
38 |
CxuiEventLog::CxuiEventLog(const QString& name, int size)
|
|
39 |
: mSize(size),
|
|
40 |
mName(name)
|
|
41 |
{
|
|
42 |
}
|
|
43 |
|
|
44 |
/*!
|
|
45 |
* Event log destructor.
|
|
46 |
*/
|
|
47 |
CxuiEventLog::~CxuiEventLog()
|
|
48 |
{
|
|
49 |
}
|
|
50 |
|
|
51 |
/*!
|
|
52 |
* Append new event to the log.
|
|
53 |
* @param type Event type description
|
|
54 |
* @param id Event id description
|
|
55 |
*/
|
|
56 |
void CxuiEventLog::append(const QString &type, const QString &value)
|
|
57 |
{
|
|
58 |
if (mSize) {
|
|
59 |
if (mEvents.size() >= mSize) {
|
|
60 |
mEvents.removeFirst();
|
|
61 |
}
|
|
62 |
mEvents.append(CxuiEvent(type, value));
|
|
63 |
}
|
|
64 |
}
|
|
65 |
|
|
66 |
/*!
|
|
67 |
* Print out the event log.
|
|
68 |
*/
|
|
69 |
void CxuiEventLog::print() const
|
|
70 |
{
|
|
71 |
if (mEvents.size()) {
|
|
72 |
|
|
73 |
CX_DEBUG(("[INFO] >>> CameraX event log[%s]", mName.toAscii().constData()));
|
|
74 |
foreach(CxuiEvent e, mEvents) {
|
|
75 |
CX_DEBUG(("[INFO] <-> event: time[%s] type[%s] value[%s]",
|
|
76 |
e.mTime.toString("HH:mm:ss.zzz").toAscii().constData(),
|
|
77 |
e.mType.toAscii().constData(),
|
|
78 |
e.mValue.toAscii().constData()));
|
|
79 |
}
|
|
80 |
CX_DEBUG(("[INFO] <<< CameraX event log[%s]", mName.toAscii().constData()));
|
|
81 |
}
|
|
82 |
}
|
|
83 |
|
|
84 |
// end of file
|