diff options
author | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-12 00:14:29 +0000 |
---|---|---|
committer | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-12 00:14:29 +0000 |
commit | 8a3fdb199a2b423ad2e573388757a9da55c69251 (patch) | |
tree | dec86f501612465d8c061a5073c49f6324da87d0 | |
parent | d2c9b36f832e4b02f58b17abc936f7d55842e944 (diff) | |
download | chromium_src-8a3fdb199a2b423ad2e573388757a9da55c69251.zip chromium_src-8a3fdb199a2b423ad2e573388757a9da55c69251.tar.gz chromium_src-8a3fdb199a2b423ad2e573388757a9da55c69251.tar.bz2 |
Revert 263364 "Merge 262563 "Handle dragging the app from a sing..."
> Merge 262563 "Handle dragging the app from a single item folder ..."
>
> > Handle dragging the app from a single item folder UI case gracefully. The item will be re-order or drop into another folder and its original parent folder should be removed.
> >
> > BUG=360241
> > R=stevenjb@chromium.org, xiyuan@chromium.org
> >
> > Review URL: https://codereview.chromium.org/228213004
>
> TBR=jennyz@chromium.org
>
> Review URL: https://codereview.chromium.org/235983003
TBR=jennyz@chromium.org
Review URL: https://codereview.chromium.org/236003003
git-svn-id: svn://svn.chromium.org/chrome/branches/1916/src@263422 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/app_list/views/apps_grid_view.cc | 36 | ||||
-rw-r--r-- | ui/app_list/views/apps_grid_view.h | 8 |
2 files changed, 14 insertions, 30 deletions
diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc index 1c9f372..9914235 100644 --- a/ui/app_list/views/apps_grid_view.cc +++ b/ui/app_list/views/apps_grid_view.cc @@ -1630,14 +1630,8 @@ void AppsGridView::ReparentItemForReorder(views::View* item_view, AppListItem* reparent_item = static_cast<AppListItemView*>(item_view)->item(); DCHECK(reparent_item->IsInFolder()); - const std::string source_folder_id = reparent_item->folder_id(); - AppListFolderItem* source_folder = - static_cast<AppListFolderItem*>(item_list_->FindItem(source_folder_id)); - - // Remove the source folder view if there is only 1 item in it, since the - // source folder will be deleted after its only child item removed from it. - if (source_folder->ChildItemCount() == 1u) - DeleteItemViewAtIndex(view_model_.GetIndexOfView(activated_item_view())); + AppListFolderItem* source_folder = static_cast<AppListFolderItem*>( + item_list_->FindItem(reparent_item->folder_id())); // Move the item from its parent folder to top level item list. // Must move to target_model_index, the location we expect the target item @@ -1650,7 +1644,8 @@ void AppsGridView::ReparentItemForReorder(views::View* item_view, model_->MoveItemToFolderAt(reparent_item, "", target_position); view_model_.Move(current_model_index, target_model_index); - RemoveLastItemFromReparentItemFolderIfNecessary(source_folder_id); + if (source_folder->ChildItemCount() == 1) + RemoveLastItemFromReparentItemFolder(source_folder); item_list_->AddObserver(this); model_->AddObserver(this); @@ -1666,15 +1661,8 @@ void AppsGridView::ReparentItemToAnotherFolder(views::View* item_view, AppListItem* reparent_item = static_cast<AppListItemView*>(item_view)->item(); DCHECK(reparent_item->IsInFolder()); - const std::string source_folder_id = reparent_item->folder_id(); - AppListFolderItem* source_folder = - static_cast<AppListFolderItem*>(item_list_->FindItem(source_folder_id)); - - // Remove the source folder view if there is only 1 item in it, since the - // source folder will be deleted after its only child item merged into the - // target item. - if (source_folder->ChildItemCount() == 1u) - DeleteItemViewAtIndex(view_model_.GetIndexOfView(activated_item_view())); + AppListFolderItem* source_folder = static_cast<AppListFolderItem*>( + item_list_->FindItem(reparent_item->folder_id())); AppListItemView* target_view = static_cast<AppListItemView*>(GetViewAtSlotOnCurrentPage(target.slot)); @@ -1707,7 +1695,8 @@ void AppsGridView::ReparentItemToAnotherFolder(views::View* item_view, } } - RemoveLastItemFromReparentItemFolderIfNecessary(source_folder_id); + if (source_folder->ChildItemCount() == 1) + RemoveLastItemFromReparentItemFolder(source_folder); item_list_->AddObserver(this); @@ -1724,12 +1713,9 @@ void AppsGridView::ReparentItemToAnotherFolder(views::View* item_view, // left, remove the last item out of the folder, delete the folder and insert it // to the data model at the same position. Make the same change to view_model_ // accordingly. -void AppsGridView::RemoveLastItemFromReparentItemFolderIfNecessary( - const std::string& source_folder_id) { - AppListFolderItem* source_folder = - static_cast<AppListFolderItem*>(item_list_->FindItem(source_folder_id)); - if (!source_folder || source_folder->ChildItemCount() != 1u) - return; +void AppsGridView::RemoveLastItemFromReparentItemFolder( + AppListFolderItem* source_folder) { + DCHECK_EQ(1u, source_folder->ChildItemCount()); // Delete view associated with the folder item to be removed. AppListItemView* folder_item_view = activated_item_view(); diff --git a/ui/app_list/views/apps_grid_view.h b/ui/app_list/views/apps_grid_view.h index d3f100c..600425d 100644 --- a/ui/app_list/views/apps_grid_view.h +++ b/ui/app_list/views/apps_grid_view.h @@ -319,11 +319,9 @@ class APP_LIST_EXPORT AppsGridView : public views::View, // to anther folder target. void ReparentItemToAnotherFolder(views::View* item_view, const Index& target); - // If there is only 1 item left in the source folder after reparenting an item - // from it, updates both data model and view_model_ for removing last item - // from the source folder and removes the source folder. - void RemoveLastItemFromReparentItemFolderIfNecessary( - const std::string& source_folder_id); + // Updates both data model and view_model_ for removing last item from + // |source_folder| which is the parent folder of the re-parenting item. + void RemoveLastItemFromReparentItemFolder(AppListFolderItem* source_folder); // If user does not drop the re-parenting folder item to any valid target, // cancel the re-parenting action, let the item go back to its original |