mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-12 15:14:12 +02:00
Add a setting to show collection search results as a tree
#1051 replaced the filtered tree with a ranked flat list. A new checkbox in Settings > General, "Afficher les résultats de recherche sous forme de liste triée" (elementscollection/search-flat-list, default on), keeps the ranked list; unticked restores the pre-#1051 filtered tree search. The Insert picker and shortcut bar call rankedSearch() directly and are unaffected. Down/Enter from the search field only apply to the flat list. Requested by scorpio810 on #1051. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G2d2Zi8BfrYRPX88zhaoFG
This commit is contained in:
@@ -1103,7 +1103,32 @@ void ElementsCollectionWidget::search()
|
|||||||
return;
|
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)
|
//Stored as "inserts" but presented as "edits", so the default (insert)
|
||||||
//is the unchecked state -- a preference reads better as an opt-out.
|
//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_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_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->m_mouse_gestures_cb->setChecked(settings.value("diagrameditor/mouse_gestures", true).toBool());
|
||||||
ui->DiagramEditor_xGrid_sb->setValue(settings.value("diagrameditor/Xgrid", 10).toInt());
|
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/grid_display_startup", ui->grid_startup_cb->isChecked());
|
||||||
settings.setValue("diagrameditor/guides_display_startup", ui->guides_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/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/context_toolbar", ui->m_context_toolbar_cb->isChecked());
|
||||||
settings.setValue("diagrameditor/mouse_gestures", ui->m_mouse_gestures_cb->isChecked());
|
settings.setValue("diagrameditor/mouse_gestures", ui->m_mouse_gestures_cb->isChecked());
|
||||||
//Grid step and key navigation
|
//Grid step and key navigation
|
||||||
|
|||||||
@@ -94,6 +94,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<widget class="QCheckBox" name="m_context_toolbar_cb">
|
<widget class="QCheckBox" name="m_context_toolbar_cb">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
|||||||
Reference in New Issue
Block a user