Subversion Repositories svn1-original

Rev

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

Rev 240 Rev 276
Line 1... Line 1...
1
#include "qmdisqualified.h"
1
#include "qmdisqualified.h"
2
#include    "consts.h"
2
#include "consts.h"
3
#include    "structs.h"
3
#include "structs.h"
4
#include    "proto.h"
4
#include "proto.h"
5
#include <QHeaderView>
5
#include <QHeaderView>
-
 
6
#include <QLabel>
6
#include <QPushButton>
7
#include <QGroupBox>
-
 
8
#include "mainwindow.h"
7
 
9
 
8
qmDisqualified::qmDisqualified(QWidget *parent) :
10
qmDisqualified::qmDisqualified(QWidget *parent) :
9
    QWidget(parent)
11
    QWidget(parent)
10
 
12
 
11
{
13
{
Line 28... Line 30...
28
    tableWidget->horizontalHeader()->setProperty("showSortIndicator", QVariant(true));
30
    tableWidget->horizontalHeader()->setProperty("showSortIndicator", QVariant(true));
29
    tableWidget->verticalHeader()->setDefaultSectionSize(20);
31
    tableWidget->verticalHeader()->setDefaultSectionSize(20);
30
    tableWidget->verticalHeader()->setProperty("showSortIndicator", QVariant(false));
32
    tableWidget->verticalHeader()->setProperty("showSortIndicator", QVariant(false));
31
    verticalLayout2->addWidget(tableWidget);
33
    verticalLayout2->addWidget(tableWidget);
32
 
34
 
-
 
35
    QHBoxLayout *horizontalLayout;
-
 
36
    horizontalLayout = new QHBoxLayout();
-
 
37
    horizontalLayout->setContentsMargins(0, 0, 0, 5);
-
 
38
 
-
 
39
    QGroupBox *groupBox2 = new QGroupBox("Bulk Set");
-
 
40
    verticalLayout2->addLayout(horizontalLayout);
-
 
41
    horizontalLayout->addWidget(groupBox2);
-
 
42
 
-
 
43
    QHBoxLayout *horizontalLayout1;
-
 
44
    QSpacerItem *horizontalSpacer1;
-
 
45
 
-
 
46
    horizontalLayout1 = new QHBoxLayout();
-
 
47
    horizontalLayout1->setContentsMargins(5, 5, 5, 5);
-
 
48
    groupBox2->setLayout(horizontalLayout1);
-
 
49
 
-
 
50
    cb_disq = new QCheckBox("Disq");
-
 
51
    cb_disq->setTristate(true);
-
 
52
    horizontalLayout1->addWidget(cb_disq);
-
 
53
 
-
 
54
    cb_ne = new QCheckBox("Non Equest");
-
 
55
    cb_ne->setTristate(true);
-
 
56
    horizontalLayout1->addWidget(cb_ne);
-
 
57
 
-
 
58
    cb_enable = new QCheckBox("Enable");
-
 
59
    cb_enable->setTristate(true);
-
 
60
    horizontalLayout1->addWidget(cb_enable);
-
 
61
 
-
 
62
    cb_vetcheck = new QCheckBox("Vet Check");
-
 
63
    cb_vetcheck->setTristate(true);
-
 
64
    horizontalLayout1->addWidget(cb_vetcheck);
-
 
65
        
-
 
66
    horizontalLayout1->addWidget(new QLabel("Team"));
-
 
67
    teamNumber = new QSpinBox();
-
 
68
    horizontalLayout1->addWidget(teamNumber);
-
 
69
 
-
 
70
    setButton = new QPushButton("Set");
-
 
71
    horizontalLayout1->addWidget(setButton);
-
 
72
 
-
 
73
    horizontalSpacer1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
-
 
74
    horizontalLayout1->addItem(horizontalSpacer1);
-
 
75
 
33
    buttonBox = new QDialogButtonBox();
76
    buttonBox = new QDialogButtonBox();
34
    pb_restore = buttonBox->addButton("Restore",QDialogButtonBox::ActionRole );
77
    pb_restore = buttonBox->addButton("Restore",QDialogButtonBox::ActionRole );
35
    pb_save = buttonBox->addButton("Save",QDialogButtonBox::ActionRole );
78
    pb_save = buttonBox->addButton("Save",QDialogButtonBox::ActionRole );
36
    verticalLayout->addWidget(buttonBox);
79
    horizontalLayout->addWidget(buttonBox);
37
 
80
 
38
    connect(pb_save, SIGNAL(clicked()), this, SLOT(save()) );
81
    connect(pb_save, SIGNAL(clicked()), this, SLOT(save()) );
39
    connect(pb_restore, SIGNAL(clicked()), this, SLOT(cancel()) );
82
    connect(pb_restore, SIGNAL(clicked()), this, SLOT(cancel()) );
-
 
83
    connect(setButton, SIGNAL(clicked()), this, SLOT(bulk_set()) );
40
    connect(tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(tableItemChanged(QTableWidgetItem *)));
84
    connect(tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(tableItemChanged(QTableWidgetItem *)));
41
    updateChanged (false);
85
    updateChanged (false);
42
}
86
}
43
 
87
 
44
qmDisqualified::~qmDisqualified()
88
qmDisqualified::~qmDisqualified()
Line 138... Line 182...
138
    }
182
    }
139
    tableWidget->sortByColumn(0,Qt::AscendingOrder);
183
    tableWidget->sortByColumn(0,Qt::AscendingOrder);
140
    tableWidget->setSortingEnabled(TRUE);
184
    tableWidget->setSortingEnabled(TRUE);
141
    tableWidget->resizeColumnsToContents();
185
    tableWidget->resizeColumnsToContents();
142
 
186
 
-
 
187
    /*
-
 
188
     ** Init the bulk_set checkboxes to tristate
-
 
189
     */
-
 
190
    cb_disq->setCheckState(Qt::PartiallyChecked);
-
 
191
    cb_enable->setCheckState(Qt::PartiallyChecked);
-
 
192
    cb_ne->setCheckState(Qt::PartiallyChecked);
-
 
193
    cb_vetcheck->setCheckState(Qt::PartiallyChecked);
-
 
194
 
-
 
195
    teamNumber->setMaximum(config.max_team);
-
 
196
    teamNumber->setMinimum(config.min_team);
-
 
197
 
143
    inPopulate = FALSE;
198
    inPopulate = FALSE;
144
    updateChanged(false);
199
    updateChanged(false);
145
}
200
}
146
 
201
 
147
void qmDisqualified::tableItemChanged(QTableWidgetItem *item)
202
void qmDisqualified::tableItemChanged(QTableWidgetItem *item)
Line 188... Line 243...
188
    {
243
    {
189
        populate();
244
        populate();
190
    }
245
    }
191
}
246
}
192
 
247
 
-
 
248
/*----------------------------------------------------------------------------
-
 
249
** FUNCTION           : bulk_set
-
 
250
**
-
 
251
** DESCRIPTION        : Set multiple attributes on the current team
-
 
252
**
-
 
253
**
-
 
254
** INPUTS             : Nothing
-
 
255
**
-
 
256
** RETURNS            : Nothing
-
 
257
**
-
 
258
----------------------------------------------------------------------------*/
-
 
259
 
-
 
260
void qmDisqualified::bulk_set(void)
-
 
261
{
-
 
262
    bool team_found = FALSE;
-
 
263
    bool item_set = FALSE;
-
 
264
 
-
 
265
    //qDebug("qmDisqualified::bulk_set:%d", teamNumber->value());
-
 
266
    for ( int ii = 0; ii < tableWidget->rowCount(); ii++)
-
 
267
    {
-
 
268
        QTableWidgetItem *item;
-
 
269
        item = tableWidget->item(ii, 0);
-
 
270
        if ( item )
-
 
271
        {
-
 
272
            int team = item->data(Qt::EditRole).toInt();
-
 
273
            if ( team && team == teamNumber->value() )
-
 
274
            {
-
 
275
                tableWidget->scrollToItem(item,QAbstractItemView::PositionAtCenter);
-
 
276
                //qDebug("Found Entry:%d", team);
-
 
277
 
-
 
278
                enum Qt::CheckState state;
-
 
279
                state = cb_disq->checkState();
-
 
280
                if (state != Qt::PartiallyChecked)
-
 
281
                {
-
 
282
                    item = tableWidget->item(ii,2);
-
 
283
                    item->setCheckState(state);
-
 
284
                    item_set = TRUE;
-
 
285
                }
-
 
286
 
-
 
287
                state = cb_ne->checkState();
-
 
288
                if (state != Qt::PartiallyChecked)
-
 
289
                {
-
 
290
                    item = tableWidget->item(ii,3);
-
 
291
                    item->setCheckState(state);
-
 
292
                    item_set = TRUE;
-
 
293
                }
-
 
294
 
-
 
295
                state = cb_enable->checkState();
-
 
296
                if (state != Qt::PartiallyChecked)
-
 
297
                {
-
 
298
                    item = tableWidget->item(ii,4);
-
 
299
                    item->setCheckState(state);
-
 
300
                    item_set = TRUE;
-
 
301
                }
-
 
302
 
-
 
303
                state = cb_vetcheck->checkState();
-
 
304
                if (state != Qt::PartiallyChecked)
-
 
305
                {
-
 
306
                    item = tableWidget->item(ii,5);
-
 
307
                    item->setCheckState(state);
-
 
308
                    item_set = TRUE;
-
 
309
                }
-
 
310
                team_found = TRUE;
-
 
311
                break;
-
 
312
            }
-
 
313
        }
-
 
314
    }
-
 
315
 
-
 
316
    /*
-
 
317
    **  Report to user
-
 
318
    */
-
 
319
    if ( team_found)
-
 
320
    {
-
 
321
        if (item_set )
-
 
322
            MainWindow::showMessage("Values set");
-
 
323
        else
-
 
324
            MainWindow::showMessage("Nothing selected to set");
-
 
325
    }
-
 
326
    else
-
 
327
    {
-
 
328
        MainWindow::showMessage("Team not found");
-
 
329
    }
-
 
330
}
-
 
331
 
-
 
332
 
193
qmDisqualifiedItem::qmDisqualifiedItem ( const QString & text, int type ) :  QTableWidgetItem(text, type+QTableWidgetItem::UserType)
333
qmDisqualifiedItem::qmDisqualifiedItem ( const QString & text, int type ) :  QTableWidgetItem(text, type+QTableWidgetItem::UserType)
194
{
334
{
195
    number = 0;
335
    number = 0;
196
}
336
}
197
qmDisqualifiedItem::qmDisqualifiedItem ( int value, int type ) :  QTableWidgetItem(type+QTableWidgetItem::UserType)
337
qmDisqualifiedItem::qmDisqualifiedItem ( int value, int type ) :  QTableWidgetItem(type+QTableWidgetItem::UserType)
Line 230... Line 370...
230
        return (other_widget->checkState() < checkState() );
370
        return (other_widget->checkState() < checkState() );
231
    }
371
    }
232
 
372
 
233
    return ( QTableWidgetItem::operator< (other) );
373
    return ( QTableWidgetItem::operator< (other) );
234
}
374
}
-
 
375
 
-
 
376