2004-10-05 Helge Hess <helge.hess@opengroupware.org>
+ * UIxMailListView: added simple navigation (v0.9.20)
+
* v0.9.19
* UIxMailPartViewer.m: added content decoding for QP, base64 and 7bit,
@interface UIxMailListView : UIxComponent
{
- NSArray *sortedUIDs; /* we always need to retrieve all anyway! */
- NSArray *messages;
- id message;
+ NSArray *sortedUIDs; /* we always need to retrieve all anyway! */
+ NSArray *messages;
+ unsigned firstMessageNumber;
+ id message;
}
@end
}
- (NSRange)fetchRange {
- return NSMakeRange(0, 50);
+ if (self->firstMessageNumber == 0)
+ return NSMakeRange(0, 50);
+ return NSMakeRange(self->firstMessageNumber - 1, 50);
}
- (NSArray *)sortedUIDs {
r = [self fetchRange];
uids = [self sortedUIDs];
-
+
/* only need to restrict if we have a lot */
if ((len = [uids count]) <= r.length) {
r.location = 0;
return r.location + r.length >= [[self sortedUIDs] count] ? NO : YES;
}
+- (unsigned int)nextFirstMessageNumber {
+ return [self firstMessageNumber] + [self fetchRange].length;
+}
+- (unsigned int)prevFirstMessageNumber {
+ NSRange r;
+ unsigned idx;
+
+ idx = [self firstMessageNumber];
+ r = [self fetchRange];
+ if (idx > r.length)
+ return (idx - r.length);
+ return 1;
+}
+
- (NSArray *)messages {
NSArray *uids;
NSArray *msgs;
- (id)defaultAction {
[self logWithFormat:@"default action ..."];
+ self->firstMessageNumber =
+ [[[[self context] request] formValueForKey:@"idx"] intValue];
return self;
}
<var:if condition="showsAllMessages" const:negate="YES">
<var:if condition="hasPrevious">
- <a href="prevBlock">prev</a> |
+ <a href="view" _idx="1">first</a> |
+ <a href="view" var:_idx="prevFirstMessageNumber">prev</a> |
</var:if>
<var:string value="firstMessageNumber"/>
<var:string value="sortedUIDs.count" />
<var:if condition="hasNext">
- | <a href="nextBlock">next</a>
+ | <a href="view" var:_idx="nextFirstMessageNumber">next</a>
</var:if>
</var:if>
</td>