From 99a2f0f807b2498dff3982c78ec65b51d7e039bd Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 25 Aug 2016 19:32:59 +0300 Subject: [PATCH] Fixed issue #553. Tape.exe crash. Issue with the Search field. (grafted from c4cc1aca74cb29d3fb57cd0718ec282b3dd0dc7b) --HG-- branch : develop --- ChangeLog.txt | 3 +- src/libs/vmisc/vtablesearch.cpp | 50 ++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index b970dacc5..4fac8d9b1 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -58,7 +58,8 @@ - [#544] Error: Color Lines are black until touched. - [#543] Detail loses details. - [#548] Bug Detail tool. Case when seam allowance is wrong. -- Called the main app in console mode doesn't show opening file error in some cases. +- Called the main app in console mode doesn't show opening file error in some cases. +- [#553] Tape.exe crash. Issue with the Search field. # Version 0.4.4 April 12, 2016 - Updated measurement templates with all measurements. Added new template Aldrich/Women measurements. diff --git a/src/libs/vmisc/vtablesearch.cpp b/src/libs/vmisc/vtablesearch.cpp index ec7c36cb6..e33498572 100644 --- a/src/libs/vmisc/vtablesearch.cpp +++ b/src/libs/vmisc/vtablesearch.cpp @@ -49,17 +49,25 @@ void VTableSearch::Clear() { SCASSERT(table != nullptr); - foreach(QTableWidgetItem *item, searchList) + for(int i = 0; i < table->rowCount(); ++i) { - if (item->row() % 2 != 0 && table->alternatingRowColors()) + for(int j = 0; j < table->columnCount(); ++j) { - item->setBackground(QPalette().alternateBase()); - } - else - { - item->setBackground(QPalette().base()); + if (QTableWidgetItem *item = table->item(i, j)) + { + if (item->row() % 2 != 0 && table->alternatingRowColors()) + { + item->setBackground(QPalette().alternateBase()); + } + else + { + item->setBackground(QPalette().base()); + } + } } } + + searchList.clear(); searchIndex = -1; } @@ -87,26 +95,24 @@ void VTableSearch::Find(const QString &term) { SCASSERT(table != nullptr); - const QList list = table->findItems(term, Qt::MatchContains); + Clear(); - if (list.isEmpty() || term.isEmpty()) + if (not term.isEmpty()) { - Clear(); - } - else - { - Clear(); + searchList = table->findItems(term, Qt::MatchContains); - searchList = list; - foreach(QTableWidgetItem *item, searchList) + if (not searchList.isEmpty()) { - item->setBackground(Qt::yellow); - } + foreach(QTableWidgetItem *item, searchList) + { + item->setBackground(Qt::yellow); + } - searchIndex = 0; - QTableWidgetItem *item = searchList.at(searchIndex); - item->setBackground(Qt::red); - table->scrollToItem(item); + searchIndex = 0; + QTableWidgetItem *item = searchList.at(searchIndex); + item->setBackground(Qt::red); + table->scrollToItem(item); + } } }