OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/app_list/views/apps_grid_view.h" | 5 #include "ui/app_list/views/apps_grid_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1726 item_list_->AddObserver(this); | 1726 item_list_->AddObserver(this); |
1727 | 1727 |
1728 if (pagination_model_.selected_page() != target.page) | 1728 if (pagination_model_.selected_page() != target.page) |
1729 pagination_model_.SelectPage(target.page, false); | 1729 pagination_model_.SelectPage(target.page, false); |
1730 } | 1730 } |
1731 | 1731 |
1732 void AppsGridView::MoveItemToFolder(AppListItemView* item_view, | 1732 void AppsGridView::MoveItemToFolder(AppListItemView* item_view, |
1733 const Index& target) { | 1733 const Index& target) { |
1734 const std::string& source_item_id = item_view->item()->id(); | 1734 const std::string& source_item_id = item_view->item()->id(); |
1735 AppListItemView* target_view = GetViewAtSlotOnCurrentPage(target.slot); | 1735 AppListItemView* target_view = GetViewAtSlotOnCurrentPage(target.slot); |
1736 const std::string& target_view_item_id = target_view->item()->id(); | 1736 DCHECK(target_view); |
1737 const std::string& target_view_item_id = target_view->item()->id(); | |
1738 | |
1739 // Check that the item is not being dropped onto itself; this should not | |
1740 // happen, but it can if something allows multiple views to share an | |
1741 // item. | |
calamity
2014/09/26 03:55:18
(e.g a folder drop does not clean up properly)
Matt Giuca
2014/09/29 03:05:03
Done.
| |
1742 DCHECK_NE(source_item_id, target_view_item_id); | |
1737 | 1743 |
1738 // Make change to data model. | 1744 // Make change to data model. |
1739 item_list_->RemoveObserver(this); | 1745 item_list_->RemoveObserver(this); |
1740 std::string folder_item_id = | 1746 std::string folder_item_id = |
1741 model_->MergeItems(target_view_item_id, source_item_id); | 1747 model_->MergeItems(target_view_item_id, source_item_id); |
1742 item_list_->AddObserver(this); | 1748 item_list_->AddObserver(this); |
1743 if (folder_item_id.empty()) { | 1749 if (folder_item_id.empty()) { |
1744 LOG(ERROR) << "Unable to merge into item id: " << target_view_item_id; | 1750 LOG(ERROR) << "Unable to merge into item id: " << target_view_item_id; |
1745 return; | 1751 return; |
1746 } | 1752 } |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2132 } | 2138 } |
2133 | 2139 |
2134 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, | 2140 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, |
2135 bool is_target_folder) { | 2141 bool is_target_folder) { |
2136 AppListItemView* target_view = GetViewAtSlotOnCurrentPage(target_index.slot); | 2142 AppListItemView* target_view = GetViewAtSlotOnCurrentPage(target_index.slot); |
2137 if (target_view) | 2143 if (target_view) |
2138 target_view->SetAsAttemptedFolderTarget(is_target_folder); | 2144 target_view->SetAsAttemptedFolderTarget(is_target_folder); |
2139 } | 2145 } |
2140 | 2146 |
2141 } // namespace app_list | 2147 } // namespace app_list |
OLD | NEW |