forked from qt-creator/qt-creator
Search results: Open editor on pressing enter on file item
Only do that on enter/return, not on double-click which also expands the item (we don't want double-click to do both). Task-number: QTCREATORBUG-18200 Change-Id: Ib4f939a76054832f12b84c8e4353b88e010f1126 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -78,6 +78,21 @@ void SearchResultTreeView::addResults(const QList<SearchResultItem> &items, Sear
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchResultTreeView::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if ((event->key() == Qt::Key_Return
|
||||||
|
|| event->key() == Qt::Key_Enter)
|
||||||
|
&& event->modifiers() == 0
|
||||||
|
&& currentIndex().isValid()
|
||||||
|
&& state() != QAbstractItemView::EditingState) {
|
||||||
|
const SearchResultItem item
|
||||||
|
= model()->data(currentIndex(), ItemDataRoles::ResultItemRole).value<SearchResultItem>();
|
||||||
|
emit jumpToSearchResult(item);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TreeView::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void SearchResultTreeView::emitJumpToSearchResult(const QModelIndex &index)
|
void SearchResultTreeView::emitJumpToSearchResult(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
if (model()->data(index, ItemDataRoles::IsGeneratedRole).toBool())
|
if (model()->data(index, ItemDataRoles::IsGeneratedRole).toBool())
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ public:
|
|||||||
SearchResultTreeModel *model() const;
|
SearchResultTreeModel *model() const;
|
||||||
void addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode);
|
void addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode);
|
||||||
|
|
||||||
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void jumpToSearchResult(const SearchResultItem &item);
|
void jumpToSearchResult(const SearchResultItem &item);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user