Overview
TheSearchSidebar class (Zeal::WidgetUi::SearchSidebar) provides the search interface and docset navigation for Zeal. It inherits from Sidebar::View and displays both the docset index tree and search results.
Header: src/libs/ui/searchsidebar.h
Namespace: Zeal::WidgetUi
Constructor
parent- Optional parent widget (defaults to nullptr)
- Creates search edit widget with completions
- Sets up tree view for displaying docset index and search results
- Creates list view for page table of contents (TOC)
- Configures keyboard shortcuts (Alt+Up/Down/PageUp/PageDown/Home/End)
- Connects to docset registry for search updates
- Initializes with docset index model
src/libs/ui/searchsidebar.cpp:34
Copy Constructor
other- Source sidebar to cloneparent- Optional parent widget
- Copies search query text
- Clones search model
- Restores expanded items
- Preserves selection state
- Maintains scroll position
src/libs/ui/searchsidebar.cpp:39
Public Methods
clone
parent- Optional parent widget for the clone
SearchSidebar instance
Reference: src/libs/ui/searchsidebar.cpp:277
pageTocModel
SearchModel
Usage: The returned model is used by browser tabs to populate the TOC with the current page’s headings.
Reference: src/libs/ui/searchsidebar.cpp:282
Signals
activated
navigationRequested
url- URL of the documentation page to navigate to
Public Slots
focusSearchEdit
clear- If true, clears the current search query
- If sidebar is not visible, sets a pending focus flag to focus when shown
- Otherwise, immediately focuses the search edit
- Optionally clears the query text
src/libs/ui/searchsidebar.cpp:287
search
query- Search query to execute
- Converts query to string and sets it in the search edit
- Triggers search through the text changed signal
src/libs/ui/searchsidebar.cpp:301
Private Slots
navigateToIndex
index- Model index of the entry to navigate to
- Cancels any pending delayed navigation
- Extracts URL from model index data
- Emits
navigationRequestedsignal
src/libs/ui/searchsidebar.cpp:307
navigateToIndexAndActivate
index- Model index of the entry
- Emits
navigationRequestedwith the entry URL - Emits
activatedsignal
src/libs/ui/searchsidebar.cpp:323
navigateToSelectionWithDelay
selection- New selection
- Stores the selected index
- Starts a 400ms timer before navigating
- Allows user to continue typing without interrupting with navigation
src/libs/ui/searchsidebar.cpp:334
setupSearchBoxCompletions
- Collects first keyword from each loaded docset
- Adds colon suffix (e.g., “qt:”, “python:”)
- Enables scoped search by docset
src/libs/ui/searchsidebar.cpp:344
Protected Methods
eventFilter
- Enter/Return: Emits
activatedsignal - Arrow keys, Page Up/Down, Home/End: Forwarded to tree view
- Left/Right only forwarded when search edit is empty
src/libs/ui/searchsidebar.cpp:362
showEvent
- Restores scroll position if pending
- Focuses search edit if pending focus flag is set
src/libs/ui/searchsidebar.cpp:391
UI Components
Search Edit
- Custom
SearchEditwidget with auto-completion - Supports docset scoping (e.g., “qt:qwidget”)
- Provides instant search as user types
- Keyboard navigation integration
Tree View
Displays either:- Docset index: When search edit is empty
- Hierarchical tree structure
- Root items are docsets
- Children are documentation entries
- Search results: When search query is present
- Flat list grouped by relevance
- Highlighted search matches
- Custom
SearchItemDelegatefor styling - Preserves expanded state across searches
- Uniform row heights for performance
src/libs/ui/searchsidebar.cpp:43
Page TOC View
- Separate list view for table of contents
- Displays headings from current page
- Hidden when TOC is empty
- Positioned below tree view in vertical splitter
src/libs/ui/searchsidebar.cpp:88
Splitter
- Vertical splitter between tree view and TOC view
- Saves/restores state in application settings
- Allows user to resize TOC height
src/libs/ui/searchsidebar.cpp:186
Search Behavior
Instant Search
Search is triggered automatically as the user types:src/libs/ui/searchsidebar.cpp:150
Delayed Navigation
Navigation to selected results is delayed by 400ms to avoid interrupting the user while typing:src/libs/ui/searchsidebar.cpp:202
Search Result Updates
Connects to docset registry search completion:src/libs/ui/searchsidebar.cpp:216
Integration with DocsetRegistry
The sidebar integrates tightly withRegistry::DocsetRegistry:
Search Execution
Search queries are forwarded to the registry:Docset Events
Listens for docset lifecycle events:- Docset loaded: Refreshes search completions
- Docset unloaded: Removes results from that docset, refreshes completions
src/libs/ui/searchsidebar.cpp:232
Search Model
UsesRegistry::SearchModel to manage search results:
- Receives results from registry
- Provides model interface for tree view
- Supports filtering by docset name
Keyboard Shortcuts
Alt+Navigation Keys
Allows navigating the tree view while focused on search edit:- Alt+Up/Down: Move selection up/down
- Alt+PageUp/PageDown: Jump page up/down
- Alt+Home/End: Jump to first/last item
src/libs/ui/searchsidebar.cpp:75
Search Edit Keys
- Enter: Activate selected result
- Arrow keys: Navigate tree (when appropriate)
- Escape: Clear search (handled by parent window)
State Preservation
When cloning for tab duplication, preserves:- Search query text
- Expanded tree items
- Current selection
- Scroll position
- TOC state
src/libs/ui/searchsidebar.cpp:118
Example Usage
Performance Considerations
Deferred Updates
When docsets are unloaded while sidebar is not visible, updates are deferred:src/libs/ui/searchsidebar.cpp:233