#include <NGObjWeb/WODisplayGroup.h>
#import <EOControl/EOControl.h>
+#import <EOControl/EOKeyValueArchiver.h>
#import <Foundation/Foundation.h>
#import <Foundation/NSNotification.h>
#include "common.h"
- (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;
}
// TODO: maybe we need to retain the selection array and just swap the first
idx = [self->objects indexOfObject:_obj];
- idxNumber = (idx != NSNotFound) ? [NSNumber numberWithUnsignedInt:idx] : nil;
+ idxNumber = (idx != NSNotFound)
+ ? [NSNumber numberWithUnsignedInt:idx] : (NSNumber *)nil;
- if (idxNumber != nil)
- [self setSelectionIndexes:[NSArray arrayWithObjects:&idxNumber count:1]];
+ if (idxNumber != nil) {
+ NSArray *a;
+
+ a = [[NSArray alloc] initWithObjects:&idxNumber count:1];
+ [self setSelectionIndexes:a];
+ [a release]; a = nil;
+ }
else
[self setSelectionIndexes:nil];
}
return NO;
idx = [self->objects indexOfObject:_obj];
- idxNumber = (idx != NSNotFound) ? [NSNumber numberWithUnsignedInt:idx] : nil;
+ idxNumber = (idx != NSNotFound)
+ ? [NSNumber numberWithUnsignedInt:idx] : (NSNumber *)nil;
// TODO: should we just exchange the first item and/or call
// -setSelectedObject: ?
/* 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]];
}
/* construct qualifier for all query-match entries */
keys = [qm keyEnumerator];
- while ((key = [keys nextObject])) {
+ while ((key = [keys nextObject]) != nil) {
NSString *op;
SEL ops;
id value;
}
/* construct max qualifiers */
-
+
keys = [qmax keyEnumerator];
while ((key = [keys nextObject]) != nil) {
EOQualifier *q;
id value;
- value = [qmin objectForKey:key];
+ value = [qmax objectForKey:key];
q = [[EOKeyValueQualifier alloc]
initWithKey:key
[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];
EODataSource *ds;
return ([(ds = [self dataSource]) respondsToSelector:_cmd])
- ? [(EODetailDataSource *)ds detailKey] : nil;
+ ? [(EODetailDataSource *)ds detailKey] : (NSString *)nil;
}
- (void)setMasterObject:(id)_object {
/* description */
- (NSString *)description {
- return [NSString stringWithFormat:@"<0x%08X %@: ds=%@>",
+ return [NSString stringWithFormat:@"<0x%p %@: ds=%@>",
self, NSStringFromClass([self class]),
[self dataSource]];
}