Commit 783cbcb3 authored by A. Wilcox's avatar A. Wilcox

XUI: Update Dashboard view to make it show stuff.

parent 8093f31a
......@@ -8,15 +8,34 @@
#import <Cocoa/Cocoa.h>
#import <Managers/AuAccountManager.h>
#import "AuXBridge.h"
@interface AuXDashboardView : NSView {
@interface AuXDashboardView : NSView <AuXBridgeDelegate> {
AuAccount account;
NSTextField *accountTitle;
NSButton *reload;
NSTextField *listedCount, *sellingCount, *soldCount;
NSTextField *sellingAmt, *soldAmt;
NSOperationQueue *queue;
NSProgressIndicator *spinny;
NSNumberFormatter *currencyFormatter;
}
-(IBAction)reloadData:(id)sender;
-(IBAction)stopLoading:(id)sender;
@property (atomic,assign) AuAccount account;
@property IBOutlet NSTextField *accountTitle;
@property IBOutlet NSButton *reload;
@property IBOutlet NSTextField *listedCount, *sellingCount, *soldCount;
@property IBOutlet NSTextField *sellingAmt, *soldAmt;
@property IBOutlet NSProgressIndicator *spinny;
@property IBOutlet NSNumberFormatter *currencyFormatter;
@end
......@@ -10,17 +10,29 @@
@implementation AuXDashboardView
@synthesize accountTitle, reload;
@synthesize listedCount, sellingCount, soldCount, sellingAmt, soldAmt;
@synthesize spinny;
-(id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
// Initialization code here.
queue = [[NSOperationQueue alloc] init];
}
return self;
}
-(void)dealloc
{
[queue cancelAllOperations];
[queue release];
[super dealloc];
}
-(AuAccount)account
{
return account;
......@@ -31,6 +43,56 @@
account = _account;
[accountTitle setStringValue:[NSString stringWithUTF8String:account.friendly]];
[currencyFormatter setCurrencySymbol:[NSString stringWithUTF8String:currency_symbol_for_code(account.site->getCurrency())]];
[self stopLoading:self];
[self reloadData:self];
}
-(IBAction)reloadData:(id)sender
{
AuXBridge *bridge = [[AuXBridge alloc] initCall:AuGetSellingSummary
withData:[NSDictionary dictionaryWithObjectsAndKeys:[NSValue valueWithPointer:account.site],@"site",nil]
delegate:self];
[queue addOperation:bridge];
[bridge release];
listedCount.stringValue = sellingCount.stringValue = soldCount.stringValue = @"";
sellingAmt.stringValue = soldAmt.stringValue = @"";
[spinny startAnimation:nil];
}
-(IBAction)stopLoading:(id)sender
{
[spinny stopAnimation:nil];
[queue cancelAllOperations];
}
-(void)auctionCallDidFailWithError:(NSDictionary *)errorDetails
{
}
-(void)auctionCallFinished:(NSNumber *)call
{
// NOTREACHED
}
-(void)auctionCallReturnedData:(NSDictionary *)data
{
AuSellingSummary *summary = (AuSellingSummary *)[[data objectForKey:@"summary"] pointerValue];
[listedCount setIntegerValue:summary->auctions_listed];
[sellingCount setIntegerValue:summary->auctions_selling];
[soldCount setIntegerValue:summary->auctions_sold];
[sellingAmt setFloatValue:summary->selling_amt];
[soldAmt setFloatValue:summary->sold_amt];
delete summary;
[spinny stopAnimation:nil];
}
@end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment