| 401 | } |
| 402 | |
| 403 | void Database::createLabels(QSqlDatabase &db) |
| 404 | { |
| 405 | QSqlQuery q(db); |
| 406 | for (int i = 0; i < 6; i++) { |
| 407 | q.prepare("INSERT INTO labels(name, image) " |
| 408 | "VALUES (:name, :image)"); |
| 409 | q.bindValue(":name", MainWindow::nameLabels().at(i)); |
| 410 | |
| 411 | QFile file(QString(":/images/label_%1").arg(i+1)); |
| 412 | file.open(QFile::ReadOnly); |
| 413 | q.bindValue(":image", file.readAll()); |
| 414 | file.close(); |
| 415 | |
| 416 | q.exec(); |
| 417 | |
| 418 | int labelId = q.lastInsertId().toInt(); |
| 419 | q.exec(QString("UPDATE labels SET num='%1' WHERE id=='%1'").arg(labelId)); |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | void Database::addColumnsToFeedsTables(QSqlDatabase &db) |
| 424 | { |