From 945f9e92ae78981ac0bccaf8bf18051a9b7ea7b0 Mon Sep 17 00:00:00 2001 From: Oleksandr Kaspruk Date: Thu, 4 Apr 2013 03:11:50 +0900 Subject: [PATCH] Fixed Delete button disabling. Change-Id: Iee5c9ece8206801524d8ffe5a91cdb37364d5609 Signed-off-by: Oleksandr Kaspruk --- project/src/FeatureManagerForm.cpp | 51 +++++++++++++++++++++++++++++-------- project/src/FeatureSetGenerator.cpp | 8 +++--- project/src/FileManagerForm.cpp | 2 +- project/src/MainForm.cpp | 4 +-- project/src/UpdatePanel.cpp | 2 +- 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/project/src/FeatureManagerForm.cpp b/project/src/FeatureManagerForm.cpp index e01f03f..6180d13 100644 --- a/project/src/FeatureManagerForm.cpp +++ b/project/src/FeatureManagerForm.cpp @@ -55,10 +55,11 @@ FeatureManagerForm::OnInitializing(void) pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); pFooter->SetBackButton(); - FooterItem pFooterItemSend; - pFooterItemSend.Construct(ID_FOOTER_ITEM_DELETE); - pFooterItemSend.SetText(L"Delete"); - pFooter->AddItem(pFooterItemSend); + FooterItem pFooterItemDelete; + pFooterItemDelete.Construct(ID_FOOTER_ITEM_DELETE); + pFooterItemDelete.SetText(L"Delete"); + pFooter->AddItem(pFooterItemDelete); + pFooter->SetItemEnabled(0, false); pFooter->AddActionEventListener(*this); return E_SUCCESS; @@ -94,15 +95,16 @@ FeatureManagerForm::OnActionPerformed (const Tizen::Ui::Control &source, int act SceneManager* pSceneManager = SceneManager::GetInstance(); AppAssert(pSceneManager); - switch(actionId) + switch (actionId) { case ID_FOOTER_ITEM_DELETE: { - for (int i = this->GetItemCount(); i >= 0; i--) + int items = this->GetItemCount() - 1; + + for (int i = items; i >= 0; i--) { if (__pIconListView->IsItemChecked(i)) { - AppLog("MainForm:: deleting item %i", i); pForm->GetFeatureManager()->DeleteFeature(i); } } @@ -158,7 +160,7 @@ FeatureManagerForm::CreateItem(int index) if (pForm->GetFeatureManager()) { const Tizen::Uix::Vision::ImageFeatureInfo* pFeature = pForm->GetFeatureManager()->GetImageFeatureInfo(index); - if(pFeature == null) + if (pFeature == null) { return pIconListViewItem; } @@ -195,7 +197,7 @@ FeatureManagerForm::CreateItem(int index) pIconListViewItem->Construct(*pBitmap, &name); - if(pByteBuffer) + if (pByteBuffer) { delete pByteBuffer; } @@ -207,6 +209,35 @@ FeatureManagerForm::CreateItem(int index) void FeatureManagerForm::OnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView &view, int index, Tizen::Ui::Controls::IconListViewItemStatus status) { + Footer* pFooter = GetFooter(); + switch (status) + { + case ICON_LIST_VIEW_ITEM_CHECKED: + { + pFooter->SetItemEnabled(0, true); + pFooter->Draw(); + } + break; + case ICON_LIST_VIEW_ITEM_UNCHECKED: + { + pFooter->SetItemEnabled(0, false); + int items = this->GetItemCount() - 1; + + for (int i = items; i >= 0 && i != index; i--) + { + if (__pIconListView->IsItemChecked(i)) + { + pFooter->SetItemEnabled(0, true); + } + } + pFooter->Draw(); + } + break; + default: + break; + } + + } void @@ -216,7 +247,7 @@ FeatureManagerForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previous __pIconListView->ScrollToItem(0); __pIconListView->UpdateList(); - if(pArgs != null) + if (pArgs != null) { pArgs->RemoveAll(); delete pArgs; diff --git a/project/src/FeatureSetGenerator.cpp b/project/src/FeatureSetGenerator.cpp index b10af36..7b9af0a 100644 --- a/project/src/FeatureSetGenerator.cpp +++ b/project/src/FeatureSetGenerator.cpp @@ -66,7 +66,7 @@ FeatureSetGenThread::Generate(Tizen::Base::String imPath, ResultInfo& resInfo) bool isRes = true; int currObject = 0; - if(!__pImageFeatureManager) + if (!__pImageFeatureManager) { return false; } @@ -96,7 +96,7 @@ FeatureSetGenThread::Generate(Tizen::Base::String imPath, ResultInfo& resInfo) Tizen::Io::DirEntry dirEntry = pDirEnum->GetCurrentDirEntry(); if (!dirEntry.IsDirectory()) { - if(Tizen::Io::File::IsFileExist(imPath + "/" + dirEntry.GetName())) + if (Tizen::Io::File::IsFileExist(imPath + "/" + dirEntry.GetName())) { __files.Add(imPath + "/" + dirEntry.GetName()); } @@ -108,7 +108,7 @@ FeatureSetGenThread::Generate(Tizen::Base::String imPath, ResultInfo& resInfo) else { - if(CheckExt(imPath) && Tizen::Io::File::IsFileExist(imPath)) + if (CheckExt(imPath) && Tizen::Io::File::IsFileExist(imPath)) { __files.Add(imPath); } @@ -185,7 +185,7 @@ FeatureSetGenThread::CheckExt(Tizen::Base::String fileName) return false; } Tizen::Base::String extension; - if(E_SUCCESS != fileName.SubString(period + 1, extension)) + if (E_SUCCESS != fileName.SubString(period + 1, extension)) { return false; } diff --git a/project/src/FileManagerForm.cpp b/project/src/FileManagerForm.cpp index 7c7d9e4..3962087 100644 --- a/project/src/FileManagerForm.cpp +++ b/project/src/FileManagerForm.cpp @@ -258,7 +258,7 @@ FileManagerForm::CheckExt(Tizen::Base::String fileName) return false; } Tizen::Base::String extension; - if(E_SUCCESS != fileName.SubString(period + 1, extension)) + if (E_SUCCESS != fileName.SubString(period + 1, extension)) { return false; } diff --git a/project/src/MainForm.cpp b/project/src/MainForm.cpp index 4d80c39..9c10f24 100644 --- a/project/src/MainForm.cpp +++ b/project/src/MainForm.cpp @@ -37,7 +37,7 @@ MainForm::MainForm(void) MainForm::~MainForm(void) { - if(__pFeatureManager) + if (__pFeatureManager) { delete __pFeatureManager; } @@ -240,7 +240,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) void MainForm::AppendImageFolder(const Tizen::Base::String& imPath, IFeatureSetGeneratorListener* listener) { - if(listener != null) + if (listener != null) { __dbGen.SetListener(listener); } diff --git a/project/src/UpdatePanel.cpp b/project/src/UpdatePanel.cpp index 239ad2c..a1f026e 100644 --- a/project/src/UpdatePanel.cpp +++ b/project/src/UpdatePanel.cpp @@ -131,7 +131,7 @@ UpdatePanel::OnSceneActivatedN( } } - if(pArgs) + if (pArgs) { pArgs->RemoveAll(true); delete pArgs; -- 2.7.4