| 913 | } |
| 914 | |
| 915 | void AddSubtractValueDialog::generateForMatrices() { |
| 916 | Q_ASSERT(m_matrix); |
| 917 | |
| 918 | WAIT_CURSOR; |
| 919 | |
| 920 | QString msg = getMessage(m_matrix->name()); |
| 921 | auto mode = m_matrix->mode(); |
| 922 | bool ok; |
| 923 | const int rows = m_matrix->rowCount(); |
| 924 | const int cols = m_matrix->columnCount(); |
| 925 | |
| 926 | if (mode == AbstractColumn::ColumnMode::Integer) { |
| 927 | int value; |
| 928 | ok = setIntValue(value); |
| 929 | |
| 930 | if (!ok) { |
| 931 | RESET_CURSOR; |
| 932 | KMessageBox::error(this, i18n("Wrong numeric value provided.")); |
| 933 | return; |
| 934 | } |
| 935 | |
| 936 | int new_data; |
| 937 | m_matrix->beginMacro(msg); |
| 938 | |
| 939 | switch (m_operation) { |
| 940 | case Subtract: |
| 941 | value *= -1; |
| 942 | [[fallthrough]]; |
| 943 | case Add: |
| 944 | for (int i = 0; i < rows; ++i) |
| 945 | for (int j = 0; j < cols; ++j) { |
| 946 | new_data = m_matrix->cell<int>(i, j); |
| 947 | new_data += value; |
| 948 | m_matrix->setCell(i, j, new_data); |
| 949 | } |
| 950 | break; |
| 951 | case Multiply: |
| 952 | for (int i = 0; i < rows; ++i) |
| 953 | for (int j = 0; j < cols; ++j) { |
| 954 | new_data = m_matrix->cell<int>(i, j); |
| 955 | new_data *= value; |
| 956 | m_matrix->setCell(i, j, new_data); |
| 957 | } |
| 958 | break; |
| 959 | case Divide: |
| 960 | for (int i = 0; i < rows; ++i) |
| 961 | for (int j = 0; j < cols; ++j) { |
| 962 | new_data = m_matrix->cell<int>(i, j); |
| 963 | new_data /= value; |
| 964 | m_matrix->setCell(i, j, new_data); |
| 965 | } |
| 966 | break; |
| 967 | case SubtractBaseline: |
| 968 | break; |
| 969 | } |
| 970 | } else if (mode == AbstractColumn::ColumnMode::BigInt) { |
| 971 | qint64 value; |
| 972 | ok = setBigIntValue(value); |
nothing calls this directly
no test coverage detected