Debian Codegraph @

src/librssguard/services/abstract/gui/formaccountdetails.h

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.
2
3 #ifndef FORMACCOUNTDETAILS_H
4 #define FORMACCOUNTDETAILS_H
5
6 #include "database/databasefactory.h"
7 #include "database/databasequeries.h"
8 #include "gui/reusable/networkproxydetails.h"
9 #include "miscellaneous/application.h"
10 #include "services/abstract/gui/accountdetails.h"
11
12 #include <QDialog>
13
14 namespace Ui {
15 class FormAccountDetails;
16 }
17
18 class ServiceRoot;
19
20 class RSSGUARD_DLLSPEC FormAccountDetails : public QDialog {
21 Q_OBJECT
22
23 public:
24 explicit FormAccountDetails(const QIcon& icon, QWidget* parent = nullptr);
25 virtual ~FormAccountDetails();
26
27 template <class T>
28 T* addEditAccount(T* account_to_edit = nullptr);
29
30 template <class T>
31 T* account() const;
32
33 protected slots:
34
35 // Applies changes.
36 // NOTE: This must be reimplemented in subclasses. Also this base
37 // implementation must be called first.
38 virtual void apply();
39
40 protected:
41 void activateTab(int index);
42 void clearTabs();
43 void insertCustomTab(QWidget* custom_tab, const QString& title, int index);
44
45 // Sets the account which will be edited.
46 // NOTE: This must be reimplemented in subclasses. Also this
47 // base implementation must be called first.
48 virtual void loadAccountData();
49
50 private:
51 void createConnections();
52
53 protected:
54 QScopedPointer<Ui::FormAccountDetails> m_ui;
55 NetworkProxyDetails* m_proxyDetails;
56 AccountDetails* m_accountDetails;
57 ServiceRoot* m_account;
58 bool m_creatingNew;
59 };
60
61 template <class T>
62 inline T* FormAccountDetails::addEditAccount(T* account_to_edit) {
63 m_creatingNew = account_to_edit == nullptr;
64
65 if (m_creatingNew) {
66 m_account = new T();
67 }
68 else {
69 m_account = account_to_edit;
70 }
71
72 // Load custom logic for account data loading.
73 loadAccountData();
74
75 if (exec() == QDialog::DialogCode::Accepted) {
76 return account<T>();
77 }
78 else {
79 return nullptr;
80 }
81 }
82
83 template <class T>
84 inline T* FormAccountDetails::account() const {
85 return qobject_cast<T*>(m_account);
86 }
87
88 #endif // FORMACCOUNTDETAILS_H