summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/bookmark_tree_controller.h
blob: 171e9795779593a76023454d17e3f3b79fa177cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Cocoa/Cocoa.h>
#include <vector>

@class BookmarkItem;
@class BookmarkManagerController;


// Controller for the bookmark tree view (the right pane).
@interface BookmarkTreeController : NSObject <NSUserInterfaceValidations> {
 @private
  IBOutlet NSOutlineView* outline_;
  IBOutlet BookmarkManagerController* manager_;
  BookmarkItem* group_;
  BOOL showsLeaves_;
  BOOL flat_;
}

// If set, leaf (URL) bookmarks are shown; if not, they're hidden.
@property BOOL showsLeaves;
// If set, displays a flat list (no hierarchy).
@property BOOL flat;
// Controls the visibility of the "Folder" column (used with search/recents.)
@property BOOL showsFolderColumn;

// The top-level bookmark folder used as the root of the outline's tree.
// Observable, bindable.
@property (assign) BookmarkItem* group;
// Controls whether leaf bookmarks or just folders are shown.
// The currently selected item(s) in the outline. (Observable.)
@property (retain) NSArray* selectedItems;
// The currently selected single item; nil on multiple selection. (Observable.)
@property (retain) BookmarkItem* selectedItem;
// The currently selected or right-clicked items, for commands to act on.
@property (readonly) NSArray* actionItems;

// The parent folder and index at which items should be inserted/pasted.
// Returns NO if insertion is not allowed.
- (BOOL)getInsertionParent:(BookmarkItem**)outParent
                     index:(NSUInteger*)outIndex;
// Just returns whether insertion is allowed.
- (BOOL)canInsert;

// Expands a folder item (including any parent folders).
// Returns YES on success, NO if it couldn't find the folder.
- (BOOL)expandItem:(BookmarkItem*)item;
// Expands parent folders, selects the item, and scrolls it into view:
// Returns YES on success, NO if it couldn't find the item.
- (BOOL)revealItem:(BookmarkItem*)item;

// Action for the New Folder command.
- (IBAction)newFolder:(id)sender;

// Action for the Delete command; also invoked by the delete key.
- (IBAction)delete:(id)sender;

// Reveals the selected search/recent item in its real folder.
- (IBAction)revealSelectedItem:(id)sender;

// Opens the selected bookmark(s) in new tabs.
- (IBAction)openItems:(id)sender;

// Makes the selected bookmark's title editable.
- (IBAction)editTitle:(id)sender;

// Returns YES if an action should be enabled.
- (BOOL)validateAction:(SEL)action;

// Called by the BookmarkManagerController to notify the data model's changed.
- (void)itemChanged:(BookmarkItem*)nodeItem
    childrenChanged:(BOOL)childrenChanged;

@end


// Drag/drop and copy/paste methods
// (These are implemented in bookmark_tree_controller_paste.mm.)
@interface BookmarkTreeController (Pasteboard)
// One-time drag-n-drop setup; called from -awakeFromNib.
- (void)registerDragTypes;
- (IBAction)cut:(id)sender;
- (IBAction)copy:(id)sender;
- (IBAction)paste:(id)sender;
@end


// Exposed only for unit tests.
@interface BookmarkTreeController (UnitTesting)
@property (readonly) NSOutlineView* outline;
- (BookmarkItem*)newFolderWithTitle:(NSString*)title;
- (NSArray*)readPropertyListFromPasteboard:(NSPasteboard*)pb;
- (BOOL)copyToPasteboard:(NSPasteboard*)pb;
- (BOOL)pasteFromPasteboard:(NSPasteboard*)pb;
- (BookmarkItem*)itemForDropOnItem:(BookmarkItem*)item
                     proposedIndex:(NSInteger*)childIndex;
- (void)moveItems:(NSArray*)items
         toFolder:(BookmarkItem*)dstParent
          atIndex:(int)dstIndex;
@end


// Outline view for bookmark tree; handles Cut/Copy/Paste and Delete key.
@interface BookmarksOutlineView : NSOutlineView
// The owning BookmarkTreeController (same as the delegate).
@property (readonly) BookmarkTreeController* bookmarkController;
@end