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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_SEARCH_RESULT_H_
6 #define UI_APP_LIST_SEARCH_RESULT_H_
10 #include "base/basictypes.h"
11 #include "base/observer_list.h"
12 #include "base/string16.h"
13 #include "ui/app_list/app_list_export.h"
14 #include "ui/base/models/list_model.h"
15 #include "ui/base/range/range.h"
16 #include "ui/gfx/image/image_skia.h"
20 class SearchResultObserver
;
22 // SearchResult consists of an icon, title text and details text. Title and
23 // details text can have tagged ranges that are displayed differently from
25 class APP_LIST_EXPORT SearchResult
{
27 // A tagged range in search result text.
29 // Similar to ACMatchClassification::Style, the style values are not
30 // mutually exclusive.
38 Tag(int styles
, size_t start
, size_t end
)
46 typedef std::vector
<Tag
> Tags
;
48 // A collection of images representing an action that can be performed on this
50 struct ActionIconSet
{
51 ActionIconSet(const gfx::ImageSkia
& base_image
,
52 const gfx::ImageSkia
& hover_image
,
53 const gfx::ImageSkia
& pressed_image
,
54 const string16
& tooltip_text
);
57 gfx::ImageSkia base_image
;
58 gfx::ImageSkia hover_image
;
59 gfx::ImageSkia pressed_image
;
61 string16 tooltip_text
;
63 typedef std::vector
<ActionIconSet
> ActionIconSets
;
66 virtual ~SearchResult();
68 const gfx::ImageSkia
& icon() const { return icon_
; }
69 void SetIcon(const gfx::ImageSkia
& icon
);
71 const string16
& title() const { return title_
; }
72 void set_title(const string16
& title
) { title_
= title
;}
74 const Tags
& title_tags() const { return title_tags_
; }
75 void set_title_tags(const Tags
& tags
) { title_tags_
= tags
; }
77 const string16
& details() const { return details_
; }
78 void set_details(const string16
& details
) { details_
= details
; }
80 const Tags
& details_tags() const { return details_tags_
; }
81 void set_details_tags(const Tags
& tags
) { details_tags_
= tags
; }
83 const ActionIconSets
& action_icons() const {
86 void SetActionIcons(const ActionIconSets
& sets
);
88 void AddObserver(SearchResultObserver
* observer
);
89 void RemoveObserver(SearchResultObserver
* observer
);
100 // Optional list of icons representing additional actions that can be
101 // performed on this result.
102 ActionIconSets action_icons_
;
104 ObserverList
<SearchResultObserver
> observers_
;
106 DISALLOW_COPY_AND_ASSIGN(SearchResult
);
109 } // namespace app_list
111 #endif // UI_APP_LIST_SEARCH_RESULT_H_