-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectweekdialog.cpp
76 lines (67 loc) · 2.44 KB
/
selectweekdialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "selectweekdialog.h"
#include "ui_selectweekdialog.h"
#include <QCheckBox>
#include <QTableWidget>
SelectWeekDialog::SelectWeekDialog( QList< bool > & boolList,
WeekButtonDelegate *invoker,
QWidget * parent )
: QDialog( parent ), delegate( invoker ), ui( new Ui::selectWeekDialog ) {
ui->setupUi( this );
for ( int i = 1; i <= 20; ++i ) {
QCheckBox *box = new QCheckBox;
box->setText( QString::number( i ) );
box->setCheckState( boolList[i - 1] ? Qt::Checked : Qt::Unchecked );
ui->gridLayout->addWidget( box, ( i - 1 ) / 5, ( i - 1 ) % 5 );
}
}
SelectWeekDialog::~SelectWeekDialog() {
delete ui;
}
void SelectWeekDialog::on_singleButton_clicked() {
for ( int i = 0; i < 20; i += 2 ) {
qobject_cast< QCheckBox * >(
ui->gridLayout->itemAtPosition( i / 5, i % 5 )->widget() )
->setCheckState( Qt::Checked );
}
for ( int i = 1; i < 20; i += 2 ) {
qobject_cast< QCheckBox * >(
ui->gridLayout->itemAtPosition( i / 5, i % 5 )->widget() )
->setCheckState( Qt::Unchecked );
}
}
void SelectWeekDialog::on_doubleButton_clicked() {
for ( int i = 0; i < 20; i += 2 ) {
qobject_cast< QCheckBox * >(
ui->gridLayout->itemAtPosition( i / 5, i % 5 )->widget() )
->setCheckState( Qt::Unchecked );
}
for ( int i = 1; i < 20; i += 2 ) {
qobject_cast< QCheckBox * >(
ui->gridLayout->itemAtPosition( i / 5, i % 5 )->widget() )
->setCheckState( Qt::Checked );
}
}
void SelectWeekDialog::on_selectAllButton_clicked() {
for ( int i = 0; i < 20; ++i ) {
qobject_cast< QCheckBox * >(
ui->gridLayout->itemAtPosition( i / 5, i % 5 )->widget() )
->setCheckState( Qt::Checked );
}
}
void SelectWeekDialog::on_clearAllButton_clicked() {
for ( int i = 0; i < 20; ++i ) {
qobject_cast< QCheckBox * >(
ui->gridLayout->itemAtPosition( i / 5, i % 5 )->widget() )
->setCheckState( Qt::Unchecked );
}
}
void SelectWeekDialog::on_buttonBox_accepted() {
QList< bool > isIn;
for ( int i = 0; i < 20; ++i ) {
isIn.append(
qobject_cast< QCheckBox * >(
ui->gridLayout->itemAtPosition( i / 5, i % 5 )->widget() )
->isChecked() );
}
delegate->isInWeek = isIn; //´«µÝ¸ødelegate
}