source: SMSSender/frontend/gui/ui/importcontacts/importcontacts_page_import.h @ 319:1ec456878bcb

separation-frontend-backend
Last change on this file since 319:1ec456878bcb was 319:1ec456878bcb, checked in by Sämy Zehnder <saemy.zehnder@…>, 8 years ago
  • Adjusts header guards to follow common pattern based on the filename.
File size: 2.8 KB
Line 
1/*
2 smssender - A frontend for fast and easy SMS sending over different gateways.
3 Copyright (C) 2007-2014, 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 FRONTEND_GUI_UI_IMPORTCONTACTS_IMPORTCONTACTS_PAGE_IMPORT_H
19#define FRONTEND_GUI_UI_IMPORTCONTACTS_IMPORTCONTACTS_PAGE_IMPORT_H
20
21#include "ui_importcontacts_page_import.h"
22
23#include <QMap>
24#include <QMutex>
25#include <QThread>
26#include <QWizardPage>
27
28#include "common/domain/stask.h"
29#include "common/exceptions/eexception.h"
30
31#include "frontend/business/contactmanager.h"
32#include "frontend/gui/ui/guimanager.h"
33#include "frontend/gui/ui/importcontacts/importcontacts_datamanager.h"
34
35namespace UI {
36
37class ImportContactsPageImport : public QWizardPage {
38    Q_OBJECT
39
40public:
41    ImportContactsPageImport(QWidget* parent, ImportContactsDataManager* dataManager,
42                             const ContactManager &contactManager, GuiManager *guiManager);
43
44public: /* QWizardPage */
45    void initializePage();
46    bool isComplete() const;
47    bool validatePage();
48
49private:
50    // Takes ownership.
51    void addImportedContact(SContact* contact);
52    // Takes ownership.
53    void _addImportedContact(SContact* contact);
54
55    void adjustNames(SContact *contact);
56    QString getUnusedName(const QString& originalName, const QStringList& usedNames);
57
58private slots:
59    void importTaskFinished(STask *task);
60    void importTaskFinishedGui();
61
62private:
63    ImportContactsDataManager * const m_dataManager;
64    const ContactManager &m_contactManager;
65    GuiManager * const m_guiManager;
66    Ui::ImportContactsPageImportClass ui;
67
68    QList<EException> m_importErrors;
69
70    QMap<QString, SContact*> m_existingContacts;
71    QMap<QString, SContact*> m_importedContacts;
72    int  m_runningTasks;
73
74    bool m_namesAdjusted;
75
76    mutable QMutex m_mutex;
77};
78
79
80class ImportTask : public SThreadedTask {
81    Q_OBJECT
82
83public:
84    explicit ImportTask(IContactImporter *importer);
85    ~ImportTask();
86
87public: /* SThreadedTask */
88    void doTheWork();
89
90public:
91        // Caller takes ownership.
92    QSet<SContact*> takeImportedContacts();
93
94private:
95    IContactImporter * const m_importer;
96    QSet<SContact*> m_importedContacts;
97};
98
99} // namespace UI
100
101#endif // FRONTEND_GUI_UI_IMPORTCONTACTS_IMPORTCONTACTS_PAGE_IMPORT_H
Note: See TracBrowser for help on using the repository browser.