| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 #import "chrome/browser/ui/cocoa/table_model_array_controller.h" | 5 #import "chrome/browser/ui/cocoa/table_model_array_controller.h" |
| 6 | 6 |
| 7 #include "app/table_model.h" | 7 #include "app/table_model.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/browser/remove_rows_table_model.h" | 10 #include "chrome/browser/remove_rows_table_model.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 - (void)modelDidChange { | 76 - (void)modelDidChange { |
| 77 NSIndexSet* indexes = [NSIndexSet indexSetWithIndexesInRange: | 77 NSIndexSet* indexes = [NSIndexSet indexSetWithIndexesInRange: |
| 78 NSMakeRange(0, [[self arrangedObjects] count])]; | 78 NSMakeRange(0, [[self arrangedObjects] count])]; |
| 79 [self removeObjectsAtArrangedObjectIndexes:indexes]; | 79 [self removeObjectsAtArrangedObjectIndexes:indexes]; |
| 80 if (model_->HasGroups()) { | 80 if (model_->HasGroups()) { |
| 81 const TableModel::Groups& groups = model_->GetGroups(); | 81 const TableModel::Groups& groups = model_->GetGroups(); |
| 82 DCHECK(groupTitle_.get()); | 82 DCHECK(groupTitle_.get()); |
| 83 for (TableModel::Groups::const_iterator it = groups.begin(); | 83 for (TableModel::Groups::const_iterator it = groups.begin(); |
| 84 it != groups.end(); ++it) { | 84 it != groups.end(); ++it) { |
| 85 NSDictionary* group = [NSDictionary dictionaryWithObjectsAndKeys: | 85 NSDictionary* group = [NSDictionary dictionaryWithObjectsAndKeys: |
| 86 base::SysWideToNSString(it->title), groupTitle_.get(), | 86 base::SysUTF16ToNSString(it->title), groupTitle_.get(), |
| 87 [NSNumber numberWithBool:YES], kIsGroupRow, | 87 [NSNumber numberWithBool:YES], kIsGroupRow, |
| 88 nil]; | 88 nil]; |
| 89 [self addObject:group]; | 89 [self addObject:group]; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 [self modelDidAddItemsInRange:NSMakeRange(0, model_->RowCount())]; | 92 [self modelDidAddItemsInRange:NSMakeRange(0, model_->RowCount())]; |
| 93 } | 93 } |
| 94 | 94 |
| 95 - (NSUInteger)offsetForGroupID:(int)groupID startingOffset:(NSUInteger)offset { | 95 - (NSUInteger)offsetForGroupID:(int)groupID startingOffset:(NSUInteger)offset { |
| 96 const TableModel::Groups& groups = model_->GetGroups(); | 96 const TableModel::Groups& groups = model_->GetGroups(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 | 185 |
| 186 - (NSDictionary*)columnValuesForRow:(NSInteger)row { | 186 - (NSDictionary*)columnValuesForRow:(NSInteger)row { |
| 187 NSMutableDictionary* dict = [NSMutableDictionary dictionary]; | 187 NSMutableDictionary* dict = [NSMutableDictionary dictionary]; |
| 188 if (model_->HasGroups()) { | 188 if (model_->HasGroups()) { |
| 189 [dict setObject:[NSNumber numberWithInt:model_->GetGroupID(row)] | 189 [dict setObject:[NSNumber numberWithInt:model_->GetGroupID(row)] |
| 190 forKey:kGroupID]; | 190 forKey:kGroupID]; |
| 191 } | 191 } |
| 192 for (NSString* identifier in columns_.get()) { | 192 for (NSString* identifier in columns_.get()) { |
| 193 int column_id = [[columns_ objectForKey:identifier] intValue]; | 193 int column_id = [[columns_ objectForKey:identifier] intValue]; |
| 194 std::wstring text = model_->GetText(row, column_id); | 194 string16 text = model_->GetText(row, column_id); |
| 195 [dict setObject:base::SysWideToNSString(text) forKey:identifier]; | 195 [dict setObject:base::SysUTF16ToNSString(text) forKey:identifier]; |
| 196 } | 196 } |
| 197 return dict; | 197 return dict; |
| 198 } | 198 } |
| 199 | 199 |
| 200 // Overridden from NSArrayController ----------------------------------------- | 200 // Overridden from NSArrayController ----------------------------------------- |
| 201 | 201 |
| 202 - (BOOL)canRemove { | 202 - (BOOL)canRemove { |
| 203 if (!model_) | 203 if (!model_) |
| 204 return NO; | 204 return NO; |
| 205 RemoveRowsTableModel::Rows rows; | 205 RemoveRowsTableModel::Rows rows; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 return indexes; | 237 return indexes; |
| 238 } | 238 } |
| 239 | 239 |
| 240 // Actions -------------------------------------------------------------------- | 240 // Actions -------------------------------------------------------------------- |
| 241 | 241 |
| 242 - (IBAction)removeAll:(id)sender { | 242 - (IBAction)removeAll:(id)sender { |
| 243 model_->RemoveAll(); | 243 model_->RemoveAll(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 @end | 246 @end |
| OLD | NEW |