Changeset 3801

Show
Ignore:
Timestamp:
09/13/08 18:08:54 (2 months ago)
Author:
timothy
Message:

Some changes that inch-along to making connection editing work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Mobile/Controllers/CQConnectionEditViewController.m

    r3785 r3801  
    6868 
    6969- (UITableViewCell *) tableView:(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath { 
    70         CQPreferencesTextCell *cell = [[CQPreferencesTextCell alloc] init]; 
    71         cell.text = @"Test"; 
    72         cell.label = @"My Label"; 
    73         return [cell autorelease]; 
     70        CQPreferencesTextCell *cell = (CQPreferencesTextCell *)[tableView dequeueReusableCellWithIdentifier:@"CQPreferencesTextCell"]; 
     71        if( ! cell ) cell = [[[CQPreferencesTextCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"CQPreferencesTextCell"] autorelease]; 
     72 
     73        if( indexPath.section == 0 ) { 
     74                if ( indexPath.row == 0 ) { 
     75                        cell.label = @"Server"; 
     76                        cell.text = @""; 
     77                } else if( indexPath.row == 1 ) { 
     78                        cell.label = @"Port"; 
     79                        cell.text = @""; 
     80                } else if( indexPath.row == 2 ) { 
     81                        cell.label = @"Use SSL"; 
     82                        cell.text = @""; 
     83                } 
     84        } else if( indexPath.section == 1 ) { 
     85                if ( indexPath.row == 0 ) { 
     86                        cell.label = @"Nickname"; 
     87                        cell.text = @""; 
     88                } else if( indexPath.row == 1 ) { 
     89                        cell.label = @"Alternates"; 
     90                        cell.text = @""; 
     91                } else if( indexPath.row == 2 ) { 
     92                        cell.label = @"Real Name"; 
     93                        cell.text = @""; 
     94                } 
     95        } else if( indexPath.section == 2 ) { 
     96                if ( indexPath.row == 0 ) { 
     97                        cell.label = @"Username"; 
     98                        cell.text = @""; 
     99                } else if( indexPath.row == 1 ) { 
     100                        cell.label = @"Password"; 
     101                        cell.text = @""; 
     102                } else if( indexPath.row == 2 ) { 
     103                        cell.label = @"Nick Password"; 
     104                        cell.text = @""; 
     105                } 
     106        } else if( indexPath.section == 3 ) { 
     107                if ( indexPath.row == 0 ) { 
     108                        cell.label = @"Connect"; 
     109                        cell.text = @""; 
     110                } else if( indexPath.row == 1 ) { 
     111                        cell.label = @"Join Rooms"; 
     112                        cell.text = @""; 
     113                } 
     114        } 
     115 
     116        return cell; 
    74117} 
    75118@end 
  • trunk/Mobile/Controllers/CQConnectionsController.m

    r3797 r3801  
    2828                return nil; 
    2929 
    30         _connections = [[NSMutableArray alloc] init]; 
    31  
    3230        self.title = NSLocalizedString(@"Connections", @"Connections tab title"); 
    3331        self.tabBarItem.image = [UIImage imageNamed:@"connections.png"]; 
     32 
     33        _connections = [[NSMutableArray alloc] init]; 
     34 
     35        connectionsViewController = [[CQConnectionsViewController alloc] init]; 
     36        [self pushViewController:connectionsViewController animated:NO]; 
    3437 
    3538        [self _loadConnectionList]; 
     
    4750#pragma mark - 
    4851 
    49 - (void) viewDidLoad { 
    50         [super viewDidLoad]; 
    51         if( !connectionsViewController ) 
    52                 connectionsViewController = [[CQConnectionsViewController alloc] init]; 
    53         [self pushViewController:connectionsViewController animated:NO]; 
     52- (void) didReceiveMemoryWarning { 
     53        if( !editViewController.view.superview ) { 
     54                [editViewController release]; 
     55                editViewController = nil; 
     56        } 
     57 
     58        [super didReceiveMemoryWarning]; 
    5459} 
    5560 
  • trunk/Mobile/Controllers/CQConnectionsViewController.m

    r3797 r3801  
    3131 
    3232        self.navigationItem.rightBarButtonItem = self.editButtonItem;    
    33  
    34         for( MVChatConnection *connection in [CQConnectionsController defaultController].connections ) 
    35                 [self addConnection:connection]; 
    3633} 
    3734 
    3835- (void) didReceiveMemoryWarning { 
    39         if( ! self.view.superview ) { 
     36        if( !connectionCreationViewController.view.superview ) { 
    4037                [connectionCreationViewController release]; 
    4138                connectionCreationViewController = nil; 
     
    9895 
    9996#pragma mark - 
    100  
    101 - (void) _registerNotificationsForConnection:(MVChatConnection *) connection { 
    102         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _didChange: ) name:MVChatConnectionNicknameAcceptedNotification object:connection]; 
    103         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _willConnect: ) name:MVChatConnectionWillConnectNotification object:connection]; 
    104         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _didConnect: ) name:MVChatConnectionDidConnectNotification object:connection]; 
    105         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _didChange: ) name:MVChatConnectionDidNotConnectNotification object:connection]; 
    106         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _didDisconnect: ) name:MVChatConnectionDidDisconnectNotification object:connection]; 
    107  
    108 //      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _errorOccurred : ) name:MVChatConnectionErrorNotification object:connection]; 
    109  
    110 //      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _requestPassword: ) name:MVChatConnectionNeedNicknamePasswordNotification object:connection]; 
    111 //      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _requestCertificatePassword: ) name:MVChatConnectionNeedCertificatePasswordNotification object:connection]; 
    112 //      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _requestPublicKeyVerification: ) name:MVChatConnectionNeedPublicKeyVerificationNotification object:connection]; 
    113 } 
    11497 
    11598- (void) _deregisterNotificationsForConnection:(MVChatConnection *) connection { 
     
    127110} 
    128111 
     112- (void) _registerNotificationsForConnection:(MVChatConnection *) connection { 
     113        // Remove any previous observers, to prevent registering twice. 
     114        [self _deregisterNotificationsForConnection:connection]; 
     115 
     116        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _didChange: ) name:MVChatConnectionNicknameAcceptedNotification object:connection]; 
     117        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _willConnect: ) name:MVChatConnectionWillConnectNotification object:connection]; 
     118        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _didConnect: ) name:MVChatConnectionDidConnectNotification object:connection]; 
     119        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _didChange: ) name:MVChatConnectionDidNotConnectNotification object:connection]; 
     120        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _didDisconnect: ) name:MVChatConnectionDidDisconnectNotification object:connection]; 
     121 
     122//      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _errorOccurred : ) name:MVChatConnectionErrorNotification object:connection]; 
     123 
     124//      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _requestPassword: ) name:MVChatConnectionNeedNicknamePasswordNotification object:connection]; 
     125//      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _requestCertificatePassword: ) name:MVChatConnectionNeedCertificatePasswordNotification object:connection]; 
     126//      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _requestPublicKeyVerification: ) name:MVChatConnectionNeedPublicKeyVerificationNotification object:connection]; 
     127} 
     128 
    129129- (void) _willConnect:(NSNotification *) notification { 
    130130        MVChatConnection *connection = notification.object; 
     
    250250 
    251251        CQConnectionTableCell *cell = (CQConnectionTableCell *)[tableView dequeueReusableCellWithIdentifier:@"CQConnectionTableCell"]; 
    252         if( ! cell ) cell = [[[CQConnectionTableCell alloc] init] autorelease]; 
     252        if( ! cell ) cell = [[[CQConnectionTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"CQConnectionTableCell"] autorelease]; 
    253253 
    254254        [cell takeValuesFromConnection:connection]; 
  • trunk/Mobile/Views/CQPreferencesTextCell.h

    r3785 r3801  
    55@property (nonatomic, copy) NSString *label; 
    66@property (nonatomic, copy) NSString *text; 
     7@property (nonatomic, copy) NSString *placeholder; 
     8@property (nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry; 
    79@property (nonatomic, readonly) UITextField *textField; 
    810@end 
  • trunk/Mobile/Views/CQPreferencesTextCell.m

    r3785 r3801  
    66                return nil; 
    77 
     8        self.backgroundColor = [UIColor clearColor]; 
     9        self.opaque = NO; 
     10 
    811        _textField = [[UITextField alloc] initWithFrame:CGRectZero]; 
    912        _label = [[UILabel alloc] initWithFrame:CGRectZero]; 
    10  
    11         _textField.leftView = _label; 
    12         _textField.leftViewMode = UITextFieldViewModeAlways; 
    13  
    14         [self.contentView addSubview:_textField]; 
    15  
    16         _textField.font = [UIFont systemFontOfSize:14.]; 
    17         _textField.textColor = [UIColor colorWithRed:0.19607843 green:0.29803922 blue:0.84313725 alpha:1.]; 
    1813 
    1914        _label.font = [UIFont boldSystemFontOfSize:18.]; 
    2015        _label.textColor = self.textColor; 
    2116        _label.highlightedTextColor = self.selectedTextColor; 
     17        _label.backgroundColor = [UIColor clearColor]; 
     18        _label.opaque = NO; 
     19 
     20        _textField.textAlignment = UITextAlignmentLeft; 
     21        _textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; 
     22        _textField.font = [UIFont systemFontOfSize:14.]; 
     23        _textField.textColor = [UIColor colorWithRed:0.235294117647059 green:0.341176470588235 blue:0.545098039215686 alpha:1.]; 
     24        _textField.backgroundColor = [UIColor clearColor]; 
     25        _textField.opaque = NO; 
     26 
     27        [self.contentView addSubview:_label]; 
     28        [self.contentView addSubview:_textField]; 
    2229 
    2330        return self; 
     
    4855} 
    4956 
     57- (NSString *) placeholder { 
     58        return _textField.placeholder; 
     59} 
     60 
     61- (void) setPlaceholder:(NSString *) placeholder { 
     62        _textField.placeholder = placeholder; 
     63} 
     64 
     65- (BOOL) isSecureTextEntry { 
     66        return _textField.secureTextEntry; 
     67} 
     68 
     69- (void) setSecureTextEntry:(BOOL) flag { 
     70        _textField.secureTextEntry = flag; 
     71} 
     72 
    5073- (void) setSelected:(BOOL) selected animated:(BOOL) animated { 
    5174        [super setSelected:selected animated:animated]; 
    5275 
    53         UIColor *backgroundColor = nil; 
    54         if( selected || animated ) backgroundColor = nil; 
    55         else backgroundColor = [UIColor whiteColor]; 
     76        _label.highlighted = selected; 
     77
    5678 
    57         _textField.backgroundColor = backgroundColor; 
    58         _textField.opaque = !selected && !animated; 
    59  
    60         _label.backgroundColor = backgroundColor; 
    61         _label.highlighted = selected; 
    62         _label.opaque = !selected && !animated; 
     79- (void) prepareForReuse { 
     80        self.label = @""; 
     81        self.text = @""; 
     82        self.placeholder = @""; 
     83        self.secureTextEntry = NO; 
    6384} 
    6485 
     
    6788 
    6889        CGRect contentRect = self.contentView.bounds; 
     90        contentRect.origin.x = 10.; 
     91        contentRect.size.width = 130.; 
     92 
     93        _label.frame = contentRect; 
     94 
     95        contentRect = self.contentView.bounds; 
     96        contentRect.origin.x = 150.; 
     97        contentRect.size.width -= 160.; 
    6998 
    7099        _textField.frame = contentRect;