phonebookengines/VirtualPhonebook/VPbkEng/src/CVPbkFoldingViewContact.cpp
branchRCL_3
changeset 20 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Virtual Phonebook folding view contact
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CVPbkFoldingViewContact.h"
       
    20 
       
    21 #include <MVPbkContactStore.h>
       
    22 #include <TVPbkFieldTypeMapping.h>
       
    23 #include <MVPbkContactStoreProperties.h>
       
    24 
       
    25 #include "CVPbkFoldingContactView.h"
       
    26 #include "TVPbkFoldingContactBookmark.h"
       
    27 
       
    28 //////////////////////////////////////////////////////////////////////////
       
    29 // TFoldingViewContactTextFieldData implementation
       
    30 //////////////////////////////////////////////////////////////////////////
       
    31 TFoldingViewContactTextFieldData::TFoldingViewContactTextFieldData(
       
    32     CVPbkFoldingViewContact& aParentContact) :
       
    33     iParentContact(aParentContact)
       
    34     {
       
    35     }
       
    36 
       
    37 TBool TFoldingViewContactTextFieldData::IsEmpty() const
       
    38     {
       
    39     return Text().Length() == 0;
       
    40     }
       
    41 
       
    42 TPtrC TFoldingViewContactTextFieldData::Text() const
       
    43     {
       
    44     return iParentContact.NativeParentView().Name();
       
    45     }
       
    46 
       
    47 void TFoldingViewContactTextFieldData::CopyL(const MVPbkContactFieldData& /*aFieldData*/)
       
    48     {
       
    49     }
       
    50 
       
    51 void TFoldingViewContactTextFieldData::SetTextL(const TDesC& /* aText */)
       
    52     {
       
    53     }
       
    54 
       
    55 TInt TFoldingViewContactTextFieldData::MaxLength() const
       
    56     {
       
    57     return KVPbkUnlimitedFieldLength;
       
    58     }
       
    59 
       
    60 // TFoldingViewContactField
       
    61 TFoldingViewContactField::TFoldingViewContactField(CVPbkFoldingViewContact& aParentContact) :
       
    62     iParentContact(aParentContact),
       
    63     iFieldData(aParentContact)
       
    64     {
       
    65     }
       
    66 
       
    67 MVPbkBaseContact& TFoldingViewContactField::ParentContact() const
       
    68     {
       
    69     return iParentContact;
       
    70     }
       
    71 
       
    72 const MVPbkFieldType* TFoldingViewContactField::MatchFieldType(TInt /*aMatchPriority*/) const
       
    73     {
       
    74     if (!iFieldType)
       
    75         {
       
    76         TVPbkFieldTypeMapping typeMapping;
       
    77         typeMapping.SetNonVersitType(EVPbkNonVersitTypeGenericLabel);
       
    78 
       
    79         iFieldType = typeMapping.FindMatch(iParentContact.ParentView().SortOrder());
       
    80         }
       
    81     return iFieldType;
       
    82     }
       
    83 
       
    84 const MVPbkFieldType* TFoldingViewContactField::BestMatchingFieldType() const
       
    85     {
       
    86     TInt dummy = 0;
       
    87     /// MatchFieldType above doesn't use the priority
       
    88     return MatchFieldType(dummy);
       
    89     }
       
    90 
       
    91 const MVPbkContactFieldData& TFoldingViewContactField::FieldData() const
       
    92     {
       
    93     return iFieldData;
       
    94     }
       
    95 
       
    96 TBool TFoldingViewContactField::IsSame(const MVPbkBaseContactField& /*aOther*/) const
       
    97     {
       
    98     return EFalse;
       
    99     }
       
   100 
       
   101 // TFoldingViewFieldCollection
       
   102 TFoldingViewFieldCollection::TFoldingViewFieldCollection(
       
   103     CVPbkFoldingViewContact& aParentContact) :
       
   104     iParentContact(aParentContact),
       
   105     iContactField(aParentContact)
       
   106     {
       
   107     }
       
   108 
       
   109 MVPbkBaseContact& TFoldingViewFieldCollection::ParentContact() const
       
   110     {
       
   111     return iParentContact;
       
   112     }
       
   113 
       
   114 TInt TFoldingViewFieldCollection::FieldCount() const
       
   115     {
       
   116     // The only field is the last name field that contains name of the contact view
       
   117     return 1;
       
   118     }
       
   119 
       
   120 const MVPbkBaseContactField& TFoldingViewFieldCollection::FieldAt(TInt /*aIndex*/) const
       
   121     {
       
   122     return iContactField;
       
   123     }
       
   124 
       
   125 
       
   126 // CVPbkFoldingViewContact
       
   127 CVPbkFoldingViewContact::CVPbkFoldingViewContact(CVPbkFoldingContactView& aParentView) :
       
   128     iParentView(aParentView),
       
   129     iFields(*this)
       
   130     {
       
   131     }
       
   132 
       
   133 CVPbkFoldingViewContact* CVPbkFoldingViewContact::NewL(CVPbkFoldingContactView& aParentView)
       
   134     {
       
   135     CVPbkFoldingViewContact* self = new(ELeave) CVPbkFoldingViewContact(aParentView);
       
   136     return self;
       
   137     }
       
   138 
       
   139 const MVPbkBaseContactFieldCollection& CVPbkFoldingViewContact::Fields() const
       
   140     {
       
   141     return iFields;
       
   142     }
       
   143 
       
   144 TBool CVPbkFoldingViewContact::IsSame(
       
   145         const MVPbkStoreContact& /*aOtherContact*/) const
       
   146     {
       
   147     // A folding contact can not be a store contact
       
   148     return EFalse;
       
   149     }
       
   150 
       
   151 TBool CVPbkFoldingViewContact::IsSame(const MVPbkViewContact& aOtherContact) const
       
   152     {
       
   153     const MVPbkViewContact* thisCnt = this;
       
   154     return thisCnt == &aOtherContact;
       
   155     }
       
   156 
       
   157 TBool CVPbkFoldingViewContact::IsSame(
       
   158         const MVPbkViewContact& /*aOtherContact*/, 
       
   159         const MVPbkContactStore* /*aContactStore*/) const
       
   160     {
       
   161     return EFalse;
       
   162     }
       
   163 
       
   164 TBool CVPbkFoldingViewContact::IsSame(
       
   165         const MVPbkStoreContact& /*aOtherContact*/, 
       
   166         const MVPbkContactStore* /*aContactStore*/) const
       
   167     {
       
   168     return EFalse;
       
   169     }
       
   170 
       
   171 TBool CVPbkFoldingViewContact::MatchContactStore(
       
   172         const TDesC& aContactStoreUri) const
       
   173     {
       
   174     return iParentView.MatchContactStore(aContactStoreUri);
       
   175     }
       
   176 
       
   177 TBool CVPbkFoldingViewContact::MatchContactStoreDomain(
       
   178         const TDesC& aContactStoreDomain) const
       
   179     {
       
   180     return iParentView.MatchContactStoreDomain(aContactStoreDomain);
       
   181     }
       
   182 
       
   183 MVPbkContactBookmark* CVPbkFoldingViewContact::CreateBookmarkLC() const
       
   184     {
       
   185     TVPbkFoldingContactBookmark* bookMark = 
       
   186         new(ELeave) TVPbkFoldingContactBookmark(*this);
       
   187     CleanupStack::PushL(bookMark);
       
   188     return bookMark;
       
   189     }
       
   190         
       
   191 MVPbkContactLink* CVPbkFoldingViewContact::CreateLinkLC() const
       
   192     {
       
   193     return NULL;
       
   194     }
       
   195 
       
   196 void CVPbkFoldingViewContact::DeleteL(MVPbkContactObserver& /*aObserver*/) const
       
   197     {
       
   198     User::Leave(KErrNotSupported);
       
   199     }
       
   200 
       
   201 MVPbkContactViewBase& CVPbkFoldingViewContact::ParentView() const
       
   202     {
       
   203     return iParentView;
       
   204     }
       
   205 
       
   206 void CVPbkFoldingViewContact::ReadL(MVPbkContactObserver& /*aObserver*/) const
       
   207     {
       
   208     User::Leave(KErrNotSupported);
       
   209     }
       
   210 
       
   211 void CVPbkFoldingViewContact::ReadAndLockL(MVPbkContactObserver& /*aObserver*/) const
       
   212     {
       
   213     User::Leave(KErrNotSupported);
       
   214     }
       
   215 
       
   216 MVPbkExpandable* CVPbkFoldingViewContact::Expandable() const
       
   217     {
       
   218     return &iParentView;
       
   219     }
       
   220 //End of file