comparison src/main.cpp @ 170:7edbfb2c0089

Add error message dialogs for cases when SQL tables could not be created, instead of just logging the errors.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 19 Sep 2017 13:47:15 +0300
parents d9b9be9c4788
children 636a24c76232
comparison
equal deleted inserted replaced
169:d9b9be9c4788 170:7edbfb2c0089
278 settings.uiSize = QSize(1000, 600); 278 settings.uiSize = QSize(1000, 600);
279 settings.uiScale = 1.0f; 279 settings.uiScale = 1.0f;
280 } 280 }
281 281
282 // 282 //
283 // Create logfile and data directory 283 // Create logfile and data directory if they do not already exist
284 // 284 //
285 settings.dataPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); 285 settings.dataPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
286 QDir path(settings.dataPath); 286 QDir path(settings.dataPath);
287 if (!path.exists(settings.dataPath)) 287 if (!path.exists(settings.dataPath))
288 path.mkpath(settings.dataPath); 288 path.mkpath(settings.dataPath);
315 "updated DATETIME NOT NULL)"). 315 "updated DATETIME NOT NULL)").
316 arg(SQL_LEN_FIRST_NAME). 316 arg(SQL_LEN_FIRST_NAME).
317 arg(SQL_LEN_LAST_NAME). 317 arg(SQL_LEN_LAST_NAME).
318 arg(SQL_LEN_EXTRA_INFO)); 318 arg(SQL_LEN_EXTRA_INFO));
319 319
320 slCheckAndReportSQLError("CREATE TABLE people", query.lastError(), true); 320 if (!slCheckAndReportSQLError("CREATE TABLE people", query.lastError(), true))
321 {
322 slErrorMsg(
323 QObject::tr("Tietokantataulua ei voitu luoda"),
324 QObject::tr("Virhe: %1<br><br>").
325 arg(db.lastError().text())
326 );
327 return 1;
328 }
321 } 329 }
322 330
323 if (!db.tables().contains("transactions")) 331 if (!db.tables().contains("transactions"))
324 { 332 {
325 query.exec(QStringLiteral( 333 query.exec(QStringLiteral(
327 "id INTEGER PRIMARY KEY, " 335 "id INTEGER PRIMARY KEY, "
328 "person INT NOT NULL, " 336 "person INT NOT NULL, "
329 "value REAL, " 337 "value REAL, "
330 "added DATETIME NOT NULL)")); 338 "added DATETIME NOT NULL)"));
331 339
332 slCheckAndReportSQLError("CREATE TABLE transactions", query.lastError(), true); 340 if (!slCheckAndReportSQLError("CREATE TABLE transactions", query.lastError(), true))
341 {
342 slErrorMsg(
343 QObject::tr("Tietokantataulua ei voitu luoda"),
344 QObject::tr("Virhe: %1<br><br>").
345 arg(db.lastError().text())
346 );
347 return 1;
348 }
333 } 349 }
334 350
335 query.finish(); 351 query.finish();
336 352
337 SyntilistaMainWindow swin; 353 SyntilistaMainWindow swin;