Changeset 1572

Show
Ignore:
Timestamp:
09/06/04 19:50:06 (4 years ago)
Author:
morris
Message:

use WCDateDidChange notification to reload topic timestamp at midnight

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredClient/trunk/WCChat.h

    r1413 r1572  
    1 /* $Id: WCChat.h,v 1.20 2004/08/03 19:28:27 morris Exp $ */ 
     1/* $Id: WCChat.h,v 1.21 2004/09/06 17:50:06 morris Exp $ */ 
    22 
    33/* 
     
    3838 
    3939 
    40 @class WCConnection, WCSplitView, WCTextView, WCTableView
     40@class WCConnection, WCSplitView, WCTextView, WCTableView, WCTopic
    4141 
    4242@interface WCChat : WCWindowController <WCGetInfoValidation> { 
     
    7676         
    7777        NSDate                                                  *_timestamp; 
     78        WCTopic                                                 *_topic; 
    7879} 
    7980 
     
    101102- (void)                                                        update; 
    102103- (void)                                                        updateButtons; 
     104- (void)                                                        updateTopic; 
     105 
    103106- (void)                                                        showSetTopic; 
    104107- (void)                                                        saveChatToURL:(NSURL *)url; 
  • WiredClient/trunk/WCChat.m

    r1550 r1572  
    1 /* $Id: WCChat.m,v 1.67 2004/08/28 15:59:11 morris Exp $ */ 
     1/* $Id: WCChat.m,v 1.68 2004/09/06 17:50:06 morris Exp $ */ 
    22 
    33/* 
     
    5050#import "WCTableView.h" 
    5151#import "WCTextView.h" 
     52#import "WCTopic.h" 
    5253#import "WCUser.h" 
    5354#import "WCUserInfo.h" 
     
    9394        [[NSNotificationCenter defaultCenter] 
    9495                addObserver:self 
     96                   selector:@selector(dateDidChange:) 
     97                           name:WCDateDidChange 
     98                         object:NULL]; 
     99 
     100        [[NSNotificationCenter defaultCenter] 
     101                addObserver:self 
    95102                selector:@selector(chatShouldAddUser:) 
    96103                name:WCChatShouldAddUser 
     
    178185 
    179186        [_timestamp release]; 
     187        [_topic release]; 
    180188         
    181189        [super dealloc]; 
     
    224232        [_chatOutputTextView scrollRangeToVisible: 
    225233                NSMakeRange([[_chatOutputTextView textStorage] length], 0)]; 
     234} 
     235 
     236 
     237 
     238- (void)dateDidChange:(NSNotification *)notification { 
     239        // --- update topic 
     240        [self updateTopic]; 
    226241} 
    227242 
     
    881896 
    882897- (void)chatShouldShowTopic:(NSNotification *)notification { 
    883         NSString                *argument, *cid, *nick, *date, *topic
     898        NSString                *argument, *cid, *nick, *login, *address, *date, *message
    884899        NSArray                 *fields; 
    885900        WCConnection    *connection; 
     
    896911        cid                     = [fields objectAtIndex:0]; 
    897912        nick            = [fields objectAtIndex:1]; 
     913        login           = [fields objectAtIndex:2]; 
     914        address         = [fields objectAtIndex:3]; 
    898915        date            = [fields objectAtIndex:4]; 
    899         topic         = [fields objectAtIndex:5]; 
     916        message               = [fields objectAtIndex:5]; 
    900917         
    901918        if([cid unsignedIntValue] != _cid) 
     
    905922                return; 
    906923         
     924        // --- create new topic 
     925        [_topic release]; 
     926        _topic = [[WCTopic alloc] init]; 
     927        [_topic setCid:_cid]; 
     928        [_topic setNick:nick]; 
     929        [_topic setLogin:login]; 
     930        [_topic setAddress:address]; 
     931        [_topic setTime:[NSDate dateWithISO8601String:date]]; 
     932        [_topic setTopic:message]; 
     933         
     934        // --- update 
     935        [self updateTopic]; 
     936         
    907937        // --- set text fields 
    908       [_topicTextField setToolTip:topic]; 
     938/*    [_topicTextField setToolTip:topic]; 
    909939        [_topicTextField setStringValue:topic]; 
    910940        [_topicNickTextField setStringValue:[NSString stringWithFormat: 
     
    913943                0x2014, 
    914944                [[NSDate dateWithISO8601String:date] 
    915                         commonDateStringWithRelative:YES capitalized:YES seconds:NO]]]; 
     945                        commonDateStringWithRelative:YES capitalized:YES seconds:NO]]];*/ 
    916946} 
    917947 
     
    13051335 
    13061336- (void)updateButtons { 
    1307         int                    row; 
     1337        int             row; 
    13081338         
    13091339        // --- get row 
     
    13201350 
    13211351 
     1352 
     1353- (void)updateTopic { 
     1354        // --- set text fields 
     1355        [_topicTextField setToolTip:[_topic topic]]; 
     1356        [_topicTextField setStringValue:[_topic topic]]; 
     1357        [_topicNickTextField setStringValue:[NSString stringWithFormat: 
     1358                NSLocalizedString(@"%@ %C %@", @"Chat topic set by (nick, time)"), 
     1359                [_topic nick], 
     1360                0x2014, 
     1361                [[_topic time] commonDateStringWithRelative:YES capitalized:YES seconds:NO]]]; 
     1362} 
     1363 
     1364 
     1365 
     1366#pragma mark - 
    13221367 
    13231368- (void)showSetTopic {