Skip to content
This repository was archived by the owner on Mar 4, 2023. It is now read-only.

Commit 09c02f0

Browse files
committed
internal code updates
1 parent 5a2fd28 commit 09c02f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+185
-117
lines changed

.qmake.conf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ win32:cross_compile: CONFIG += winrt
55

66
DEFINES += QT_DEPRECATED_WARNINGS QT_ASCII_CAST_WARNINGS
77

8-
MODULE_VERSION = 4.0.0
8+
MODULE_VERSION_MAJOR = 4
9+
MODULE_VERSION_MINOR = 0
10+
MODULE_VERSION_PATCH = 1
11+
MODULE_VERSION_IMPORT = $${MODULE_VERSION_MAJOR}.$${MODULE_VERSION_MINOR}
12+
MODULE_VERSION = $${MODULE_VERSION_MAJOR}.$${MODULE_VERSION_MINOR}.$${MODULE_VERSION_PATCH}
13+

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ osx_image: xcode9.2
99

1010
env:
1111
global:
12-
- QT_VER=5.10.0
12+
- QPMX_CACHE_DIR=$HOME/.qpmx-cache
13+
- QT_VER=5.10.1
1314
- EXTRA_MODULES=".qtremoteobjects .skycoder42.jsonserializer"
1415
- STATIC_QT_MODS="qttools qtwebsockets qtscxml qtremoteobjects"
1516
- STATIC_EXTRA_MODS="qtjsonserializer"
@@ -20,7 +21,7 @@ matrix:
2021
env:
2122
- PLATFORM=gcc_64
2223
- BUILD_DOC=true
23-
- EXTRA_PKG="libsecret-1-dev gnome-keyring" #in order to build secrectservice keystore
24+
- EXTRA_PKG="libsecret-1-dev" #in order to build secrectservice keystore
2425
- os: linux
2526
env:
2627
- PLATFORM=android_armv7
@@ -59,10 +60,10 @@ deploy:
5960
before_cache:
6061
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
6162
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
62-
#TODO rm qpmx locks
63+
- rm -fr $QPMX_CACHE_DIR/locks
6364
cache:
6465
directories:
65-
- $HOME/.cache/Skycoder42/qpmx
6666
- $HOME/.gradle/caches/
6767
- $HOME/.gradle/wrapper/
6868
- $HOME/.android/build-cache
69+
- $QPMX_CACHE_DIR

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ auto store = new QtDataSync::DataStore(this); //Use the "default setup"
158158
//store an entry
159159
store->save<Data>({42, "tree"});
160160
//load all entries
161-
foreach(Data d, store->loadAll<Data>()) {
161+
for(Data d : store->loadAll<Data>()) {
162162
qDebug() << d.key << d.value;
163163
});
164164
```

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ image:
55
version: build-{build}
66

77
environment:
8-
QT_VER: 5.10.0
8+
QT_VER: 5.10.1
99
EXTRA_MODULES: .qtremoteobjects;.skycoder42.jsonserializer
1010
STATIC_QT_MODS: qttools qtwebsockets qtscxml qtremoteobjects
1111
STATIC_EXTRA_MODS: qtjsonserializer

doc/datatypestore.dox

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ initially. This can be a potentially long operation, and thus you should only us
225225
number of datasets does not get extremly big.
226226

227227
One additional feature of the store is that it provides read-only STL iterators for easy access.
228-
Using it with foreach however is currently not possible, as the store is not a value type.
228+
Using it with for/foreach however is currently not possible, as the store is not a value type.
229229

230230
@sa DataStore, DataStore::loadAll, DataTypeStore
231231
*/

examples/datasync/Sample/accountdialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void AccountDialog::exec(const QString &setup, QWidget *parent)
7070
void AccountDialog::updateDevices(const QList<QtDataSync::DeviceInfo> &devices)
7171
{
7272
ui->treeWidget->clear();
73-
foreach(auto device, devices) {
73+
for(auto device : devices) {
7474
auto item = new QTreeWidgetItem(ui->treeWidget);
7575
item->setText(0, device.name());
7676
item->setText(1, printFingerprint(device.fingerprint()));
@@ -111,7 +111,7 @@ void AccountDialog::login(QtDataSync::LoginRequest request)
111111
QString AccountDialog::printFingerprint(const QByteArray &fingerprint)
112112
{
113113
QByteArrayList res;
114-
foreach(char c, fingerprint)
114+
for(char c : fingerprint)
115115
res.append(QByteArray(1, c).toHex());
116116
return QString::fromUtf8(res.join(':'));
117117
}

examples/datasync/Sample/exchangedialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void ExchangeDialog::exec(QtDataSync::AccountManager *manager, QWidget *parent)
3535
void ExchangeDialog::devicesChanged(QList<QtDataSync::UserInfo> devices)
3636
{
3737
ui->treeWidget->clear();
38-
foreach(auto dev, devices) {
38+
for(auto dev : devices) {
3939
auto item = new QTreeWidgetItem(ui->treeWidget);
4040
item->setText(0, dev.name());
4141
item->setText(1, QStringLiteral("%1:%2").arg(dev.address().toString()).arg(dev.port()));

src/datasync/changecontroller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void ChangeController::uploadNext(bool emitStarted)
143143

144144
//skip stuff already beeing uploaded (could still have changed, but to prevent errors)
145145
auto skip = false;
146-
foreach(auto mKey, _activeUploads.keys()) {
146+
for(auto mKey : _activeUploads.keys()) {
147147
if(key == mKey) {
148148
skip = true;
149149
break;

src/datasync/changeemitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void ChangeEmitter::triggerRemoteClear(const QByteArray &typeName)
5858
{
5959
if(_cache) {
6060
QWriteLocker _(&_cache->lock);
61-
foreach(auto key, _cache->cache.keys()) {
61+
for(auto key : _cache->cache.keys()) {
6262
if(key.typeName == typeName)
6363
_cache->cache.remove(key);
6464
}

src/datasync/cryptocontroller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ QStringList CryptoController::allKeystoreKeys()
129129
QStringList CryptoController::availableKeystoreKeys()
130130
{
131131
QStringList keys;
132-
foreach(auto key, factory->allKeys()) {
132+
for(auto key : factory->allKeys()) {
133133
if(factory->isAvailable(key))
134134
keys.append(key);
135135
}
@@ -860,7 +860,7 @@ void CryptoController::cleanCiphers() const
860860
auto keys = settings()->childKeys();
861861
settings()->endGroup();
862862

863-
foreach(auto key, keys) {
863+
for(auto key : keys) {
864864
auto ok = false;
865865
auto keyIndex = key.toUInt(&ok);
866866
if(!ok)

src/datasync/datastore.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ QStringList DataStore::keys(int metaTypeId) const
5454

5555
QVariantList DataStore::loadAll(int metaTypeId) const
5656
{
57-
auto jsonList = d->store->loadAll(d->typeName(metaTypeId));
5857
QVariantList resList;
59-
foreach(auto val, jsonList)
58+
for(auto val : d->store->loadAll(d->typeName(metaTypeId)))
6059
resList.append(d->serializer->deserialize(val, metaTypeId));
6160
return resList;
6261
}
@@ -139,17 +138,15 @@ void DataStore::update(int metaTypeId, QObject *object) const
139138

140139
QVariantList DataStore::search(int metaTypeId, const QString &query, SearchMode mode) const
141140
{
142-
auto jsonList = d->store->find(d->typeName(metaTypeId), query, mode);
143141
QVariantList resList;
144-
foreach(auto val, jsonList)
142+
for(auto val : d->store->find(d->typeName(metaTypeId), query, mode))
145143
resList.append(d->serializer->deserialize(val, metaTypeId));
146144
return resList;
147145
}
148146

149147
void DataStore::iterate(int metaTypeId, const function<bool (QVariant)> &iterator) const
150148
{
151-
auto keyList = keys(metaTypeId);
152-
foreach(auto key, keyList) {
149+
for(auto key : keys(metaTypeId)) {
153150
if(!iterator(load(metaTypeId, key)))
154151
break;
155152
}

src/datasync/datastore.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,8 @@ template<typename T, typename K>
238238
QList<K> DataStore::keys() const
239239
{
240240
QTDATASYNC_STORE_ASSERT(T);
241-
auto kList = keys<T>();
242241
QList<K> rList;
243-
foreach(auto k, kList)
242+
for(auto k : keys<T>())
244243
rList.append(QVariant(k).template value<K>());
245244
return rList;
246245
}
@@ -249,9 +248,8 @@ template<typename T>
249248
QList<T> DataStore::loadAll() const
250249
{
251250
QTDATASYNC_STORE_ASSERT(T);
252-
auto mList = loadAll(qMetaTypeId<T>());
253251
QList<T> rList;
254-
foreach(auto v, mList)
252+
for(auto v : loadAll(qMetaTypeId<T>()))
255253
rList.append(v.template value<T>());
256254
return rList;
257255
}
@@ -302,9 +300,8 @@ template<typename T>
302300
QList<T> DataStore::search(const QString &query, SearchMode mode) const
303301
{
304302
QTDATASYNC_STORE_ASSERT(T);
305-
auto mList = search(qMetaTypeId<T>(), query, mode);
306303
QList<T> rList;
307-
foreach(auto v, mList)
304+
for(auto v : search(qMetaTypeId<T>(), query, mode))
308305
rList.append(v.template value<T>());
309306
return rList;
310307
}

src/datasync/datastoremodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ void DataStoreModelPrivate::createRoleNames()
317317
void DataStoreModelPrivate::clearHashObjects()
318318
{
319319
if(QMetaType::typeFlags(type).testFlag(QMetaType::PointerToQObject)) {
320-
foreach(auto v, dataHash)
320+
for(auto v : dataHash)
321321
deleteObject(v);
322322
}
323323
dataHash.clear();

src/datasync/datatypestore.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ CachingDataTypeStore<TType, TKey>::CachingDataTypeStore(DataStore *store, QObjec
330330
_data()
331331
{
332332
auto userProp = TType::staticMetaObject.userProperty();
333-
foreach(auto data, store->loadAll<TType>())
333+
for(auto data : store->loadAll<TType>())
334334
_data.insert(userProp.readOnGadget(&data).template value<TKey>(), data);
335335

336336
connect(_store, &DataStore::dataChanged,
@@ -474,7 +474,7 @@ CachingDataTypeStore<TType*, TKey>::CachingDataTypeStore(DataStore *store, QObje
474474
_data()
475475
{
476476
auto userProp = TType::staticMetaObject.userProperty();
477-
foreach(auto data, store->loadAll<TType*>()){
477+
for(auto data : store->loadAll<TType*>()){
478478
data->setParent(this);
479479
_data.insert(userProp.read(data).template value<TKey>(), data);
480480
}
@@ -616,7 +616,7 @@ void CachingDataTypeStore<TType*, TKey>::evalDataResetted()
616616
auto data = _data;
617617
_data.clear();
618618
emit dataResetted();
619-
foreach(auto d, data)
619+
for(auto d : data)
620620
d->deleteLater();
621621
}
622622

src/datasync/defaults.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void DefaultsPrivate::clearDefaults()
244244
for(auto it = setupDefaults.constBegin(); it != setupDefaults.constEnd(); it++)
245245
weakRefs.append({it.key(), it.value().toWeakRef()});
246246
setupDefaults.clear();
247-
foreach(auto ref, weakRefs) {
247+
for(auto ref : weakRefs) {
248248
#undef QTDATASYNC_LOG
249249
#define QTDATASYNC_LOG ref.second.toStrongRef()->logger
250250
if(ref.second)
@@ -305,7 +305,7 @@ DefaultsPrivate::DefaultsPrivate(const QString &setupName, const QDir &storageDi
305305
DefaultsPrivate::~DefaultsPrivate()
306306
{
307307
QMutexLocker _(&roMutex);
308-
foreach(auto node, roNodes)
308+
for(auto node : roNodes)
309309
node->deleteLater();
310310
roNodes.clear();
311311
}

src/datasync/emitteradapter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void EmitterAdapter::dropCached(const QByteArray &typeName)
138138
return;
139139

140140
QWriteLocker _(&_cache->lock);
141-
foreach(auto key, _cache->cache.keys()) {
141+
for(auto key : _cache->cache.keys()) {
142142
if(key.typeName == typeName)
143143
_cache->cache.remove(key);
144144
}

src/datasync/migrationhelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void MigrationRunnable::run()
178178
//special: copy headers
179179
oldSettings->beginGroup(QStringLiteral("RemoteConnector/headers"));
180180
currentSettings->beginGroup(QStringLiteral("connector/") + RemoteConnector::keyRemoteHeaders);
181-
foreach(auto key, oldSettings->childKeys()) {
181+
for(auto key : oldSettings->childKeys()) {
182182
copyConf(oldSettings, key,
183183
currentSettings, key);
184184
}

src/datasync/remoteconnector.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ void RemoteConnector::error(QAbstractSocket::SocketError error)
516516
void RemoteConnector::sslErrors(const QList<QSslError> &errors)
517517
{
518518
auto shouldClose = true;
519-
foreach(auto error, errors) {
519+
for(auto error : errors) {
520520
if(error.error() == QSslError::SelfSignedCertificate ||
521521
error.error() == QSslError::SelfSignedCertificateInChain)
522522
shouldClose = shouldClose &&
@@ -790,9 +790,8 @@ QVariant RemoteConnector::sValue(const QString &key) const
790790
if(key == keyRemoteHeaders) {
791791
if(settings()->childGroups().contains(keyRemoteHeaders)) {
792792
settings()->beginGroup(keyRemoteHeaders);
793-
auto keys = settings()->childKeys();
794793
RemoteConfig::HeaderHash headers;
795-
foreach(auto key, keys)
794+
for(auto key : settings()->childKeys())
796795
headers.insert(key.toUtf8(), settings()->value(key).toByteArray());
797796
settings()->endGroup();
798797
return QVariant::fromValue(headers);
@@ -1074,7 +1073,7 @@ void RemoteConnector::onDevices(const DevicesMessage &message)
10741073
if(checkIdle(message)) {
10751074
logDebug() << "Received list of devices with" << message.devices.size() << "entries";
10761075
_deviceCache.clear();
1077-
foreach(auto device, message.devices)
1076+
for(auto device : message.devices)
10781077
_deviceCache.append(DeviceInfo{get<0>(device), get<1>(device), get<2>(device)});
10791078
emit devicesListed(_deviceCache);
10801079
}
@@ -1180,7 +1179,7 @@ void RemoteConnector::onDeviceKeys(const DeviceKeysMessage &message)
11801179
reply.cmac = _cryptoController->generateEncryptionKeyCmac(reply.keyIndex); //cmac for the new key
11811180
//do not store this mac to be send again!
11821181

1183-
foreach(auto info, message.devices) {
1182+
for(auto info : message.devices) {
11841183
try {
11851184
//verify the device knows the previous secret (which is still the current one)
11861185
auto cryptInfo = QSharedPointer<AsymmetricCryptoInfo>::create(_cryptoController->rng(),

src/datasync/synchelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void hashNext(QCryptographicHash &hash, const QJsonValue &value)
106106
hash.addData(value.toString().toUtf8());
107107
break;
108108
case QJsonValue::Array:
109-
foreach(auto v, value.toArray())
109+
for(auto v : value.toArray())
110110
hashNext(hash, v);
111111
break;
112112
case QJsonValue::Object:

src/datasync/userexchangemanager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void UserExchangeManager::readDatagram()
202202

203203
auto isSelf = false;
204204
if(datagram.senderPort() == d->socket->localPort()) {
205-
foreach(auto addr, QNetworkInterface::allAddresses()) {
205+
for(auto addr : QNetworkInterface::allAddresses()) {
206206
if(addr.isEqual(datagram.senderAddress())) {
207207
isSelf = true;
208208
break;
@@ -250,7 +250,7 @@ void UserExchangeManager::readDatagram()
250250

251251
//try to find the already existing user info for that data
252252
bool found = false;
253-
foreach(auto key, d->devices.keys()) {
253+
for(auto key : d->devices.keys()) {
254254
if(info == key) {
255255
found = true;
256256
if(isInfo) { //isInfo -> reset timeout, update name if neccessary

src/imports/qmldatasync/qmldatasync.pro renamed to src/imports/datasync/datasync.pro

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
QT = core datasync qml
22

3+
CXX_MODULE = datasync
34
TARGETPATH = de/skycoder42/QtDataSync
4-
IMPORT_VERSION = 1.0
5+
TARGET = declarative_datasync
6+
IMPORT_VERSION = $$MODULE_VERSION_IMPORT
7+
DEFINES += "VERSION_MAJOR=$$MODULE_VERSION_MAJOR"
8+
DEFINES += "VERSION_MINOR=$$MODULE_VERSION_MINOR"
59

6-
HEADERS += qmldatasync_plugin.h \
10+
HEADERS += \
711
qqmldatastore.h \
812
qqmlsyncmanager.h \
913
qqmlaccountmanager.h \
1014
qqmldatastoremodel.h \
11-
qqmluserexchangemanager.h
15+
qqmluserexchangemanager.h \
16+
qtdatasync_plugin.h
1217

13-
SOURCES += qmldatasync_plugin.cpp \
18+
SOURCES += \
1419
qqmldatastore.cpp \
1520
qqmlsyncmanager.cpp \
1621
qqmlaccountmanager.cpp \
1722
qqmldatastoremodel.cpp \
18-
qqmluserexchangemanager.cpp
23+
qqmluserexchangemanager.cpp \
24+
qtdatasync_plugin.cpp
1925

2026
OTHER_FILES += qmldir
2127

22-
IMPORT_VERSION = 1.0
23-
2428
generate_qmltypes {
2529
typeextra1.target = qmltypes
2630
typeextra1.depends += export LD_LIBRARY_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/lib/:$(LD_LIBRARY_PATH)"
27-
qmltypes.depends += typeextra1
28-
2931
typeextra2.target = qmltypes
3032
typeextra2.depends += export QML2_IMPORT_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/qml/"
31-
qmltypes.depends += typeextra2
3233
QMAKE_EXTRA_TARGETS += typeextra1 typeextra2
3334
}
3435

3536
load(qml_plugin)
3637

3738
generate_qmltypes {
39+
qmltypes.depends = ../../../qml/$$TARGETPATH/$(TARGET) #overwrite the target deps
40+
3841
mfirst.target = all
3942
mfirst.depends += qmltypes
4043
QMAKE_EXTRA_TARGETS += mfirst

0 commit comments

Comments
 (0)