Rev 170 | Rev 229 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "qmdialogstatus.h"#include <QGroupBox>#include <QTableWidget>#include <QVBoxLayout>#include <QStringList>#include <QHeaderView>#include "consts.h"#include "structs.h"#include "proto.h"QmDialogStatus::QmDialogStatus(QWidget *parent) : QDialog(parent){QVBoxLayout *layout = new QVBoxLayout;setLayout(layout);setSizeGripEnabled(true);QGroupBox *gb = new QGroupBox("Summary Display", this);layout->addWidget(gb);QVBoxLayout *layout2 = new QVBoxLayout;gb->setLayout(layout2);// Table HeaderQTableWidget *tb = new QTableWidget(config.num_class + 1,4);//tb->horizontalHeader()->setStretchLastSection(true);tb->horizontalHeader()->setSortIndicatorShown(true);QStringList labels;labels << "Category" << "Total" << "Disq" << "NonEq";tb->setHorizontalHeaderLabels(labels);tb->verticalHeader()->setDefaultSectionSize(17);tb->setSortingEnabled(false);tb->setAlternatingRowColors(true);layout2->addWidget(tb);if( load_report_data() ){t_class_summary data;calc_class_summary( & data );// Insert summary dataint ii;for (ii = 0; ii < config.num_class; ii++){tb->setItem(ii,0, new QmDialogStatusTableItem(config.team_class[ii].full_name));tb->setItem(ii,1, new QmDialogStatusTableItem(data.teamclass[ii+1].total));tb->setItem(ii,2, new QmDialogStatusTableItem(data.teamclass[ii+1].disqualified,0));tb->setItem(ii,3, new QmDialogStatusTableItem(data.teamclass[ii+1].non_equestrian,0));}tb->setItem(ii,0, new QmDialogStatusTableItem("Totals", 1));tb->setItem(ii,1, new QmDialogStatusTableItem(data.total.total, 1));tb->setItem(ii,2, new QmDialogStatusTableItem(data.total.disqualified, 1));tb->setItem(ii,3, new QmDialogStatusTableItem(data.total.non_equestrian, 1));tb->sortItems ( 0, Qt::AscendingOrder );tb->setSortingEnabled(true);tb->resizeColumnsToContents();tb->resizeRowsToContents();// Kludge. It not corrcet, but it does size the screenresize(tb->viewport()->size());}}QmDialogStatusTableItem::QmDialogStatusTableItem ( const QString & text, int type ) : QTableWidgetItem(text, type+QTableWidgetItem::UserType){}QmDialogStatusTableItem::QmDialogStatusTableItem ( int value, int type ) : QTableWidgetItem(type+QTableWidgetItem::UserType){setData(0,value);}// Returns true if the item is less than the other item; otherwise returns false.// Ensure that marked rowas are sorted as 'always' highestbool QmDialogStatusTableItem::operator< ( const QTableWidgetItem & other ) const{if (type() != QTableWidgetItem::UserType ){return (false);}const QmDialogStatusTableItem * other_widget = dynamic_cast<const QmDialogStatusTableItem*>(&other);if (other_widget && other_widget->type() != QTableWidgetItem::UserType ){return true;}return ( QTableWidgetItem::operator< (other) );}