logsui/logscntfinder/inc/logscntentry.h
changeset 2 7119b73b84d6
child 4 e52d42f9500c
equal deleted inserted replaced
0:4a5361db8937 2:7119b73b84d6
       
     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 
       
    18 #ifndef LOGSCNTENTRY_H
       
    19 #define LOGSCNTENTRY_H
       
    20 
       
    21 #include <logscntfinderexport.h>
       
    22 #include <QObject>
       
    23 #include <QList>
       
    24 #include <QString>
       
    25 
       
    26 
       
    27 class LogsCntEntry;
       
    28 typedef QObject LogsCntEntryHandle;
       
    29 
       
    30 
       
    31 class LogsCntText
       
    32 {
       
    33 public:
       
    34 
       
    35     inline LogsCntText() : mHighlights(0){}
       
    36     inline const QString& text() const {return mText;}
       
    37     inline int highlights() const {return mHighlights;}
       
    38     LOGSCNTFINDER_EXPORT QString richText( QString startTag = QString("<b><u>"), 
       
    39                                            QString endTag = QString("</u></b>")) const;
       
    40     
       
    41     
       
    42 private:
       
    43     
       
    44     QString mText;
       
    45     QString mTranslatedText;
       
    46     int mHighlights;
       
    47     
       
    48     friend class LogsCntEntry;
       
    49     friend class UT_LogsCntEntry;
       
    50     friend class UT_LogsCntFinder;
       
    51 };
       
    52 
       
    53 typedef QList<LogsCntText> LogsCntTextList;
       
    54 
       
    55 class LogsCntEntry
       
    56 {
       
    57 public:
       
    58 
       
    59     enum EntryType {
       
    60         EntryTypeHistory,
       
    61         EntryTypeContact
       
    62     };
       
    63     
       
    64     LOGSCNTFINDER_EXPORT LogsCntEntry( LogsCntEntryHandle& handle, 
       
    65                                        quint32 cid );
       
    66     LogsCntEntry( quint32 cid );
       
    67     LogsCntEntry( const LogsCntEntry& entry );
       
    68     ~LogsCntEntry();
       
    69     LOGSCNTFINDER_EXPORT EntryType type() const;
       
    70     LOGSCNTFINDER_EXPORT const LogsCntTextList& firstName() const;
       
    71     LOGSCNTFINDER_EXPORT const LogsCntTextList& lastName() const;
       
    72     LOGSCNTFINDER_EXPORT quint32 contactId() const;
       
    73     LOGSCNTFINDER_EXPORT LogsCntEntryHandle* handle() const;
       
    74     LOGSCNTFINDER_EXPORT void setFirstName( const QString& name );
       
    75     LOGSCNTFINDER_EXPORT void setLastName( const QString& name );
       
    76     LOGSCNTFINDER_EXPORT const LogsCntText& phoneNumber() const;
       
    77     LOGSCNTFINDER_EXPORT const QString& avatarPath() const;
       
    78     LOGSCNTFINDER_EXPORT void setPhoneNumber( const QString& number );
       
    79     LOGSCNTFINDER_EXPORT void setAvatarPath( const QString& avatarpath );
       
    80     LOGSCNTFINDER_EXPORT const QString& speedDial() const;
       
    81     
       
    82     bool isCached() const;
       
    83     void setHighlights( const QString& pattern );
       
    84     void setSpeedDial( const QString& number );
       
    85     bool match( const QString& pattern ) const;
       
    86 
       
    87 private:
       
    88     
       
    89     void doSetText( const QString& text, LogsCntTextList& textlist ); 
       
    90     void doSetHighlights( const QString& pattern, LogsCntTextList& nameArray );
       
    91     void resetHighlights( LogsCntTextList& nameArray );
       
    92     bool doSimpleMatch( const QString& pattern ) const;
       
    93     bool doComplexMatch( QStringList patternArray ) const;
       
    94     
       
    95 
       
    96 private:
       
    97     
       
    98     EntryType mType;
       
    99     quint32 mCid;
       
   100     LogsCntTextList mFirstName;
       
   101     LogsCntTextList mLastName;
       
   102     bool mCached;
       
   103     LogsCntEntryHandle* mHandle;
       
   104     LogsCntText mPhoneNumber;
       
   105     QString mAvatarPath;
       
   106     QString mSpeedDial;
       
   107     
       
   108     friend class UT_LogsCntEntry;
       
   109     friend class UT_LogsCntFinder;
       
   110 };
       
   111 
       
   112 typedef QList<LogsCntEntry*> LogsCntEntryList;
       
   113     
       
   114 
       
   115 #endif //LOGSCNTENTRY_H