Subversion Repositories svn1

Rev

Rev 340 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
188 - 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) :
189 - 10
    QWidget(parent)
188 - 11
{
189 - 12
    resize ( 600,400);
188 - 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);
286 david 26
    buttonBox->setContentsMargins(0,0,5,5);
189 - 27
    buttonBox->addButton( new QPushButton("Recalc"),QDialogButtonBox::AcceptRole);
28
    QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(calculate()));
188 - 29
 
30
    verticalLayout->addWidget(buttonBox);
31
 
323 david 32
    verticalLayout2 = new QVBoxLayout(scrollAreaWidgetContents);
188 - 33
 
34
}
35
 
323 david 36
/*----------------------------------------------------------------------------
37
** FUNCTION           : calculate
38
**
39
** DESCRIPTION        : Recalculate an dre-display event status
40
**                      Delete and recreate a large amount of the widget
41
**
42
**
43
** INPUTS             :
44
**
45
** RETURNS            :
46
**
47
----------------------------------------------------------------------------*/
48
 
189 - 49
void QmEventStatus::calculate(void)
50
{
323 david 51
 
52
    /*
53
    ** Delete the contents of the existing layout
54
    */
55
    //qDebug("QmEventStatus::calculate:%d",verticalLayout2->layout()->count());
56
    QLayoutItem *child;
57
    while ((child = verticalLayout2->layout()->takeAt(0)) != 0) {
58
         //qDebug("Child Found:%p,%p, %p", child,child->layout(), child->widget());
59
        QWidget *childWidget = child->widget();
60
        if (childWidget)
61
        {
62
            delete child->widget();
63
        }
64
        delete child;
65
     }
66
 
67
    /*
68
    ** Load report data and generate place sorting
69
    */
189 - 70
    if( load_report_data() )
71
    {
72
        srt_place();
314 david 73
        //qDebug("Calulate Event Status");
323 david 74
 
75
        /*
76
        ** Insert Data by Category
77
        */
189 - 78
        for( int j = 0; j <= config.num_class; j++ )
79
        {
313 david 80
            if (j == 0 || config.team_class[j-1].abr[0])
189 - 81
            {
323 david 82
                QGroupBox * groupBox = new QGroupBox(j ? config.team_class[j - 1].full_name : "Complete Event");
83
                groupBox->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
84
                verticalLayout2->addWidget(groupBox);
85
                QHBoxLayout * horizontalLayout = new QHBoxLayout(groupBox);
86
 
87
                /*
88
                ** Insert Data by Leg
89
                */
313 david 90
                for( int i = 0; i <= config.num_legs; i++ )
91
                {
347 david 92
                    QmStatusItem *item = new QmStatusItem(i ? config.leg_name[i - 1] : "Overall");
93
                    item->setData(stats.fast.team[i][j], stats.fast.time[i][j],stats.average[i][j] );
94
                    horizontalLayout->addWidget ( item );
313 david 95
                }
189 - 96
            }
97
        }
98
    }
99
}
100
 
101
void QmEventStatus::showEvent ( QShowEvent * event )
102
{
103
    //qDebug("QmEventStatus::showEvent");
104
    if ( ! event->spontaneous() )
105
    {
106
        calculate();
107
    }
108
}
109
 
188 - 110
QmEventStatus::~QmEventStatus()
111
{
189 - 112
 
188 - 113
}