Changeset View
Changeset View
Standalone View
Standalone View
src/kdefrontend/dockwidgets/CorrelationCoefficientDock.cpp
Context not available. | |||||
73 | ui.cbTest->addItem( i18n("Spearman"), CorrelationCoefficient::Spearman); | 73 | ui.cbTest->addItem( i18n("Spearman"), CorrelationCoefficient::Spearman); | ||
---|---|---|---|---|---|
74 | ui.cbTest->addItem( i18n("Chi Square"), CorrelationCoefficient::ChiSquare); | 74 | ui.cbTest->addItem( i18n("Chi Square"), CorrelationCoefficient::ChiSquare); | ||
75 | 75 | | |||
76 | ui.leNRows->setText("2"); | ||||
77 | ui.leNColumns->setText("2"); | ||||
78 | | ||||
79 | ui.leNRows->setValidator(new QIntValidator(this)); | ||||
80 | ui.leNColumns->setValidator(new QIntValidator(this)); | ||||
81 | | ||||
76 | ui.lTestType->hide(); | 82 | ui.lTestType->hide(); | ||
77 | ui.cbTestType->hide(); | 83 | ui.cbTestType->hide(); | ||
78 | // adding item to tests and testtype combo box; | 84 | ui.lCalculateStats->hide(); | ||
79 | // making all test blocks invisible at starting. | 85 | ui.chbCalculateStats->hide(); | ||
80 | ui.lStatsFromSpreadsheet->hide(); | 86 | ui.lNRows->hide(); | ||
81 | ui.chbStatsFromSpreadsheet->hide(); | 87 | ui.leNRows->hide(); | ||
88 | ui.lNColumns->hide(); | ||||
89 | ui.leNColumns->hide(); | ||||
82 | ui.lCategorical->hide(); | 90 | ui.lCategorical->hide(); | ||
83 | ui.chbCategorical->hide(); | 91 | ui.chbCategorical->hide(); | ||
84 | ui.lCol1->hide(); | 92 | ui.lCol1->hide(); | ||
85 | ui.cbCol1->hide(); | 93 | ui.cbCol1->hide(); | ||
86 | ui.lCol2->hide(); | 94 | ui.lCol2->hide(); | ||
87 | ui.cbCol2->hide(); | 95 | ui.cbCol2->hide(); | ||
96 | ui.lCol3->hide(); | ||||
97 | ui.cbCol3->hide(); | ||||
88 | ui.lAlpha->hide(); | 98 | ui.lAlpha->hide(); | ||
89 | ui.leAlpha->hide(); | 99 | ui.leAlpha->hide(); | ||
90 | ui.pbPerformTest->setEnabled(false); | 100 | ui.pbPerformTest->setEnabled(false); | ||
Context not available. | |||||
128 | connect(ui.cbTest, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CorrelationCoefficientDock::showTestType); | 138 | connect(ui.cbTest, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CorrelationCoefficientDock::showTestType); | ||
129 | connect(ui.cbTestType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CorrelationCoefficientDock::showCorrelationCoefficient); | 139 | connect(ui.cbTestType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CorrelationCoefficientDock::showCorrelationCoefficient); | ||
130 | connect(ui.chbCategorical, &QCheckBox::stateChanged, this, &CorrelationCoefficientDock::changeCbCol2Label); | 140 | connect(ui.chbCategorical, &QCheckBox::stateChanged, this, &CorrelationCoefficientDock::changeCbCol2Label); | ||
131 | connect(ui.chbStatsFromSpreadsheet, &QCheckBox::stateChanged, this, &CorrelationCoefficientDock::chbColumnStatisticsStateChanged); | 141 | connect(ui.chbCalculateStats, &QCheckBox::stateChanged, this, &CorrelationCoefficientDock::chbColumnStatsStateChanged); | ||
142 | connect(ui.leNRows, &QLineEdit::textChanged, this, &CorrelationCoefficientDock::leNRowsChanged); | ||||
143 | connect(ui.leNColumns, &QLineEdit::textChanged, this, &CorrelationCoefficientDock::leNColumnsChanged); | ||||
144 | connect(ui.pbExportToSpreadsheet, &QPushButton::clicked, this, &CorrelationCoefficientDock::exportStatsTableToSpreadsheet); | ||||
132 | 145 | | |||
133 | connect(ui.pbPerformTest, &QPushButton::clicked, this, &CorrelationCoefficientDock::findCorrelationCoefficient); | 146 | connect(ui.pbPerformTest, &QPushButton::clicked, this, &CorrelationCoefficientDock::findCorrelationCoefficient); | ||
134 | connect(ui.cbCol1, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CorrelationCoefficientDock::col1IndexChanged); | 147 | connect(ui.cbCol1, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CorrelationCoefficientDock::col1IndexChanged); | ||
Context not available. | |||||
203 | void CorrelationCoefficientDock::showCorrelationCoefficient() { | 216 | void CorrelationCoefficientDock::showCorrelationCoefficient() { | ||
204 | m_test |= ui.cbTestType->currentData().toInt(); | 217 | m_test |= ui.cbTestType->currentData().toInt(); | ||
205 | 218 | | |||
206 | ui.lCol1->show(); | 219 | ui.lCalculateStats->setVisible(testType(m_test) == CorrelationCoefficient::ChiSquare); | ||
207 | ui.cbCol1->show(); | 220 | ui.chbCalculateStats->setVisible(testType(m_test) == CorrelationCoefficient::ChiSquare); | ||
208 | | ||||
209 | ui.lCol2->show(); | | |||
210 | ui.cbCol2->show(); | | |||
211 | | ||||
212 | ui.lStatsFromSpreadsheet->setVisible(testType(m_test) == CorrelationCoefficient::ChiSquare); | | |||
213 | ui.chbStatsFromSpreadsheet->setVisible(testType(m_test) == CorrelationCoefficient::ChiSquare); | | |||
214 | ui.chbStatsFromSpreadsheet->setChecked(true); | | |||
215 | 221 | | |||
216 | ui.lCategorical->setVisible(testType(m_test) == CorrelationCoefficient::Pearson); | 222 | if (testType(m_test) != CorrelationCoefficient::ChiSquare) | ||
217 | ui.chbCategorical->setVisible(testType(m_test) == CorrelationCoefficient::Pearson); | 223 | ui.chbCalculateStats->setChecked(true); | ||
218 | | ||||
219 | ui.lAlpha->setVisible(m_test == (CorrelationCoefficient::ChiSquare | CorrelationCoefficient::IndependenceTest)); | | |||
220 | ui.leAlpha->setVisible(m_test == (CorrelationCoefficient::ChiSquare | CorrelationCoefficient::IndependenceTest)); | | |||
221 | | ||||
222 | setColumnsComboBoxView(); | | |||
223 | 224 | | |||
224 | ui.pbPerformTest->setEnabled(nonEmptySelectedColumns()); | 225 | chbColumnStatsStateChanged(); | ||
225 | } | 226 | } | ||
226 | 227 | | |||
227 | void CorrelationCoefficientDock::findCorrelationCoefficient() { | 228 | void CorrelationCoefficientDock::findCorrelationCoefficient() { | ||
228 | QVector<Column*> cols; | 229 | QVector<Column*> cols; | ||
229 | 230 | | |||
230 | if (ui.cbCol1->count() == 0) | 231 | if (ui.chbCategorical->isChecked() && ui.cbCol1->count() == 0) | ||
231 | return; | 232 | return; | ||
232 | 233 | | |||
233 | cols << reinterpret_cast<Column*>(ui.cbCol1->currentData().toLongLong()); | 234 | cols << reinterpret_cast<Column*>(ui.cbCol1->currentData().toLongLong()); | ||
234 | cols << reinterpret_cast<Column*>(ui.cbCol2->currentData().toLongLong()); | 235 | cols << reinterpret_cast<Column*>(ui.cbCol2->currentData().toLongLong()); | ||
235 | 236 | | |||
237 | if (testSubType(m_test) == CorrelationCoefficient::IndependenceTest) | ||||
238 | cols << reinterpret_cast<Column*>(ui.cbCol3->currentData().toLongLong()); | ||||
239 | | ||||
236 | m_correlationCoefficient->setColumns(cols); | 240 | m_correlationCoefficient->setColumns(cols); | ||
237 | m_correlationCoefficient->performTest(m_test, ui.chbCategorical->isChecked()); | 241 | m_correlationCoefficient->performTest(m_test, ui.chbCategorical->isChecked(), ui.chbCalculateStats->isChecked()); | ||
238 | } | 242 | } | ||
239 | 243 | | |||
240 | void CorrelationCoefficientDock::setModelIndexFromAspect(TreeViewComboBox* cb, const AbstractAspect* aspect) { | 244 | void CorrelationCoefficientDock::setModelIndexFromAspect(TreeViewComboBox* cb, const AbstractAspect* aspect) { | ||
Context not available. | |||||
422 | } | 426 | } | ||
423 | } | 427 | } | ||
424 | 428 | | |||
425 | void CorrelationCoefficientDock::chbColumnStatisticsStateChanged() { | 429 | void CorrelationCoefficientDock::chbColumnStatsStateChanged() { | ||
426 | bool chbChecked = ui.chbStatsFromSpreadsheet->isChecked(); | 430 | bool chbChecked = ui.chbCalculateStats->isChecked(); | ||
427 | 431 | | |||
428 | ui.lVariables->setVisible(chbChecked); | 432 | ui.lVariables->setVisible(chbChecked); | ||
429 | ui.lCol1->setVisible(chbChecked); | 433 | ui.lCol1->setVisible(chbChecked); | ||
430 | ui.cbCol1->setVisible(chbChecked); | 434 | ui.cbCol1->setVisible(chbChecked); | ||
431 | ui.lCol2->setVisible(chbChecked); | 435 | ui.lCol2->setVisible(chbChecked); | ||
432 | ui.cbCol2->setVisible(chbChecked); | 436 | ui.cbCol2->setVisible(chbChecked); | ||
437 | ui.lCol3->setVisible(chbChecked); | ||||
438 | ui.cbCol3->setVisible(chbChecked); | ||||
439 | | ||||
440 | ui.lCategorical->setVisible(chbChecked && testType(m_test) == CorrelationCoefficient::Pearson); | ||||
441 | ui.chbCategorical->setVisible(chbChecked && testType(m_test) == CorrelationCoefficient::Pearson); | ||||
442 | | ||||
443 | ui.lNRows->setVisible(!chbChecked); | ||||
444 | ui.leNRows->setVisible(!chbChecked); | ||||
445 | | ||||
446 | ui.lNColumns->setVisible(!chbChecked); | ||||
447 | ui.leNColumns->setVisible(!chbChecked); | ||||
448 | ui.pbExportToSpreadsheet->setVisible(!chbChecked); | ||||
449 | | ||||
450 | if (chbChecked) { | ||||
451 | setColumnsComboBoxView(); | ||||
452 | ui.pbPerformTest->setEnabled(nonEmptySelectedColumns()); | ||||
453 | } else | ||||
454 | ui.pbPerformTest->setEnabled(true); | ||||
455 | | ||||
456 | if (m_correlationCoefficient != nullptr) | ||||
457 | m_correlationCoefficient->initInputStatsTable(m_test, chbChecked, ui.leNRows->text().toInt(), ui.leNColumns->text().toInt()); | ||||
458 | } | ||||
459 | | ||||
460 | void CorrelationCoefficientDock::leNRowsChanged() { | ||||
461 | if (m_correlationCoefficient != nullptr) | ||||
462 | m_correlationCoefficient->setInputStatsTableNRows(ui.leNRows->text().toInt()); | ||||
463 | } | ||||
464 | | ||||
465 | void CorrelationCoefficientDock::leNColumnsChanged() { | ||||
466 | if (m_correlationCoefficient != nullptr) | ||||
467 | m_correlationCoefficient->setInputStatsTableNCols(ui.leNColumns->text().toInt()); | ||||
468 | } | ||||
469 | | ||||
470 | void CorrelationCoefficientDock::exportStatsTableToSpreadsheet() { | ||||
471 | if (ui.chbCalculateStats->isVisible() && !ui.chbCalculateStats->isChecked()) | ||||
472 | m_correlationCoefficient->exportStatTableToSpreadsheet(); | ||||
433 | } | 473 | } | ||
434 | 474 | | |||
435 | ////************************************************************* | 475 | ////************************************************************* | ||
Context not available. | |||||
485 | void CorrelationCoefficientDock::setColumnsComboBoxView() { | 525 | void CorrelationCoefficientDock::setColumnsComboBoxView() { | ||
486 | ui.cbCol1->clear(); | 526 | ui.cbCol1->clear(); | ||
487 | ui.cbCol2->clear(); | 527 | ui.cbCol2->clear(); | ||
528 | ui.cbCol3->clear(); | ||||
488 | 529 | | |||
489 | QList<Column*>::iterator i; | 530 | QList<Column*>::iterator i; | ||
490 | 531 | | |||
Context not available. | |||||
523 | break; | 564 | break; | ||
524 | } | 565 | } | ||
525 | case CorrelationCoefficient::ChiSquare: { | 566 | case CorrelationCoefficient::ChiSquare: { | ||
526 | switch (testSubType(m_test)) { | 567 | if (testSubType(m_test) == CorrelationCoefficient::IndependenceTest) { | ||
527 | case CorrelationCoefficient::IndependenceTest: | | |||
528 | for (i = m_twoCategoricalCols.begin(); i != m_twoCategoricalCols.end(); i++) { | 568 | for (i = m_twoCategoricalCols.begin(); i != m_twoCategoricalCols.end(); i++) { | ||
529 | ui.cbCol1->addItem( (*i)->name(), qint64(*i)); | 569 | ui.cbCol1->addItem( (*i)->name(), qint64(*i)); | ||
530 | ui.cbCol2->addItem( (*i)->name(), qint64(*i)); | 570 | ui.cbCol2->addItem( (*i)->name(), qint64(*i)); | ||
Context not available. | |||||
533 | ui.cbCol1->addItem( (*i)->name(), qint64(*i)); | 573 | ui.cbCol1->addItem( (*i)->name(), qint64(*i)); | ||
534 | ui.cbCol2->addItem( (*i)->name(), qint64(*i)); | 574 | ui.cbCol2->addItem( (*i)->name(), qint64(*i)); | ||
535 | } | 575 | } | ||
536 | break; | 576 | for (i = m_onlyValuesCols.begin(); i != m_onlyValuesCols.end(); i++) { | ||
577 | ui.cbCol3->addItem( (*i)->name(), qint64(*i)); | ||||
578 | } | ||||
537 | } | 579 | } | ||
538 | break; | 580 | break; | ||
539 | } | 581 | } | ||
Context not available. |