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 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#import "base/mac/cocoa_protocols.h" 12#include "base/memory/scoped_nsobject.h" 13#include "base/memory/scoped_ptr.h" 14#include "ui/base/models/table_model_observer.h" 15 16class RemoveRowsObserverBridge; 17class RemoveRowsTableModel; 18@class TableModelArrayController; 19 20// This class allows you to use a RemoveRowsTableModel with Cocoa bindings. 21// It maps the CanRemoveRows method to its canRemove property, and exposes 22// RemoveRows and RemoveAll as actions (remove: and removeAll:). 23// If the table model has groups, these are inserted into the list of arranged 24// objects as group rows. 25// The designated initializer is the same as for NSArrayController, 26// initWithContent:, but usually this class is instantiated from a nib file. 27// Clicking on a group row selects all rows belonging to that group, like it 28// does in a Windows table_view. 29// In order to show group rows, this class must be the delegate of the 30// NSTableView. 31@interface TableModelArrayController : NSArrayController<NSTableViewDelegate> { 32 @private 33 RemoveRowsTableModel* model_; // weak 34 scoped_ptr<RemoveRowsObserverBridge> tableObserver_; 35 scoped_nsobject<NSDictionary> columns_; 36 scoped_nsobject<NSString> groupTitle_; 37} 38 39// Bind this controller to the given model. 40// |columns| is a dictionary mapping table column bindings to NSNumbers 41// containing the column identifier in the TableModel. 42// |groupTitleColumn| is the column in the table that should display the group 43// title for a group row, usually the first column. If the model doesn't have 44// groups, it can be nil. 45- (void)bindToTableModel:(RemoveRowsTableModel*)model 46 withColumns:(NSDictionary*)columns 47 groupTitleColumn:(NSString*)groupTitleColumn; 48 49- (IBAction)removeAll:(id)sender; 50 51@end 52 53#endif // CHROME_BROWSER_UI_COCOA_TABLE_MODEL_ARRAY_CONTROLLER_H_ 54 55