logsui/logsapp/tsrc/ut_logsapp/logsengine_stub/logsmatchesmodel.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 04 Oct 2010 00:17:41 +0300
changeset 20 6a40edd41841
parent 6 41c0a814d878
permissions -rw-r--r--
Revision: 201037 Kit: 201039

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#include "logsmatchesmodel.h"
#include "logslogger.h"
#include "logsengdefs.h"
#include "logsdbconnector.h"
#include "logscall.h"
#include "logsdetailsmodel.h"
#include "logscontact.h"

Q_DECLARE_METATYPE(LogsCall*)
Q_DECLARE_METATYPE(LogsDetailsModel*)

// -----------------------------------------------------------------------------
// 
// -----------------------------------------------------------------------------
//
LogsMatchesModel::LogsMatchesModel( LogsDbConnector& dbConnector ) 
    : LogsAbstractModel()
{
    LOGS_QDEBUG( "logs [ENG] -> LogsMatchesModel::LogsMatchesModel()" )    
    mDbConnector = &dbConnector;
    mLastCall = QString("constructor");
    mTextData.append( "firstitem" );
    
    LOGS_QDEBUG( "logs [ENG] <- LogsMatchesModel::LogsMatchesModel()" )
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
LogsMatchesModel::~LogsMatchesModel()
{
    LOGS_QDEBUG( "logs [ENG] -> LogsMatchesModel::~LogsMatchesModel()" )
    LOGS_QDEBUG( "logs [ENG] <- LogsMatchesModel::~LogsMatchesModel()" )
}

// -----------------------------------------------------------------------------
// From QAbstractItemModel
// -----------------------------------------------------------------------------
//
int LogsMatchesModel::rowCount(const QModelIndex & /* parent */) const
{
    return mTextData.count();
}

// -----------------------------------------------------------------------------
// From QAbstractItemModel
// -----------------------------------------------------------------------------
//
QVariant LogsMatchesModel::data(const QModelIndex &index, int role) const
{
    Q_UNUSED(index);
    Q_UNUSED(role);
    if ( role == RoleCall && mTextData.count() > 0 ) {
        LogsCall* logsCall = new LogsCall();
        QVariant var = qVariantFromValue(logsCall);
        return var;
    } else if (role == RoleDetailsModel) {
        if (mTextData.count() > 0){
           LogsDetailsModel* logsDetails = new LogsDetailsModel();
           QVariant var = qVariantFromValue(logsDetails);
           return var;     
        }
   }
    return QVariant();
}

void LogsMatchesModel::logsMatches( const QString& pattern )
{
    Q_UNUSED(pattern);
    mLastCall = QString("logsMatches");
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
QString LogsMatchesModel::lastCall()
{
    return mLastCall;
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
void LogsMatchesModel::resetLastCall()
{
    mLastCall = QString();
}