MCPcopy Create free account
hub / github.com/KDE/labplot / maskValues

Method maskValues

src/frontend/spreadsheet/DropValuesDialog.cpp:937–992  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

935};
936
937void DropValuesDialog::maskValues() const {
938 Q_ASSERT(m_spreadsheet);
939
940 // settings for numeric columns
941 const auto op = static_cast<Operator>(ui.cbOperator->currentIndex());
942 const auto numberLocale = QLocale();
943 bool ok;
944 const double value1 = numberLocale.toDouble(ui.leValue1->text(), &ok);
945 if (!ok && m_hasNumeric) {
946 KMessageBox::error(nullptr, i18n("Invalid numeric value."));
947 ui.leValue1->setFocus();
948 return;
949 }
950
951 const double value2 = numberLocale.toDouble(ui.leValue2->text(), &ok);
952 if (ui.leValue2->isVisible() && !ok) {
953 KMessageBox::error(nullptr, i18n("Invalid numeric value."));
954 ui.leValue2->setFocus();
955 return;
956 }
957
958 // settings for text columns
959 const auto opText = static_cast<OperatorText>(ui.cbOperatorText->currentIndex());
960 const auto& valueText = ui.leValueText->text();
961
962 // settings for DateTime columns;
963 const auto opDateTime = static_cast<Operator>(ui.cbOperatorDateTime->currentIndex());
964 double value1DateTime = ui.dteValue1->dateTime().toMSecsSinceEpoch();
965 double value2DateTime = ui.dteValue2->dateTime().toMSecsSinceEpoch();
966
967 WAIT_CURSOR;
968 m_spreadsheet->beginMacro(i18n("%1: mask values", m_spreadsheet->name()));
969 for (auto* col : m_columns) {
970 if (col->isNumeric()) {
971 auto* task = new MaskValuesTask(col, op, value1, value2);
972 task->run();
973 // TODO: writing to the undo-stack in Column::setMasked() is not tread-safe -> redesign
974 // QThreadPool::globalInstance()->start(task);
975 delete task;
976 } else if (col->columnMode() == AbstractColumn::ColumnMode::DateTime) {
977 auto* task = new MaskValuesTask(col, opDateTime, value1DateTime, value2DateTime);
978 task->run();
979 delete task;
980 } else {
981 auto* task = new MaskTextValuesTask(col, opText, valueText);
982 task->run();
983 delete task;
984 }
985 }
986
987 // wait until all columns were processed
988 // QThreadPool::globalInstance()->waitForDone();
989
990 m_spreadsheet->endMacro();
991 RESET_CURSOR;
992}
993
994void DropValuesDialog::dropValues() const {

Callers

nothing calls this directly

Calls 11

beginMacroMethod · 0.80
endMacroMethod · 0.80
currentIndexMethod · 0.45
textMethod · 0.45
setFocusMethod · 0.45
isVisibleMethod · 0.45
dateTimeMethod · 0.45
nameMethod · 0.45
isNumericMethod · 0.45
runMethod · 0.45
columnModeMethod · 0.45

Tested by

no test coverage detected