]> err.no Git - scalable-opengroupware.org/blobdiff - UI/SOGoUI/SOGoAptFormatter.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1190 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / SOGoUI / SOGoAptFormatter.m
index 6f0d91d1ff86d19fcc90a3f9db4fb683b3a47279..4824f4b4a43984443a6ab5c31350bef3f1832214 100644 (file)
   02111-1307, USA.
 */
 
-#include "SOGoAptFormatter.h"
-#include "common.h"
+#import <NGExtensions/NSCalendarDate+misc.h>
+#import <NGExtensions/NSObject+Logs.h>
+#import <NGExtensions/NSNull+misc.h>
+
+#import "SOGoAptFormatter.h"
 
 @interface SOGoAptFormatter(PrivateAPI)
 - (NSString *)titleForApt:(id)_apt :(NSCalendarDate *)_refDate;
   self->formatAction = @selector(shortTitleForApt::);
 }
 
+- (void)setShortMonthTitleOnly {
+  self->formatAction = @selector(shortMonthTitleForApt::);
+}
+
 - (void)setPrivateSuppressAll {
   self->formatAction = @selector(suppressApt::);
 }
   NSString *title;
   
   title = [self titleForApt:_apt :_refDate];
-  if ([title length] > 12)
-    title = [[title substringToIndex:11] stringByAppendingString:@"..."];
+  if ([title length] > 50)
+    title = [[title substringToIndex: 49] stringByAppendingString:@"..."];
+  
+  return title;
+}
+
+- (NSString *)shortMonthTitleForApt:(id)_apt :(NSCalendarDate *)_refDate {
+  NSMutableString *title;
+  NSCalendarDate *startDate;
+  NSTimeZone *dtz;
+
+  title = [NSMutableString new];
+  [title autorelease];
+
+  dtz        = [self displayTZ];
+  startDate  = [_apt valueForKey: @"startDate"];
+  [startDate setTimeZone:dtz];
+  [self appendTimeInfoForDate: startDate usingReferenceDate: nil
+        toBuffer: title];
+  [title appendFormat: @" %@", [self titleForApt:_apt :_refDate]];
   
   return title;
 }
   return aptDescr;
 }
 
-- (NSString *)fullDetailsForApt:(id)_apt :(NSCalendarDate *)_refDate {
+- (NSString *) fullDetailsForApt: (id)_apt
+                                : (NSCalendarDate *)_refDate
+{
   NSMutableString *aptDescr;
-  NSString        *s;
-    
-  aptDescr = [NSMutableString stringWithCapacity:60];
-  [self appendTimeInfoFromApt:_apt
-        usingReferenceDate:_refDate
-        toBuffer:aptDescr];
-  if ((s = [_apt valueForKey:@"location"]) != nil) {
-    if([s length] > 12)
-      s = [[s substringToIndex:11] stringByAppendingString:@"..."];
-    [aptDescr appendFormat:@" (%@)", s];
-  }
-  if ((s = [self shortTitleForApt:_apt :_refDate]) != nil)
+  NSString *s;
+
+  aptDescr = [NSMutableString stringWithCapacity: 60];
+  [self appendTimeInfoFromApt: _apt
+        usingReferenceDate: _refDate
+        toBuffer: aptDescr];
+  s = [_apt valueForKey: @"location"];
+  if ([s length] > 0)
+    {
+      if ([s length] > 50)
+        s = [[s substringToIndex: 49] stringByAppendingString: @"..."];
+      [aptDescr appendFormat:@" (%@)", s];
+    }
+  s = [self shortTitleForApt: _apt : _refDate];
+  if ([s length] > 0)
     [aptDescr appendFormat:@"<br />%@", s];
   
   return aptDescr;
 }
 
-- (NSString *)detailsForPrivateApt:(id)_apt :(NSCalendarDate *)_refDate {
+- (NSString *) detailsForPrivateApt: (id) _apt
+                                   : (NSCalendarDate *) _refDate
+{
   NSMutableString *aptDescr;
   NSString        *s;
 
   return aptDescr;
 }
 
-- (NSString *)titleOnlyForPrivateApt:(id)_apt :(NSCalendarDate *)_refDate {
+- (NSString *) titleOnlyForPrivateApt: (id)_apt
+                                     : (NSCalendarDate *) _refDate
+{
   NSString *s;
   
   s = [self privateTitle];
-  if(!s)
-    return @"";
+  if (!s)
+    s = @"";
+
   return s;
 }
 
-- (NSString *)tooltipForApt:(id)_apt :(NSCalendarDate *)_refDate {
+- (NSString *) tooltipForApt: (id)_apt
+                            : (NSCalendarDate *) _refDate
+{
   NSMutableString *aptDescr;
-  NSString        *s;
+  NSString *s;
 
-  aptDescr = [NSMutableString stringWithCapacity:60];
-  [self appendTimeInfoFromApt:_apt
-        usingReferenceDate:_refDate
-        toBuffer:aptDescr];  
-  if ((s = [self titleForApt:_apt :_refDate]) != nil)
-    [aptDescr appendFormat:@"\n%@", s];
-  if ((s = [_apt valueForKey:@"location"]) != nil)
+  aptDescr = [NSMutableString stringWithCapacity: 60];
+  [aptDescr appendString: @"Date: "];
+  [self appendTimeInfoFromApt: _apt
+        usingReferenceDate: _refDate
+        toBuffer: aptDescr];
+  s = [self titleForApt: _apt : _refDate];
+  if ([s length] > 0)
+    [aptDescr appendFormat: @"\nTitle: %@", s];
+  s = [_apt valueForKey: @"location"];
+  if ([s length] > 0)
+    [aptDescr appendFormat: @"\nLocation: %@", s];
+  s = [_apt valueForKey: @"description"];
+  if ([s length] > 0)
     [aptDescr appendFormat:@"\n%@", s];
-    
+
   return aptDescr;
 }
 
-- (NSString *)tooltipForPrivateApt:(id)_apt :(NSCalendarDate *)_refDate {
+- (NSString *) tooltipForPrivateApt: (id) _apt
+                                   : (NSCalendarDate *) _refDate
+{
   NSMutableString *aptDescr;
-  NSString        *s;
+  NSString *s;
   
-  aptDescr = [NSMutableString stringWithCapacity:25];
-  [self appendTimeInfoFromApt:_apt
-        usingReferenceDate:_refDate
-        toBuffer:aptDescr];  
+  aptDescr = [NSMutableString stringWithCapacity: 25];
+  [self appendTimeInfoFromApt: _apt
+        usingReferenceDate: _refDate
+        toBuffer: aptDescr];  
   if ((s = [self privateTitle]) != nil)
     [aptDescr appendFormat:@"\n%@", s];
 
   return aptDescr;
 }
 
-- (NSString *)suppressApt:(id)_apt :(NSCalendarDate *)_refDate {
+- (NSString *) suppressApt: (id) _apt
+                          : (NSCalendarDate *) _refDate
+{
   return @"";
 }