2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file HmCustomIconListProvider.cpp = false;
19 * @brief This is the implementation for the IconListItemProviderCustom class
20 * This class contains the functions which are required managing the IconListView's items
23 #include "HmApplicationUtils.h"
24 #include "HmCustomIconListProvider.h"
25 #include "HmCustomPageControl.h"
26 #include "HmHomeItemInfo.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Ui::Controls;
36 CustomIconListProvider::CustomIconListProvider(int index)
38 , __isProjectedItemInvalid(false)
42 , __pPageItemProvider(null)
43 , __pMovementItem(null)
44 , __pOverayBitmap(null)
46 // No implementation required
49 CustomIconListProvider::~CustomIconListProvider(void)
51 if (__pOverayBitmap != null)
53 delete __pOverayBitmap;
54 __pOverayBitmap = null;
59 CustomIconListProvider::GetEditMode(void) const
65 CustomIconListProvider::GetMovingItem(void) const
67 return __pMovementItem;
71 CustomIconListProvider::GetMovingItemIndex() const
73 return __currentIndex;
76 IPageControlItemProvider*
77 CustomIconListProvider::GetPageControlItemProvider(void)
79 return __pPageItemProvider;
83 CustomIconListProvider::SetEditMode(bool editMode)
86 __editMode = editMode;
91 CustomIconListProvider::SetIndex(int index)
93 // sets the index of the provider
99 CustomIconListProvider::SetMaxCountOfIcons(int iconCount)
101 // sets the maximum number of icons in the page.
102 __iconsPerPage = iconCount;
107 CustomIconListProvider::SetMovingItem(Tizen::Ui::Controls::IconListViewItem* pMovedItem)
109 __pMovementItem = pMovedItem;
113 CustomIconListProvider::SetMovingItemIndex(int movedIndex)
115 __currentIndex = movedIndex;
119 CustomIconListProvider::SetPageControlItemProvider(IPageControlItemProvider* pItemProvider)
121 __pPageItemProvider = pItemProvider;
125 CustomIconListProvider::SetProjectedItemInvalid(bool isInvalid)
127 __isProjectedItemInvalid = isInvalid;
131 CustomIconListProvider::CreateItem(int index)
133 IconListViewItem* pItem = null;
134 HomeItemInfo* pItemInfo = null;
136 pItemInfo = __pPageItemProvider->GetItem(__index, index);
137 // if application icon
138 if (pItemInfo != null)
141 if (__pMovementItem != null && __currentIndex == index && !__isProjectedItemInvalid)
143 pItem = __pMovementItem;
147 Bitmap* pItemBitmap = null;
148 String appName = static_cast<HomeItemInfo*>(pItemInfo)->GetAppName();
149 String iconPath = pItemInfo->GetIconPath();
151 if (!iconPath.IsEmpty())
153 // gets the application icon if exists
154 pItemBitmap = pItemInfo->GetApplicationIcon();
155 // creates the icon if application icon doesn't exist.
156 if (pItemBitmap == null)
158 pItemBitmap = ApplicationUtils::GetApplicationIconBitmapN(iconPath, appName);
159 pItemInfo->SetApplicationIcon(pItemBitmap);
162 // constructs the item for the IconListView
163 if (pItemBitmap != null)
165 pItem = new (std::nothrow) IconListViewItem(); //
166 pItem->Construct(*pItemBitmap);
173 bool showDeleteButton = true;
175 if (pItemInfo != null)
177 showDeleteButton = pItemInfo->IsUnistallable();
180 if (showDeleteButton)
182 if (__pOverayBitmap == null)
184 __pOverayBitmap = ApplicationUtils::GetResourceBitmapN(IDB_CLOSE_ICON);
187 if (__pOverayBitmap != null)
189 // adds overlay bitmap to IconListView items if in edit mode.
192 pItem->SetOverlayBitmap(IDA_OVERLAYBITMAP_CLOSE, __pOverayBitmap, ALIGNMENT_RIGHT, ALIGNMENT_TOP);
202 CustomIconListProvider::DeleteItem(int index, IconListViewItem* pItem)
206 if (__pMovementItem != null && __pMovementItem->GetHashCode() == pItem->GetHashCode())
220 CustomIconListProvider::GetItemCount(void)
222 if (__pPageItemProvider != null)
224 return __pPageItemProvider->GetItemCount(__index);