Chromium Code Reviews| Index: ui/app_list/app_list_model.h |
| diff --git a/ui/app_list/app_list_model.h b/ui/app_list/app_list_model.h |
| index 76619ec80f2c9ee274b670f9ddd1369f7d3e3e68..f50ed949bbadf530738080db6647616091120064 100644 |
| --- a/ui/app_list/app_list_model.h |
| +++ b/ui/app_list/app_list_model.h |
| @@ -10,10 +10,12 @@ |
| #include "base/observer_list.h" |
| #include "ui/app_list/app_list_export.h" |
| #include "ui/app_list/app_list_item_list.h" |
| +#include "ui/app_list/app_list_item_list_observer.h" |
| #include "ui/base/models/list_model.h" |
| namespace app_list { |
| +class AppListFolderItem; |
| class AppListItem; |
| class AppListItemList; |
| class AppListModelObserver; |
| @@ -24,7 +26,11 @@ class SearchResult; |
| // SearchBoxModel and SearchResults. The AppListItemList sub model owns a list |
| // of AppListItems and is displayed in the grid view. SearchBoxModel is |
| // the model for SearchBoxView. SearchResults owns a list of SearchResult. |
| -class APP_LIST_EXPORT AppListModel { |
| +// NOTE: Currently this class observes |item_list_|. The View code may |
| +// move entries in the item list directly (but can not add or remove them) and |
| +// the model needs to notify its observers when this occurs. |
| + |
| +class APP_LIST_EXPORT AppListModel : public AppListItemListObserver { |
| public: |
| enum Status { |
| STATUS_NORMAL, |
| @@ -34,19 +40,52 @@ class APP_LIST_EXPORT AppListModel { |
| typedef ui::ListModel<SearchResult> SearchResults; |
| AppListModel(); |
| - ~AppListModel(); |
| + virtual ~AppListModel(); |
| void AddObserver(AppListModelObserver* observer); |
| void RemoveObserver(AppListModelObserver* observer); |
| void SetStatus(Status status); |
| + // Finds the item matching |id|. |
| + AppListItem* FindItem(const std::string& id); |
| + |
| + // Adds |item| to the model. |
| + void AddItem(AppListItem* item); |
|
tapted
2014/01/28 11:56:53
I think the preferred way to document the ownershi
stevenjb
2014/01/28 18:28:08
If you'll pardon the pun, I wanted to limit the sc
tapted
2014/01/28 23:33:54
I was going by a chromium dev thread - https://gro
stevenjb
2014/01/29 00:11:31
Yeah, that's generally the consensus, and I don't
|
| + |
| + // Merges two items. If the target item is a folder, the source item is added |
| + // to that folder, otherwise a new folder is created in the same position as |
| + // the target item. Returns the id of the target folder. |
| + const std::string& MergeItems(const std::string& target_item_id, |
| + const std::string& source_item_id); |
| + |
| + // Sets the position of |item| in |item_list_|. |
| + void SetItemPosition(AppListItem* item, |
| + const syncer::StringOrdinal& new_position); |
| + |
| + // Deletes the item matching |id| from |item_list_|. |
| + void DeleteItem(const std::string& id); |
| + |
| AppListItemList* item_list() { return item_list_.get(); } |
| SearchBoxModel* search_box() { return search_box_.get(); } |
| SearchResults* results() { return results_.get(); } |
| Status status() const { return status_; } |
| private: |
| + // AppListItemListObserver |
| + virtual void OnListItemMoved(size_t from_index, |
|
tapted
2014/01/28 11:56:53
nit: OVERRIDEs last?
stevenjb
2014/01/28 18:28:08
I'm unaware of that convention, and prefer to list
tapted
2014/01/28 23:33:54
I thought it was convention, but don't really feel
stevenjb
2014/01/29 00:11:31
If it is I'm unaware. Frequently they are public a
|
| + size_t to_index, |
| + AppListItem* item) OVERRIDE; |
| + |
| + // Returns the position of the last item in |item_list_| or an initial one. |
| + syncer::StringOrdinal GetLastItemPosition(); |
| + |
| + // Adds |item| to |item_list_| and notifies observers. |
| + void AddItemToItemList(AppListItem* item); |
| + |
| + // Adds |item| to |folder|. |
| + void AddItemToFolder(AppListFolderItem* folder, AppListItem* item); |
| + |
| scoped_ptr<AppListItemList> item_list_; |
| scoped_ptr<SearchBoxModel> search_box_; |
| scoped_ptr<SearchResults> results_; |