~hmatuschek/+junk/qdmr-package

« back to all changes in this revision

Viewing changes to lib/config.cc

  • Committer: Hannes Matuschek
  • Date: 2020-07-07 14:49:41 UTC
  • mfrom: (1.1.4)
  • Revision ID: hmatuschek@gmail.com-20200707144941-niwxz5phhmi0kt1w
* Finalized implementation of MD5R.
* Fixed RD-5R upload.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#include <cmath>
8
8
#include "csvreader.hh"
9
9
#include "csvwriter.hh"
 
10
#include "userdatabase.hh"
10
11
 
11
12
 
12
13
/* ********************************************************************************************* *
13
14
 * Implementation of Config
14
15
 * ********************************************************************************************* */
15
 
Config::Config(QObject *parent)
 
16
Config::Config(UserDatabase *userdb, QObject *parent)
16
17
  : QObject(parent), _modified(false), _contacts(new ContactList(this)), _rxGroupLists(new RXGroupLists(this)),
17
18
    _channels(new ChannelList(this)), _zones(new ZoneList(this)), _scanlists(new ScanLists(this)),
18
19
    _gpsSystems(new GPSSystems(this)),
19
20
    _id(0), _name(), _introLine1(), _introLine2(), _mic_level(2),
20
 
    _speech(false)
 
21
    _speech(false), _uploadUserDB(false), _userDB(userdb)
21
22
{
22
23
  connect(_contacts, SIGNAL(modified()), this, SIGNAL(modified()));
23
24
  connect(_rxGroupLists, SIGNAL(modified()), this, SIGNAL(modified()));
141
142
  emit modified();
142
143
}
143
144
 
 
145
bool
 
146
Config::uploadUserDB() const {
 
147
  return _uploadUserDB;
 
148
}
 
149
void
 
150
Config::setUploadUserDB(bool upload) {
 
151
  if (upload == _uploadUserDB)
 
152
    return;
 
153
  _uploadUserDB = upload;
 
154
  emit modified();
 
155
}
 
156
 
 
157
bool
 
158
Config::hasUserDB() const {
 
159
  return (nullptr != _userDB) && (_userDB->count());
 
160
}
 
161
UserDatabase *
 
162
Config::userDB() const {
 
163
  return _userDB;
 
164
}
 
165
void
 
166
Config::setUserDB(UserDatabase *userdb) {
 
167
  if (_userDB)
 
168
    disconnect(_userDB, SIGNAL(destroyed()), this, SLOT(onUserDBDeleted()));
 
169
  _userDB = userdb;
 
170
  if (_userDB)
 
171
    connect(_userDB, SIGNAL(destroyed()), this, SLOT(onUserDBDeleted()));
 
172
}
 
173
 
144
174
void
145
175
Config::reset() {
146
176
  // Reset lists
156
186
  _introLine2.clear();
157
187
  _mic_level = 2;
158
188
  _speech    = false;
 
189
  _uploadUserDB = false;
159
190
  emit modified();
160
191
}
161
192
 
164
195
  _modified = true;
165
196
}
166
197
 
 
198
void
 
199
Config::onUserDBDeleted() {
 
200
  _userDB = nullptr;
 
201
}
 
202
 
167
203
bool
168
204
Config::readCSV(const QString &filename, QString &errorMessage) {
169
205
  QFile file(filename);