mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
ElementCollectionWidgetWidget : Set search start when text to search have at least 3 letters.
The goal is to avoid gui freeze when search for 1 or 2 letters (in this case qet search for every item and take a lot of time).
This commit is contained in:
@@ -741,17 +741,22 @@ void ElementsCollectionWidget::search()
|
||||
return;
|
||||
}
|
||||
|
||||
//start the search when text have at least 3 letters.
|
||||
if (text.count() < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
hideCollection(true);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||
QStringList text_list = text.split("+", QString::SkipEmptyParts);
|
||||
const QStringList text_list = text.split("+", QString::SkipEmptyParts);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 5.14 or later")
|
||||
#endif
|
||||
QStringList text_list = text.split("+", Qt::SkipEmptyParts);
|
||||
const QStringList text_list = text.split("+", Qt::SkipEmptyParts);
|
||||
#endif
|
||||
QModelIndexList match_index;
|
||||
foreach (QString txt, text_list) {
|
||||
for (QString txt : text_list) {
|
||||
match_index << m_model->match(m_showed_index.isValid()
|
||||
? m_model->index(0,0,m_showed_index)
|
||||
: m_model->index(0,0),
|
||||
@@ -762,7 +767,7 @@ void ElementsCollectionWidget::search()
|
||||
| Qt::MatchRecursive);
|
||||
}
|
||||
|
||||
foreach(QModelIndex index, match_index)
|
||||
for(QModelIndex index : match_index)
|
||||
showAndExpandItem(index);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user