source: SMSSender/frontend/business/contactimporter/contactfilesimporter.h @ 316:16f8e7f93ca4

separation-frontend-backend
Last change on this file since 316:16f8e7f93ca4 was 316:16f8e7f93ca4, checked in by Sämy Zehnder <saemy.zehnder@…>, 8 years ago
  • Adds the copyright header to each file and updates the development period.
File size: 2.4 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 CONTACTFILESIMPORTER_H_
19#define CONTACTFILESIMPORTER_H_
20
21#include <QMap>
22#include <QSettings>
23#include <QString>
24#include <QStringList>
25
26#include "common/business/icontactimporter.h"
27
28class ContactFilesImporterDataManager;
29class ContactFilesImporter : public IContactImporter {
30    Q_INTERFACES(IContactImporter)
31
32public:
33    ContactFilesImporter();
34
35    QString describingName() const;
36    bool isApplicable() const;
37
38    void init();
39
40    // Caller takes ownership of contacts.
41    void importContacts(QSet<SContact*> *contacts);
42
43    ContactFilesImporterDataManager *dataManager() const;
44
45private:
46    struct CSVFile {
47        QStringList keys;
48        QList<QMap<QString, QString> > values; // key => value
49    };
50
51private:
52    const QScopedPointer<ContactFilesImporterDataManager> m_dataManager;
53
54    // Caller takes ownership of contacts.
55    void readV1ContactsFile(const QSettings& ini, QSet<SContact*> *contacts) const;
56
57    // Caller takes ownership of contacts.
58    void readV2ContactsFile(const QSettings& ini, QSet<SContact*> *contacts) const;
59
60    CSVFile parseCSV(const QString& filename) const;
61    void readCSV(const CSVFile& csv, QSet<SContact*> *contacts) const;
62};
63
64class ContactFilesImporterDataManager : public QObject {
65    Q_OBJECT
66
67public:
68    ContactFilesImporterDataManager() {}
69
70    void addContactFile(const QString &path);
71    void setContactFileSelected(const QString &path, bool selected);
72
73    bool isContactFileSelected(const QString &path) const;
74    const QMap<QString, bool> &selectionMap() const;
75
76signals:
77    void dataChanged();
78
79private:
80    QMap<QString, bool> m_selectedFileMap;
81};
82
83#endif /* ABSTRACTCONTACTFILESIMPORTER_H_ */
Note: See TracBrowser for help on using the repository browser.