Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: ui/base/models/simple_menu_model.cc

Issue 12755019: Add 2-lines summary to CC/Address for Wallet items. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: SubLabel and sub-label -> Sublabel and sublabel. Added description. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/base/models/simple_menu_model.cc
diff --git a/ui/base/models/simple_menu_model.cc b/ui/base/models/simple_menu_model.cc
index 4d5213262739f62e0ab63e4a6252e685d00c0174..227d5029afbad25fe7f6bab00532a1c288d60891 100644
--- a/ui/base/models/simple_menu_model.cc
+++ b/ui/base/models/simple_menu_model.cc
@@ -16,6 +16,7 @@ const int kSeparatorId = -1;
struct SimpleMenuModel::Item {
int command_id;
string16 label;
+ string16 sublabel;
gfx::Image icon;
ItemType type;
int group_id;
@@ -40,6 +41,11 @@ string16 SimpleMenuModel::Delegate::GetLabelForCommandId(int command_id) const {
return string16();
}
+string16 SimpleMenuModel::Delegate::GetSublabelForCommandId(
+ int command_id) const {
+ return string16();
+}
+
bool SimpleMenuModel::Delegate::GetIconForCommandId(
int command_id, gfx::Image* image_skia) const {
return false;
@@ -72,8 +78,8 @@ SimpleMenuModel::~SimpleMenuModel() {
}
void SimpleMenuModel::AddItem(int command_id, const string16& label) {
- Item item = { command_id, label, gfx::Image(), TYPE_COMMAND, -1, NULL,
- NULL, NORMAL_SEPARATOR };
+ Item item = { command_id, label, string16(), gfx::Image(),
+ TYPE_COMMAND, -1, NULL, NULL, NORMAL_SEPARATOR };
AppendItem(item);
}
@@ -82,8 +88,8 @@ void SimpleMenuModel::AddItemWithStringId(int command_id, int string_id) {
}
void SimpleMenuModel::AddCheckItem(int command_id, const string16& label) {
- Item item = { command_id, label, gfx::Image(), TYPE_CHECK, -1, NULL,
- NULL, NORMAL_SEPARATOR };
+ Item item = { command_id, label, string16(), gfx::Image(),
+ TYPE_CHECK, -1, NULL, NULL, NORMAL_SEPARATOR };
AppendItem(item);
}
@@ -93,8 +99,8 @@ void SimpleMenuModel::AddCheckItemWithStringId(int command_id, int string_id) {
void SimpleMenuModel::AddRadioItem(int command_id, const string16& label,
int group_id) {
- Item item = { command_id, label, gfx::Image(), TYPE_RADIO, group_id, NULL,
- NULL, NORMAL_SEPARATOR };
+ Item item = { command_id, label, string16(), gfx::Image(),
+ TYPE_RADIO, group_id, NULL, NULL, NORMAL_SEPARATOR };
AppendItem(item);
}
@@ -118,8 +124,8 @@ void SimpleMenuModel::AddSeparator(MenuSeparatorType separator_type) {
if (separator_type != NORMAL_SEPARATOR)
NOTIMPLEMENTED();
#endif
- Item item = { kSeparatorId, string16(), gfx::Image(), TYPE_SEPARATOR,
- -1, NULL, NULL , separator_type };
+ Item item = { kSeparatorId, string16(), string16(), gfx::Image(),
+ TYPE_SEPARATOR, -1, NULL, NULL , separator_type };
AppendItem(item);
}
@@ -130,15 +136,15 @@ void SimpleMenuModel::RemoveTrailingSeparators() {
void SimpleMenuModel::AddButtonItem(int command_id,
ButtonMenuItemModel* model) {
- Item item = { command_id, string16(), gfx::Image(), TYPE_BUTTON_ITEM, -1,
- NULL, model, NORMAL_SEPARATOR };
+ Item item = { command_id, string16(), string16(), gfx::Image(),
+ TYPE_BUTTON_ITEM, -1, NULL, model, NORMAL_SEPARATOR };
AppendItem(item);
}
void SimpleMenuModel::AddSubMenu(int command_id, const string16& label,
MenuModel* model) {
- Item item = { command_id, label, gfx::Image(), TYPE_SUBMENU, -1, model,
- NULL, NORMAL_SEPARATOR };
+ Item item = { command_id, label, string16(), gfx::Image(),
+ TYPE_SUBMENU, -1, model, NULL, NORMAL_SEPARATOR };
AppendItem(item);
}
@@ -149,8 +155,8 @@ void SimpleMenuModel::AddSubMenuWithStringId(int command_id,
void SimpleMenuModel::InsertItemAt(
int index, int command_id, const string16& label) {
- Item item = { command_id, label, gfx::Image(), TYPE_COMMAND, -1, NULL,
- NULL, NORMAL_SEPARATOR };
+ Item item = { command_id, label, string16(), gfx::Image(),
+ TYPE_COMMAND, -1, NULL, NULL, NORMAL_SEPARATOR };
InsertItemAtIndex(item, index);
}
@@ -166,15 +172,15 @@ void SimpleMenuModel::InsertSeparatorAt(int index,
NOTIMPLEMENTED();
}
#endif
- Item item = { kSeparatorId, string16(), gfx::Image(), TYPE_SEPARATOR,
- -1, NULL, NULL, separator_type };
+ Item item = { kSeparatorId, string16(), string16(), gfx::Image(),
+ TYPE_SEPARATOR, -1, NULL, NULL, separator_type };
InsertItemAtIndex(item, index);
}
void SimpleMenuModel::InsertCheckItemAt(
int index, int command_id, const string16& label) {
- Item item = { command_id, label, gfx::Image(), TYPE_CHECK, -1, NULL,
- NULL, NORMAL_SEPARATOR };
+ Item item = { command_id, label, string16(), gfx::Image(),
+ TYPE_CHECK, -1, NULL, NULL, NORMAL_SEPARATOR };
InsertItemAtIndex(item, index);
}
@@ -185,8 +191,8 @@ void SimpleMenuModel::InsertCheckItemWithStringIdAt(
void SimpleMenuModel::InsertRadioItemAt(
int index, int command_id, const string16& label, int group_id) {
- Item item = { command_id, label, gfx::Image(), TYPE_RADIO, group_id, NULL,
- NULL, NORMAL_SEPARATOR };
+ Item item = { command_id, label, string16(), gfx::Image(),
+ TYPE_RADIO, group_id, NULL, NULL, NORMAL_SEPARATOR };
InsertItemAtIndex(item, index);
}
@@ -198,8 +204,8 @@ void SimpleMenuModel::InsertRadioItemWithStringIdAt(
void SimpleMenuModel::InsertSubMenuAt(
int index, int command_id, const string16& label, MenuModel* model) {
- Item item = { command_id, label, gfx::Image(), TYPE_SUBMENU, -1, model,
- NULL, NORMAL_SEPARATOR };
+ Item item = { command_id, label, string16(), gfx::Image(),
+ TYPE_SUBMENU, -1, model, NULL, NORMAL_SEPARATOR };
InsertItemAtIndex(item, index);
}
@@ -213,6 +219,10 @@ void SimpleMenuModel::SetIcon(int index, const gfx::Image& icon) {
items_[ValidateItemIndex(index)].icon = icon;
}
+void SimpleMenuModel::SetSublabel(int index, const string16& sublabel) {
+ items_[ValidateItemIndex(index)].sublabel = sublabel;
+}
+
void SimpleMenuModel::Clear() {
items_.clear();
}
@@ -259,6 +269,12 @@ string16 SimpleMenuModel::GetLabelAt(int index) const {
return items_[ValidateItemIndex(index)].label;
}
+string16 SimpleMenuModel::GetSublabelAt(int index) const {
+ if (IsItemDynamicAt(index))
+ return delegate_->GetSublabelForCommandId(GetCommandIdAt(index));
+ return items_[ValidateItemIndex(index)].sublabel;
+}
+
bool SimpleMenuModel::IsItemDynamicAt(int index) const {
if (delegate_)
return delegate_->IsItemForCommandIdDynamic(GetCommandIdAt(index));
« components/autofill/browser/wallet/wallet_items.cc ('K') | « ui/base/models/simple_menu_model.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698