diff --git a/src/mumble/SearchDialog.cpp b/src/mumble/SearchDialog.cpp index dd1ac8a67c0..cc8cd9112fa 100644 --- a/src/mumble/SearchDialog.cpp +++ b/src/mumble/SearchDialog.cpp @@ -4,6 +4,7 @@ // Mumble source tree or at . #include "SearchDialog.h" +#include "Accessibility.h" #include "Channel.h" #include "ClientUser.h" #include "MainWindow.h" @@ -26,6 +27,8 @@ #include +#include + namespace Search { QString SearchDialog::toString(UserAction action) { @@ -245,6 +248,31 @@ void SearchDialog::on_searchResultTree_itemActivated(QTreeWidgetItem *item, int) } } +void SearchDialog::on_searchResultTree_itemChanged(QTreeWidgetItem *c, int column) { + if (!c || column != 0 || Global::get().uiSession == 0) { + return; + } + + SearchResultItem &item = static_cast< SearchResultItem & >(*c); + if (item.getResult().type == SearchType::User) { + const ClientUser *user = ClientUser::get(item.getID()); + + if (user) { + item.setData(1, Qt::AccessibleTextRole, Mumble::Accessibility::userToText(user)); + item.setData(1, Qt::AccessibleDescriptionRole, Mumble::Accessibility::userToText(user)); + qDebug() << Mumble::Accessibility::userToText(user); + } + } else { + const Channel *channel = Channel::get(static_cast< int >(item.getID())); + + if (channel) { + item.setData(1, Qt::AccessibleTextRole, Mumble::Accessibility::channelToText(channel)); + item.setData(1, Qt::AccessibleDescriptionRole, Mumble::Accessibility::channelToText(channel)); + qDebug() << Mumble::Accessibility::channelToText(channel); + } + } +} + void SearchDialog::searchAgain() { search(searchField->text()); } diff --git a/src/mumble/SearchDialog.h b/src/mumble/SearchDialog.h index 7ddc7ce1825..c5c2f616717 100644 --- a/src/mumble/SearchDialog.h +++ b/src/mumble/SearchDialog.h @@ -117,6 +117,7 @@ public slots: void on_regexOption_clicked(bool checked); void on_searchResultTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); void on_searchResultTree_itemActivated(QTreeWidgetItem *item, int column); + void on_searchResultTree_itemChanged(QTreeWidgetItem *item, int column); void searchAgain(); void clearSearchResults(); void search(const QString &searchTerm); diff --git a/src/mumble/SearchDialog.ui b/src/mumble/SearchDialog.ui index 4885fddda53..ee026eed7a7 100644 --- a/src/mumble/SearchDialog.ui +++ b/src/mumble/SearchDialog.ui @@ -58,6 +58,9 @@ + + Qt::StrongFocus + Search results diff --git a/src/mumble/widgets/SearchDialogTree.cpp b/src/mumble/widgets/SearchDialogTree.cpp index 5be761f5c6b..0f981170b20 100644 --- a/src/mumble/widgets/SearchDialogTree.cpp +++ b/src/mumble/widgets/SearchDialogTree.cpp @@ -6,6 +6,7 @@ #include "SearchDialogTree.h" #include +#include void SearchDialogTree::resizeEvent(QResizeEvent *event) { // We have to update the layout on every resize since we have wrapping text that is displayed in the @@ -17,3 +18,15 @@ void SearchDialogTree::resizeEvent(QResizeEvent *event) { scheduleDelayedItemsLayout(); } + +QModelIndex SearchDialogTree::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) { + QModelIndex mi = QTreeWidget::moveCursor(cursorAction, modifiers); + + if (cursorAction == QAbstractItemView::MoveUp || cursorAction == QAbstractItemView::MoveDown) { + mi = model()->index(mi.row(), 1); + } + + qDebug() << mi; + + return mi; +} diff --git a/src/mumble/widgets/SearchDialogTree.h b/src/mumble/widgets/SearchDialogTree.h index 36fc75e58e6..2914956f942 100644 --- a/src/mumble/widgets/SearchDialogTree.h +++ b/src/mumble/widgets/SearchDialogTree.h @@ -7,6 +7,8 @@ #define MUMBLE_MUMBLE_WIDGETS_SEARCHDIALOGTREE_H_ #include +#include +#include class QResizeEvent; @@ -14,6 +16,8 @@ class SearchDialogTree : public QTreeWidget { public: using QTreeWidget::QTreeWidget; + QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override; + protected: void resizeEvent(QResizeEvent *event) override; };