Line data Source code
1 : #pragma once
2 :
3 : #include <QDialog>
4 : #include <functional>
5 :
6 : class QLineEdit;
7 : class QTableView;
8 : class QStandardItemModel;
9 : class QSortFilterProxyModel;
10 : class ContactStore;
11 :
12 : // T-157: Dialog for viewing, searching, adding, editing and deleting contacts.
13 : class ContactManagerDialog : public QDialog {
14 130 : Q_OBJECT
15 : friend class TestSprint55Dialogs;
16 :
17 : public:
18 : explicit ContactManagerDialog(ContactStore *store,
19 : QWidget *parent = nullptr);
20 :
21 : signals:
22 : void composeToContact(const QString &email, const QString &displayName);
23 :
24 : private slots:
25 : void onAddContact();
26 : void onDeleteContact();
27 : void onEditContact();
28 :
29 : private:
30 : // T-304: Runtime language switching
31 : void retranslateUi();
32 :
33 : protected:
34 : void changeEvent(QEvent *event) override;
35 :
36 : void setupUi();
37 : void reloadContacts();
38 : int selectedContactId() const;
39 :
40 : // Modal test seams (standard pattern): default to the real Qt dialogs,
41 : // overridden in unit tests so add/edit/delete run headless.
42 : std::function<QString(const QString &title, const QString &label,
43 : const QString &initial, bool *ok)>
44 : m_promptText;
45 : std::function<bool(const QString &title, const QString &text)> m_confirm;
46 :
47 : ContactStore *m_store;
48 : QLineEdit *m_searchEdit = nullptr;
49 : QTableView *m_table = nullptr;
50 : QStandardItemModel *m_model = nullptr;
51 : QSortFilterProxyModel *m_proxy = nullptr;
52 : };
|