3 #include <qpushbutton.h>
5 #include "Application.h"
6 #include "AutoTestDlg.h"
9 AutoTestDlg::AutoTestDlg(QWidget* parent)
13 setWindowTitle(tr("DLG_AUTO_TEST"));
14 QString dir = Application::getResourceDir();
15 QPixmap autoIcon( dir + tr( "ICON_AUTO_TEST" ) );
16 setWindowIcon(autoIcon);
18 QGridLayout* pMainLayout = new QGridLayout(this);
19 pMainLayout->setMargin(5);
20 pMainLayout->setSpacing(5);
22 QLabel* lab = new QLabel(tr("LAB_START"), this);
23 pMainLayout->addWidget(lab, 0, 0);
25 lab = new QLabel(tr("LAB_STOP"), this);
26 pMainLayout->addWidget(lab, 1, 0);
28 lab = new QLabel(tr("LAB_STEP"), this);
29 pMainLayout->addWidget(lab, 2, 0);
31 const int MinNbOfItems = 100000; // to see noticable effect
32 const int MaxNbOfItems = 1000000; // to avoid too long computations
33 const int ItemsStep = 100000;
34 const int MinStep = 50000;
35 const int StepStep = 50000;
37 myStartSpin = new QSpinBox(this);
38 myStartSpin->setMinimum(MinNbOfItems);
39 myStartSpin->setMaximum(MaxNbOfItems);
40 myStartSpin->setSingleStep(ItemsStep);
41 pMainLayout->addWidget(myStartSpin, 0, 1);
42 verify(connect(myStartSpin, SIGNAL(valueChanged(int)), SLOT(checkStepSpinState())));
44 myStopSpin = new QSpinBox(this);
45 myStopSpin->setMinimum(MinNbOfItems);
46 myStopSpin->setMaximum(MaxNbOfItems);
47 myStartSpin->setSingleStep(ItemsStep);
48 pMainLayout->addWidget(myStopSpin, 1, 1);
49 verify(connect(myStopSpin, SIGNAL(valueChanged(int)), SLOT(setStartMaxValue(int))));
50 verify(connect(myStopSpin, SIGNAL(valueChanged(int)), SLOT(checkStepSpinState())));
52 const int StopSpinDefaultValue = 2 * myStartSpin -> minimum();
53 myStopSpin -> setValue(StopSpinDefaultValue);
54 myStartSpin -> setMaximum(myStopSpin -> value());
56 myStepSpin = new QSpinBox(this);
57 myStepSpin->setMinimum(MinStep);
58 myStepSpin->setMaximum(MaxNbOfItems - MinNbOfItems);
59 myStepSpin->setSingleStep(StepStep);
60 pMainLayout->addWidget(myStepSpin, 2, 1);
62 lab = new QLabel(tr("LAB_ITEMS"), this);
63 pMainLayout->addWidget(lab, 0, 2);
65 lab = new QLabel(tr("LAB_ITEMS"), this);
66 pMainLayout->addWidget(lab, 1, 2);
68 lab = new QLabel(tr("LAB_ITEMS"), this);
69 pMainLayout->addWidget(lab, 2, 2);
71 QFrame* separator = new QFrame(this);
72 separator->setFrameStyle(QFrame::HLine | QFrame::Sunken);
73 pMainLayout->addWidget(separator, 3, 0, 1, 3 );
75 QHBoxLayout* hcbox = new QHBoxLayout();
78 myTeCheck = new QCheckBox(tr( "MEN_BTN_TEXT" ), this);
79 hcbox->addWidget(myTeCheck);
80 verify(connect(myTeCheck, SIGNAL(clicked()), this, SLOT(onText())));
82 hcbox->addSpacing( 5 );
84 pMainLayout->addLayout(hcbox, 4, 0, 1, 3);
86 QHBoxLayout* hbox = new QHBoxLayout();
89 QPushButton* btn = new QPushButton(tr("BTN_START"), this);
90 // btn->setDefault(true);
91 verify(connect(btn, SIGNAL(clicked()), this, SLOT(onStart())));
92 btn->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
94 btn = new QPushButton(tr("BTN_CANCEL"), this);
95 verify(connect(btn, SIGNAL(clicked()), this, SLOT(onCancel())));
96 btn->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
99 pMainLayout->addLayout(hbox, 5, 0, 1, 3);
102 void AutoTestDlg::onStart()
107 void AutoTestDlg::onCancel()
112 void AutoTestDlg::setStartMaxValue(int i)
114 myStartSpin -> setMaximum(i);
115 if (myStartSpin -> value() > myStartSpin -> maximum())
116 myStartSpin -> setValue(myStartSpin -> maximum());
119 void AutoTestDlg::checkStepSpinState()
123 if (myStartSpin -> value() == myStopSpin -> value())
124 myStepSpin -> setEnabled(false);
126 myStepSpin -> setEnabled(true);
130 void AutoTestDlg::onText()
132 int MinNbOfItems, MaxNbOfItems, DefaultStartSpinVal, DefaultStopSpinVal,
133 ItemsStep, MinStep, StepStep;
135 if (myTeCheck -> isChecked())
137 MinNbOfItems = 1000; // to see noticeable effect
138 MaxNbOfItems = 100000; // to avoid too long computations
139 DefaultStartSpinVal = 10000;
140 DefaultStopSpinVal = 20000;
147 MinNbOfItems = 100000; // to see noticeable effect
148 MaxNbOfItems = 1000000; // to avoid too long computations
149 DefaultStartSpinVal = 100000;
150 DefaultStopSpinVal = 200000;
156 myStartSpin -> setRange(MinNbOfItems, MaxNbOfItems);
157 myStartSpin -> setSingleStep(ItemsStep);
158 myStartSpin -> setValue(DefaultStartSpinVal);
160 myStopSpin -> setRange(MinNbOfItems, MaxNbOfItems);
161 myStopSpin -> setSingleStep(ItemsStep);
163 myStopSpin -> setValue(DefaultStopSpinVal);
164 myStartSpin -> setMaximum(myStopSpin -> value());
166 myStepSpin -> setRange(MinStep, MaxNbOfItems - MinNbOfItems);
167 myStepSpin -> setSingleStep(StepStep);
168 myStepSpin -> setValue(MinStep);