NSURL *URL = [NSURL fileURLWithPath:filename];
NJMapping *mapping = [NJMapping mappingWithContentsOfURL:URL
error:&error];
- if ([self.mappingsController[mapping.name] hasConflictWith:mapping]) {
- [self promptForMapping:mapping atIndex:self.mappingsController.count];
- } else if (self.mappingsController[mapping.name]) {
- [self.mappingsController[mapping.name] mergeEntriesFrom:mapping];
+ if ([[self.mappingsController mappingForKey:mapping.name] hasConflictWith:mapping]) {
+ [self promptForMapping:mapping atIndex:self.mappingsController.mappings.count];
+ } else if ([self.mappingsController mappingForKey:mapping.name]) {
+ [[self.mappingsController mappingForKey:mapping.name] mergeEntriesFrom:mapping];
} else if (mapping) {
[self.mvc beginUpdates];
[self.mappingsController addMapping:mapping];
- [self.mvc addedMappingAtIndex:self.mappingsController.count - 1 startEditing:NO];
+ [self.mvc addedMappingAtIndex:self.mappingsController.mappings.count - 1 startEditing:NO];
[self.mvc endUpdates];
[self.mappingsController activateMapping:mapping];
} else {
NSError *error;
NJMapping *mapping = [NJMapping mappingWithContentsOfURL:panel.URL
error:&error];
- if ([self.mappingsController[mapping.name] hasConflictWith:mapping]) {
- [self promptForMapping:mapping atIndex:self.mappingsController.count];
- } else if (self.mappingsController[mapping.name]) {
- [self.mappingsController[mapping.name] mergeEntriesFrom:mapping];
+ if ([[self.mappingsController mappingForKey:mapping.name] hasConflictWith:mapping]) {
+ [self promptForMapping:mapping atIndex:self.mappingsController.mappings.count];
+ } else if ([self.mappingsController mappingForKey:mapping.name]) {
+ [[self.mappingsController mappingForKey:mapping.name] mergeEntriesFrom:mapping];
} else if (mapping) {
[self.mappingsController addMapping:mapping];
} else {
}
- (void)promptForMapping:(NJMapping *)mapping atIndex:(NSInteger)idx {
- NJMapping *mergeInto = self.mappingsController[mapping.name];
+ NJMapping *mergeInto = [self.mappingsController mappingForKey:mapping.name];
NSAlert *conflictAlert = [[NSAlert alloc] init];
conflictAlert.messageText = NSLocalizedString(@"import conflict prompt", @"Title of import conflict alert");
conflictAlert.informativeText =
}
- (NSInteger)numberOfMappings:(NJMappingsViewController *)mvc {
- return self.mappingsController.count;
+ return self.mappingsController.mappings.count;
}
- (NJMapping *)mappingsViewController:(NJMappingsViewController *)mvc
mappingForIndex:(NSUInteger)idx {
- return self.mappingsController[idx];
+ return self.mappingsController.mappings[idx];
}
- (void)mappingsViewController:(NJMappingsViewController *)mvc
renameMappingAtIndex:(NSInteger)index
toName:(NSString *)name {
- [self.mappingsController renameMapping:self.mappingsController[index]
+ [self.mappingsController renameMapping:self.mappingsController.mappings[index]
to:name];
}
canMoveMappingFromIndex:(NSInteger)fromIdx
toIndex:(NSInteger)toIdx {
return fromIdx != toIdx && fromIdx != 0 && toIdx != 0
- && toIdx < (NSInteger)self.mappingsController.count;
+ && toIdx < (NSInteger)self.mappingsController.mappings.count;
}
- (void)mappingsViewController:(NJMappingsViewController *)mvc
error:(NSError **)error {
NJMapping *mapping = [NJMapping mappingWithContentsOfURL:url
error:error];
- if ([self.mappingsController[mapping.name] hasConflictWith:mapping]) {
+ if ([[self.mappingsController mappingForKey:mapping.name] hasConflictWith:mapping]) {
[self promptForMapping:mapping atIndex:index];
- } else if (self.mappingsController[mapping.name]) {
- [self.mappingsController[mapping.name] mergeEntriesFrom:mapping];
+ } else if ([self.mappingsController mappingForKey:mapping.name]) {
+ [[self.mappingsController mappingForKey:mapping.name] mergeEntriesFrom:mapping];
} else if (mapping) {
[self.mvc beginUpdates];
[self.mvc addedMappingAtIndex:index startEditing:NO];
- (void)mappingsViewController:(NJMappingsViewController *)mvc
addMapping:(NJMapping *)mapping {
[mvc beginUpdates];
- [mvc addedMappingAtIndex:self.mappingsController.count startEditing:YES];
+ [mvc addedMappingAtIndex:self.mappingsController.mappings.count startEditing:YES];
[self.mappingsController addMapping:mapping];
[mvc endUpdates];
[self.mappingsController activateMapping:mapping];
- (void)mappingsViewController:(NJMappingsViewController *)mvc
choseMappingAtIndex:(NSInteger)idx {
- [self.mappingsController activateMapping:self.mappingsController[idx]];
+ [self.mappingsController activateMapping:self.mappingsController.mappings[idx]];
}
- (id)deviceViewController:(NJDeviceViewController *)dvc
elementForUID:(NSString *)uid {
- return self.deviceController[uid];
+ return [self.deviceController elementForUID:uid];
}
- (void)deviceViewControllerDidSelectNothing:(NJDeviceViewController *)dvc {
- (void)deviceController:(NJDeviceController *)dc
didAddDevice:(NJDevice *)device {
- [self.dvc addedDevice:device atIndex:dc.count - 1];
+ [self.dvc addedDevice:device atIndex:dc.devices.count - 1];
}
- (void)deviceController:(NJDeviceController *)dc
}
- (NSInteger)numberOfDevicesInDeviceList:(NJDeviceViewController *)dvc {
- return self.deviceController.count;
+ return self.deviceController.devices.count;
}
- (NJDevice *)deviceViewController:(NJDeviceViewController *)dvc
deviceForIndex:(NSUInteger)idx {
- return self.deviceController[idx];
+ return self.deviceController.devices[idx];
}
- (IBAction)simulatingEventsChanged:(NSButton *)sender {
return self;
}
-- (NJMapping *)objectForKeyedSubscript:(NSString *)name {
+- (NJMapping *)mappingForKey:(NSString *)name {
for (NJMapping *mapping in _mappings)
if ([name isEqualToString:mapping.name])
return mapping;
return nil;
}
-- (NJMapping *)objectAtIndexedSubscript:(NSUInteger)idx {
- return idx < _mappings.count ? _mappings[idx] : nil;
-}
-
- (void)mappingsSet {
[self postLoadProcess];
[NSNotificationCenter.defaultCenter
[self mappingsSet];
}
-- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
- objects:(__unsafe_unretained id [])buffer
- count:(NSUInteger)len {
- return [_mappings countByEnumeratingWithState:state
- objects:buffer
- count:len];
-}
-
- (void)activateMappingForProcess:(NSRunningApplication *)app {
NJMapping *oldMapping = _manualMapping;
NSArray *names = app.possibleMappingNames;
BOOL found = NO;
for (NSString *name in names) {
- NJMapping *mapping = self[name];
+ NJMapping *mapping = [self mappingForKey:name];
if (mapping) {
[self activateMapping:mapping];
found = YES;
}
- (void)postLoadProcess {
- for (NJMapping *mapping in self)
- [mapping postLoadProcess:self];
+ for (NJMapping *mapping in self.mappings)
+ [mapping postLoadProcess:self.mappings];
}
- (void)load {
- (void)removeMappingAtIndex:(NSInteger)idx {
NSInteger currentIdx = [self indexOfMapping:_currentMapping];
[_mappings removeObjectAtIndex:idx];
- [self activateMapping:self[MIN(currentIdx, _mappings.count - 1)]];
+ [self activateMapping:self.mappings[MIN(currentIdx, _mappings.count - 1)]];
[self mappingsChanged];
}
[self mappingsChanged];
}
-- (NSUInteger)count {
- return _mappings.count;
-}
-
@end