Subversion Repositories svn1-original

Rev

Rev 193 | Rev 195 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 193 Rev 194
Line 1... Line 1...
1
#include "qmdisqualified.h"
1
#include "qmdisqualified.h"
2
#include "ui_qmdisqualified.h"
-
 
3
 
-
 
4
#include    "consts.h"
2
#include    "consts.h"
5
#include    "structs.h"
3
#include    "structs.h"
6
#include    "proto.h"
4
#include    "proto.h"
-
 
5
#include <QHeaderView>
7
 
6
 
8
qmDisqualified::qmDisqualified(QWidget *parent) :
7
qmDisqualified::qmDisqualified(QWidget *parent) :
9
    QWidget(parent),
8
    QWidget(parent)
10
    ui(new Ui::qmDisqualified)
-
 
-
 
9
 
11
{
10
{
12
    inPopulate = FALSE;
11
    inPopulate = FALSE;
13
    ui->setupUi(this);
12
    resize ( 600,400);
-
 
13
 
-
 
14
    QVBoxLayout *verticalLayout = new QVBoxLayout(this);
-
 
15
    verticalLayout->setContentsMargins(0, 0, 0, 0);
14
 
16
 
-
 
17
    QGroupBox *groupBox = new QGroupBox("Disqualified and Non Equestrian");
-
 
18
    verticalLayout->addWidget(groupBox);
-
 
19
 
-
 
20
    QVBoxLayout *verticalLayout2 = new QVBoxLayout(groupBox);
-
 
21
 
-
 
22
    tableWidget = new QTableWidget(groupBox);
-
 
23
    tableWidget->setObjectName(QString::fromUtf8("tableWidget"));
-
 
24
    //tableWidget->setGeometry(QRect(10, 20, 501, 421));
-
 
25
    tableWidget->setAlternatingRowColors(true);
-
 
26
    tableWidget->horizontalHeader()->setProperty("showSortIndicator", QVariant(true));
-
 
27
    tableWidget->verticalHeader()->setDefaultSectionSize(20);
-
 
28
    tableWidget->verticalHeader()->setProperty("showSortIndicator", QVariant(false));
-
 
29
    verticalLayout2->addWidget(tableWidget);
-
 
30
 
-
 
31
    buttonBox = new QDialogButtonBox();
-
 
32
    buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
-
 
33
    buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
-
 
34
    buttonBox->addButton("Load",QDialogButtonBox::ActionRole );
-
 
35
    verticalLayout->addWidget(buttonBox);
-
 
36
 
15
    connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(save()) );
37
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(save()) );
16
    connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(cancel()) );
38
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancel()) );
17
    connect(ui->loadButton, SIGNAL(released()), this, SLOT(populate()) );
39
    //connect(buttonBox, SIGNAL(????), this, SLOT(populate()) );
18
    connect(ui->tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(tableItemChanged(QTableWidgetItem *)));
40
    connect(tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(tableItemChanged(QTableWidgetItem *)));
19
}
41
}
20
 
42
 
21
qmDisqualified::~qmDisqualified()
43
qmDisqualified::~qmDisqualified()
22
{
44
{
23
    delete ui;
45
 
24
}
46
}
25
 
47
 
26
void qmDisqualified::save(void)
48
void qmDisqualified::save(void)
27
{
49
{
28
    team_type team_buf;
50
    team_type team_buf;
29
    for ( int ii = 0; ii < ui->tableWidget->rowCount(); ii++)
51
    for ( int ii = 0; ii < tableWidget->rowCount(); ii++)
30
    {
52
    {
31
        QTableWidgetItem *item;
53
        QTableWidgetItem *item;
32
        item = ui->tableWidget->item(ii, 0);
54
        item = tableWidget->item(ii, 0);
33
        if ( item )
55
        if ( item )
34
        {
56
        {
35
            if ( item->data(Qt::UserRole + 1).toBool() )
57
            if ( item->data(Qt::UserRole + 1).toBool() )
36
            {
58
            {
37
                int team = item->data(Qt::EditRole).toInt();
59
                int team = item->data(Qt::EditRole).toInt();
38
                if ( team )
60
                if ( team )
39
                {
61
                {
40
                    qDebug("Detected change:%d", team);
62
                    qDebug("Detected change:%d", team);
41
                    g_record( team, &team_buf );
63
                    g_record( team, &team_buf );
42
 
64
 
43
                    item = ui->tableWidget->item(ii,2);
65
                    item = tableWidget->item(ii,2);
44
                    team_buf.flags.disqualified =  ( item->checkState () == Qt::Checked);
66
                    team_buf.flags.disqualified =  ( item->checkState () == Qt::Checked);
45
 
67
 
46
                    item = ui->tableWidget->item(ii,3);
68
                    item = tableWidget->item(ii,3);
47
                    team_buf.flags.non_equestrian =  ( item->checkState () == Qt::Checked);
69
                    team_buf.flags.non_equestrian =  ( item->checkState () == Qt::Checked);
48
//TODO: If nonEquestrian, then also disqualified ??  Original is.
70
//TODO: If nonEquestrian, then also disqualified ??  Original is.
49
 
71
 
50
                    item = ui->tableWidget->item(ii,4);
72
                    item = tableWidget->item(ii,4);
51
                    team_buf.flags.valid =  ( item->checkState () == Qt::Checked);
73
                    team_buf.flags.valid =  ( item->checkState () == Qt::Checked);
52
 
74
 
53
                    put_team_record( team, &team_buf );
75
                    put_team_record( team, &team_buf );
54
                }
76
                }
55
            }
77
            }
Line 70... Line 92...
70
    inPopulate = TRUE;
92
    inPopulate = TRUE;
71
 
93
 
72
    /*
94
    /*
73
    ** Delete existing entries in the table
95
    ** Delete existing entries in the table
74
    */
96
    */
75
    ui->tableWidget->clearContents();
97
    tableWidget->clearContents();
76
    ui->tableWidget->setRowCount(config.max_team);
98
    tableWidget->setRowCount(config.max_team);
77
    ui->tableWidget->setColumnCount(6);
99
    tableWidget->setColumnCount(6);
78
    ui->tableWidget->setSortingEnabled(FALSE);
100
    tableWidget->setSortingEnabled(FALSE);
79
 
101
 
80
    /*
102
    /*
81
    ** Scan all the team data
103
    ** Scan all the team data
82
    */
104
    */
83
    for ( int team = config.min_team; team <= config.max_team; team++)
105
    for ( int team = config.min_team; team <= config.max_team; team++)
84
    {
106
    {
85
        ui->tableWidget->hideRow ( team );
107
        tableWidget->hideRow ( team );
86
        if( valid_field( team ) )
108
        if( valid_field( team ) )
87
        {
109
        {
88
            g_record( team, &team_buf );
110
            g_record( team, &team_buf );
89
            if( team_buf.flags.valid || true )
111
            if( team_buf.flags.valid || true )
90
            {
112
            {
91
                qmDisqualifiedItem *item;
113
                qmDisqualifiedItem *item;
92
 
114
 
93
                ui->tableWidget->showRow( team );
115
                tableWidget->showRow( team );
94
 
116
 
95
                item = new qmDisqualifiedItem(team);
117
                item = new qmDisqualifiedItem(team);
96
                item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
118
                item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
97
                ui->tableWidget->setItem(team, 0, item );
119
                tableWidget->setItem(team, 0, item );
98
 
120
 
99
                item = new qmDisqualifiedItem(team_buf.name);
121
                item = new qmDisqualifiedItem(team_buf.name);
100
                item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
122
                item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
101
                ui->tableWidget->setItem(team, 1, item );
123
                tableWidget->setItem(team, 1, item );
102
 
124
 
103
                ui->tableWidget->setItem(team, 2, new qmDisqualifiedItem("Disq", team_buf.flags.disqualified, team) );
125
                tableWidget->setItem(team, 2, new qmDisqualifiedItem("Disq", team_buf.flags.disqualified, team) );
104
                ui->tableWidget->setItem(team, 3, new qmDisqualifiedItem("Non Equest",team_buf.flags.non_equestrian,team) );
126
                tableWidget->setItem(team, 3, new qmDisqualifiedItem("Non Equest",team_buf.flags.non_equestrian,team) );
105
                ui->tableWidget->setItem(team, 4, new qmDisqualifiedItem("Enable", team_buf.flags.valid,team) );
127
                tableWidget->setItem(team, 4, new qmDisqualifiedItem("Enable", team_buf.flags.valid,team) );
106
 
128
 
107
                item = new qmDisqualifiedItem("Bad Times", team_buf.flags.bad_times);
129
                item = new qmDisqualifiedItem("Bad Times", team_buf.flags.bad_times);
108
                item->setFlags(Qt::ItemIsSelectable/* | Qt::ItemIsEnabled*/);
130
                item->setFlags(Qt::ItemIsSelectable/* | Qt::ItemIsEnabled*/);
109
                ui->tableWidget->setItem(team, 5, item  );
131
                tableWidget->setItem(team, 5, item  );
110
            }
132
            }
111
        }
133
        }
112
    }
134
    }
113
    ui->tableWidget->sortByColumn(0,Qt::AscendingOrder);
135
    tableWidget->sortByColumn(0,Qt::AscendingOrder);
114
    ui->tableWidget->setSortingEnabled(TRUE);
136
    tableWidget->setSortingEnabled(TRUE);
115
    ui->tableWidget->resizeColumnsToContents();
137
    tableWidget->resizeColumnsToContents();
116
 
138
 
117
    inPopulate = FALSE;
139
    inPopulate = FALSE;
118
}
140
}
119
 
141
 
120
void qmDisqualified::tableItemChanged(QTableWidgetItem *item)
142
void qmDisqualified::tableItemChanged(QTableWidgetItem *item)