|
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 |
|
19 |
|
20 |
|
21 #include <aknnotewrappers.h> //CAknWarningNote |
|
22 #include <eikedwin.h> //CEikEdwin |
|
23 |
|
24 #include <aknfep.rsg> |
|
25 |
|
26 #include "aknfepuserdbquerydlg.h" |
|
27 #include "dbmanagement.h" |
|
28 |
|
29 const TInt KErrMsgMaxLength = 60; |
|
30 const TInt KTextMaxLength = 10; |
|
31 |
|
32 CAknFepUserDBQueryDlg::CAknFepUserDBQueryDlg( CDBManagement* aDBEngine, |
|
33 TDes& aText, const TTone& aTone ) : |
|
34 CAknTextQueryDialog ( aText, aTone ), iDBEngine(aDBEngine) |
|
35 { |
|
36 iptrbuf = & aText; |
|
37 iItemText = NULL; |
|
38 } |
|
39 |
|
40 CAknFepUserDBQueryDlg::~CAknFepUserDBQueryDlg() |
|
41 { |
|
42 if ( iItemText ) |
|
43 { |
|
44 delete iItemText; |
|
45 iItemText = NULL; |
|
46 } |
|
47 } |
|
48 |
|
49 CAknFepUserDBQueryDlg* CAknFepUserDBQueryDlg::NewLC( CDBManagement* aDBEngine, |
|
50 TDes& aText, const TDesC& aPrompt, const TTone& aTone ) |
|
51 { |
|
52 CAknFepUserDBQueryDlg* self = new (ELeave)CAknFepUserDBQueryDlg( aDBEngine, aText, aTone ); |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL( aPrompt ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 CAknFepUserDBQueryDlg* CAknFepUserDBQueryDlg::NewL( CDBManagement* aDBEngine, |
|
59 TDes& aText, const TDesC& aPrompt, const TTone& aTone ) |
|
60 { |
|
61 CAknFepUserDBQueryDlg* self=CAknFepUserDBQueryDlg::NewLC( aDBEngine, aText, aPrompt, aTone ); |
|
62 CleanupStack::Pop( self ); // self; |
|
63 return self; |
|
64 } |
|
65 |
|
66 void CAknFepUserDBQueryDlg::ConstructL( const TDesC& aPrompt ) |
|
67 { |
|
68 SetPromptL( aPrompt ); |
|
69 } |
|
70 |
|
71 TBool CAknFepUserDBQueryDlg::OkToExitL( TInt aButtonId ) |
|
72 { |
|
73 TBuf<KErrMsgMaxLength> errMsg; |
|
74 if (aButtonId == EAknSoftkeyOk) |
|
75 { |
|
76 CAknQueryControl* control = |
|
77 static_cast<CAknQueryControl*>(ControlOrNull(EGeneralQuery)); |
|
78 CEikEdwin* editor = static_cast<CEikEdwin*> |
|
79 ( control->ControlByLayoutOrNull( EDataLayout ) ); |
|
80 |
|
81 iItemText = editor->GetTextInHBufL(); |
|
82 TBuf<KTextMaxLength> textbuf; |
|
83 |
|
84 if( iItemText != NULL ) |
|
85 { |
|
86 textbuf.Copy( iItemText->Des() ); |
|
87 } |
|
88 |
|
89 if( !iDBEngine->InputPhraseCheck( textbuf ) ) |
|
90 { |
|
91 iptrbuf->Zero(); |
|
92 iptrbuf->Copy( textbuf ); |
|
93 |
|
94 iDBEngine->GetErrMsg( errMsg ); |
|
95 errMsg.Copy( errMsg.Mid( 1 ) ); |
|
96 |
|
97 |
|
98 if ( iItemText ) |
|
99 { |
|
100 delete iItemText; |
|
101 iItemText = NULL; |
|
102 } |
|
103 editor->SetTextL( &textbuf ); |
|
104 //note fot err message |
|
105 CAknWarningNote* note = new( ELeave ) CAknWarningNote(); |
|
106 note->SetTimeout( CAknNoteDialog::EShortTimeout ); |
|
107 note->ExecuteLD( errMsg ); |
|
108 |
|
109 UpdateLeftSoftKeyL(); |
|
110 return EFalse; |
|
111 } |
|
112 iptrbuf->Zero(); |
|
113 iptrbuf->Copy( textbuf ); |
|
114 if ( iItemText ) |
|
115 { |
|
116 delete iItemText; |
|
117 iItemText = NULL; |
|
118 } |
|
119 return ETrue; |
|
120 } |
|
121 else |
|
122 { |
|
123 if (aButtonId == EAknSoftkeyCancel) |
|
124 { |
|
125 return ETrue; |
|
126 } |
|
127 } |
|
128 return ETrue; |
|
129 } |
|
130 |
|
131 |
|
132 void CAknFepUserDBQueryDlg::PostLayoutDynInitL() |
|
133 { |
|
134 CAknQueryControl* control = |
|
135 static_cast<CAknQueryControl*>(ControlOrNull(EGeneralQuery)); |
|
136 CEikEdwin* editor = static_cast<CEikEdwin*> |
|
137 ( control->ControlByLayoutOrNull( EDataLayout ) ); |
|
138 editor->SetTextL( iptrbuf ); |
|
139 SetFocus(ETrue); |
|
140 SetFocusing(ETrue); |
|
141 } |
|
142 |
|
143 // End of file |