advanced and data type specific find functions
| 731 | // **** advanced and data type specific find functions **** |
| 732 | // ********************************************************** |
| 733 | bool SearchReplaceWidget::findNext(bool proceed, bool findAndReplace) { |
| 734 | // search pattern(s) |
| 735 | const auto type = static_cast<DataType>(uiSearchReplace.cbDataType->currentIndex()); |
| 736 | QString pattern1; |
| 737 | QString pattern2; |
| 738 | QString replaceValue; |
| 739 | switch (type) { |
| 740 | case DataType::Text: |
| 741 | pattern1 = uiSearchReplace.cbValueText->currentText(); |
| 742 | addCurrentTextToHistory(uiSearchReplace.cbValueText); |
| 743 | if (findAndReplace) { |
| 744 | replaceValue = uiSearchReplace.cbReplaceText->currentText(); |
| 745 | addCurrentTextToHistory(uiSearchReplace.cbReplaceText); |
| 746 | } |
| 747 | break; |
| 748 | case DataType::Numeric: |
| 749 | pattern1 = uiSearchReplace.cbValue1->currentText(); |
| 750 | pattern2 = uiSearchReplace.cbValue2->currentText(); |
| 751 | addCurrentTextToHistory(uiSearchReplace.cbValue1); |
| 752 | addCurrentTextToHistory(uiSearchReplace.cbValue2); |
| 753 | if (findAndReplace) { |
| 754 | replaceValue = uiSearchReplace.cbReplace->currentText(); |
| 755 | addCurrentTextToHistory(uiSearchReplace.cbReplace); |
| 756 | } |
| 757 | break; |
| 758 | case DataType::DateTime: |
| 759 | pattern1 = uiSearchReplace.dteValue1->text(); |
| 760 | pattern2 = uiSearchReplace.dteValue2->text(); |
| 761 | if (findAndReplace) |
| 762 | replaceValue = uiSearchReplace.dteReplace->text(); |
| 763 | break; |
| 764 | } |
| 765 | |
| 766 | if (pattern1.isEmpty()) { |
| 767 | highlight(type, false); |
| 768 | return true; |
| 769 | } |
| 770 | |
| 771 | if (findAndReplace && replaceValue.isEmpty()) |
| 772 | return false; |
| 773 | |
| 774 | // settings |
| 775 | const auto opText = static_cast<OperatorText>(uiSearchReplace.cbOperatorText->currentData().toInt()); |
| 776 | const auto opNumeric = static_cast<Operator>(uiSearchReplace.cbOperator->currentData().toInt()); |
| 777 | const auto opDateTime = static_cast<Operator>(uiSearchReplace.cbOperatorDateTime->currentData().toInt()); |
| 778 | const auto cs = uiSearchReplace.tbMatchCase->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive; |
| 779 | const bool columnMajor = (uiSearchReplace.cbOrder->currentIndex() == 0); |
| 780 | |
| 781 | // spreadsheet size and the start cell |
| 782 | const int colCount = m_spreadsheet->columnCount(); |
| 783 | const int rowCount = m_spreadsheet->rowCount(); |
| 784 | int curRow = m_view->firstSelectedRow(); |
| 785 | int curCol = m_view->firstSelectedColumn(); |
| 786 | |
| 787 | if (columnMajor && proceed) { |
| 788 | if (curRow != rowCount - 1) |
| 789 | ++curRow; // not the last row yet, navigate to the next row |
| 790 | else { |