-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
registry: Allow to cancel current searches
When user types into the search box the previous search is canceled. This improves the speed with which the results can be obtained. Based on #460 plus cosmetic changes. Related to #265, #523.
- Loading branch information
Showing
6 changed files
with
107 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2015 Artur Spychaj | ||
** Contact: http://zealdocs.org/contact.html | ||
** | ||
** This file is part of Zeal. | ||
** | ||
** Zeal is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Zeal is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Zeal. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
****************************************************************************/ | ||
|
||
#include "cancellationtoken.h" | ||
|
||
using namespace Zeal; | ||
|
||
CancellationToken::CancellationToken() | ||
{ | ||
m_cancelled = QSharedPointer<bool>(new bool(false)); | ||
} | ||
|
||
void CancellationToken::cancel() | ||
{ | ||
*m_cancelled = true; | ||
} | ||
|
||
bool CancellationToken::isCanceled() const | ||
{ | ||
return *m_cancelled; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2015 Artur Spychaj | ||
** Contact: http://zealdocs.org/contact.html | ||
** | ||
** This file is part of Zeal. | ||
** | ||
** Zeal is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Zeal is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Zeal. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef CANCELLATIONTOKEN_H | ||
#define CANCELLATIONTOKEN_H | ||
|
||
#include <QSharedPointer> | ||
|
||
namespace Zeal { | ||
|
||
/// Token that stores whether cancel was called on it. | ||
/// In async code can be used to check if another thread called cancel. | ||
struct CancellationToken | ||
{ | ||
public: | ||
CancellationToken(); | ||
bool isCanceled() const; | ||
void cancel(); | ||
|
||
private: | ||
QSharedPointer<bool> m_cancelled; | ||
}; | ||
|
||
} | ||
|
||
Q_DECLARE_METATYPE(Zeal::CancellationToken) | ||
|
||
#endif // CANCELLATIONTOKEN_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters