Subversion Repositories svn1

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
95 david 1
#include "qmconfclass.h"
174 - 2
#include "qmconfig.h"
95 david 3
#include "ui_qmconfclass.h"
99 david 4
#include    "consts.h"
5
#include    "structs.h"
6
#include    "proto.h"
180 - 7
#include "mainwindow.h"
310 david 8
#include "qmTableWidgetItem.h"
95 david 9
 
286 david 10
#include <QDialogButtonBox>
99 david 11
#include "QTableWidgetItem"
107 david 12
#include "spinboxdelegate.h"
13
#include "timedelegate.h"
111 david 14
#include "textdelegate.h"
180 - 15
#include <QMenu>
99 david 16
 
227 - 17
#define COL_ABR 0
18
#define COL_CLASS 1
19
#define COL_TIME 2
20
#define COL_WINNERS 3
21
#define COL_NE 4
22
#define COL_NE_WINNERS 5
23
#define COL_ST_TOTAL 6
228 - 24
#define COL_ST_VALID 7
25
#define COL_ST_DISQ 8
26
#define COL_ST_NONEQ 9
27
#define COL_ST_VET 10
284 david 28
#define COL_ST_CEV 11
29
#define COL_ST_CNE 12
311 david 30
#define COL_INDEX 13
227 - 31
 
311 david 32
#define COL_COUNT 14
227 - 33
 
311 david 34
 
104 - 35
QmConfClass::QmConfClass(QWidget *parent) :
286 david 36
    QWidget(parent)
95 david 37
{
181 - 38
    populating = false;
312 david 39
    dirty = false;
99 david 40
 
286 david 41
    QVBoxLayout *verticalLayout = new QVBoxLayout(this);
42
    verticalLayout->setContentsMargins(0, 0, 0, 0);
43
 
44
    QGroupBox *groupBox = new QGroupBox("Class");
45
    verticalLayout->addWidget(groupBox);
46
    QVBoxLayout *verticalLayout2 = new QVBoxLayout(groupBox);
47
    tableWidget = new QTableWidget(groupBox);
48
    tableWidget->setAlternatingRowColors(true);
49
    tableWidget->setRowCount(config.num_class + 1);
50
    tableWidget->setColumnCount(COL_COUNT);
51
    tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
52
    tableWidget->horizontalHeader()->setVisible(true);
53
    tableWidget->horizontalHeader()->setDefaultSectionSize(70);
54
    tableWidget->horizontalHeader()->setHighlightSections(true);
290 david 55
    //tableWidget->horizontalHeader()->setStretchLastSection(true);
286 david 56
    tableWidget->verticalHeader()->setVisible(true);
57
    tableWidget->verticalHeader()->setDefaultSectionSize(20);
58
    //tableWidget->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding );
59
    //tableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
60
    verticalLayout2->addWidget(tableWidget);
61
 
62
    //QSpacerItem *verticalSpacer1;
63
    //verticalSpacer1 = new QSpacerItem(0, 10, QSizePolicy::Expanding, QSizePolicy::Expanding);
64
    //verticalLayout2->addItem(verticalSpacer1);
65
 
66
    QHBoxLayout *horizontalLayout;
67
    horizontalLayout = new QHBoxLayout();
68
    horizontalLayout->setContentsMargins(0, 0, 5, 5);
69
    verticalLayout->addLayout(horizontalLayout);
70
 
71
    QDialogButtonBox *buttonBox = new QDialogButtonBox();
72
    pushButtonRestore = buttonBox->addButton("Restore",QDialogButtonBox::ActionRole );
73
    pushButtonSave = buttonBox->addButton("Save",QDialogButtonBox::ActionRole );
74
    horizontalLayout->addWidget(buttonBox);
75
 
76
 
77
    connect(pushButtonSave, SIGNAL(clicked(bool)), this, SLOT(save()) );
78
    connect(pushButtonRestore, SIGNAL(clicked(bool)), this, SLOT(cancel()) );
79
 
109 david 80
    QStringList labels;
228 - 81
    labels << "Abr" << "Full Name" << "Start Time" << "Winners" << "NE" << "NE Winners";
109 david 82
 
311 david 83
    labels << "Total" << "Valid" <<"Disqual" << "NonEq" << "VetCheck" << "Comp Ev" << " Comp NE";
107 david 84
 
311 david 85
    labels << "Index";
86
 
87
    tableWidget->setHorizontalHeaderLabels(labels);
88
 
286 david 89
    connect(tableWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ctxMenu(const QPoint &)));
90
    connect(tableWidget, SIGNAL(cellChanged(int,int)), this, SLOT(cellChanged(int,int)));
180 - 91
 
107 david 92
    /*
93
    **  Setup delegated for specialised editing
94
    */
286 david 95
    tableWidget->setItemDelegateForColumn(COL_ABR, new textDelegate(2));
96
    tableWidget->setItemDelegateForColumn(COL_CLASS, new textDelegate(LEN_CLASS_NAME));
97
    tableWidget->setItemDelegateForColumn(COL_TIME, new timeDelegate());
98
    tableWidget->setItemDelegateForColumn(COL_WINNERS, new SpinBoxDelegate(0,50));
99
    tableWidget->setItemDelegateForColumn(COL_NE_WINNERS, new SpinBoxDelegate(0,50));
312 david 100
}
107 david 101
 
312 david 102
/*----------------------------------------------------------------------------
103
** FUNCTION           : showEvent 
104
**
105
** DESCRIPTION        : Called when the page is shown
106
**                      Used to refresh the contents of the display as well
107
**                      as show them for the first time
108
**
109
----------------------------------------------------------------------------*/
110
 
111
void QmConfClass::showEvent ( QShowEvent * event )
112
{
113
    //qDebug("populate::showEvent");
114
    if ( ! event->spontaneous() && !dirty )
115
    {
116
        populate();
117
    }
311 david 118
}
180 - 119
 
311 david 120
/*----------------------------------------------------------------------------
121
** FUNCTION           : populate
122
**
123
** DESCRIPTION        : Populate the display with information
124
**
125
----------------------------------------------------------------------------*/
180 - 126
 
104 - 127
void QmConfClass::populate(void)
99 david 128
{
311 david 129
    bool    reportDataLoaded = false;
130
    t_class_summary data;
131
 
181 - 132
    populating = true;
310 david 133
    tableWidget->clearContents();
313 david 134
    tableWidget->setRowCount(0);
310 david 135
    tableWidget->setSortingEnabled(false);
311 david 136
 
137
    /*
138
    ** Load Report Data if we can
139
    */
140
    if( load_report_data() )
99 david 141
    {
311 david 142
        calc_class_summary( & data );
143
        reportDataLoaded = true;
144
    }
105 - 145
 
311 david 146
    /*
147
    **  Add all the information
148
    */
149
    int ii = 0;
150
    int entryIndex = 0;
151
    for ( ii = 0; ii < MAX_CLASS; ii++)
152
    {
153
        if ( config.team_class[ii].abr[0] )
111 david 154
        {
311 david 155
            // Keep the config item index entry
156
            //  Will need it when we write stiff out
313 david 157
            tableWidget->setRowCount(tableWidget->rowCount() + 1);
158
 
311 david 159
            tableWidget->setItem(entryIndex, COL_INDEX, new qmTwiNumber(ii));
160
 
313 david 161
            tableWidget->setItem(entryIndex, COL_ABR,        new qmTwiString(config.team_class[ii].abr) );
162
            tableWidget->setItem(entryIndex, COL_CLASS,      new qmTwiString(config.team_class[ii].full_name ));
311 david 163
 
111 david 164
            QTableWidgetItem *item;
165
            item = new QTableWidgetItem();
166
            item->setData(Qt::EditRole,QTime().addSecs(config.team_class[ii].start) );
311 david 167
            tableWidget->setItem(entryIndex, COL_TIME, item);
107 david 168
 
313 david 169
            tableWidget->setItem(entryIndex, COL_WINNERS,    new qmTwiEditNumber(config.class_winners[ii]));
170
            tableWidget->setItem(entryIndex, COL_NE,         new qmTwiEditFlag("",config.nonequestrian_class == 1 + ii));
171
            tableWidget->setItem(entryIndex, COL_NE_WINNERS, new qmTwiEditNumber(config.class_ne_winners[ii]));
181 - 172
 
311 david 173
            if (reportDataLoaded)
174
            {
175
                tableWidget->setItem(entryIndex,COL_ST_TOTAL, new qmTwiNumber(data.teamclass[ii+1].total) );
176
                tableWidget->setItem(entryIndex,COL_ST_VALID, new qmTwiNumber(data.teamclass[ii+1].valid) );
177
                tableWidget->setItem(entryIndex,COL_ST_DISQ,  new qmTwiNumber(data.teamclass[ii+1].disqualified));
178
                tableWidget->setItem(entryIndex,COL_ST_NONEQ, new qmTwiNumber(data.teamclass[ii+1].non_equestrian));
179
                tableWidget->setItem(entryIndex,COL_ST_VET,   new qmTwiNumber(data.teamclass[ii+1].vet_check));
180
                tableWidget->setItem(entryIndex,COL_ST_CEV,   new qmTwiNumber(data.teamclass[ii+1].valid_ev));
181
                tableWidget->setItem(entryIndex,COL_ST_CNE,   new qmTwiNumber(data.teamclass[ii+1].valid_ne));
182
            }
183
            entryIndex++;
111 david 184
        }
99 david 185
    }
311 david 186
 
187
    //  Insert Totals
188
    //      Flag that items on this this row is not to be sorted - or at least 
189
    //      sorted at the end
190
    //
191
    if (reportDataLoaded)
192
    {
313 david 193
        tableWidget->setRowCount(tableWidget->rowCount() + 1);
311 david 194
        tableWidget->setItem(entryIndex,COL_ABR,      new qmTwiString("Totals", 1));
324 david 195
 
196
        tableWidget->setItem(entryIndex, COL_CLASS,         new qmTwiString(""));
197
        tableWidget->setItem(entryIndex, COL_TIME,          new qmTwiString(""));
198
        tableWidget->setItem(entryIndex, COL_WINNERS,       new qmTwiString(""));
199
        tableWidget->setItem(entryIndex, COL_NE,            new qmTwiString(""));
200
        tableWidget->setItem(entryIndex, COL_NE_WINNERS,    new qmTwiString(""));
201
        tableWidget->setItem(entryIndex, COL_INDEX,         new qmTwiString(""));
202
 
311 david 203
        tableWidget->setItem(entryIndex,COL_ST_TOTAL, new qmTwiNumber(data.total.total, 1));
204
        tableWidget->setItem(entryIndex,COL_ST_VALID, new qmTwiNumber(data.total.valid, 1));
205
        tableWidget->setItem(entryIndex,COL_ST_DISQ,  new qmTwiNumber(data.total.disqualified, 1));
206
        tableWidget->setItem(entryIndex,COL_ST_NONEQ, new qmTwiNumber(data.total.non_equestrian, 1));
207
        tableWidget->setItem(entryIndex,COL_ST_VET,   new qmTwiNumber(data.total.vet_check, 1));
208
        tableWidget->setItem(entryIndex,COL_ST_CEV,   new qmTwiNumber(data.total.valid_ev, 1));
209
        tableWidget->setItem(entryIndex,COL_ST_CNE,   new qmTwiNumber(data.total.valid_ne, 1));
210
    }
211
 
212
    tableWidget->resizeColumnsToContents();
213
    tableWidget->resizeRowsToContents();
313 david 214
    tableWidget->sortByColumn ( COL_INDEX, Qt::AscendingOrder );
311 david 215
    tableWidget->setSortingEnabled(true);
216
 
181 - 217
    updateChanged(false);
218
    populating = false;
99 david 219
}
220
 
104 - 221
void QmConfClass::save(void)
99 david 222
{
104 - 223
    /*
224
    **    Copy original data
225
    */
176 - 226
    QmConfig newcfg(config);
104 - 227
 
228
    /*
229
    **  Extract the data from the Widgets
312 david 230
    **  Trap: The Class info is cross ref by index into the table
231
    **        Thus we need to maintain the order in the config.
104 - 232
    */
311 david 233
    for (int entryIndex = 0; entryIndex < tableWidget->rowCount(); entryIndex++)
104 - 234
    {
310 david 235
 
236
        // Check that this is a real Entry or the 'Totals' header
324 david 237
        //      Real rows have a COL_INDEX entry that is not empty
310 david 238
        //
311 david 239
        QTableWidgetItem *item = tableWidget->item ( entryIndex, COL_INDEX );
240
        if (! item)
310 david 241
        {
314 david 242
            //qDebug("Ignore row:%d", entryIndex);
310 david 243
            continue;
244
        }
324 david 245
        if ( item->text().length() == 0)
246
        {
247
            //qDebug("Ignore empty row:%d", entryIndex);
248
            continue;
249
        }
311 david 250
        int ii = item->text().toInt();
314 david 251
        //qDebug("Processing: %d", ii);
310 david 252
 
312 david 253
        /*
313 david 254
        ** This is a new entry - allocate a new index 
255
        **  Scan the entire available space looking for the first empty slot
312 david 256
        */
257
        if (ii < 0)
311 david 258
        {
313 david 259
            for (ii = 0; ii < MAX_CLASS ; ii++)
260
            {
261
                if (newcfg.team_class[ii].abr[0] == 0)
262
                {
263
                    break;
264
                }
265
            }
312 david 266
        }
267
 
268
        if (ii >= MAX_CLASS )
269
        {
270
            qDebug("Ignore row:%d. Class out of range", entryIndex);
311 david 271
            continue;
272
        }
273
 
274
        item = tableWidget->item ( entryIndex, COL_ABR );
111 david 275
        if ( item )
276
        {
277
            strncpy(newcfg.team_class[ii].abr, qPrintable(item->text()), sizeof(newcfg.team_class[ii].abr)-1);
278
        }
279
        else
280
        {
281
            *newcfg.team_class[ii].abr = 0;
282
        }
104 - 283
 
310 david 284
        item = tableWidget->item ( entryIndex, COL_CLASS );
111 david 285
        if ( item )
286
        {
287
            strncpy(newcfg.team_class[ii].full_name, qPrintable(item->text()), sizeof(newcfg.team_class[ii].full_name)-1);
288
        }
289
        else
290
        {
291
            *newcfg.team_class[ii].full_name = 0;
292
        }
108 david 293
 
310 david 294
        item = tableWidget->item( entryIndex, COL_TIME );
111 david 295
        if ( item )
296
        {
195 david 297
            QVariant data = item->data(Qt::EditRole);
298
            if (data.isValid())
299
            {
300
                newcfg.team_class[ii].start = QTime(0,0,0).secsTo(item->data(Qt::EditRole).toTime());
301
            }
302
            else
303
            {
304
                newcfg.team_class[ii].start = -1;
305
            }
111 david 306
        }
307
        else
308
        {
195 david 309
            newcfg.team_class[ii].start = -1;
111 david 310
        }
311
 
310 david 312
        item = tableWidget->item( entryIndex, COL_WINNERS );
111 david 313
        if ( item )
314
        {
315
            newcfg.class_winners[ii] = item->data(Qt::EditRole).toInt();
316
        }
317
        else
318
        {
319
            newcfg.class_winners[ii] = 0;
320
        }
227 - 321
 
310 david 322
        item = tableWidget->item( entryIndex, COL_NE );
181 - 323
        if ( item )
324
        {
325
            if ( item->checkState() == Qt::Checked)
326
            {
327
                newcfg.nonequestrian_class = ii;
328
                strncpy(newcfg.nonequestrian_class_abr, newcfg.team_class[ii].abr, sizeof(newcfg.team_class[ii].abr)-1);
329
            }
330
        }
227 - 331
 
310 david 332
        item = tableWidget->item( entryIndex, COL_NE_WINNERS );
227 - 333
        if ( item )
334
        {
335
            newcfg.class_ne_winners[ii] = item->data(Qt::EditRole).toInt();
336
        }
337
        else
338
        {
339
            newcfg.class_ne_winners[ii] = 0;
340
        }
104 - 341
    }
342
 
181 - 343
    // Validate the data
344
    try
104 - 345
    {
181 - 346
        MainWindow::showMessage( "Saving Config");
104 - 347
 
181 - 348
        /*
349
         **  Now do the Class definitions
350
         */
351
 
352
        for( int i = 0; i < MAX_CLASS; i++ )
104 - 353
        {
181 - 354
            compact( newcfg.team_class[i].abr );
355
            compact( newcfg.team_class[i].full_name );
104 - 356
        }
181 - 357
 
358
        for( int i = 0; i < MAX_CLASS; i++ )
104 - 359
        {
181 - 360
            if( ( newcfg.team_class[i].abr[0] == '\0' ) != ( newcfg.team_class[i].full_name[0] == '\0' ) )
361
            {
362
                throw( "Configuration error. Class without description" );
363
 
364
            }
365
            if( newcfg.team_class[i].abr[0] != '\0' && newcfg.team_class[i].start < 0L )
366
            {
367
                throw( "Configuration error. Bad start time on class" );
368
 
369
            }
104 - 370
        }
371
 
313 david 372
        //  Calculate new max number of classes
373
        //      Scan from the end looking for the last one used
374
        //
375
        for (int i = MAX_CLASS-1; i >= 0; i--)
376
        {
377
            if (newcfg.team_class[i].abr[0])
378
            {
314 david 379
                //qDebug("num_class:%d -> %d", newcfg.num_class, 1+i);
313 david 380
                newcfg.num_class = 1 + i;
381
                break;
382
            }
383
        }
104 - 384
 
181 - 385
        for( int i = newcfg.num_class; i < MAX_CLASS; i++ )
386
            if( newcfg.team_class[i].full_name[0] )
387
            {
313 david 388
                qDebug( "Configuration error: Missing Class name. Gaps not allowed" );
181 - 389
            }
390
 
391
        if( newcfg.num_class == 0 )
104 - 392
        {
181 - 393
            throw( "Error: No categories defined" );
394
 
104 - 395
        }
396
 
312 david 397
        /*
398
        ** Test for duplicate abbreviations 
399
        ** I know its a slow agorithm, but its only a small set 
400
        */
401
        for( int i = 0; i < MAX_CLASS; i++ )
402
        {
403
            if (newcfg.team_class[i].abr[0] != '\0')
404
            {
405
                for (int j = i+1; j < MAX_CLASS; j++)
406
                {
407
                    if (newcfg.team_class[j].abr[0] != '\0')
408
                    {
409
                        if (    newcfg.team_class[i].abr[0] == newcfg.team_class[j].abr[0]
410
                             && newcfg.team_class[i].abr[1] == newcfg.team_class[j].abr[1]
411
                            )
412
                        {
413
                            qDebug("Duplicate abr: %s", newcfg.team_class[i].abr);
414
                            throw( "Error: Duplicate abbreviations detected");
415
                        }
416
                    }
417
                }
418
            }
419
        }
420
 
421
        /*
422
        ** Sanity Test
423
        */
181 - 424
        newcfg.nonequestrian_class = newcfg.lookup_class( newcfg.nonequestrian_class_abr );
425
        if( newcfg.equestrian_leg && newcfg.nonequestrian_class == 0 )
426
            MainWindow::showMessage( "WARNING: Non-equestrian class not found" );
314 david 427
        //qDebug("NE Index is: %d", newcfg.nonequestrian_class );
181 - 428
        /*
429
        **  Sanity test of the data
430
        */
431
        for( int i = 0; i < MAX_CLASS; i++ )
432
        {
433
            if( newcfg.team_class[i].abr[0] != '\0' && newcfg.class_winners[i] == 0 )
434
            {
312 david 435
                if (newcfg.nonequestrian_class != i+1)
436
                {
437
                    MainWindow::showMessage(QString("Warning: Class without winners:")+ newcfg.team_class[i].abr); 
438
                }
181 - 439
            }
111 david 440
        }
441
 
227 - 442
        /*
443
        ** Cannot mix winners for NE class and NE Winners for each class
444
        */
445
        if (newcfg.nonequestrian_class)
446
        {
447
            newcfg.class_ne_winners_by_class = false;
448
            for( int i = 0; i < MAX_CLASS; i++ )
449
            {
228 - 450
                if ( newcfg.class_ne_winners[i])
451
                {
452
                    newcfg.class_ne_winners_by_class = true;
453
                    break;
454
                }
227 - 455
            }
456
            if (newcfg.class_winners[newcfg.nonequestrian_class - 1] && newcfg.class_ne_winners_by_class )
457
            {
458
                MainWindow::showMessage( QString("Should not mix NE winners by each class and by NE Class"));
459
                //throw( "Error: Cannot mix NE winners by each class and by NE Class" );
460
            }
461
        }
462
 
463
 
104 - 464
        config = newcfg;
176 - 465
        config.write_config();
181 - 466
        updateChanged(false);
467
 
312 david 468
        // Force re-populate so that the index field is now correct
469
        populate();
470
 
471
 
104 - 472
    }
313 david 473
    catch (const char * str )
181 - 474
    {
475
        MainWindow::showMessage(str);
476
    }
104 - 477
 
99 david 478
}
479
 
104 - 480
void QmConfClass::cancel(void)
99 david 481
{
482
    populate();
483
}
484
 
104 - 485
QmConfClass::~QmConfClass()
95 david 486
{
286 david 487
 
95 david 488
}
489
 
180 - 490
void QmConfClass::ctxMenu(const QPoint & pos)
491
{
314 david 492
    //qDebug("Context Menu");
180 - 493
    QMenu *menu = new QMenu;
312 david 494
    menu->addAction(tr("New Category"), this, SLOT(ctxMenuAddRow()));
495
 
496
    /*
313 david 497
    **      Determine if we can delete an item
498
    **          Can delete a category we added in this session
499
    **          Can delete one if it has no teams using it.
312 david 500
    */
286 david 501
    QTableWidgetItem *item = tableWidget->itemAt(pos);
180 - 502
    if (item)
503
    {
312 david 504
        int row = item->row();
314 david 505
        //qDebug("Item is at row:%d", row);
312 david 506
        QTableWidgetItem *indexItem = tableWidget->item ( row, COL_INDEX );
507
        if (indexItem)
508
        {
509
            int index = indexItem->text().toInt();
314 david 510
            //qDebug("Item is at row:%d, Index: %d", row, index);
312 david 511
            if (index < 0)
512
            {
313 david 513
                menu->addAction(tr("Delete Newly added Category"), this, SLOT(ctxMenuDeleteRow())); 
312 david 514
            }
313 david 515
            else
516
            {
517
                QTableWidgetItem *itemTotalCount = tableWidget->item ( row, COL_ST_TOTAL );
518
                if (itemTotalCount)
519
                {
520
                    int count = itemTotalCount->text().toInt();
521
                    if (count == 0)
522
                    {
523
                        menu->addAction(tr("Delete Category - its not used"), this, SLOT(ctxMenuDeleteRow()));  
524
                    }
525
                }
526
 
527
            }
312 david 528
        }
180 - 529
    }
313 david 530
    menu->exec(tableWidget->mapToGlobal(pos));
180 - 531
}
532
 
533
void QmConfClass::ctxMenuDeleteRow(void)
534
{
312 david 535
    //
536
    //  Assume that if the menu was shown, then we can delete it
537
    // 
286 david 538
    //qDebug ("DELETE ROW: %d", tableWidget->currentRow () );
313 david 539
    //tableWidget->removeCellWidget(tableWidget->currentRow (), COL_ABR);
540
    //tableWidget->removeRow(tableWidget->currentRow ());
541
    tableWidget->item(tableWidget->currentRow (), COL_ABR)->setText("");
542
    tableWidget->item(tableWidget->currentRow (), COL_CLASS)->setText("");
314 david 543
    tableWidget->hideRow(tableWidget->currentRow ());
189 - 544
    updateChanged(true);
180 - 545
}
546
 
547
void QmConfClass::ctxMenuAddRow(void)
548
{
313 david 549
    tableWidget->setSortingEnabled(false);
286 david 550
    tableWidget->setRowCount( 1+ tableWidget->rowCount());
324 david 551
 
552
    /*
553
    **  Insert non-editable fields in the status part of the table
554
    */
312 david 555
    tableWidget->setItem(tableWidget->rowCount() - 1, COL_INDEX, new qmTwiNumber(-1));
324 david 556
    for (int ii= COL_ST_TOTAL; ii < COL_INDEX; ii++)
557
    {
558
        tableWidget->setItem(tableWidget->rowCount() - 1, ii, new qmTwiString(""));
559
    }
180 - 560
}
561
 
181 - 562
void QmConfClass::cellChanged(int row,int col)
563
{
564
    if ( populating )
565
        return;
312 david 566
    if (col == COL_INDEX)
567
        return;
568
 
569
    updateChanged(true); 
181 - 570
    populating = true;
571
    //qDebug("Cell changed: %d, %d", row, col);
227 - 572
    if (col == COL_NE)
181 - 573
    {
286 david 574
        for (int ii = 0; ii < tableWidget->rowCount(); ii++)
181 - 575
        {
286 david 576
            QTableWidgetItem *item = tableWidget->item(ii, COL_NE);
181 - 577
            if (item)
578
            {
579
                item->setCheckState(ii == row ? Qt::Checked : Qt::Unchecked);
580
            }
581
        }
582
    }
583
    populating = false;
584
}
585
 
586
void QmConfClass::updateChanged(bool newDirty)
587
{
588
    if (newDirty != dirty)
589
    {
590
        dirty = newDirty;
591
        if (dirty)
592
        {
286 david 593
            pushButtonSave->setEnabled(true);
594
            pushButtonSave->setStyleSheet("background-color: rgb(255, 0, 0);");
181 - 595
        }
596
        else
597
        {
286 david 598
            pushButtonSave->setEnabled(false);
599
            pushButtonSave->setStyleSheet("");
181 - 600
        }
601
    }
602
}
603
 
104 - 604
void QmConfClass::changeEvent(QEvent *e)
95 david 605
{
606
    QWidget::changeEvent(e);
607
    switch (e->type()) {
286 david 608
 
95 david 609
    default:
610
        break;
611
    }
612
}