| 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 |
|
| 327 |
david |
32 |
verticalLayout2 = new QVBoxLayout(scrollAreaWidgetContents);
|
| 192 |
- |
33 |
|
|
|
34 |
}
|
|
|
35 |
|
| 327 |
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 |
|
| 193 |
- |
49 |
void QmEventStatus::calculate(void)
|
|
|
50 |
{
|
| 327 |
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 |
*/
|
| 193 |
- |
70 |
if( load_report_data() )
|
|
|
71 |
{
|
|
|
72 |
srt_place();
|
| 318 |
david |
73 |
//qDebug("Calulate Event Status");
|
| 327 |
david |
74 |
|
|
|
75 |
/*
|
|
|
76 |
** Insert Data by Category
|
|
|
77 |
*/
|
| 193 |
- |
78 |
for( int j = 0; j <= config.num_class; j++ )
|
|
|
79 |
{
|
| 317 |
david |
80 |
if (j == 0 || config.team_class[j-1].abr[0])
|
| 193 |
- |
81 |
{
|
| 327 |
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 |
*/
|
| 317 |
david |
90 |
for( int i = 0; i <= config.num_legs; i++ )
|
|
|
91 |
{
|
| 363 |
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 );
|
| 317 |
david |
95 |
}
|
| 193 |
- |
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 |
|
| 192 |
- |
110 |
QmEventStatus::~QmEventStatus()
|
|
|
111 |
{
|
| 193 |
- |
112 |
|
| 192 |
- |
113 |
}
|