Subversion Repositories svn1-original

Rev

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

Rev 194 Rev 195
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 <QPushButton>
6
 
7
 
7
qmDisqualified::qmDisqualified(QWidget *parent) :
8
qmDisqualified::qmDisqualified(QWidget *parent) :
8
    QWidget(parent)
9
    QWidget(parent)
9
 
10
 
10
{
11
{
11
    inPopulate = FALSE;
12
    inPopulate = false;
-
 
13
    dirty = true;
12
    resize ( 600,400);
14
    resize ( 600,400);
13
 
15
 
14
    QVBoxLayout *verticalLayout = new QVBoxLayout(this);
16
    QVBoxLayout *verticalLayout = new QVBoxLayout(this);
15
    verticalLayout->setContentsMargins(0, 0, 0, 0);
17
    verticalLayout->setContentsMargins(0, 0, 0, 0);
16
 
18
 
Line 27... Line 29...
27
    tableWidget->verticalHeader()->setDefaultSectionSize(20);
29
    tableWidget->verticalHeader()->setDefaultSectionSize(20);
28
    tableWidget->verticalHeader()->setProperty("showSortIndicator", QVariant(false));
30
    tableWidget->verticalHeader()->setProperty("showSortIndicator", QVariant(false));
29
    verticalLayout2->addWidget(tableWidget);
31
    verticalLayout2->addWidget(tableWidget);
30
 
32
 
31
    buttonBox = new QDialogButtonBox();
33
    buttonBox = new QDialogButtonBox();
32
    buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
34
    pb_load = buttonBox->addButton("Load",QDialogButtonBox::ActionRole );
33
    buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
35
    pb_restore = buttonBox->addButton("Restore",QDialogButtonBox::ActionRole );
34
    buttonBox->addButton("Load",QDialogButtonBox::ActionRole );
36
    pb_save = buttonBox->addButton("Save",QDialogButtonBox::ActionRole );
35
    verticalLayout->addWidget(buttonBox);
37
    verticalLayout->addWidget(buttonBox);
36
 
38
 
37
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(save()) );
39
    connect(pb_save, SIGNAL(clicked()), this, SLOT(save()) );
38
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancel()) );
40
    connect(pb_restore, SIGNAL(clicked()), this, SLOT(cancel()) );
39
    //connect(buttonBox, SIGNAL(????), this, SLOT(populate()) );
41
    connect(pb_load, SIGNAL(clicked()), this, SLOT(populate()) );
40
    connect(tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(tableItemChanged(QTableWidgetItem *)));
42
    connect(tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(tableItemChanged(QTableWidgetItem *)));
-
 
43
    updateChanged (false);
41
}
44
}
42
 
45
 
43
qmDisqualified::~qmDisqualified()
46
qmDisqualified::~qmDisqualified()
44
{
47
{
45
 
48
 
Line 135... Line 138...
135
    tableWidget->sortByColumn(0,Qt::AscendingOrder);
138
    tableWidget->sortByColumn(0,Qt::AscendingOrder);
136
    tableWidget->setSortingEnabled(TRUE);
139
    tableWidget->setSortingEnabled(TRUE);
137
    tableWidget->resizeColumnsToContents();
140
    tableWidget->resizeColumnsToContents();
138
 
141
 
139
    inPopulate = FALSE;
142
    inPopulate = FALSE;
-
 
143
    updateChanged(false);
140
}
144
}
141
 
145
 
142
void qmDisqualified::tableItemChanged(QTableWidgetItem *item)
146
void qmDisqualified::tableItemChanged(QTableWidgetItem *item)
143
{
147
{
144
    if ( !inPopulate )
148
    if ( !inPopulate )
Line 149... Line 153...
149
            item->setData(Qt::BackgroundRole, QBrush(QColor(255,0,0,50)));
153
            item->setData(Qt::BackgroundRole, QBrush(QColor(255,0,0,50)));
150
 
154
 
151
            // Mark first item in row to help detect changes
155
            // Mark first item in row to help detect changes
152
            int row = item->row();
156
            int row = item->row();
153
            item->tableWidget()->item(row,0)->setData(Qt::UserRole + 1, true );
157
            item->tableWidget()->item(row,0)->setData(Qt::UserRole + 1, true );
-
 
158
            item->tableWidget()->item(row,0)->setData(Qt::BackgroundRole, QBrush(QColor(255,0,0,50)));
-
 
159
        }
-
 
160
 
-
 
161
        updateChanged(true);
-
 
162
    }
-
 
163
}
-
 
164
 
-
 
165
void qmDisqualified::updateChanged(bool newDirty)
-
 
166
{
-
 
167
    if (newDirty != dirty)
-
 
168
    {
-
 
169
        dirty = newDirty;
-
 
170
        if (dirty)
-
 
171
        {
-
 
172
            //ui->Changed->setVisible(true);
-
 
173
            pb_save->setEnabled(true);
-
 
174
            pb_save->setStyleSheet("background-color: rgb(255, 0, 0);");
-
 
175
        }
-
 
176
        else
-
 
177
        {
-
 
178
            //ui->Changed->setVisible(false);
-
 
179
            pb_save->setEnabled(false);
-
 
180
            pb_save->setStyleSheet("");
154
        }
181
        }
155
    }
182
    }
156
}
183
}
157
 
184
 
-
 
185
void qmDisqualified::showEvent ( QShowEvent * event )
-
 
186
{
-
 
187
    qDebug("qmDisqualified::showEvent");
-
 
188
    if ( ! event->spontaneous() && !dirty )
-
 
189
    {
-
 
190
        populate();
-
 
191
    }
-
 
192
}
-
 
193
 
158
qmDisqualifiedItem::qmDisqualifiedItem ( const QString & text, int type ) :  QTableWidgetItem(text, type+QTableWidgetItem::UserType)
194
qmDisqualifiedItem::qmDisqualifiedItem ( const QString & text, int type ) :  QTableWidgetItem(text, type+QTableWidgetItem::UserType)
159
{
195
{
160
    number = 0;
196
    number = 0;
161
}
197
}
162
qmDisqualifiedItem::qmDisqualifiedItem ( int value, int type ) :  QTableWidgetItem(type+QTableWidgetItem::UserType)
198
qmDisqualifiedItem::qmDisqualifiedItem ( int value, int type ) :  QTableWidgetItem(type+QTableWidgetItem::UserType)