- (id)selectNext {
unsigned int idx;
- if ([self->displayObjects count] == 0)
+ if (![self->displayObjects isNotEmpty])
return nil;
- if ([self->selectionIndexes count] == 0) {
+ if (![self->selectionIndexes isNotEmpty]) {
[self setSelectionIndexes:uint0Array];
return nil;
}
- (id)selectPrevious {
unsigned int idx;
- if ([self->displayObjects count] == 0)
+ if (![self->displayObjects isNotEmpty])
return nil;
- if ([self->selectionIndexes count] == 0) {
+ if (![self->selectionIndexes isNotEmpty]) {
[self setSelectionIndexes:uint0Array];
return nil;
}
/* should try to restore selection */
[self clearSelection];
- if ([_objects count] > 0 && [self selectsFirstObjectAfterFetch]) {
+ if ([_objects isNotEmpty] && [self selectsFirstObjectAfterFetch])
[self setSelectionIndexes:uint0Array];
- }
}
- (NSArray *)allObjects {
}
[self updateDisplayedObjects];
-
+
if ([self selectsFirstObjectAfterFetch]) {
[self clearSelection];
- if ([objs count] > 0)
+ if ([objs isNotEmpty])
[self setSelectedObject:[objs objectAtIndex:0]];
}
[q release];
}
- if ([quals count] == 0)
+ if (![quals isNotEmpty])
return nil;
if ([quals count] == 1)
return [quals objectAtIndex:0];
- (void)qualifyDataSource {
EODataSource *ds;
EOQualifier *q;
+ NSDictionary *bindings;
- ds = [self dataSource];
+ if ((ds = [self dataSource]) == nil)
+ [self warnWithFormat:@"no datasource set: %@", NSStringFromSelector(_cmd)];
+
+ /* build qualifier */
if ((q = [self qualifierFromQueryValues]) != nil)
[self setQualifier:q];
- if ([ds respondsToSelector:@selector(setAuxiliaryQualifier:)])
+ /* set qualifier in datasource */
+
+ if ([ds respondsToSelector:@selector(setAuxiliaryQualifier:)]) {
[ds setAuxiliaryQualifier:[self qualifier]];
+ //[self logWithFormat:@"set aux qualifier in %@: %@", ds,[self qualifier]];
+ }
else if ([ds respondsToSelector:@selector(setQualifier:)])
[ds setQualifier:[self qualifier]];
else {
/* could not qualify ds */
+ [self warnWithFormat:@"could not qualify datasource: %@", ds];
}
- if ([ds respondsToSelector:@selector(setQualifierBindings:)])
- [ds setQualifierBindings:[self queryBindings]];
+ /* set bindings in datasource */
+
+ if ([(bindings = [self queryBindings]) isNotEmpty]) {
+ if ([ds respondsToSelector:@selector(setQualifierBindings:)])
+ [ds setQualifierBindings:bindings];
+ else {
+ [self warnWithFormat:@"could not set bindings in datasource %@: %@",
+ ds, bindings];
+ }
+ }
+
+ /* perform fetch */
+ /* action method, returns 'nil' to stay on page */
[self fetch];
if ([self inQueryMode])
[self setInQueryMode:NO];
}
+- (id)qualifyDataSourceAndReturnDisplayCount {
+ /*
+ This is a 'hack' created because we can't bind (and therefore 'call')
+ 'void' methods in .wod files.
+ */
+ [self qualifyDataSource];
+ return [NSNumber numberWithUnsignedInt:[[self displayedObjects] count]];
+}
/* object creation */
- (id)insert {
unsigned idx;
- idx = [self->selectionIndexes count] > 0
+ idx = [self->selectionIndexes isNotEmpty]
? ([[self->selectionIndexes objectAtIndex:0] unsignedIntValue] + 1)
: [self->objects count];