2016-11-02 21:01:02 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Jonathan White <support@dmapps.us>
|
2017-06-09 17:40:36 -04:00
|
|
|
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
|
2016-11-02 21:01:02 -04:00
|
|
|
*
|
|
|
|
* This program 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 2 or (at your option)
|
|
|
|
* version 3 of the License.
|
|
|
|
*
|
|
|
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KEEPASSX_SEARCHWIDGET_H
|
|
|
|
#define KEEPASSX_SEARCHWIDGET_H
|
|
|
|
|
|
|
|
#include <QTimer>
|
2017-05-11 14:36:06 -04:00
|
|
|
#include <QWidget>
|
2016-11-02 21:01:02 -04:00
|
|
|
|
|
|
|
#include "core/SignalMultiplexer.h"
|
2017-05-11 14:36:06 -04:00
|
|
|
#include "gui/DatabaseWidget.h"
|
2016-11-02 21:01:02 -04:00
|
|
|
|
2018-03-31 16:01:30 -04:00
|
|
|
namespace Ui
|
|
|
|
{
|
2016-11-02 21:01:02 -04:00
|
|
|
class SearchWidget;
|
|
|
|
}
|
|
|
|
|
2018-11-01 21:33:27 -04:00
|
|
|
class PopupHelpWidget;
|
|
|
|
|
2016-11-02 21:01:02 -04:00
|
|
|
class SearchWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-10-28 10:47:24 -04:00
|
|
|
explicit SearchWidget(QWidget* parent = nullptr);
|
2018-03-19 23:16:22 -04:00
|
|
|
~SearchWidget() override;
|
|
|
|
|
|
|
|
Q_DISABLE_COPY(SearchWidget)
|
2016-11-02 21:01:02 -04:00
|
|
|
|
|
|
|
void connectSignals(SignalMultiplexer& mx);
|
2016-11-28 19:02:21 -05:00
|
|
|
void setCaseSensitive(bool state);
|
2017-06-20 15:54:13 -04:00
|
|
|
void setLimitGroup(bool state);
|
2016-11-02 21:01:02 -04:00
|
|
|
|
2016-12-23 23:14:50 -05:00
|
|
|
protected:
|
2018-11-01 21:33:27 -04:00
|
|
|
// Filter key presses in the search field
|
2018-03-19 23:16:22 -04:00
|
|
|
bool eventFilter(QObject* obj, QEvent* event) override;
|
2016-12-23 23:14:50 -05:00
|
|
|
|
2016-11-02 21:01:02 -04:00
|
|
|
signals:
|
2017-05-11 14:36:06 -04:00
|
|
|
void search(const QString& text);
|
2016-11-28 19:02:21 -05:00
|
|
|
void caseSensitiveChanged(bool state);
|
2017-06-20 15:54:13 -04:00
|
|
|
void limitGroupChanged(bool state);
|
2016-12-22 02:21:52 -05:00
|
|
|
void escapePressed();
|
|
|
|
void copyPressed();
|
|
|
|
void downPressed();
|
2017-01-04 20:46:52 -05:00
|
|
|
void enterPressed();
|
2016-11-02 21:01:02 -04:00
|
|
|
|
|
|
|
public slots:
|
2018-10-28 10:47:24 -04:00
|
|
|
void databaseChanged(DatabaseWidget* dbWidget = nullptr);
|
2016-11-02 21:01:02 -04:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void startSearchTimer();
|
|
|
|
void startSearch();
|
|
|
|
void updateCaseSensitive();
|
2017-06-20 15:54:13 -04:00
|
|
|
void updateLimitGroup();
|
2017-01-04 20:46:52 -05:00
|
|
|
void searchFocus();
|
2018-11-01 21:33:27 -04:00
|
|
|
void toggleHelp();
|
2016-11-02 21:01:02 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
const QScopedPointer<Ui::SearchWidget> m_ui;
|
2018-11-01 21:33:27 -04:00
|
|
|
PopupHelpWidget* m_helpWidget;
|
2016-11-02 21:01:02 -04:00
|
|
|
QTimer* m_searchTimer;
|
2018-11-15 17:37:16 -05:00
|
|
|
QTimer* m_clearSearchTimer;
|
2017-05-11 14:36:06 -04:00
|
|
|
QAction* m_actionCaseSensitive;
|
2017-06-20 15:54:13 -04:00
|
|
|
QAction* m_actionLimitGroup;
|
2016-11-02 21:01:02 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SEARCHWIDGET_H
|