//
//  DetailContent.m
//  Apex Mobile
//
//  Created by Ray on 14-3-7.
//  Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
//

#import "DetailContent.h"

@implementation DetailContent
- (id)init
{
    self = [super init];
    if (self) {
        self.segments = [[NSArray alloc] init];
        self.webviewHeight = [[NSMutableDictionary alloc] init];
        self.result_code = RESULT_TRUE;
    }
    return self;
}
-(long) get_segmentcount
{
    return self.segments.count;
}
-(int) get_itemcount :(long)idx
{
    int count=0;
    NSDictionary* segment = self.segments[idx];
    NSString* type =[segment valueForKey:@"_type"];
    if([type isEqualToString:@"table"])
        count=1;
    else
        count=[[segment valueForKey:@"count"] intValue];
    
    return count;
    
}
-(NSDictionary*)get_item_seg :(long)seg row:(long)row
{
    NSDictionary* segment = self.segments[seg];
    
    NSString* type =[segment valueForKey:@"_type"];
    if([type isEqualToString:@"table"])
        return segment;
    else if([type isEqualToString:@"mapping"])
    {
        return [segment objectForKey:[NSString stringWithFormat:@"item%ld",row]];
    }
    else
    {
        return segment;
    }
}
-(NSString*) get_segmenttype :(long)idx
{
    NSDictionary* segment = self.segments[idx];
    NSString* type =[segment valueForKey:@"_type"];
    return type;
}
-(NSString*) get_segmentname : (long)seg
{
    NSDictionary* segment = self.segments[seg];
    NSString* name =[segment valueForKey:@"_name"];
    return name;
}

//-(float) itemHeightAtIndexPath:(NSIndexPath *)indexPath
//{
//    int x = indexPath.section;
//    int y = indexPath.row;
//    NSMutableDictionary* segHeight= [self.itemHeight objectForKey:[NSString stringWithFormat:@"%d",indexPath.section]];
//    float itemHeight = [[segHeight valueForKey:[NSString stringWithFormat:@"%d",indexPath.row]] floatValue];
//    return itemHeight;
//}
//-(void) set_itemheight:(float)height AtIndexPath:(NSIndexPath *)indexPath
//{
//    NSMutableDictionary* segHeight= [self.itemHeight objectForKey:[NSString stringWithFormat:@"%d",indexPath.section]];
//    if(segHeight==nil)
//        segHeight = [[NSMutableDictionary alloc]init];
//    [segHeight setValue:[NSString stringWithFormat:@"%f",height] forKey:[NSString stringWithFormat:@"%d",indexPath.row]];
//    
//    [self.itemHeight setValue:segHeight forKey:[NSString stringWithFormat:@"%d",indexPath.section]];
//    
//}
@end
