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