Subversion Repositories svn1-original

Rev

Rev 317 | Rev 327 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
192 - 1
#include "qmeventstatus.h"
2
#include "ui_qmeventstatus.h"
3
#include "qmstatusitem.h"
4
#include "QGroupBox"
5
#include    "consts.h"
6
#include    "structs.h"
7
#include    "proto.h"
8
 
9
QmEventStatus::QmEventStatus(QWidget *parent) :
193 - 10
    QWidget(parent)
192 - 11
{
193 - 12
    resize ( 600,400);
192 - 13
 
14
    verticalLayout = new QVBoxLayout(this);
15
    verticalLayout->setContentsMargins(0, 0, 0, 0);
16
    scrollArea = new QScrollArea(this);
17
    scrollArea->setWidgetResizable(true);
18
    scrollAreaWidgetContents = new QWidget();
19
    scrollAreaWidgetContents->setGeometry(QRect(0, 0, 395, 264));
20
    scrollArea->setWidget(scrollAreaWidgetContents);
21
 
22
    verticalLayout->addWidget(scrollArea);
23
 
24
    buttonBox = new QDialogButtonBox(this);
25
    buttonBox->setOrientation(Qt::Horizontal);
290 david 26
    buttonBox->setContentsMargins(0,0,5,5);
193 - 27
    buttonBox->addButton( new QPushButton("Recalc"),QDialogButtonBox::AcceptRole);
28
    QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(calculate()));
192 - 29
 
30
    verticalLayout->addWidget(buttonBox);
31
 
32
    QVBoxLayout *verticalLayout2 = new QVBoxLayout(scrollAreaWidgetContents);
33
 
34
    for( int j = 0; j <= config.num_class; j++ )
35
    {
317 david 36
        if (j == 0 || config.team_class[j-1].abr[0])
37
        {
38
            QGroupBox * groupBox = new QGroupBox(j ? config.team_class[j - 1].full_name : "Complete Event");
39
            groupBox->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
40
            verticalLayout2->addWidget(groupBox);
41
            QHBoxLayout * horizontalLayout = new QHBoxLayout(groupBox);
192 - 42
 
317 david 43
            for( int i = 0; i <= config.num_legs; i++ )
44
            {
45
                if (i == 0 || config.team_class[i-1].abr[0])
46
                {
47
                    QmStatusItem *item = new QmStatusItem(i ? config.leg_name[i - 1] : "Overall"); 
48
                    statusItems[i][j] = item;
49
                    //item->setData(stats.fast.team[i][j], stats.fast.time[i][j],stats.average[i][j] );
50
                    horizontalLayout->addWidget ( item );
51
                }
52
            }
192 - 53
        }
54
    }
55
}
56
 
193 - 57
void QmEventStatus::calculate(void)
58
{
59
    if( load_report_data() )
60
    {
61
        srt_place();
318 david 62
        //qDebug("Calulate Event Status");
193 - 63
        for( int j = 0; j <= config.num_class; j++ )
64
        {
317 david 65
            if (j == 0 || config.team_class[j-1].abr[0])
193 - 66
            {
317 david 67
                for( int i = 0; i <= config.num_legs; i++ )
68
                {
69
                    QmStatusItem * item = statusItems[i][j];
318 david 70
                    if (item)
71
                    {
72
                        item->setData(stats.fast.team[i][j], stats.fast.time[i][j], stats.average[i][j]); 
73
                    }
317 david 74
                }
193 - 75
            }
76
        }
77
    }
78
}
79
 
80
void QmEventStatus::showEvent ( QShowEvent * event )
81
{
82
    //qDebug("QmEventStatus::showEvent");
83
    if ( ! event->spontaneous() )
84
    {
85
        calculate();
86
    }
87
}
88
 
192 - 89
QmEventStatus::~QmEventStatus()
90
{
193 - 91
 
192 - 92
}