HistoryListForm::HistoryListForm(void)
{
+ __pBookmarkList = null;
__pGroupedListView =null;
__pSearchListView = null;
__pSearchBar = null;
__pGroupData->RemoveAll(false);
delete __pGroupData;
}
+ if(__pBookmarkList != null)
+ {
+ __pBookmarkList->RemoveAll(false);
+ delete __pBookmarkList;
+ }
}
bool
}
}
+ __pBookmarkList = new(std::nothrow) Collection::ArrayList();
+ __pBookmarkList->Construct();
+ BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
return r;
}
result r = E_FAILURE;
History* pHistory = null;
Bitmap* pBitmap = null;
+ Bitmap* pBookmarkBitmap = null;
GroupItemClass* pGroupItemClass = null;
CustomItem* pItem = new(std::nothrow) CustomItem();
int bookmarkBtnWidth = 0;
return null;
}
}
-// if (pHistory->GetBookmarkId().GetLength()>0)
-// {
-// pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
-// }
-// else
-// {
-// pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
-// }
+ bool urlFoundInBookmark = false;
+
+ if(__pBookmarkList != null)
+ {
+ for (int i = 0; i < __pBookmarkList->GetCount();i++)
+ {
+ BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
+ if(pHistory->GetHistoryUrl().CompareTo(pBookMark->GetUrl()) == 0)
+ {
+ urlFoundInBookmark = true;
+ break;
+ }
+ else
+ {
+ pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
+ }
+ }
+ }
+ if (urlFoundInBookmark == true)
+ {
+ pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
+ }
+ else
+ {
+ pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
+ }
bookmarkBtnWidth = 64;
else
r = pItem->AddElement(Rectangle(104, 70, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 48), IDA_FORMAT_URL, pHistory->GetHistoryUrl(),32,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,true);
TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
-// if ( pBookmarkBitmap != null)
-// {
-// r = pItem->AddElement(Rectangle(GetClientAreaBounds().width - bookmarkBtnWidth - 16, (128 - pBookmarkBitmap->GetHeight())/2, bookmarkBtnWidth, bookmarkBtnWidth), IDA_FORMAT_BOOKMARK, *pBookmarkBitmap);
-// TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
-// delete pBookmarkBitmap;
-// }
+ if ( pBookmarkBitmap != null)
+ {
+ r = pItem->AddElement(Rectangle(GetClientAreaBounds().width - bookmarkBtnWidth - 16, (128 - pBookmarkBitmap->GetHeight())/2, bookmarkBtnWidth, bookmarkBtnWidth), IDA_FORMAT_BOOKMARK, *pBookmarkBitmap);
+ TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
+ delete pBookmarkBitmap;
+ }
return pItem;
CATCH:
return;
}
+ if(__pBookmarkList != null)
+ {
+ __pBookmarkList->RemoveAll(false);
+ }
+
+ BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
+
Invalidate(true);
}
toggledUrl = pHistory->GetHistoryUrl();
AppLog("History's Bookmark ID %ls ToggledUrl %ls",pHistory->GetBookmarkId().GetPointer(),toggledUrl.GetPointer());
- if (pHistory->GetBookmarkId().GetLength() > 0)
- {
- AppLog("Already added to bookmark so will be removed");
- String bookmarkId = L"";
- int id = 0;
- bookmarkId = pHistory->GetBookmarkId();
- Integer::Parse(bookmarkId,id);
- BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
- pHistory->SetBookmarkId(L"");
- //listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);
-
- for(int grindex = 0 ; grindex < __pGroupData->GetCount() ; grindex++)
+ bool bookmarkFound = false;
+ BookmarkData* pBookMark = null;
+ if(__pBookmarkList != null)
+ {
+ for (int i = 0; i < __pBookmarkList->GetCount(); i++)
{
- pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(grindex));
- if (pGroupItemClass == null)
+ pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
+ if (toggledUrl.CompareTo(pBookMark->GetUrl()) == 0)
{
- continue;
- }
- for(int index = 0 ; index < pGroupItemClass->GetHistoryData()->GetCount() ; index++)
- {
- pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(index));
- if (pHistory == null)
- {
- continue;
- }
- if (toggledUrl.CompareTo(pHistory->GetHistoryUrl()) == 0)
- {
- pHistory->SetBookmarkId(L"");
- AppLog("Already added to bookmark so will be removed");
- String bookmarkId = L"";
- int id = 0;
-
- bookmarkId = pHistory->GetBookmarkId();
- Integer::Parse(bookmarkId,id);
- BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
- pHistory->SetBookmarkId(L"");
- //listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);
-
- for(int grindex = 0 ; grindex < __pGroupData->GetCount() ; grindex++)
- {
- pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(grindex));
- if (pGroupItemClass == null)
- {
- continue;
- }
- for(int index = 0 ; index < pGroupItemClass->GetHistoryData()->GetCount() ; index++)
- {
- pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(index));
- if (pHistory == null)
- {
- continue;
- }
- if (toggledUrl.CompareTo(pHistory->GetHistoryUrl()) == 0)
- {
- pHistory->SetBookmarkId(L"");
- //listView.RefreshList(grindex,index,LIST_REFRESH_TYPE_ITEM_MODIFY);
- }
- }
- }
-
- //listView.RefreshList(grindex,index,LIST_REFRESH_TYPE_ITEM_MODIFY);
- }
+ bookmarkFound = true;
+ break;
}
}
- listView.UpdateList();
-
}
- else
+ if(bookmarkFound == false)
{
- AppLog("Adding history to bookmark");
+ // Add the history in bookmark database
result r = E_FAILURE;
BookmarkData pBookmark;
pBookmark.SetFaviconId(pHistory->GetFaviconId());
r = BookmarkPresentationModel::GetInstance()->SaveBookmark(pBookmark);
- if (!IsFailed(r))
- {
- AppLog("History added to bookmark with ID %ls",pBookmark.GetBookmarkId().GetPointer());
- pHistory->SetBookmarkId(pBookmark.GetBookmarkId());
- }
-
- listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);
+ }
+ else
+ {
+ // remove the history from bookmark database
+ BookmarkPresentationModel::GetInstance()->DeleteBookmark(toggledUrl);
+ }
- for(int grindex = 0 ; grindex < __pGroupData->GetCount() ; grindex++)
- {
- pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(grindex));
- if (pGroupItemClass == null)
- {
- continue;
- }
- for(int index = 0 ; index < pGroupItemClass->GetHistoryData()->GetCount() ; index++)
- {
- pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(index));
- if (pHistory == null)
- {
- continue;
- }
- if (toggledUrl.CompareTo(pHistory->GetHistoryUrl()) == 0)
- {
- pHistory->SetBookmarkId(pBookmark.GetBookmarkId());
- //listView.RefreshList(grindex,index,LIST_REFRESH_TYPE_ITEM_MODIFY);
- }
- }
- }
- listView.UpdateList();
+ if(__pBookmarkList != null)
+ {
+ __pBookmarkList->RemoveAll(false);
+ BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
}
+ listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);
+ listView.UpdateList();
}
else
{
-
pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
if (pGroupItemClass == null)
{