| 163 |
david |
1 |
#include "qmdialogstatus.h"
|
|
|
2 |
#include <QGroupBox>
|
|
|
3 |
#include <QTableWidget>
|
|
|
4 |
#include <QVBoxLayout>
|
|
|
5 |
#include <QStringList>
|
|
|
6 |
#include <QHeaderView>
|
|
|
7 |
|
|
|
8 |
#include "consts.h"
|
|
|
9 |
#include "structs.h"
|
|
|
10 |
#include "proto.h"
|
|
|
11 |
|
|
|
12 |
QmDialogStatus::QmDialogStatus(QWidget *parent) : QDialog(parent)
|
|
|
13 |
{
|
|
|
14 |
QVBoxLayout *layout = new QVBoxLayout;
|
|
|
15 |
setLayout(layout);
|
|
|
16 |
setSizeGripEnabled(true);
|
|
|
17 |
|
|
|
18 |
QGroupBox *gb = new QGroupBox("Summary Display", this);
|
|
|
19 |
layout->addWidget(gb);
|
|
|
20 |
|
|
|
21 |
QVBoxLayout *layout2 = new QVBoxLayout;
|
|
|
22 |
gb->setLayout(layout2);
|
|
|
23 |
|
|
|
24 |
// Table Header
|
| 228 |
- |
25 |
QTableWidget *tb = new QTableWidget(config.num_class + 1,6);
|
| 164 |
david |
26 |
//tb->horizontalHeader()->setStretchLastSection(true);
|
| 163 |
david |
27 |
tb->horizontalHeader()->setSortIndicatorShown(true);
|
|
|
28 |
QStringList labels;
|
| 228 |
- |
29 |
labels << "Category" << "Total" << "Valid" << "Disq" << "NonEq" << "VetCheck";
|
| 163 |
david |
30 |
tb->setHorizontalHeaderLabels(labels);
|
|
|
31 |
tb->verticalHeader()->setDefaultSectionSize(17);
|
|
|
32 |
tb->setSortingEnabled(false);
|
| 165 |
david |
33 |
tb->setAlternatingRowColors(true);
|
| 163 |
david |
34 |
layout2->addWidget(tb);
|
|
|
35 |
|
|
|
36 |
if( load_report_data() )
|
|
|
37 |
{
|
|
|
38 |
t_class_summary data;
|
|
|
39 |
calc_class_summary( & data );
|
|
|
40 |
|
|
|
41 |
// Insert summary data
|
|
|
42 |
int ii;
|
|
|
43 |
for (ii = 0; ii < config.num_class; ii++)
|
|
|
44 |
{
|
| 164 |
david |
45 |
tb->setItem(ii,0, new QmDialogStatusTableItem(config.team_class[ii].full_name));
|
|
|
46 |
tb->setItem(ii,1, new QmDialogStatusTableItem(data.teamclass[ii+1].total));
|
| 228 |
- |
47 |
tb->setItem(ii,2, new QmDialogStatusTableItem(data.teamclass[ii+1].valid));
|
|
|
48 |
tb->setItem(ii,3, new QmDialogStatusTableItem(data.teamclass[ii+1].disqualified,0));
|
|
|
49 |
tb->setItem(ii,4, new QmDialogStatusTableItem(data.teamclass[ii+1].non_equestrian,0));
|
|
|
50 |
tb->setItem(ii,5, new QmDialogStatusTableItem(data.teamclass[ii+1].vet_check,0));
|
| 163 |
david |
51 |
}
|
|
|
52 |
|
| 164 |
david |
53 |
tb->setItem(ii,0, new QmDialogStatusTableItem("Totals", 1));
|
|
|
54 |
tb->setItem(ii,1, new QmDialogStatusTableItem(data.total.total, 1));
|
| 228 |
- |
55 |
tb->setItem(ii,2, new QmDialogStatusTableItem(data.total.valid, 1));
|
|
|
56 |
tb->setItem(ii,3, new QmDialogStatusTableItem(data.total.disqualified, 1));
|
|
|
57 |
tb->setItem(ii,4, new QmDialogStatusTableItem(data.total.non_equestrian, 1));
|
|
|
58 |
tb->setItem(ii,5, new QmDialogStatusTableItem(data.total.vet_check, 1));
|
| 163 |
david |
59 |
|
| 164 |
david |
60 |
tb->sortItems ( 0, Qt::AscendingOrder );
|
|
|
61 |
tb->setSortingEnabled(true);
|
| 163 |
david |
62 |
tb->resizeColumnsToContents();
|
|
|
63 |
tb->resizeRowsToContents();
|
| 165 |
david |
64 |
|
| 167 |
david |
65 |
// Kludge. It not corrcet, but it does size the screen
|
| 166 |
david |
66 |
resize(tb->viewport()->size());
|
| 163 |
david |
67 |
}
|
|
|
68 |
}
|
| 164 |
david |
69 |
|
|
|
70 |
QmDialogStatusTableItem::QmDialogStatusTableItem ( const QString & text, int type ) : QTableWidgetItem(text, type+QTableWidgetItem::UserType)
|
|
|
71 |
{
|
|
|
72 |
}
|
|
|
73 |
QmDialogStatusTableItem::QmDialogStatusTableItem ( int value, int type ) : QTableWidgetItem(type+QTableWidgetItem::UserType)
|
|
|
74 |
{
|
|
|
75 |
setData(0,value);
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
// Returns true if the item is less than the other item; otherwise returns false.
|
|
|
79 |
// Ensure that marked rowas are sorted as 'always' highest
|
|
|
80 |
bool QmDialogStatusTableItem::operator< ( const QTableWidgetItem & other ) const
|
|
|
81 |
{
|
|
|
82 |
if (type() != QTableWidgetItem::UserType )
|
|
|
83 |
{
|
|
|
84 |
return (false);
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
const QmDialogStatusTableItem * other_widget = dynamic_cast<const QmDialogStatusTableItem*>(&other);
|
|
|
88 |
if (other_widget && other_widget->type() != QTableWidgetItem::UserType )
|
|
|
89 |
{
|
|
|
90 |
return true;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
return ( QTableWidgetItem::operator< (other) );
|
|
|
94 |
}
|