Fixed Nabi Issues
[apps/osp/Internet.git] / src / IntHistoryListForm.cpp
index 5fe41f4..933cda8 100644 (file)
@@ -159,6 +159,7 @@ HistoryListForm::OnInitializing(void)
        {
                return E_FAILURE;
        }
+       __pSearchBar->AddFocusEventListener(*this);
        __pSearchListView = new(std::nothrow) GroupedListView();
        if (__pSearchListView == null)
        {
@@ -276,9 +277,9 @@ HistoryListForm::OnActionPerformed(const Control& source, int actionId)
        break;
        case IDA_TABBAR_ITEM_1:
        {
-               result r = GetHeader()->SetItemSelected(1);
-               AppLog("SetItemSelected result %s",GetErrorMessage(r));
-               GetHeader()->Invalidate(true);
+       //      result r = GetHeader()->SetItemSelected(1);
+       //      AppLog("SetItemSelected result %s",GetErrorMessage(r));
+       //      GetHeader()->Invalidate(true);
 
                if (pSceneManager != null)
                {
@@ -292,20 +293,14 @@ HistoryListForm::OnActionPerformed(const Control& source, int actionId)
                        }
                        else
                        {
-
                                if(pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT))!= E_SUCCESS)
                                {
                                        AppLogDebug("BookmarkListForm::OnActionPerformed GoBackward failed");
                                        return;
                                }
-
                        }
                }
-//             r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
-               if (IsFailed(r))
-               {
-                       return;
-               }
+
        }
        break;
        default:
@@ -314,6 +309,18 @@ HistoryListForm::OnActionPerformed(const Control& source, int actionId)
 }
 
 void
+HistoryListForm::OnFocusGained(const Tizen::Ui::Control& source)
+{
+       __pSearchListView->SetEnabled(false);
+}
+
+void
+HistoryListForm::OnFocusLost(const Tizen::Ui::Control& source)
+{
+       __pSearchListView->SetEnabled(true);
+       __searchHistory = false;
+}
+void
 HistoryListForm::OnFormBackRequested(Form& source)
 {
        SceneManager* pSceneManager = SceneManager::GetInstance();
@@ -468,7 +475,7 @@ HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
 
 
                if (pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK") || pGroupItemClass->GetTitleText() == weeksAgo2
-                               || pGroupItemClass->GetTitleText() == weeksAgo3 || pGroupItemClass->GetTitleText() == weeksAgo4 || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_MONTH") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_BODY_OLDER"))
+                               || pGroupItemClass->GetTitleText() == weeksAgo3 || pGroupItemClass->GetTitleText() == weeksAgo4 || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_BODY_LAST_MONTH") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_BODY_OLDER"))
                {
                        text.Append(L" - ");
                        text.Append(pGroupItemClass->GetEndTime().GetDay());
@@ -585,19 +592,20 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
                }
        }
        bool urlFoundInBookmark = false;
-
-       if(__pBookmarkList != null)
-       {
-               for (int i = 0; i < __pBookmarkList->GetCount();i++)
-               {
-                       BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
-                       if(pBookMark != null && pHistory->GetHistoryUrl().CompareTo(pBookMark->GetUrl()) == 0)
-                       {
-                               urlFoundInBookmark = true;
-                               break;
-                       }
-               }
-       }
+//
+//     if(__pBookmarkList != null)
+//     {
+//             for (int i = 0; i < __pBookmarkList->GetCount();i++)
+//             {
+//                     BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
+//                     if(pBookMark != null && pHistory->GetHistoryUrl().CompareTo(pBookMark->GetUrl()) == 0)
+//                     {
+//                             urlFoundInBookmark = true;
+//                             break;
+//                     }
+//             }
+//     }
+       BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(pHistory->GetHistoryUrl(),urlFoundInBookmark);
        if (urlFoundInBookmark == true)
        {
                pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
@@ -677,7 +685,7 @@ HistoryListForm::GetGroupCount(void)
                        int count = 0;
                        DateTime startTime;
                        DateTime endTime;
-                       HistoryPresentationModel::GetCurrentDateTime(endTime);;
+                       HistoryPresentationModel::GetCurrentDateTime(endTime);
 
                        startTime.SetValue(0,0,0);
 
@@ -691,6 +699,11 @@ HistoryListForm::GetGroupCount(void)
                else
                {
                        int count = 0;
+                       if (__searchText.GetLength() > 0)
+                       {
+                               __searchText.Replace(L"%", L"/%");
+                               __searchText.Replace(L"_", L"/_");
+                       }
                //      String searchText = __pSearchBar->GetText();
                        result r = HistoryPresentationModel::GetInstance()->GetSearchHistoryCount(count, __searchText);
                        if(count)
@@ -835,7 +848,12 @@ HistoryListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId
        }
 
        int count = 0;
-       HistoryPresentationModel::GetInstance()->GetHistoryCount(count);
+       DateTime startTime;
+       DateTime endTime;
+       HistoryPresentationModel::GetCurrentDateTime(endTime);;
+
+       startTime.SetValue(0,0,0);
+       HistoryPresentationModel::GetInstance()->GetHistoryCountWithTimeRange(startTime,endTime,count);
        if (count == 0)
        {
                __pSearchBar->SetShowState(false);
@@ -853,10 +871,10 @@ HistoryListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId
        //              __pGroupedListView->UpdateList();
        //      }
 
-       result r = GetHeader()->SetItemSelected(2);
+       result r = GetHeader()->SetItemSelected(1);
        if (IsFailed(r))
        {
-               AppLog("HistoryListForm::OnSceneActivatedN header failed %ls", GetErrorMessage(r));
+               AppLog("HistoryListForm::OnSceneActivatedN header failed %s", GetErrorMessage(r));
                return;
        }
 
@@ -905,18 +923,19 @@ HistoryListForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
 
                bool bookmarkFound = false;
                BookmarkData* pBookMark = null;
-               if(__pBookmarkList != null)
-               {
-                       for (int i = 0; i < __pBookmarkList->GetCount(); i++)
-                       {
-                               pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
-                               if (pBookMark != null && toggledUrl.CompareTo(pBookMark->GetUrl()) == 0)
-                               {
-                                       bookmarkFound = true;
-                                       break;
-                               }
-                       }
-               }
+//             if(__pBookmarkList != null)
+//             {
+//                     for (int i = 0; i < __pBookmarkList->GetCount(); i++)
+//                     {
+//                             pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
+//                             if (pBookMark != null && toggledUrl.CompareTo(pBookMark->GetUrl()) == 0)
+//                             {
+//                                     bookmarkFound = true;
+//                                     break;
+//                             }
+//                     }
+//             }
+               BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(toggledUrl,bookmarkFound);
                if(bookmarkFound == false)
                {
                        // Add the history in bookmark database
@@ -928,7 +947,13 @@ HistoryListForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
                        bookmark.SetBookmarkTitle(bookmarkTitle);
                        bookmark.SetUrl(pHistory->GetHistoryUrl());
                        bookmark.SetFaviconId(pHistory->GetFaviconId());
-                       bookmark.SetFavIconBuffer(*pHistory->GetFavIconBuffer());
+                       if(pHistory->GetFavIconBuffer())
+                       {
+                               ByteBuffer *pBuffer = new ByteBuffer();
+
+                               pBuffer->Construct(*pHistory->GetFavIconBuffer());
+                               bookmark.SetFavIconBuffer(*pBuffer);
+                       }
                        //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(pBookmark);
                        r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(bookmark);
                }
@@ -1311,7 +1336,7 @@ HistoryListForm::CreateGroupItems()
                {
                        return;
                }
-               titleText = CommonUtil::GetString(L"IDS_BR_BODY_SEARCHED_ITEMS");
+               titleText = CommonUtil::GetString(L"IDS_BR_BODY_SEARCH");
                pGroupItemClass->SetTitleText(titleText);
                r = __pGroupData->Add(*pGroupItemClass);
                if (IsFailed(r))
@@ -1824,7 +1849,7 @@ HistoryListForm::CreateGroupItems()
                {
                        return;
                }
-               titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_MONTH");
+               titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_MONTH");
                pGroupItemClass->SetTitleText(titleText);
                dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
                dateTime.AddDays(-1);