OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stack> | 5 #include <stack> |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_base_controller.h" | 7 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_base_controller.h" |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
12 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
13 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_all_tabs_controller.h" | 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_all_tabs_controller.h" |
16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" | 16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" |
17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_tree_browser_cell.h" | 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_tree_browser_cell.h" |
18 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 18 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/base/l10n/l10n_util_mac.h" | 21 #include "ui/base/l10n/l10n_util_mac.h" |
22 | 22 |
23 @interface NSCell(multilinebookmarks) | |
24 - (void)setUsesSingleLineMode:(BOOL)flag; | |
25 @end | |
26 | |
23 @interface BookmarkEditorBaseController () | 27 @interface BookmarkEditorBaseController () |
24 | 28 |
25 // Return the folder tree object for the given path. | 29 // Return the folder tree object for the given path. |
26 - (BookmarkFolderInfo*)folderForIndexPath:(NSIndexPath*)path; | 30 - (BookmarkFolderInfo*)folderForIndexPath:(NSIndexPath*)path; |
27 | 31 |
28 // (Re)build the folder tree from the BookmarkModel's current state. | 32 // (Re)build the folder tree from the BookmarkModel's current state. |
29 - (void)buildFolderTree; | 33 - (void)buildFolderTree; |
30 | 34 |
31 // Notifies the controller that the bookmark model has changed. | 35 // Notifies the controller that the bookmark model has changed. |
32 // |selection| specifies if the current selection should be | 36 // |selection| specifies if the current selection should be |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 [self didChangeValueForKey:@"folderTreeArray"]; | 561 [self didChangeValueForKey:@"folderTreeArray"]; |
558 | 562 |
559 // Expose the parent folder children. | 563 // Expose the parent folder children. |
560 [folderTreeView_ expandItem:parentInfo]; | 564 [folderTreeView_ expandItem:parentInfo]; |
561 | 565 |
562 // Select the new folder node and put the folder name into edit mode. | 566 // Select the new folder node and put the folder name into edit mode. |
563 selection = [selection indexPathByAddingIndex:[children count] - 1]; | 567 selection = [selection indexPathByAddingIndex:[children count] - 1]; |
564 [self setTableSelectionPath:selection]; | 568 [self setTableSelectionPath:selection]; |
565 NSInteger row = [folderTreeView_ selectedRow]; | 569 NSInteger row = [folderTreeView_ selectedRow]; |
566 DCHECK(row >= 0); | 570 DCHECK(row >= 0); |
571 | |
572 NSCell *folderCell = [folderTreeView_ preparedCellAtColumn:0 row:row]; | |
Ilya Sherman
2011/11/30 06:09:38
nit: "NSCell *" -> "NSCell* "
| |
573 if ([folderCell | |
574 respondsToSelector:@selector(setUsesSingleLineMode:)]) { | |
575 [folderCell setUsesSingleLineMode:YES]; | |
576 } | |
577 | |
567 [folderTreeView_ editColumn:0 row:row withEvent:nil select:YES]; | 578 [folderTreeView_ editColumn:0 row:row withEvent:nil select:YES]; |
568 } | 579 } |
569 } | 580 } |
570 | 581 |
571 - (void)createNewFolders { | 582 - (void)createNewFolders { |
572 AutoReset<BOOL> creatingNewFoldersSetter(&creatingNewFolders_, YES); | 583 AutoReset<BOOL> creatingNewFoldersSetter(&creatingNewFolders_, YES); |
573 // Scan the tree looking for nodes marked 'newFolder' and create those nodes. | 584 // Scan the tree looking for nodes marked 'newFolder' and create those nodes. |
574 NSArray* folderTreeArray = [self folderTreeArray]; | 585 NSArray* folderTreeArray = [self folderTreeArray]; |
575 for (BookmarkFolderInfo *folderInfo in folderTreeArray) { | 586 for (BookmarkFolderInfo *folderInfo in folderTreeArray) { |
576 [self createNewFoldersForFolder:folderInfo | 587 [self createNewFoldersForFolder:folderInfo |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
649 } | 660 } |
650 | 661 |
651 // Implementing isEqual: allows the NSTreeController to preserve the selection | 662 // Implementing isEqual: allows the NSTreeController to preserve the selection |
652 // and open/shut state of outline items when the data changes. | 663 // and open/shut state of outline items when the data changes. |
653 - (BOOL)isEqual:(id)other { | 664 - (BOOL)isEqual:(id)other { |
654 return [other isKindOfClass:[BookmarkFolderInfo class]] && | 665 return [other isKindOfClass:[BookmarkFolderInfo class]] && |
655 folderNode_ == [(BookmarkFolderInfo*)other folderNode]; | 666 folderNode_ == [(BookmarkFolderInfo*)other folderNode]; |
656 } | 667 } |
657 | 668 |
658 @end | 669 @end |
OLD | NEW |