|
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 CNTDISPLAYTEXTFORMATTER_H_ |
|
19 #define CNTDISPLAYTEXTFORMATTER_H_ |
|
20 |
|
21 #include <QObject> |
|
22 #include <qcontactfilter.h> |
|
23 QTM_USE_NAMESPACE |
|
24 |
|
25 #define TAG_START "<span style=\"background-color:%1;color:%2\">" |
|
26 #define TAG_END "</span>" |
|
27 |
|
28 class CntDisplayTextFormatter |
|
29 { |
|
30 public: |
|
31 virtual ~CntDisplayTextFormatter(){} |
|
32 virtual QString formattedText( const QString aText, const QContactFilter& aCriteria ) = 0; |
|
33 }; |
|
34 |
|
35 class CntDummyDisplayTextFormatter : public QObject, public CntDisplayTextFormatter |
|
36 { |
|
37 Q_OBJECT |
|
38 public: |
|
39 CntDummyDisplayTextFormatter(){} |
|
40 ~CntDummyDisplayTextFormatter(){} |
|
41 |
|
42 inline QString formattedText( const QString aText, const QContactFilter& aCriteria ) |
|
43 { |
|
44 Q_UNUSED( aCriteria ); |
|
45 return aText; |
|
46 } |
|
47 }; |
|
48 |
|
49 class CntHTMLDisplayTextFormatter : public QObject, public CntDisplayTextFormatter |
|
50 { |
|
51 Q_OBJECT |
|
52 |
|
53 public: |
|
54 CntHTMLDisplayTextFormatter(); |
|
55 virtual ~CntHTMLDisplayTextFormatter(); |
|
56 |
|
57 /*! |
|
58 * Format given text with applied filter. Not that only following filter is supported: |
|
59 * |
|
60 * QContactDetailFilter filter; |
|
61 * filter.setDetailDefinitionName( QContactDisplayLabel::DefinitionName ); |
|
62 * filter.setMatchFlags( QContactDetailFilter::MatchStartsWith ); |
|
63 * |
|
64 * \param aText Buffer where to format |
|
65 * \param aCriteria Applied filter |
|
66 */ |
|
67 QString formattedText( const QString aText, const QContactFilter& aCriteria ); |
|
68 |
|
69 /*! |
|
70 * Insert tag to given text leaving given number |
|
71 * of characters between start and end tag. |
|
72 * By default highlight is inserted. |
|
73 * |
|
74 * \param aText Buffer where to insert tags |
|
75 * \param aNumOfCharacters Number of characters to highlight |
|
76 */ |
|
77 virtual void insertTag( QString& aText, int aNumOfCharacters ); |
|
78 }; |
|
79 #endif /* CNTDISPLAYTEXTFORMATTER_H_ */ |