Rev 327 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "qmeventstatus.h"#include "ui_qmeventstatus.h"#include "qmstatusitem.h"#include "QGroupBox"#include "consts.h"#include "structs.h"#include "proto.h"QmEventStatus::QmEventStatus(QWidget *parent) :QWidget(parent){resize ( 600,400);verticalLayout = new QVBoxLayout(this);verticalLayout->setContentsMargins(0, 0, 0, 0);scrollArea = new QScrollArea(this);scrollArea->setWidgetResizable(true);scrollAreaWidgetContents = new QWidget();scrollAreaWidgetContents->setGeometry(QRect(0, 0, 395, 264));scrollArea->setWidget(scrollAreaWidgetContents);verticalLayout->addWidget(scrollArea);buttonBox = new QDialogButtonBox(this);buttonBox->setOrientation(Qt::Horizontal);buttonBox->setContentsMargins(0,0,5,5);buttonBox->addButton( new QPushButton("Recalc"),QDialogButtonBox::AcceptRole);QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(calculate()));verticalLayout->addWidget(buttonBox);verticalLayout2 = new QVBoxLayout(scrollAreaWidgetContents);}/*----------------------------------------------------------------------------** FUNCTION : calculate**** DESCRIPTION : Recalculate an dre-display event status** Delete and recreate a large amount of the widget****** INPUTS :**** RETURNS :**----------------------------------------------------------------------------*/void QmEventStatus::calculate(void){/*** Delete the contents of the existing layout*///qDebug("QmEventStatus::calculate:%d",verticalLayout2->layout()->count());QLayoutItem *child;while ((child = verticalLayout2->layout()->takeAt(0)) != 0) {//qDebug("Child Found:%p,%p, %p", child,child->layout(), child->widget());QWidget *childWidget = child->widget();if (childWidget){delete child->widget();}delete child;}/*** Load report data and generate place sorting*/if( load_report_data() ){srt_place();//qDebug("Calulate Event Status");/*** Insert Data by Category*/for( int j = 0; j <= config.num_class; j++ ){if (j == 0 || config.team_class[j-1].abr[0]){QGroupBox * groupBox = new QGroupBox(j ? config.team_class[j - 1].full_name : "Complete Event");groupBox->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);verticalLayout2->addWidget(groupBox);QHBoxLayout * horizontalLayout = new QHBoxLayout(groupBox);/*** Insert Data by Leg*/for( int i = 0; i <= config.num_legs; i++ ){if (i == 0 || config.team_class[i-1].abr[0]){QmStatusItem *item = new QmStatusItem(i ? config.leg_name[i - 1] : "Overall");item->setData(stats.fast.team[i][j], stats.fast.time[i][j],stats.average[i][j] );horizontalLayout->addWidget ( item );}}}}}}void QmEventStatus::showEvent ( QShowEvent * event ){//qDebug("QmEventStatus::showEvent");if ( ! event->spontaneous() ){calculate();}}QmEventStatus::~QmEventStatus(){}