Subversion Repositories svn1-original

Rev

Rev 335 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
99 david 1
#include "qmconfclass.h"
178 - 2
#include "qmconfig.h"
99 david 3
#include "ui_qmconfclass.h"
103 david 4
#include    "consts.h"
5
#include    "structs.h"
6
#include    "proto.h"
184 - 7
#include "mainwindow.h"
314 david 8
#include "qmTableWidgetItem.h"
99 david 9
 
290 david 10
#include <QDialogButtonBox>
103 david 11
#include "QTableWidgetItem"
111 david 12
#include "spinboxdelegate.h"
13
#include "timedelegate.h"
115 david 14
#include "textdelegate.h"
184 - 15
#include <QMenu>
103 david 16
 
231 - 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
232 - 24
#define COL_ST_VALID 7
25
#define COL_ST_DISQ 8
26
#define COL_ST_NONEQ 9
27
#define COL_ST_VET 10
288 david 28
#define COL_ST_CEV 11
29
#define COL_ST_CNE 12
315 david 30
#define COL_INDEX 13
231 - 31
 
315 david 32
#define COL_COUNT 14
231 - 33
 
315 david 34
 
108 - 35
QmConfClass::QmConfClass(QWidget *parent) :
290 david 36
    QWidget(parent)
99 david 37
{
185 - 38
    populating = false;
316 david 39
    dirty = false;
103 david 40
 
290 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);
294 david 55
    //tableWidget->horizontalHeader()->setStretchLastSection(true);
290 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
 
113 david 80
    QStringList labels;
232 - 81
    labels << "Abr" << "Full Name" << "Start Time" << "Winners" << "NE" << "NE Winners";
113 david 82
 
315 david 83
    labels << "Total" << "Valid" <<"Disqual" << "NonEq" << "VetCheck" << "Comp Ev" << " Comp NE";
111 david 84
 
315 david 85
    labels << "Index";
86
 
87
    tableWidget->setHorizontalHeaderLabels(labels);
88
 
290 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)));
184 - 91
 
111 david 92
    /*
93
    **  Setup delegated for specialised editing
94
    */
290 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));
316 david 100
}
111 david 101
 
316 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
    }
315 david 118
}
184 - 119
 
315 david 120
/*----------------------------------------------------------------------------
121
** FUNCTION           : populate
122
**
123
** DESCRIPTION        : Populate the display with information
124
**
125
----------------------------------------------------------------------------*/
184 - 126
 
108 - 127
void QmConfClass::populate(void)
103 david 128
{
315 david 129
    bool    reportDataLoaded = false;
130
    t_class_summary data;
131
 
185 - 132
    populating = true;
314 david 133
    tableWidget->clearContents();
317 david 134
    tableWidget->setRowCount(0);
314 david 135
    tableWidget->setSortingEnabled(false);
315 david 136
 
137
    /*
138
    ** Load Report Data if we can
139
    */
140
    if( load_report_data() )
103 david 141
    {
315 david 142
        calc_class_summary( & data );
143
        reportDataLoaded = true;
144
    }
109 - 145
 
315 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] )
115 david 154
        {
315 david 155
            // Keep the config item index entry
156
            //  Will need it when we write stiff out
317 david 157
            tableWidget->setRowCount(tableWidget->rowCount() + 1);
158
 
315 david 159
            tableWidget->setItem(entryIndex, COL_INDEX, new qmTwiNumber(ii));
160
 
317 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 ));
315 david 163
 
115 david 164
            QTableWidgetItem *item;
165
            item = new QTableWidgetItem();
166
            item->setData(Qt::EditRole,QTime().addSecs(config.team_class[ii].start) );
315 david 167
            tableWidget->setItem(entryIndex, COL_TIME, item);
111 david 168
 
317 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]));
185 - 172
 
315 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++;
115 david 184
        }
103 david 185
    }
315 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
    {
317 david 193
        tableWidget->setRowCount(tableWidget->rowCount() + 1);
315 david 194
        tableWidget->setItem(entryIndex,COL_ABR,      new qmTwiString("Totals", 1));
328 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
 
315 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();
317 david 214
    tableWidget->sortByColumn ( COL_INDEX, Qt::AscendingOrder );
315 david 215
    tableWidget->setSortingEnabled(true);
216
 
185 - 217
    updateChanged(false);
218
    populating = false;
103 david 219
}
220
 
108 - 221
void QmConfClass::save(void)
103 david 222
{
108 - 223
    /*
224
    **    Copy original data
225
    */
180 - 226
    QmConfig newcfg(config);
108 - 227
 
228
    /*
229
    **  Extract the data from the Widgets
316 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.
108 - 232
    */
315 david 233
    for (int entryIndex = 0; entryIndex < tableWidget->rowCount(); entryIndex++)
108 - 234
    {
314 david 235
 
236
        // Check that this is a real Entry or the 'Totals' header
328 david 237
        //      Real rows have a COL_INDEX entry that is not empty
314 david 238
        //
315 david 239
        QTableWidgetItem *item = tableWidget->item ( entryIndex, COL_INDEX );
240
        if (! item)
314 david 241
        {
318 david 242
            //qDebug("Ignore row:%d", entryIndex);
314 david 243
            continue;
244
        }
328 david 245
        if ( item->text().length() == 0)
246
        {
247
            //qDebug("Ignore empty row:%d", entryIndex);
248
            continue;
249
        }
315 david 250
        int ii = item->text().toInt();
318 david 251
        //qDebug("Processing: %d", ii);
314 david 252
 
316 david 253
        /*
317 david 254
        ** This is a new entry - allocate a new index 
255
        **  Scan the entire available space looking for the first empty slot
316 david 256
        */
257
        if (ii < 0)
315 david 258
        {
317 david 259
            for (ii = 0; ii < MAX_CLASS ; ii++)
260
            {
261
                if (newcfg.team_class[ii].abr[0] == 0)
262
                {
263
                    break;
264
                }
265
            }
316 david 266
        }
267
 
268
        if (ii >= MAX_CLASS )
269
        {
270
            qDebug("Ignore row:%d. Class out of range", entryIndex);
315 david 271
            continue;
272
        }
273
 
274
        item = tableWidget->item ( entryIndex, COL_ABR );
115 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
        }
108 - 283
 
314 david 284
        item = tableWidget->item ( entryIndex, COL_CLASS );
115 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
        }
112 david 293
 
314 david 294
        item = tableWidget->item( entryIndex, COL_TIME );
115 david 295
        if ( item )
296
        {
199 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
            }
115 david 306
        }
307
        else
308
        {
199 david 309
            newcfg.team_class[ii].start = -1;
115 david 310
        }
311
 
314 david 312
        item = tableWidget->item( entryIndex, COL_WINNERS );
115 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
        }
231 - 321
 
314 david 322
        item = tableWidget->item( entryIndex, COL_NE );
185 - 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
        }
231 - 331
 
314 david 332
        item = tableWidget->item( entryIndex, COL_NE_WINNERS );
231 - 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
        }
108 - 341
    }
342
 
185 - 343
    // Validate the data
344
    try
108 - 345
    {
185 - 346
        MainWindow::showMessage( "Saving Config");
108 - 347
 
185 - 348
        /*
349
         **  Now do the Class definitions
350
         */
351
 
352
        for( int i = 0; i < MAX_CLASS; i++ )
108 - 353
        {
185 - 354
            compact( newcfg.team_class[i].abr );
355
            compact( newcfg.team_class[i].full_name );
108 - 356
        }
185 - 357
 
358
        for( int i = 0; i < MAX_CLASS; i++ )
108 - 359
        {
185 - 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
            }
108 - 370
        }
371
 
317 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
            {
318 david 379
                //qDebug("num_class:%d -> %d", newcfg.num_class, 1+i);
317 david 380
                newcfg.num_class = 1 + i;
381
                break;
382
            }
383
        }
108 - 384
 
185 - 385
        for( int i = newcfg.num_class; i < MAX_CLASS; i++ )
386
            if( newcfg.team_class[i].full_name[0] )
387
            {
317 david 388
                qDebug( "Configuration error: Missing Class name. Gaps not allowed" );
185 - 389
            }
390
 
391
        if( newcfg.num_class == 0 )
108 - 392
        {
185 - 393
            throw( "Error: No categories defined" );
394
 
108 - 395
        }
396
 
316 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
        */
185 - 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" );
318 david 427
        //qDebug("NE Index is: %d", newcfg.nonequestrian_class );
185 - 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
            {
316 david 435
                if (newcfg.nonequestrian_class != i+1)
436
                {
437
                    MainWindow::showMessage(QString("Warning: Class without winners:")+ newcfg.team_class[i].abr); 
438
                }
185 - 439
            }
115 david 440
        }
441
 
231 - 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
            {
232 - 450
                if ( newcfg.class_ne_winners[i])
451
                {
452
                    newcfg.class_ne_winners_by_class = true;
453
                    break;
454
                }
231 - 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
 
108 - 464
        config = newcfg;
180 - 465
        config.write_config();
185 - 466
        updateChanged(false);
467
 
316 david 468
        // Force re-populate so that the index field is now correct
469
        populate();
470
 
471
 
108 - 472
    }
317 david 473
    catch (const char * str )
185 - 474
    {
475
        MainWindow::showMessage(str);
476
    }
108 - 477
 
103 david 478
}
479
 
108 - 480
void QmConfClass::cancel(void)
103 david 481
{
482
    populate();
483
}
484
 
108 - 485
QmConfClass::~QmConfClass()
99 david 486
{
290 david 487
 
99 david 488
}
489
 
184 - 490
void QmConfClass::ctxMenu(const QPoint & pos)
491
{
318 david 492
    //qDebug("Context Menu");
184 - 493
    QMenu *menu = new QMenu;
316 david 494
    menu->addAction(tr("New Category"), this, SLOT(ctxMenuAddRow()));
495
 
496
    /*
317 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.
316 david 500
    */
290 david 501
    QTableWidgetItem *item = tableWidget->itemAt(pos);
184 - 502
    if (item)
503
    {
316 david 504
        int row = item->row();
318 david 505
        //qDebug("Item is at row:%d", row);
316 david 506
        QTableWidgetItem *indexItem = tableWidget->item ( row, COL_INDEX );
507
        if (indexItem)
508
        {
509
            int index = indexItem->text().toInt();
318 david 510
            //qDebug("Item is at row:%d, Index: %d", row, index);
316 david 511
            if (index < 0)
512
            {
317 david 513
                menu->addAction(tr("Delete Newly added Category"), this, SLOT(ctxMenuDeleteRow())); 
316 david 514
            }
317 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
            }
316 david 528
        }
184 - 529
    }
317 david 530
    menu->exec(tableWidget->mapToGlobal(pos));
184 - 531
}
532
 
533
void QmConfClass::ctxMenuDeleteRow(void)
534
{
316 david 535
    //
536
    //  Assume that if the menu was shown, then we can delete it
537
    // 
290 david 538
    //qDebug ("DELETE ROW: %d", tableWidget->currentRow () );
317 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("");
318 david 543
    tableWidget->hideRow(tableWidget->currentRow ());
193 - 544
    updateChanged(true);
184 - 545
}
546
 
547
void QmConfClass::ctxMenuAddRow(void)
548
{
317 david 549
    tableWidget->setSortingEnabled(false);
290 david 550
    tableWidget->setRowCount( 1+ tableWidget->rowCount());
328 david 551
 
552
    /*
553
    **  Insert non-editable fields in the status part of the table
554
    */
316 david 555
    tableWidget->setItem(tableWidget->rowCount() - 1, COL_INDEX, new qmTwiNumber(-1));
328 david 556
    for (int ii= COL_ST_TOTAL; ii < COL_INDEX; ii++)
557
    {
558
        tableWidget->setItem(tableWidget->rowCount() - 1, ii, new qmTwiString(""));
559
    }
184 - 560
}
561
 
185 - 562
void QmConfClass::cellChanged(int row,int col)
563
{
564
    if ( populating )
565
        return;
316 david 566
    if (col == COL_INDEX)
567
        return;
568
 
569
    updateChanged(true); 
185 - 570
    populating = true;
571
    //qDebug("Cell changed: %d, %d", row, col);
231 - 572
    if (col == COL_NE)
185 - 573
    {
290 david 574
        for (int ii = 0; ii < tableWidget->rowCount(); ii++)
185 - 575
        {
290 david 576
            QTableWidgetItem *item = tableWidget->item(ii, COL_NE);
185 - 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
        {
290 david 593
            pushButtonSave->setEnabled(true);
594
            pushButtonSave->setStyleSheet("background-color: rgb(255, 0, 0);");
185 - 595
        }
596
        else
597
        {
290 david 598
            pushButtonSave->setEnabled(false);
599
            pushButtonSave->setStyleSheet("");
185 - 600
        }
601
    }
602
}
603
 
108 - 604
void QmConfClass::changeEvent(QEvent *e)
99 david 605
{
606
    QWidget::changeEvent(e);
607
    switch (e->type()) {
290 david 608
 
99 david 609
    default:
610
        break;
611
    }
612
}