Subversion Repositories svn1-original

Rev

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