logsui/logsapp/tsrc/ut_logsapp/logsengine_stub/logsmodel.cpp
changeset 0 4a5361db8937
child 2 7119b73b84d6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/logsui/logsapp/tsrc/ut_logsapp/logsengine_stub/logsmodel.cpp	Tue May 04 12:39:37 2010 +0300
@@ -0,0 +1,197 @@
+/*
+* 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 "logsmodel.h"
+#include "logscall.h"
+#include "logsmessage.h"
+#include "logsdetailsmodel.h"
+#include "logscontact.h"
+#include "logsmatchesmodel.h"
+
+Q_DECLARE_METATYPE(LogsCall*)
+Q_DECLARE_METATYPE(LogsDetailsModel*)
+Q_DECLARE_METATYPE(LogsMessage*)
+Q_DECLARE_METATYPE(LogsContact*)
+
+
+bool mMatchesModelCreated = false;
+
+// -----------------------------------------------------------------------------
+// LogsModel::LogsModel
+// -----------------------------------------------------------------------------
+//
+LogsModel::LogsModel(LogsModelType /*modelType*/, bool /*resourceControl*/) : 
+    LogsAbstractModel(), mDbConnector(0), mIsCleared(false)
+{
+    mEmptyModel = false;
+    mTestIsMarkingNeeded = false;
+    mTestEventsMarked = false;
+    mMissedCallsCounterCleared = false;
+    mRefreshCalled = false;
+    mCompressCalled = false;
+}
+
+// -----------------------------------------------------------------------------
+// LogsModel::~LogsModel
+// -----------------------------------------------------------------------------
+//
+LogsModel::~LogsModel()
+{
+    mTextData.clear();
+    mIconData.clear();
+    //delete mDbConnector; // Not created in stub, no point in deletion 
+}
+
+        
+// -----------------------------------------------------------------------------
+// LogsModel::clearList
+// -----------------------------------------------------------------------------
+//
+bool LogsModel::clearList(LogsModel::ClearType /*cleartype*/)
+{
+    mIsCleared = true;
+    return true;
+}
+
+// -----------------------------------------------------------------------------
+// LogsModel::clearList
+// -----------------------------------------------------------------------------
+//
+int LogsModel::clearMissedCallsCounter()
+{
+    mMissedCallsCounterCleared = true;
+    return 0;
+}
+       
+// -----------------------------------------------------------------------------
+// LogsModel::logsMatchesModel
+// -----------------------------------------------------------------------------
+//
+LogsMatchesModel* LogsModel::logsMatchesModel()
+{
+    mMatchesModelCreated = true;
+    return new LogsMatchesModel(*mDbConnector);
+}
+
+// -----------------------------------------------------------------------------
+// LogsModel::markEventsSeen
+// -----------------------------------------------------------------------------
+//
+bool LogsModel::markEventsSeen(LogsModel::ClearType /*cleartype*/)
+{
+    mTestEventsMarked = true;
+    return mTestIsMarkingNeeded;
+}
+
+// -----------------------------------------------------------------------------
+// LogsModel::refreshData
+// -----------------------------------------------------------------------------
+//
+int LogsModel::refreshData()
+{
+    mRefreshCalled = true;
+}
+
+// -----------------------------------------------------------------------------
+// LogsModel::compressData
+// -----------------------------------------------------------------------------
+//
+int LogsModel::compressData()
+{
+    mCompressCalled = true;
+}
+
+// -----------------------------------------------------------------------------
+// LogsModel::rowCount
+// -----------------------------------------------------------------------------
+//
+int LogsModel::rowCount(const QModelIndex &parent) const
+{
+    Q_UNUSED(parent);
+    if ( mEmptyModel ){
+        return 0;
+    }
+    return 1;//mTextData.count();
+};
+
+// -----------------------------------------------------------------------------
+// LogsModel::data
+// -----------------------------------------------------------------------------
+//
+QVariant LogsModel::data(const QModelIndex &index, int role) const
+{
+    if (!index.isValid()) {
+        return QVariant();
+    }
+    
+    if (role == Qt::DisplayRole) {
+        return QVariant(mTextData);
+    } else if (role == Qt::DecorationRole) {
+        return QVariant(mIconData);
+    }else if ( role == RoleCall ){ 
+        if (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;         
+        }
+    } else if (role == RoleMessage) {
+         if (mTextData.count() > 0){
+            LogsMessage* logsMessage = new LogsMessage();
+            QVariant var = qVariantFromValue(logsMessage);
+            return var;         
+        }
+    } else if (role == RoleContact)
+        if (mTextData.count() > 0){
+            LogsContact* logsContact = new LogsContact();
+            QVariant var = qVariantFromValue(logsContact);
+            return var;
+        }
+    return QVariant();
+}
+
+// -----------------------------------------------------------------------------
+// LogsModel::addTextData
+// -----------------------------------------------------------------------------
+//
+void LogsModel::addTextData(QString text)
+{
+    mTextData.append(text);
+    reset();
+}
+
+// -----------------------------------------------------------------------------
+// LogsModel::isMatchesModelCreated
+// -----------------------------------------------------------------------------
+//
+bool LogsModel::isMatchesModelCreated()
+{
+		return mMatchesModelCreated;
+}
+
+// -----------------------------------------------------------------------------
+// LogsModel::setMatchesModelCreated
+// -----------------------------------------------------------------------------
+//
+void LogsModel::setMatchesModelCreated(bool isCreated)
+{
+		mMatchesModelCreated = isCreated;
+}