|
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 textbuf.Copy( iItemText->Des() ); |
|
84 |
|
85 if( !iDBEngine->InputPhraseCheck( textbuf ) ) |
|
86 { |
|
87 iptrbuf->Zero(); |
|
88 iptrbuf->Copy( textbuf ); |
|
89 |
|
90 iDBEngine->GetErrMsg( errMsg ); |
|
91 errMsg.Copy( errMsg.Mid( 1 ) ); |
|
92 |
|
93 |
|
94 if ( iItemText ) |
|
95 { |
|
96 delete iItemText; |
|
97 iItemText = NULL; |
|
98 } |
|
99 editor->SetTextL( &textbuf ); |
|
100 //note fot err message |
|
101 CAknWarningNote* note = new( ELeave ) CAknWarningNote(); |
|
102 note->SetTimeout( CAknNoteDialog::EShortTimeout ); |
|
103 note->ExecuteLD( errMsg ); |
|
104 |
|
105 UpdateLeftSoftKeyL(); |
|
106 return EFalse; |
|
107 } |
|
108 iptrbuf->Zero(); |
|
109 iptrbuf->Copy( textbuf ); |
|
110 if ( iItemText ) |
|
111 { |
|
112 delete iItemText; |
|
113 iItemText = NULL; |
|
114 } |
|
115 return ETrue; |
|
116 } |
|
117 else |
|
118 { |
|
119 if (aButtonId == EAknSoftkeyCancel) |
|
120 { |
|
121 return ETrue; |
|
122 } |
|
123 } |
|
124 return ETrue; |
|
125 } |
|
126 |
|
127 |
|
128 void CAknFepUserDBQueryDlg::PostLayoutDynInitL() |
|
129 { |
|
130 CAknQueryControl* control = |
|
131 static_cast<CAknQueryControl*>(ControlOrNull(EGeneralQuery)); |
|
132 CEikEdwin* editor = static_cast<CEikEdwin*> |
|
133 ( control->ControlByLayoutOrNull( EDataLayout ) ); |
|
134 editor->SetTextL( iptrbuf ); |
|
135 SetFocus(ETrue); |
|
136 SetFocusing(ETrue); |
|
137 } |
|
138 |
|
139 // End of file |