Subversion Repositories svn1

Rev

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

Rev 307 Rev 308
Line 9... Line 9...
9
#include    "proto.h"
9
#include    "proto.h"
10
#include "mainwindow.h"
10
#include "mainwindow.h"
11
#include "qmdialogteameditor.h"
11
#include "qmdialogteameditor.h"
12
 
12
 
13
 
13
 
-
 
14
/*----------------------------------------------------------------------------
-
 
15
** FUNCTION           : qmFullData
-
 
16
**
-
 
17
** DESCRIPTION        : Display all the team data in colums that can be sorted 
-
 
18
**
-
 
19
**
-
 
20
** INPUTS             :
-
 
21
**
-
 
22
** RETURNS            :
-
 
23
**
-
 
24
----------------------------------------------------------------------------*/
14
 
25
 
15
qmFullData::qmFullData(QWidget *parent) :
26
qmFullData::qmFullData(QWidget *parent) :
16
    QWidget(parent)
27
    QWidget(parent)
17
{
28
{
-
 
29
 
-
 
30
    /*
-
 
31
    ** Create the main display region 
-
 
32
    **      A groupbox with a table in it
-
 
33
    **      A 'refresh' button
-
 
34
    */
-
 
35
 
18
    QVBoxLayout *verticalLayout = new QVBoxLayout(this);
36
    QVBoxLayout *verticalLayout = new QVBoxLayout(this);
19
    verticalLayout->setContentsMargins(0, 0, 0, 0);
37
    verticalLayout->setContentsMargins(0, 0, 0, 0);
20
 
38
 
21
    QGroupBox *groupBox = new QGroupBox("Class");
39
    QGroupBox *groupBox = new QGroupBox("Class");
22
    verticalLayout->addWidget(groupBox);
40
    verticalLayout->addWidget(groupBox);
23
    QVBoxLayout *verticalLayout2 = new QVBoxLayout(groupBox);
41
    QVBoxLayout *verticalLayout2 = new QVBoxLayout(groupBox);
24
    tableWidget = new QTableWidget(groupBox);
42
    tableWidget = new QTableWidget(groupBox);
25
    tableWidget->setAlternatingRowColors(true);
43
    tableWidget->setAlternatingRowColors(true);
26
    tableWidget->setRowCount(config.num_teams + 1);
44
    //tableWidget->setRowCount(config.num_teams + 1);
27
    tableWidget->setColumnCount(config.num_legs + 3);
45
    //tableWidget->setColumnCount(config.num_legs + 3);
28
    //tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
46
    //tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
29
    tableWidget->horizontalHeader()->setVisible(true);
47
    tableWidget->horizontalHeader()->setVisible(true);
30
    tableWidget->horizontalHeader()->setDefaultSectionSize(70);
48
    tableWidget->horizontalHeader()->setDefaultSectionSize(70);
31
    tableWidget->horizontalHeader()->setHighlightSections(true);
49
    tableWidget->horizontalHeader()->setHighlightSections(true);
32
 
50
 
Line 59... Line 77...
59
 
77
 
60
    tableWidget->setHorizontalHeaderLabels(labels);
78
    tableWidget->setHorizontalHeaderLabels(labels);
61
    tableWidget->resizeColumnsToContents();
79
    tableWidget->resizeColumnsToContents();
62
}
80
}
63
 
81
 
-
 
82
/*----------------------------------------------------------------------------
-
 
83
** FUNCTION           : showEvent
-
 
84
**
-
 
85
** DESCRIPTION        : Slot that is wired into the main windows widget
-
 
86
**                      It will be called when the main window widget changes
-
 
87
**                      If this display is the current display, then load new data
-
 
88
**
-
 
89
** INPUTS             : index of the tab that now has focus
-
 
90
**
-
 
91
----------------------------------------------------------------------------*/
-
 
92
 
-
 
93
void qmFullData::showEvent ( QShowEvent * event )
-
 
94
{
-
 
95
    qDebug("qmFullData::showEvent");
-
 
96
    if ( ! event->spontaneous() )
-
 
97
    {
-
 
98
        loadData();
-
 
99
    }
-
 
100
}
-
 
101
 
-
 
102
/*----------------------------------------------------------------------------
-
 
103
** FUNCTION           : loadData
-
 
104
**
-
 
105
** DESCRIPTION        : Load Data into the Window
-
 
106
**
-
 
107
**
-
 
108
** INPUTS             :
-
 
109
**
-
 
110
** RETURNS            :
-
 
111
**
-
 
112
----------------------------------------------------------------------------*/
-
 
113
 
64
void qmFullData::loadData(void)
114
void qmFullData::loadData(void)
65
{
115
{
66
    team_type team_buf;
116
    team_type team_buf;
67
 
117
 
68
    /*
118
    /*
Line 107... Line 157...
107
    tableWidget->sortByColumn(0,Qt::AscendingOrder);
157
    tableWidget->sortByColumn(0,Qt::AscendingOrder);
108
    tableWidget->setSortingEnabled(TRUE);
158
    tableWidget->setSortingEnabled(TRUE);
109
    tableWidget->resizeColumnsToContents();
159
    tableWidget->resizeColumnsToContents();
110
}
160
}
111
 
161
 
-
 
162
/*----------------------------------------------------------------------------
-
 
163
** FUNCTION           : selectTeam
-
 
164
**
-
 
165
** DESCRIPTION        : Given a table row/col, locate the team and
-
 
166
**                      if its valid, then open up a modal dialog to
-
 
167
**                      edit the team data.
-
 
168
** 
-
 
169
**                      On return, refresh all data in the page.
-
 
170
**
-
 
171
** INPUTS             :
-
 
172
**
-
 
173
** RETURNS            :
-
 
174
**
-
 
175
----------------------------------------------------------------------------*/
-
 
176
 
112
void qmFullData::selectTeam( int row, int col)
177
void qmFullData::selectTeam( int row, int col)
113
{
178
{
114
    //qDebug("qmFullData::selectTeam:%d,%d",row,col);
179
    //qDebug("qmFullData::selectTeam:%d,%d",row,col);
115
    QTableWidgetItem *item = tableWidget->item(row,0);
180
    QTableWidgetItem *item = tableWidget->item(row,0);
116
    if (item)
181
    if (item)
117
    {
182
    {
-
 
183
        //qDebug("qmFullData::selectTeam:%d,%d, %p",row,col, item);
118
        const qmTwiNumber * itemNumber = dynamic_cast<const qmTwiNumber*>(item);
184
        const qmTwiNumber * itemNumber = dynamic_cast<const qmTwiNumber*>(item);
119
        if ( itemNumber)
185
        if ( itemNumber)
-
 
186
        {
120
            qDebug("qmFullData::selectTeam: Team:%d",itemNumber->number);
187
            //qDebug("qmFullData::selectTeam: Team:%d",itemNumber->number);
121
            qmDialogTeamEditor dialog(itemNumber->number, this);
188
            qmDialogTeamEditor dialog(itemNumber->number, this);
122
            dialog.exec();
189
            dialog.exec();
123
            loadData();
190
            loadData();
-
 
191
        }
124
 
192
 
125
    }
193
    }
126
}
194
}
127
 
195
 
-
 
196
/*----------------------------------------------------------------------------
-
 
197
** FUNCTION           : qmTwi...
-
 
198
**
-
 
199
** DESCRIPTION        : A collection of helper classes to help display team
-
 
200
**                      information in a table.
-
 
201
** 
-
 
202
**                      All derive from QTableWidgetItem and display read-only
-
 
203
**                      data
-
 
204
** 
-
 
205
**                      Some of them have associated sorting functions to
-
 
206
**                      order data in a pleasing manner.
-
 
207
**
-
 
208
**
-
 
209
** INPUTS             :
-
 
210
**
-
 
211
** RETURNS            :
-
 
212
**
-
 
213
----------------------------------------------------------------------------*/
-
 
214
 
128
qmTwiString::qmTwiString ( QString value  ) :  QTableWidgetItem(0)
215
qmTwiString::qmTwiString ( QString value  ) :  QTableWidgetItem(0)
129
{
216
{
130
    setData(0,value);
217
    setData(0,value);
131
    setFlags(flags() & ~Qt::ItemIsEditable);
218
    setFlags(flags() & ~Qt::ItemIsEditable);
132
}
219
}