223 } else { |
222 } else { |
224 query.bindValue(":recno", this->recno); |
223 query.bindValue(":recno", this->recno); |
225 } |
224 } |
226 query.exec(); |
225 query.exec(); |
227 if (query.lastError().isValid()) { |
226 if (query.lastError().isValid()) { |
228 qDebug() << "EditProfileMash" << query.lastError(); |
227 qWarning() << "EditProfileMash" << query.lastError(); |
229 QMessageBox::warning(this, tr("Database error"), |
228 QMessageBox::warning(this, tr("Database error"), |
230 tr("MySQL error: %1\n%2\n%3") |
229 tr("MySQL error: %1\n%2\n%3") |
231 .arg(query.lastError().nativeErrorCode()) |
230 .arg(query.lastError().nativeErrorCode()) |
232 .arg(query.lastError().driverText()) |
231 .arg(query.lastError().driverText()) |
233 .arg(query.lastError().databaseText())); |
232 .arg(query.lastError().databaseText())); |
240 this->textIsChanged = false; |
239 this->textIsChanged = false; |
241 WindowTitle(); |
240 WindowTitle(); |
242 } |
241 } |
243 |
242 |
244 |
243 |
|
244 void EditProfileMash::on_cloneButton_clicked() |
|
245 { |
|
246 QSqlQuery query; |
|
247 |
|
248 query.prepare("INSERT INTO profile_mash SET name=:name, notes=:notes, steps=:steps, uuid=:uuid"); |
|
249 query.bindValue(":name", ui->nameEdit->text() + " [copy]"); |
|
250 query.bindValue(":notes", ui->notesEdit->toPlainText()); |
|
251 query.bindValue(":steps", this->steps.toJson(QJsonDocument::Compact)); |
|
252 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
|
253 |
|
254 query.exec(); |
|
255 if (query.lastError().isValid()) { |
|
256 qWarning() << "EditProfileMash" << query.lastError(); |
|
257 QMessageBox::warning(this, tr("Database error"), |
|
258 tr("MySQL error: %1\n%2\n%3") |
|
259 .arg(query.lastError().nativeErrorCode()) |
|
260 .arg(query.lastError().driverText()) |
|
261 .arg(query.lastError().databaseText())); |
|
262 } else { |
|
263 qDebug() << "EditProfileMash Saved"; |
|
264 } |
|
265 } |
|
266 |
|
267 |
245 void EditProfileMash::on_deleteButton_clicked() |
268 void EditProfileMash::on_deleteButton_clicked() |
246 { |
269 { |
247 QSqlQuery query; |
270 QSqlQuery query; |
|
271 |
|
272 int rc = QMessageBox::warning(this, tr("Delete mash profile"), tr("Delete %1").arg(ui->nameEdit->text()), |
|
273 QMessageBox::Yes | QMessageBox::No, QMessageBox::No); |
|
274 if (rc == QMessageBox::No) |
|
275 return; |
248 |
276 |
249 query.prepare("DELETE FROM profile_mash WHERE record = :recno"); |
277 query.prepare("DELETE FROM profile_mash WHERE record = :recno"); |
250 query.bindValue(":recno", this->recno); |
278 query.bindValue(":recno", this->recno); |
251 query.exec(); |
279 query.exec(); |
252 if (query.lastError().isValid()) { |
280 if (query.lastError().isValid()) { |
253 qDebug() << "EditProfileMash" << query.lastError(); |
281 qWarning() << "EditProfileMash" << query.lastError(); |
254 QMessageBox::warning(this, tr("Database error"), |
282 QMessageBox::warning(this, tr("Database error"), |
255 tr("MySQL error: %1\n%2\n%3") |
283 tr("MySQL error: %1\n%2\n%3") |
256 .arg(query.lastError().nativeErrorCode()) |
284 .arg(query.lastError().nativeErrorCode()) |
257 .arg(query.lastError().driverText()) |
285 .arg(query.lastError().driverText()) |
258 .arg(query.lastError().databaseText())); |
286 .arg(query.lastError().databaseText())); |