forked from gnachman/iTerm2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBookmarkListView.h
167 lines (141 loc) · 5.58 KB
/
BookmarkListView.h
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
** BookmarkTableController.m
** iTerm
**
** Created by George Nachman on 8/26/10.
** Project: iTerm
**
** Description: Custom view that shows a search field and table of bookmarks
** and integrates them.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
*/
#import <Cocoa/Cocoa.h>
#import "BookmarkModel.h"
@class iTermSearchField;
@class BookmarkRow;
// This is an intermediate model that wraps BookmarkModel and allows
// each BookmarkListView to have a different ordering of bookmarks.
// It represents bookmarks are BookmarkRow objects which have a
// key-value coding and can be sorted by the columns relevant to
// BookmarkListView.
@interface BookmarkModelWrapper : NSObject
{
BookmarkModel* underlyingModel;
NSMutableArray* bookmarks;
NSMutableString* filter;
NSArray* sortDescriptors;
}
- (id)initWithModel:(BookmarkModel*)model;
- (void)dealloc;
- (void)setSortDescriptors:(NSArray*)newSortDescriptors;
- (NSArray*)sortDescriptors;
// Cause the underlying model to have the visible bookmarks in the same order as
// they appear here. Only bookmarks matching the filter are pushed.
- (void)pushOrderToUnderlyingModel;
// Sort the local representation according to sort descriptors set with setSortDescriptors.
- (void)sort;
// These functions take the filter (set with setFilter) into account with respect to indices.
- (int)numberOfBookmarks;
- (BookmarkRow*)bookmarkRowAtIndex:(int)index;
- (Bookmark*)bookmarkAtIndex:(int)index;
- (int)indexOfBookmarkWithGuid:(NSString*)guid;
- (void)moveBookmarkWithGuid:(NSString*)guid toIndex:(int)index;
- (BookmarkModel*)underlyingModel;
// Copy bookmarks matchin the filter from the underlying model.
- (void)sync;
// Show only bookmarks matching a search query 'filter'.
- (void)setFilter:(NSString*)newFilter;
@end
@interface BookmarkTableView : NSTableView
{
id parent_;
}
- (void)setParent:(id)parent;
@end
@protocol BookmarkTableDelegate
@optional
- (void)bookmarkTableSelectionDidChange:(id)bookmarkTable;
@optional
- (void)bookmarkTableSelectionWillChange:(id)bookmarkTable;
@optional
- (void)bookmarkTableRowSelected:(id)bookmarkTable;
@optional
- (NSMenu*)bookmarkTable:(id)bookmarkTable menuForEvent:(NSEvent*)theEvent;
@end
@interface BookmarkListView : NSView <NSTextFieldDelegate, NSTableViewDataSource, NSTableViewDelegate> {
int normalRowHeight_;
int rowHeightWithTags_;
NSScrollView* scrollView_;
iTermSearchField* searchField_;
BookmarkTableView* tableView_;
NSTableColumn* tableColumn_;
NSTableColumn* commandColumn_;
NSTableColumn* shortcutColumn_;
NSTableColumn* starColumn_;
NSTableColumn* tagsColumn_;
NSObject<BookmarkTableDelegate> *delegate_;
NSSet* selectedGuids_;
BOOL debug;
BookmarkModelWrapper* dataSource_;
int margin_;
}
- (void)awakeFromNib;
- (id)initWithFrame:(NSRect)frameRect;
- (id)initWithFrame:(NSRect)frameRect model:(BookmarkModel*)dataSource;
- (void)setDelegate:(NSObject<BookmarkTableDelegate> *)delegate;
- (void)dealloc;
- (BookmarkModelWrapper*)dataSource;
- (void)setUnderlyingDatasource:(BookmarkModel*)dataSource;
- (void)focusSearchField;
// Drag drop
- (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard;
- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)op;
- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id <NSDraggingInfo>)info
row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation;
// DataSource methods
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView;
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)rowIndex;
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex;
- (BOOL)selectionShouldChangeInTableView:(NSTableView *)aTableView;
- (NSDragOperation)tableView:(NSTableView *)aTableView validateDrop:(id < NSDraggingInfo >)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)operation;
// Delegate methods
- (BOOL)selectionShouldChangeInTableView:(NSTableView *)aTableView;
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification;
// Don't use this if you've called allowMultipleSelections.
- (int)selectedRow;
- (void)reloadData;
- (void)selectRowIndex:(int)theIndex;
- (void)selectRowByGuid:(NSString*)guid;
- (int)numberOfRows;
- (void)hideSearch;
- (void)allowEmptySelection;
- (void)allowMultipleSelections;
- (void)deselectAll;
- (void)multiColumns;
// Dont' use this if you've called allowMultipleSelections
- (NSString*)selectedGuid;
- (NSSet*)selectedGuids;
- (BOOL)hasSelection;
- (NSArray *)orderedSelectedGuids;
- (void)dataChangeNotification:(id)sender;
- (void)onDoubleClick:(id)sender;
- (void)eraseQuery;
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize;
- (void)turnOnDebug;
- (NSTableView*)tableView;
- (id)delegate;
- (void)setFont:(NSFont *)theFont;
- (void)disableArrowHandler;
@end