forked from qt-creator/qt-creator
Core: Allow to pass a reason for a failed search
... and make use of it in the LanguageClient. Change-Id: I7e47a7419c7168c5e26709ae225e4887d4c5089b Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -103,9 +103,9 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
|
|||||||
auto messageLayout = new QHBoxLayout(m_messageWidget);
|
auto messageLayout = new QHBoxLayout(m_messageWidget);
|
||||||
messageLayout->setContentsMargins(2, 2, 2, 2);
|
messageLayout->setContentsMargins(2, 2, 2, 2);
|
||||||
m_messageWidget->setLayout(messageLayout);
|
m_messageWidget->setLayout(messageLayout);
|
||||||
QLabel *messageLabel = new QLabel(tr("Search was canceled."));
|
m_messageLabel = new QLabel;
|
||||||
messageLabel->setPalette(pal);
|
m_messageLabel->setPalette(pal);
|
||||||
messageLayout->addWidget(messageLabel);
|
messageLayout->addWidget(m_messageLabel);
|
||||||
layout->addWidget(m_messageWidget);
|
layout->addWidget(m_messageWidget);
|
||||||
m_messageWidget->setVisible(false);
|
m_messageWidget->setVisible(false);
|
||||||
|
|
||||||
@@ -435,7 +435,7 @@ void SearchResultWidget::setReplaceEnabled(bool enabled)
|
|||||||
m_replaceButton->setEnabled(enabled);
|
m_replaceButton->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchResultWidget::finishSearch(bool canceled)
|
void SearchResultWidget::finishSearch(bool canceled, const QString &reason)
|
||||||
{
|
{
|
||||||
Id sizeWarningId(SIZE_WARNING_ID);
|
Id sizeWarningId(SIZE_WARNING_ID);
|
||||||
m_infoBar.removeInfo(sizeWarningId);
|
m_infoBar.removeInfo(sizeWarningId);
|
||||||
@@ -444,6 +444,8 @@ void SearchResultWidget::finishSearch(bool canceled)
|
|||||||
m_replaceButton->setEnabled(m_count > 0);
|
m_replaceButton->setEnabled(m_count > 0);
|
||||||
m_preserveCaseCheck->setEnabled(m_count > 0);
|
m_preserveCaseCheck->setEnabled(m_count > 0);
|
||||||
m_cancelButton->setVisible(false);
|
m_cancelButton->setVisible(false);
|
||||||
|
if (canceled)
|
||||||
|
m_messageLabel->setText(reason.isEmpty() ? tr("Search was canceled.") : reason);
|
||||||
m_messageWidget->setVisible(canceled);
|
m_messageWidget->setVisible(canceled);
|
||||||
m_searchAgainButton->setVisible(m_searchAgainSupported);
|
m_searchAgainButton->setVisible(m_searchAgainSupported);
|
||||||
m_searching = false;
|
m_searching = false;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
void setReplaceEnabled(bool enabled);
|
void setReplaceEnabled(bool enabled);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void finishSearch(bool canceled);
|
void finishSearch(bool canceled, const QString &reason);
|
||||||
void sendRequestPopup();
|
void sendRequestPopup();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -118,6 +118,7 @@ private:
|
|||||||
QWidget *m_descriptionContainer = nullptr;
|
QWidget *m_descriptionContainer = nullptr;
|
||||||
QLabel *m_label = nullptr;
|
QLabel *m_label = nullptr;
|
||||||
QLabel *m_searchTerm = nullptr;
|
QLabel *m_searchTerm = nullptr;
|
||||||
|
QLabel *m_messageLabel = nullptr;
|
||||||
QToolButton *m_cancelButton = nullptr;
|
QToolButton *m_cancelButton = nullptr;
|
||||||
QLabel *m_matchesFoundLabel = nullptr;
|
QLabel *m_matchesFoundLabel = nullptr;
|
||||||
bool m_preserveCaseSupported = true;
|
bool m_preserveCaseSupported = true;
|
||||||
|
|||||||
@@ -838,9 +838,9 @@ void SearchResult::setFilter(SearchResultFilter *filter)
|
|||||||
Notifies the \uicontrol {Search Results} output pane that the current search
|
Notifies the \uicontrol {Search Results} output pane that the current search
|
||||||
has been \a canceled, and the UI should reflect that.
|
has been \a canceled, and the UI should reflect that.
|
||||||
*/
|
*/
|
||||||
void SearchResult::finishSearch(bool canceled)
|
void SearchResult::finishSearch(bool canceled, const QString &reason)
|
||||||
{
|
{
|
||||||
m_widget->finishSearch(canceled);
|
m_widget->finishSearch(canceled, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public slots:
|
|||||||
void addResult(const SearchResultItem &item);
|
void addResult(const SearchResultItem &item);
|
||||||
void addResults(const QList<SearchResultItem> &items, AddMode mode);
|
void addResults(const QList<SearchResultItem> &items, AddMode mode);
|
||||||
void setFilter(SearchResultFilter *filter); // Takes ownership
|
void setFilter(SearchResultFilter *filter); // Takes ownership
|
||||||
void finishSearch(bool canceled);
|
void finishSearch(bool canceled, const QString &reason = {});
|
||||||
void setTextToReplace(const QString &textToReplace);
|
void setTextToReplace(const QString &textToReplace);
|
||||||
void restart();
|
void restart();
|
||||||
void setReplaceEnabled(bool enabled);
|
void setReplaceEnabled(bool enabled);
|
||||||
|
|||||||
@@ -401,8 +401,11 @@ void SymbolSupport::handleRenameResponse(Core::SearchResult *search,
|
|||||||
const RenameRequest::Response &response)
|
const RenameRequest::Response &response)
|
||||||
{
|
{
|
||||||
const std::optional<PrepareRenameRequest::Response::Error> &error = response.error();
|
const std::optional<PrepareRenameRequest::Response::Error> &error = response.error();
|
||||||
if (error.has_value())
|
QString errorMessage;
|
||||||
|
if (error.has_value()) {
|
||||||
m_client->log(*error);
|
m_client->log(*error);
|
||||||
|
errorMessage = error->toString();
|
||||||
|
}
|
||||||
|
|
||||||
const std::optional<WorkspaceEdit> &edits = response.result();
|
const std::optional<WorkspaceEdit> &edits = response.result();
|
||||||
if (edits.has_value()) {
|
if (edits.has_value()) {
|
||||||
@@ -412,7 +415,7 @@ void SymbolSupport::handleRenameResponse(Core::SearchResult *search,
|
|||||||
search->setSearchAgainEnabled(false);
|
search->setSearchAgainEnabled(false);
|
||||||
search->finishSearch(false);
|
search->finishSearch(false);
|
||||||
} else {
|
} else {
|
||||||
search->finishSearch(error.has_value());
|
search->finishSearch(error.has_value(), errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user