|
1 /* |
|
2 * Copyright (c) 2009 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 #include "logsmatchesmodel.h" |
|
18 #include "logslogger.h" |
|
19 #include "logsengdefs.h" |
|
20 #include "logsdbconnector.h" |
|
21 #include "logscall.h" |
|
22 #include "logsdetailsmodel.h" |
|
23 #include "logscontact.h" |
|
24 |
|
25 Q_DECLARE_METATYPE(LogsCall*) |
|
26 Q_DECLARE_METATYPE(LogsDetailsModel*) |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 LogsMatchesModel::LogsMatchesModel( LogsDbConnector& dbConnector ) |
|
33 : LogsAbstractModel() |
|
34 { |
|
35 LOGS_QDEBUG( "logs [ENG] -> LogsMatchesModel::LogsMatchesModel()" ) |
|
36 mDbConnector = &dbConnector; |
|
37 mLastCall = QString(); |
|
38 mTextData.append( "firstitem" ); |
|
39 |
|
40 LOGS_QDEBUG( "logs [ENG] <- LogsMatchesModel::LogsMatchesModel()" ) |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 LogsMatchesModel::~LogsMatchesModel() |
|
48 { |
|
49 LOGS_QDEBUG( "logs [ENG] -> LogsMatchesModel::~LogsMatchesModel()" ) |
|
50 LOGS_QDEBUG( "logs [ENG] <- LogsMatchesModel::~LogsMatchesModel()" ) |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // From QAbstractItemModel |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 int LogsMatchesModel::rowCount(const QModelIndex & /* parent */) const |
|
58 { |
|
59 return mTextData.count(); |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // From QAbstractItemModel |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 QVariant LogsMatchesModel::data(const QModelIndex &index, int role) const |
|
67 { |
|
68 Q_UNUSED(index); |
|
69 Q_UNUSED(role); |
|
70 if ( role == RoleCall && mTextData.count() > 0 ) { |
|
71 LogsCall* logsCall = new LogsCall(); |
|
72 QVariant var = qVariantFromValue(logsCall); |
|
73 return var; |
|
74 } else if (role == RoleDetailsModel) { |
|
75 if (mTextData.count() > 0){ |
|
76 LogsDetailsModel* logsDetails = new LogsDetailsModel(); |
|
77 QVariant var = qVariantFromValue(logsDetails); |
|
78 return var; |
|
79 } |
|
80 } |
|
81 return QVariant(); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void LogsMatchesModel::logsMatches( const QString& pattern ) |
|
89 { |
|
90 Q_UNUSED(pattern); |
|
91 mLastCall = QString("logsMatches"); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 LogsContact* LogsMatchesModel::createContact(const QString& number) |
|
99 { |
|
100 return new LogsContact(number); |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 QString LogsMatchesModel::lastCall() |
|
108 { |
|
109 return mLastCall; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void LogsMatchesModel::resetLastCall() |
|
117 { |
|
118 mLastCall = QString(); |
|
119 } |