18
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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: Landmarks category selector dialog
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
// INCLUDE FILES
|
|
27 |
#include "TLmkItemIdDbCombiInfo.h"
|
|
28 |
#include "CLmkCategorySelectorDlg.h"
|
|
29 |
#include "CLmkDlgCategorySelectorImpl.h"
|
|
30 |
#include <lmkui.rsg>
|
|
31 |
#include <landmarks.rsg>
|
|
32 |
#include <lmkerrors.h>
|
|
33 |
|
|
34 |
|
|
35 |
// CONSTANTS
|
|
36 |
/// Unnamed namespace for local definitions
|
|
37 |
namespace {
|
|
38 |
|
|
39 |
//const TInt KSingleSelectedGranularity = 1;
|
|
40 |
_LIT( KPanicMsg, "CLmkCategorySelectorDlg" );
|
|
41 |
|
|
42 |
void Panic( TPanicCode aReason )
|
|
43 |
{
|
|
44 |
User::Panic( KPanicMsg, aReason );
|
|
45 |
}
|
|
46 |
} // namespace
|
|
47 |
|
|
48 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
49 |
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
// CLmkCategorySelectorDlg::CLmkCategorySelectorDlg
|
|
52 |
// C++ default constructor can NOT contain any code, that
|
|
53 |
// might leave.
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CLmkCategorySelectorDlg::CLmkCategorySelectorDlg()
|
|
57 |
: iIsMultiSelector( ETrue )
|
|
58 |
{
|
|
59 |
}
|
|
60 |
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
// CLmkCategorySelectorDlg::ConstructL
|
|
63 |
// Symbian 2nd phase constructor can leave.
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
void CLmkCategorySelectorDlg::ConstructL(
|
|
67 |
TBool aShowEmptyCategories )
|
|
68 |
{
|
|
69 |
iDbs.Append( CPosLandmarkDatabase::OpenL());
|
|
70 |
iSelector = CLmkDlgCategorySelectorImpl::NewL( *(iDbs[0]), aShowEmptyCategories );
|
|
71 |
iSelector->SetEmptyDlgLabel(R_LMK_EMPTY_NO_CATEGORIES ,R_LMK_GUIDE_CREATE_LANDMARK);
|
|
72 |
}
|
|
73 |
|
|
74 |
// -----------------------------------------------------------------------------
|
|
75 |
// CLmkCategorySelectorDlg::NewL
|
|
76 |
// Two-phased constructor.
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
EXPORT_C CLmkCategorySelectorDlg* CLmkCategorySelectorDlg::NewL(
|
|
80 |
TBool aShowEmptyCategories )
|
|
81 |
{
|
|
82 |
CLmkCategorySelectorDlg* self = new ( ELeave ) CLmkCategorySelectorDlg();
|
|
83 |
CleanupStack::PushL( self );
|
|
84 |
self->ConstructL(aShowEmptyCategories );
|
|
85 |
CleanupStack::Pop();
|
|
86 |
return self;
|
|
87 |
}
|
|
88 |
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
// CLmkCategorySelectorDlg::~CLmkCategorySelectorDlg
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
EXPORT_C CLmkCategorySelectorDlg::~CLmkCategorySelectorDlg()
|
|
94 |
{
|
|
95 |
if ( iDestroyedPtr )
|
|
96 |
{
|
|
97 |
*iDestroyedPtr = ETrue;
|
|
98 |
}
|
|
99 |
delete iSelector;
|
|
100 |
if (iDbs.Count() > 0 )
|
|
101 |
{
|
|
102 |
delete iDbs[0];
|
|
103 |
iDbs.Close();
|
|
104 |
}
|
|
105 |
}
|
|
106 |
|
|
107 |
// -----------------------------------------------------------------------------
|
|
108 |
// CLmkCategorySelectorDlg::SetMopParent
|
|
109 |
// -----------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
EXPORT_C void CLmkCategorySelectorDlg::SetMopParent( MObjectProvider* aParent )
|
|
112 |
{
|
|
113 |
__ASSERT_DEBUG( iSelector, Panic( KLmkPanicNullMember ) );
|
|
114 |
iSelector->SetMopParent( aParent );
|
|
115 |
}
|
|
116 |
|
|
117 |
// -----------------------------------------------------------------------------
|
|
118 |
// CLmkCategorySelectorDlg::ExecuteLD
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
// For multiple database support
|
|
122 |
EXPORT_C TInt CLmkCategorySelectorDlg::ExecuteLD( TLmkItemIdDbCombiInfo& aSelected )
|
|
123 |
{
|
|
124 |
__ASSERT_ALWAYS( iSelector, Panic( KLmkPanicNullMember ) );
|
|
125 |
|
|
126 |
// "D" function semantics
|
|
127 |
CleanupStack::PushL( this );
|
|
128 |
TBool thisDestroyed( EFalse );
|
|
129 |
iDestroyedPtr = &thisDestroyed;
|
|
130 |
|
|
131 |
TPosLmItemId selectedId;
|
|
132 |
|
|
133 |
TInt result = iSelector->ExecuteL( selectedId );
|
|
134 |
|
|
135 |
//If user has selected Ok then only return the selected items
|
|
136 |
if(result)
|
|
137 |
{
|
|
138 |
aSelected.SetItemId(selectedId);
|
|
139 |
aSelected.SetLmDb(CPosLandmarkDatabase::OpenL());
|
|
140 |
} //end if(result)
|
|
141 |
|
|
142 |
if ( thisDestroyed )
|
|
143 |
{
|
|
144 |
// this object has been deleted already
|
|
145 |
CleanupStack::Pop( this );
|
|
146 |
}
|
|
147 |
else
|
|
148 |
{
|
|
149 |
CleanupStack::PopAndDestroy( this );
|
|
150 |
}
|
|
151 |
|
|
152 |
return result;
|
|
153 |
}
|
|
154 |
|
|
155 |
// -----------------------------------------------------------------------------
|
|
156 |
// CLmkCategorySelectorDlg::ExecuteLD
|
|
157 |
// -----------------------------------------------------------------------------
|
|
158 |
//
|
|
159 |
// For multiple database support
|
|
160 |
EXPORT_C TInt CLmkCategorySelectorDlg::ExecuteLD(
|
|
161 |
RArray<TLmkItemIdDbCombiInfo>& aSelectedItems )
|
|
162 |
{
|
|
163 |
__ASSERT_ALWAYS( iSelector, Panic( KLmkPanicNullMember ) );
|
|
164 |
|
|
165 |
// "D" function semantics
|
|
166 |
CleanupStack::PushL( this );
|
|
167 |
TBool thisDestroyed( EFalse );
|
|
168 |
iDestroyedPtr = &thisDestroyed;
|
|
169 |
RArray<TPosLmItemId> selectedItems;
|
|
170 |
selectedItems.Reset();
|
|
171 |
for(TInt i = 0; i < aSelectedItems.Count(); i++)
|
|
172 |
{
|
|
173 |
TLmkItemIdDbCombiInfo getItem = aSelectedItems[i];
|
|
174 |
selectedItems.Append(getItem.GetItemId());
|
|
175 |
}
|
|
176 |
TInt result = iSelector->ExecuteL( selectedItems );
|
|
177 |
aSelectedItems.Reset();
|
|
178 |
//If user has clicked on Ok then only return the selection
|
|
179 |
TInt itemCount = selectedItems.Count();
|
|
180 |
if(itemCount > 0)
|
|
181 |
{
|
|
182 |
|
|
183 |
CPosLandmarkDatabase* pDb = CPosLandmarkDatabase::OpenL();
|
|
184 |
|
|
185 |
for (TInt i = 0; i < itemCount; i++)
|
|
186 |
{
|
|
187 |
TLmkItemIdDbCombiInfo selItem;
|
|
188 |
selItem.SetItemId(selectedItems[i]);
|
|
189 |
selItem.SetLmDb(pDb);
|
|
190 |
aSelectedItems.Append(selItem);
|
|
191 |
}
|
|
192 |
|
|
193 |
} //end if(result)
|
|
194 |
|
|
195 |
selectedItems.Close();
|
|
196 |
if ( thisDestroyed )
|
|
197 |
{
|
|
198 |
// this object has been deleted already
|
|
199 |
CleanupStack::Pop( this );
|
|
200 |
}
|
|
201 |
else
|
|
202 |
{
|
|
203 |
CleanupStack::PopAndDestroy( this );
|
|
204 |
}
|
|
205 |
|
|
206 |
return result;
|
|
207 |
}
|
|
208 |
// End of File
|