OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/views/bookmark_editor_view.h" | 5 #include "chrome/browser/views/bookmark_editor_view.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 this, l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_BUTTON))); | 280 this, l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_BUTTON))); |
281 new_group_button_->SetParentOwned(false); | 281 new_group_button_->SetParentOwned(false); |
282 tree_view_->SetContextMenuController(this); | 282 tree_view_->SetContextMenuController(this); |
283 | 283 |
284 tree_view_->SetRootShown(false); | 284 tree_view_->SetRootShown(false); |
285 new_group_button_->SetEnabled(false); | 285 new_group_button_->SetEnabled(false); |
286 new_group_button_->SetID(kNewGroupButtonID); | 286 new_group_button_->SetID(kNewGroupButtonID); |
287 } | 287 } |
288 | 288 |
289 // Yummy layout code. | 289 // Yummy layout code. |
| 290 GridLayout* layout = CreatePanelGridLayout(this); |
| 291 SetLayoutManager(layout); |
| 292 |
290 const int labels_column_set_id = 0; | 293 const int labels_column_set_id = 0; |
291 const int single_column_view_set_id = 1; | 294 const int single_column_view_set_id = 1; |
292 const int buttons_column_set_id = 2; | 295 const int buttons_column_set_id = 2; |
293 GridLayout* layout = CreatePanelGridLayout(this); | 296 |
294 SetLayoutManager(layout); | |
295 ColumnSet* column_set = layout->AddColumnSet(labels_column_set_id); | 297 ColumnSet* column_set = layout->AddColumnSet(labels_column_set_id); |
296 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | 298 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
297 GridLayout::USE_PREF, 0, 0); | 299 GridLayout::USE_PREF, 0, 0); |
298 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); | 300 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); |
299 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, | 301 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, |
300 GridLayout::USE_PREF, 0, 0); | 302 GridLayout::USE_PREF, 0, 0); |
301 | 303 |
302 column_set = layout->AddColumnSet(single_column_view_set_id); | 304 column_set = layout->AddColumnSet(single_column_view_set_id); |
303 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 305 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
304 GridLayout::FIXED, kTreeWidth, 0); | 306 GridLayout::FIXED, kTreeWidth, 0); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. | 451 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. |
450 | 452 |
451 tree_view_->SetSelectedNode(b_node); | 453 tree_view_->SetSelectedNode(b_node); |
452 } | 454 } |
453 | 455 |
454 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() { | 456 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() { |
455 EditorNode* root_node = new EditorNode(std::wstring(), 0); | 457 EditorNode* root_node = new EditorNode(std::wstring(), 0); |
456 const BookmarkNode* bb_root_node = bb_model_->root_node(); | 458 const BookmarkNode* bb_root_node = bb_model_->root_node(); |
457 CreateNodes(bb_root_node, root_node); | 459 CreateNodes(bb_root_node, root_node); |
458 DCHECK(root_node->GetChildCount() == 2); | 460 DCHECK(root_node->GetChildCount() == 2); |
459 DCHECK(bb_root_node->GetChild(0)->GetType() == | 461 DCHECK(bb_root_node->GetChild(0)->GetType() == BookmarkNode::BOOKMARK_BAR); |
460 history::StarredEntry::BOOKMARK_BAR); | 462 DCHECK(bb_root_node->GetChild(1)->GetType() == BookmarkNode::OTHER_NODE); |
461 DCHECK(bb_root_node->GetChild(1)->GetType() == history::StarredEntry::OTHER); | |
462 return root_node; | 463 return root_node; |
463 } | 464 } |
464 | 465 |
465 void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node, | 466 void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node, |
466 BookmarkEditorView::EditorNode* b_node) { | 467 BookmarkEditorView::EditorNode* b_node) { |
467 for (int i = 0; i < bb_node->GetChildCount(); ++i) { | 468 for (int i = 0; i < bb_node->GetChildCount(); ++i) { |
468 const BookmarkNode* child_bb_node = bb_node->GetChild(i); | 469 const BookmarkNode* child_bb_node = bb_node->GetChild(i); |
469 if (child_bb_node->is_folder()) { | 470 if (child_bb_node->is_folder()) { |
470 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), | 471 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), |
471 child_bb_node->id()); | 472 child_bb_node->id()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 break; | 551 break; |
551 } | 552 } |
552 } | 553 } |
553 DCHECK(child_bb_node); | 554 DCHECK(child_bb_node); |
554 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); | 555 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); |
555 } | 556 } |
556 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node, | 557 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node, |
557 parent_b_node, parent_bb_node); | 558 parent_b_node, parent_bb_node); |
558 } | 559 } |
559 } | 560 } |
OLD | NEW |