Changeset View
Changeset View
Standalone View
Standalone View
plugins/quickopen/quickopenwidget.cpp
Context not available. | |||||
198 | ui.list->setModel( nullptr ); | 198 | ui.list->setModel( nullptr ); | ||
---|---|---|---|---|---|
199 | ui.list->setVerticalScrollMode(QAbstractItemView::ScrollPerItem); | 199 | ui.list->setVerticalScrollMode(QAbstractItemView::ScrollPerItem); | ||
200 | m_model->setTreeView( ui.list ); | 200 | m_model->setTreeView( ui.list ); | ||
201 | ui.list->setModel( m_model ); | 201 | | ||
202 | m_proxy = new QSortFilterProxyModel; | ||||
203 | m_proxy->setSourceModel(m_model); | ||||
204 | m_proxy->setDynamicSortFilter(true); | ||||
205 | if( m_model->allScopes().isEmpty() && m_model->allTypes().isEmpty() ) | ||||
206 | m_proxy->sort(1); | ||||
207 | | ||||
208 | m_model->setProxyModel(m_proxy); | ||||
209 | | ||||
210 | ui.list->setModel( m_proxy ); | ||||
202 | 211 | | |||
203 | m_filterTimer.stop(); | 212 | m_filterTimer.stop(); | ||
204 | m_filter = QString(); | 213 | m_filter = QString(); | ||
Context not available. | |||||
223 | } | 232 | } | ||
224 | 233 | | |||
225 | QuickOpenWidget::~QuickOpenWidget() { | 234 | QuickOpenWidget::~QuickOpenWidget() { | ||
235 | delete m_proxy; | ||||
236 | m_model->setProxyModel( nullptr ); | ||||
226 | m_model->setTreeView( nullptr ); | 237 | m_model->setTreeView( nullptr ); | ||
227 | } | 238 | } | ||
228 | 239 | | |||
Context not available. | |||||
311 | m_model->textChanged( m_filter ); | 322 | m_model->textChanged( m_filter ); | ||
312 | 323 | | |||
313 | QModelIndex currentIndex = m_model->index(0, 0, QModelIndex()); | 324 | QModelIndex currentIndex = m_model->index(0, 0, QModelIndex()); | ||
314 | ui.list->selectionModel()->setCurrentIndex( currentIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows | QItemSelectionModel::Current ); | 325 | | ||
326 | ui.list->selectionModel()->setCurrentIndex( m_proxy->mapFromSource( currentIndex ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows | QItemSelectionModel::Current ); | ||||
315 | 327 | | |||
316 | callRowSelected(); | 328 | callRowSelected(); | ||
317 | } | 329 | } | ||
Context not available. | |||||
326 | 338 | | |||
327 | void QuickOpenWidget::accept() { | 339 | void QuickOpenWidget::accept() { | ||
328 | QString filterText = ui.searchLine->text(); | 340 | QString filterText = ui.searchLine->text(); | ||
329 | m_model->execute( ui.list->currentIndex(), filterText ); | 341 | m_model->execute( m_proxy->mapToSource( ui.list->currentIndex() ), filterText ); | ||
330 | } | 342 | } | ||
331 | 343 | | |||
332 | void QuickOpenWidget::doubleClicked ( const QModelIndex & index ) { | 344 | void QuickOpenWidget::doubleClicked ( const QModelIndex & index ) { | ||
Context not available. | |||||
490 | //which kills the quickopen widget. | 502 | //which kills the quickopen widget. | ||
491 | QPointer<QObject> stillExists(this); | 503 | QPointer<QObject> stillExists(this); | ||
492 | 504 | | |||
493 | if( m_model->execute( ui.list->currentIndex(), filterText ) ) { | 505 | if( m_model->execute( m_proxy->mapToSource( ui.list->currentIndex() ), filterText ) ) { | ||
494 | 506 | | |||
495 | if(!stillExists) | 507 | if(!stillExists) | ||
496 | return true; | 508 | return true; | ||
Context not available. |