source: SMSSender/frontend/gui/ui/main/main.h @ 315:e6c8bb244ecd

separation-frontend-backend
Last change on this file since 315:e6c8bb244ecd was 315:e6c8bb244ecd, checked in by Sämy Zehnder <saemy.zehnder@…>, 6 years ago
  • Separates the frontend from the backend code.
  • At this point the schoolnet gateway is converted only.
  • Removes bc & da prefixes from the filenames.
File size: 5.0 KB
Line 
1/*
2 smssender - A frontend for fast and easy SMS sending over different gateways.
3 Copyright (C) 2007-2012, gorrión. See http://smssender.gorrion.ch
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef UI_MAIN_H
19#define UI_MAIN_H
20
21#include "ui_main.h"
22
23#include <QStringListModel>
24#include <QShortcut>
25#include <QSet>
26#include <QMap>
27#include <QMainWindow>
28#include <QTreeWidgetItem>
29#include <QSortFilterProxyModel>
30
31#include "common/domain/scontact.h"
32#include "common/domain/sgroup.h"
33#include "common/domain/sdatatypes.h"
34#include "common/domain/sversion.h"
35#include "frontend/business/accountinitmanager.h"
36#include "frontend/business/updatemanager.h"
37#include "frontend/business/settings.h"
38#include "frontend/gui/bootstrap.h"
39#include "frontend/gui/business/managerfactory.h"
40#include "frontend/gui/ui/models/accounttreemodel.h"
41#include "frontend/gui/ui/models/contactgroupmodel.h"
42
43namespace UI {
44
45class TaskStatusBar;
46
47class Main : public QMainWindow{
48    Q_OBJECT
49
50public:
51    explicit Main(const Bootstrap &bootstrap);
52
53protected:
54    void changeEvent(QEvent* event);
55
56private:
57    Ui::MainClass ui;
58
59    AccountTreeModel*                accountModel_;
60    QSortFilterProxyModel*           accountFilterModel_;
61
62    ContactGroupListModel*           contactGroupListModel_;
63    QSortFilterProxyModel*           contactGroupSortModel_;
64
65    QMap<QString, IAccount*>         accountStrToAccount;
66
67    QMap<QTreeWidgetItem*, const SContact*> nodeToContact;
68    QMap<QTreeWidgetItem*, const SGroup*> nodeToGroup;
69
70    /* Recipient list */
71    bool           isContactNode(const QTreeWidgetItem* node);
72    bool           isGroupNode(const QTreeWidgetItem* node);
73    const SContact *getContactOfNode(const QTreeWidgetItem* node);
74    const SGroup *getGroupOfNode(const QTreeWidgetItem* node);
75    bool           isNodeContactOrHasContact(const QTreeWidgetItem* node, const SContact& contact);
76    bool           isContactAlreadyRecipient(const SContact& contact);
77    bool           isGroupAlreadyRecipient(const SGroup& group);
78
79    void           addRecipient(const SContact& contact, QTreeWidgetItem* parent = NULL);
80    void           addRecipient(const SGroup& group);
81    void           removeRecipient(QTreeWidgetItem* node);
82    void           removeNode(QTreeWidgetItem* node);
83
84    QSet<const SContact *> getRecipientContacts(bool withGroupContacts);
85    QSet<const SContact *> getRecipientContacts(bool withGroupContacts, QTreeWidgetItem* node);
86    QSet<const SGroup*> getRecipientGroups();
87
88
89    void setShortcuts();
90
91    void recalculateSMSCosts() const;
92
93    /* Account */
94    bool isAllFilled();
95    void enableSendBtnIfAllFilled();
96
97    void clearMessage();
98    void clearRecipients();
99    void sendMessage();
100
101    IAccount* selectedAccount() const;
102
103private slots: /* Autoconnect */
104    void on_btnSend_clicked();
105
106    void on_btnAddRecipient_clicked();
107    void on_btnRemoveRecipient_clicked();
108    void on_treeRecipients_itemSelectionChanged();
109
110    void on_txtMessage_textChanged();
111    void on_lstAccounts_currentIndexChanged(int index);
112
113    void on_lstContacts_editTextChanged(const QString& text);
114    void on_lstContacts_completerActivated(const QString& text);
115    void on_lstContacts_returnPressed();
116    void reenableRecipientAdding();
117
118    void on_actionNewMessage_triggered(bool checked);
119
120    void on_actionAccounts_triggered(bool checked);
121    void on_actionAddressBook_triggered(bool checked);
122        void on_actionPreferences_triggered(bool checked);
123        void on_actionAbout_triggered(bool checked);
124
125    void on_shortcutNewMessage();
126    void on_shortcutClearMessageText();
127    void on_shortcutClearRecipients();
128    void on_shortcutSendMessage();
129
130private slots:
131    void onSettingChanged(int setting);
132
133    void onAccountInitStateChanged(IAccount* account);
134    void onAccountInitFailed(IAccount* account, const EException& exception);
135
136    void onAccountRowInserted();
137
138    void onAccountsLoaded();
139
140    void onSMSSendingFinished(STask* task);
141    void onSMSSendingErrorOccured(STask* task);
142
143    void onUpdateAvailable(const SVersion& newVersion, UpdateManager::UpdateType type);
144
145private slots:
146    void smsSendingFinished(STask::Result taskResult);
147    void smsSendingErrorOccured(const EException &exception);
148
149private slots:
150    void checkForAccounts();
151
152private:
153    const Bootstrap &m_bootstrap;
154    const ManagerFactory &m_managerFactory;
155
156    QSet<QShortcut*> m_shortcuts;
157    bool             m_recipientAddingEnabled;
158
159    TaskStatusBar* m_statusBarButton;
160};
161
162} // namespace UI
163
164#endif // UI_MAIN_H
Note: See TracBrowser for help on using the repository browser.