Subversion Repositories svn1

Rev

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

Rev 241 Rev 255
Line 30... Line 30...
30
** RETURNS            :
30
** RETURNS            :
31
**
31
**
32
----------------------------------------------------------------------------*/
32
----------------------------------------------------------------------------*/
33
 
33
 
34
 
34
 
35
qmTeamDisplay::qmTeamDisplay(QWidget *parent) :
35
qmTeamDisplay::qmTeamDisplay(QWidget *parent, int initialTeam, bool useDone) :
36
    QWidget(parent),
36
    QWidget(parent),
37
    ui(new Ui::QmTeamDisplay)
37
    ui(new Ui::QmTeamDisplay)
38
{
38
{
39
    ui->setupUi(this);
39
    ui->setupUi(this);
40
    team = 0;
40
    team = 0;
41
    dirty = true;
41
    dirty = true;
42
    populating = true;
42
    populating = false;
-
 
43
    enableDone = useDone;
43
 
44
 
44
    /*
45
    /*
45
    ** Populate the Combo Box
46
    ** Populate the Combo Box
46
    ** Should do more often
47
    ** Should do more often
47
    */
48
    */
Line 87... Line 88...
87
    connect(ui->nonEquestrian , SIGNAL(clicked(bool)), this, SLOT(recalculateTimes()));
88
    connect(ui->nonEquestrian , SIGNAL(clicked(bool)), this, SLOT(recalculateTimes()));
88
    connect(ui->disabled , SIGNAL(clicked(bool)), this, SLOT(changed()));
89
    connect(ui->disabled , SIGNAL(clicked(bool)), this, SLOT(changed()));
89
    connect(ui->VetCheck , SIGNAL(clicked(bool)), this, SLOT(changed()));
90
    connect(ui->VetCheck , SIGNAL(clicked(bool)), this, SLOT(changed()));
90
 
91
 
91
    updateChanged(false);
92
    updateChanged(false);
92
    populating = false;
-
 
93
    populate(config.min_team);
93
    populate(initialTeam ? initialTeam : config.min_team);
94
}
94
}
95
 
95
 
96
/*----------------------------------------------------------------------------
96
/*----------------------------------------------------------------------------
97
** FUNCTION           : ~qmTeamDisplay
97
** FUNCTION           : ~qmTeamDisplay
98
**
98
**
Line 109... Line 109...
109
{
109
{
110
    delete ui;
110
    delete ui;
111
}
111
}
112
 
112
 
113
/*----------------------------------------------------------------------------
113
/*----------------------------------------------------------------------------
-
 
114
** FUNCTION           : blockSignals
-
 
115
**
-
 
116
** DESCRIPTION        : Block signal from widgets that set Changed
-
 
117
**                      while populating the display
-
 
118
**
-
 
119
**
-
 
120
** INPUTS             : state - New blocking state
-
 
121
**
-
 
122
** RETURNS            : Nothing
-
 
123
**
-
 
124
----------------------------------------------------------------------------*/
-
 
125
 
-
 
126
void qmTeamDisplay::blockSignals(bool state)
-
 
127
{
-
 
128
//    ui->pushButtonSave->blockSignals(state);
-
 
129
//    ui->pushButtonRestore->blockSignals(state);
-
 
130
//    ui->teamNumber->blockSignals(state);
-
 
131
 
-
 
132
    ui->name->blockSignals(state);
-
 
133
    ui->category->blockSignals(state);
-
 
134
    ui->members->blockSignals(state);
-
 
135
    ui->disqualified->blockSignals(state);
-
 
136
    ui->nonEquestrian->blockSignals(state);
-
 
137
    ui->disabled->blockSignals(state);
-
 
138
    ui->VetCheck->blockSignals(state);
-
 
139
 
-
 
140
    for ( int ii = 0 ; ii <= config.num_legs; ii++)
-
 
141
    {
-
 
142
        lt[ii]->blockSignals(state);
-
 
143
    }
-
 
144
}
-
 
145
 
-
 
146
 
-
 
147
 
-
 
148
/*----------------------------------------------------------------------------
114
** FUNCTION           : populate
149
** FUNCTION           : populate
115
**
150
**
116
** DESCRIPTION        : Populate the widget with data
151
** DESCRIPTION        : Populate the widget with data
117
**
152
**
118
**
153
**
Line 126... Line 161...
126
{
161
{
127
    /*
162
    /*
128
    **  Update the spinner that describes the current team number
163
    **  Update the spinner that describes the current team number
129
    */
164
    */
130
    populating = true;
165
    populating = true;
-
 
166
    blockSignals(true);
131
 
167
 
132
    ui->teamNumber->setMaximum(config.max_team);
168
    ui->teamNumber->setMaximum(config.max_team);
133
    ui->teamNumber->setMinimum(config.min_team);
169
    ui->teamNumber->setMinimum(config.min_team);
134
    ui->teamNumber->setValue(team_number);
170
    ui->teamNumber->setValue(team_number);
135
    team = team_number;
171
    team = team_number;
Line 220... Line 256...
220
    for ( int ii = 0 ; ii <= config.num_legs; ii++)
256
    for ( int ii = 0 ; ii <= config.num_legs; ii++)
221
    {
257
    {
222
        lt[ii]->setData(&team_buf.leg[ii]);
258
        lt[ii]->setData(&team_buf.leg[ii]);
223
    }
259
    }
224
 
260
 
225
    populating = false;
-
 
226
    updateChanged(false);
261
    updateChanged(false);
-
 
262
    populating = false;
-
 
263
    blockSignals(false);
-
 
264
    
227
}
265
}
228
 
266
 
229
void qmTeamDisplay::updateCategory(void)
267
void qmTeamDisplay::updateCategory(void)
230
{
268
{
231
     ui->category_abr->setText( config.team_class[ui->category->currentIndex()].abr );
269
     ui->category_abr->setText( config.team_class[ui->category->currentIndex()].abr );
Line 314... Line 352...
314
 
352
 
315
/*----------------------------------------------------------------------------
353
/*----------------------------------------------------------------------------
316
** FUNCTION           : save
354
** FUNCTION           : save
317
**
355
**
318
** DESCRIPTION        : Save the data back to disk
356
** DESCRIPTION        : Save the data back to disk
-
 
357
**                      Also called if nothing to save - ie Done Mode
319
**
358
**
320
** INPUTS             :
359
** INPUTS             :
321
**
360
**
322
** RETURNS            :
361
** RETURNS            :
323
**
362
**
324
----------------------------------------------------------------------------*/
363
----------------------------------------------------------------------------*/
325
 
364
 
326
void qmTeamDisplay::save(void)
365
void qmTeamDisplay::save(void)
327
{
366
{
-
 
367
    if ( dirty )
328
 
368
    {
329
    /*
369
        /*
330
    ** Save the record back to disk
370
        ** Save the record back to disk
331
    */
371
        */
332
    suckData();
372
        suckData();
333
    put_team_record( team, &team_buf );
373
        put_team_record( team, &team_buf );
334
    populate(team);
374
        populate(team);
-
 
375
    }
-
 
376
    else
-
 
377
    {
-
 
378
        if ( enableDone )
-
 
379
            emit dialogDone(1);
-
 
380
    }
335
}
381
}
336
 
382
 
337
/*----------------------------------------------------------------------------
383
/*----------------------------------------------------------------------------
338
** FUNCTION           : cancel
384
** FUNCTION           : cancel
339
**
385
**
Line 352... Line 398...
352
    populate(team);
398
    populate(team);
353
}
399
}
354
 
400
 
355
void qmTeamDisplay::changed(void)
401
void qmTeamDisplay::changed(void)
356
{
402
{
-
 
403
//QObject * who = sender () ;
-
 
404
//qDebug ("Changed: %p", who);
357
    if (populating)
405
    if (populating)
358
        return;
406
        return;
359
    updateChanged(true);
407
    updateChanged(true);
360
//qDebug ("Changed");
-
 
-
 
408
 
361
}
409
}
362
 
410
 
363
void qmTeamDisplay::updateChanged(bool newDirty)
411
void qmTeamDisplay::updateChanged(bool newDirty)
364
{
412
{
365
    //qDebug("updateChanged: %d -> %d", newDirty, dirty);
413
    //qDebug("updateChanged: %d, %d -> %d", populating, dirty, newDirty );
366
    if (newDirty != dirty)
414
    if (newDirty != dirty)
367
    {
415
    {
368
        dirty = newDirty;
416
        dirty = newDirty;
369
        if (dirty)
417
        if (dirty)
370
        {
418
        {
371
            ui->Changed->setVisible(true);
419
            ui->Changed->setVisible(true);
372
            ui->teamNumber->setEnabled(false);
420
            ui->teamNumber->setEnabled(false);
373
            ui->pushButtonSave->setEnabled(true);
421
            ui->pushButtonSave->setEnabled(true);
374
            ui->pushButtonSave->setStyleSheet("background-color: rgb(255, 0, 0);");
422
            ui->pushButtonSave->setStyleSheet("background-color: rgb(255, 0, 0);");
-
 
423
            ui->pushButtonSave->setText("Save");
375
        }
424
        }
376
        else
425
        else
377
        {
426
        {
378
            ui->Changed->setVisible(false);
427
            ui->Changed->setVisible(false);
379
            ui->teamNumber->setEnabled(true);
428
            ui->teamNumber->setEnabled(true);
380
            ui->pushButtonSave->setEnabled(false);
429
            //ui->pushButtonSave->setEnabled(false);
381
            ui->pushButtonSave->setStyleSheet("");
430
            ui->pushButtonSave->setStyleSheet("");
-
 
431
 
-
 
432
            if ( enableDone )
-
 
433
                ui->pushButtonSave->setText("Done");
382
        }
434
        }
383
    }
435
    }
384
}
436
}
385
 
437
 
386
/*----------------------------------------------------------------------------
438
/*----------------------------------------------------------------------------