summaryrefslogtreecommitdiffstats
path: root/src/core/autofill_popup_controller.h
blob: 1b4d8d7e831c717aeb5bca7bd94409ae49fc3c0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef AUTOFILL_POPUP_CONTROLLER_H
#define AUTOFILL_POPUP_CONTROLLER_H

#include <QtWebEngineCore/private/qtwebenginecoreglobal_p.h>

#include <QModelIndex>
#include <QObject>
#include <QScopedPointer>
#include <QStringListModel>

namespace QtWebEngineCore {

class AutofillPopupControllerPrivate;

class Q_WEBENGINECORE_EXPORT AutofillPopupController : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QStringListModel *model READ model CONSTANT FINAL)

public:
    ~AutofillPopupController();

    QStringListModel *model() { return &m_model; }

    void selectPreviousSuggestion();
    void selectNextSuggestion();
    void selectFirstSuggestion();
    void selectLastSuggestion();

    void notifyPopupShown();
    void notifyPopupHidden();

public Q_SLOTS:
    void selectSuggestion(int index);
    void acceptSuggestion();

Q_SIGNALS:
    void currentIndexChanged(const QModelIndex &index);

private:
    AutofillPopupController(AutofillPopupControllerPrivate *);
    QScopedPointer<AutofillPopupControllerPrivate> d;

    void setCurrentIndex(const QModelIndex &index);

    // Only called by AutofillClientQt:
    void updateModel();

    QStringListModel m_model;
    QModelIndex m_currentIndex;

    friend class AutofillClientQt;
};

} // namespace QtWebEngineCore

Q_DECLARE_METATYPE(QtWebEngineCore::AutofillPopupController *)

#endif // AUTOFILL_POPUP_CONTROLLER_H