Commit 7a6a37920a936085b87bb03e97ccbe5c1cd17d29

Authored by Josh Klontz
1 parent 0495f89e

updated dbGallery

Showing 1 changed file with 11 additions and 11 deletions
sdk/plugins/gallery.cpp
@@ -474,17 +474,17 @@ class dbGallery : public Gallery @@ -474,17 +474,17 @@ class dbGallery : public Gallery
474 static QSqlDatabase db; 474 static QSqlDatabase db;
475 if (!db.isValid()) db = QSqlDatabase::addDatabase("QSQLITE"); 475 if (!db.isValid()) db = QSqlDatabase::addDatabase("QSQLITE");
476 db.setDatabaseName(file); 476 db.setDatabaseName(file);
477 - if (!db.open()) qFatal("Input::loadDatabase failed to open SQLite database %s.", qPrintable((QString)file)); 477 + if (!db.open()) qFatal("Failed to open SQLite database %s.", qPrintable(file.name));
478 478
479 if (!import.isNull()) { 479 if (!import.isNull()) {
480 - qDebug("Parsing %s", qPrintable((QString)import)); 480 + qDebug("Parsing %s", qPrintable(import.name));
481 QStringList lines = QtUtils::readLines(import); 481 QStringList lines = QtUtils::readLines(import);
482 QList<QStringList> cells; cells.reserve(lines.size()); 482 QList<QStringList> cells; cells.reserve(lines.size());
483 const QRegExp re("\\s*,\\s*"); 483 const QRegExp re("\\s*,\\s*");
484 - foreach (const QString &line, lines) 484 + foreach (const QString &line, lines) {
485 cells.append(line.split(re)); 485 cells.append(line.split(re));
486 - if (cells.size() < 2) qFatal("Input::loadDatabase expected at least two rows in %s.", qPrintable((QString)import));  
487 - if (cells[0].size() != cells[1].size()) qFatal("Input::loadDatabase column count mismatch."); 486 + if (cells.last().size() != cells.first().size()) qFatal("Column count mismatch.");
  487 + }
488 488
489 QStringList columns, qMarks; 489 QStringList columns, qMarks;
490 QList<QVariantList> variantLists; 490 QList<QVariantList> variantLists;
@@ -506,21 +506,21 @@ class dbGallery : public Gallery @@ -506,21 +506,21 @@ class dbGallery : public Gallery
506 qDebug("Creating table %s", qPrintable(table)); 506 qDebug("Creating table %s", qPrintable(table));
507 QSqlQuery q(db); 507 QSqlQuery q(db);
508 if (!q.exec("CREATE TABLE " + table + " (" + columns.join(", ") + ");")) 508 if (!q.exec("CREATE TABLE " + table + " (" + columns.join(", ") + ");"))
509 - qFatal("Input::loadDatabase %s.", qPrintable(q.lastError().text())); 509 + qFatal("%s.", qPrintable(q.lastError().text()));
510 if (!q.prepare("insert into " + table + " values (" + qMarks.join(", ") + ")")) 510 if (!q.prepare("insert into " + table + " values (" + qMarks.join(", ") + ")"))
511 - qFatal("Input::loadDatabase %s.", qPrintable(q.lastError().text())); 511 + qFatal("%s.", qPrintable(q.lastError().text()));
512 foreach (const QVariantList &vl, variantLists) 512 foreach (const QVariantList &vl, variantLists)
513 q.addBindValue(vl); 513 q.addBindValue(vl);
514 - if (!q.execBatch()) qFatal("Input::loadDatabase %s.", qPrintable(q.lastError().text())); 514 + if (!q.execBatch()) qFatal("%s.", qPrintable(q.lastError().text()));
515 } 515 }
516 516
517 QSqlQuery q(db); 517 QSqlQuery q(db);
518 if (query.startsWith('\'') && query.endsWith('\'')) 518 if (query.startsWith('\'') && query.endsWith('\''))
519 query = query.mid(1, query.size()-2); 519 query = query.mid(1, query.size()-2);
520 if (!q.exec(query)) 520 if (!q.exec(query))
521 - qFatal("Input::loadDatabase %s.", qPrintable(q.lastError().text())); 521 + qFatal("%s.", qPrintable(q.lastError().text()));
522 if ((q.record().count() == 0) || (q.record().count() > 3)) 522 if ((q.record().count() == 0) || (q.record().count() > 3))
523 - qFatal("Input::loadDatabase query record expected one to three fields, got %d.", q.record().count()); 523 + qFatal("Query record expected one to three fields, got %d.", q.record().count());
524 const bool hasMetadata = (q.record().count() >= 2); 524 const bool hasMetadata = (q.record().count() >= 2);
525 const bool hasFilter = (q.record().count() >= 3); 525 const bool hasFilter = (q.record().count() >= 3);
526 526
@@ -599,7 +599,7 @@ class dbGallery : public Gallery @@ -599,7 +599,7 @@ class dbGallery : public Gallery
599 void write(const Template &t) 599 void write(const Template &t)
600 { 600 {
601 (void) t; 601 (void) t;
602 - qFatal("Writing to a dbGallery not supported."); 602 + qFatal("Writing not supported.");
603 } 603 }
604 }; 604 };
605 605