mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-27 20:44:13 +02:00
Merge pull request #1083 from ispyisail/feature/search-tree-option
Add a setting to show collection search results as a tree
This commit is contained in:
@@ -1103,7 +1103,32 @@ void ElementsCollectionWidget::search()
|
||||
return;
|
||||
}
|
||||
|
||||
showFlatResults(rankedSearch(text, m_showed_index));
|
||||
QSettings settings;
|
||||
if (settings.value(QStringLiteral("elementscollection/search-flat-list"),
|
||||
true).toBool())
|
||||
{
|
||||
showFlatResults(rankedSearch(text, m_showed_index));
|
||||
return;
|
||||
}
|
||||
|
||||
//Tree search: hide what does not match, expand what does.
|
||||
clearFlatResults();
|
||||
hideCollection(true);
|
||||
const QStringList text_list = text.split("+", Qt::SkipEmptyParts);
|
||||
QModelIndexList match_index;
|
||||
for (const 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),
|
||||
Qt::UserRole+1,
|
||||
QVariant(txt),
|
||||
-1,
|
||||
Qt::MatchContains
|
||||
| Qt::MatchRecursive);
|
||||
}
|
||||
|
||||
for (const QModelIndex &index : std::as_const(match_index))
|
||||
showAndExpandItem(index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,6 +70,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
//Stored as "inserts" but presented as "edits", so the default (insert)
|
||||
//is the unchecked state -- a preference reads better as an opt-out.
|
||||
ui->m_collection_dblclick_edits->setChecked(!settings.value("elementscollection/double-click-inserts", true).toBool());
|
||||
ui->m_collection_search_flat_cb->setChecked(settings.value("elementscollection/search-flat-list", true).toBool());
|
||||
ui->m_context_toolbar_cb->setChecked(settings.value("diagrameditor/context_toolbar", true).toBool());
|
||||
ui->m_mouse_gestures_cb->setChecked(settings.value("diagrameditor/mouse_gestures", true).toBool());
|
||||
ui->DiagramEditor_xGrid_sb->setValue(settings.value("diagrameditor/Xgrid", 10).toInt());
|
||||
@@ -302,6 +303,7 @@ void GeneralConfigurationPage::applyConf()
|
||||
settings.setValue("diagrameditor/grid_display_startup", ui->grid_startup_cb->isChecked());
|
||||
settings.setValue("diagrameditor/guides_display_startup", ui->guides_startup_cb->isChecked());
|
||||
settings.setValue("elementscollection/double-click-inserts", !ui->m_collection_dblclick_edits->isChecked());
|
||||
settings.setValue("elementscollection/search-flat-list", ui->m_collection_search_flat_cb->isChecked());
|
||||
settings.setValue("diagrameditor/context_toolbar", ui->m_context_toolbar_cb->isChecked());
|
||||
settings.setValue("diagrameditor/mouse_gestures", ui->m_mouse_gestures_cb->isChecked());
|
||||
//Grid step and key navigation
|
||||
|
||||
@@ -94,6 +94,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_collection_search_flat_cb">
|
||||
<property name="toolTip">
|
||||
<string>Coché : une seule liste, la meilleure correspondance en premier. Décoché : l'arborescence de la collection, filtrée sur la recherche.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Afficher les résultats de recherche sous forme de liste triée</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_context_toolbar_cb">
|
||||
<property name="toolTip">
|
||||
|
||||
Reference in New Issue
Block a user