table_model_array_controller.h revision 21d179b334e59e9a3bfcaed4c4430bef1bc5759d
1// Copyright (c) 2010 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_UI_COCOA_TABLE_MODEL_ARRAY_CONTROLLER_H_ 6#define CHROME_BROWSER_UI_COCOA_TABLE_MODEL_ARRAY_CONTROLLER_H_ 7#pragma once 8 9#import <Cocoa/Cocoa.h> 10 11#include "app/table_model_observer.h" 12#import "base/mac/cocoa_protocols.h" 13#include "base/scoped_nsobject.h" 14#include "base/scoped_ptr.h" 15 16class RemoveRowsObserverBridge; 17class RemoveRowsTableModel; 18@class TableModelArrayController; 19 20// This class functions as an adapter from a RemoveRowsTableModel to a Cocoa 21// NSArrayController, to be used with bindings. 22// It maps the CanRemoveRows method to its canRemove property, and exposes 23// RemoveRows and RemoveAll as actions (remove: and removeAll:). 24// If the table model has groups, these are inserted into the list of arranged 25// objects as group rows. 26// The designated initializer is the same as for NSArrayController, 27// initWithContent:, but usually this class is instantiated from a nib file. 28// Clicking on a group row selects all rows belonging to that group, like it 29// does in a Windows table_view. 30// In order to show group rows, this class must be the delegate of the 31// NSTableView. 32@interface TableModelArrayController : NSArrayController<NSTableViewDelegate> { 33 @private 34 RemoveRowsTableModel* model_; // weak 35 scoped_ptr<RemoveRowsObserverBridge> tableObserver_; 36 scoped_nsobject<NSDictionary> columns_; 37 scoped_nsobject<NSString> groupTitle_; 38} 39 40// Bind this controller to the given model. 41// |columns| is a dictionary mapping table column bindings to NSNumbers 42// containing the column identifier in the TableModel. 43// |groupTitleColumn| is the column in the table that should display the group 44// title for a group row, usually the first column. If the model doesn't have 45// groups, it can be nil. 46- (void)bindToTableModel:(RemoveRowsTableModel*)model 47 withColumns:(NSDictionary*)columns 48 groupTitleColumn:(NSString*)groupTitleColumn; 49 50- (IBAction)removeAll:(id)sender; 51 52@end 53 54#endif // CHROME_BROWSER_UI_COCOA_TABLE_MODEL_ARRAY_CONTROLLER_H_ 55