void PictureDao::update (Picture picture) { m_database->open(); PictureProperties properties = picture.pictureProperties(); QString query ("UPDATE pictures SET "); query += "name='" + picture.name() + "',"; query += "path=" + m_database->formatString( picture.path() ) + ","; query += "brightness=" + QString::number(properties.brightness) + ","; query += "contrast=" + QString::number(properties.contrast) + ","; query += "gamma=" + QString::number(properties.gamma) + ","; query += "wb_red=" + QString::number(properties.wb_red) + ","; query += "wb_green=" + QString::number(properties.wb_green) + ","; query += "wb_blue=" + QString::number(properties.wb_blue); query += " WHERE id=" + QString::number(picture.id()) + ";"; qDebug() << query; m_database->exec( query ); m_database->close(); }
void PictureDao::create (Picture picture) { m_database->open(); QString query ("INSERT INTO pictures (name,path,brightness,contrast,gamma,wb_red,wb_green,wb_blue) VALUES ("); PictureProperties properties = picture.pictureProperties(); query += "'" + picture.name() + "',"; query += m_database->formatString( picture.path() ) +","; query += QString::number(properties.brightness) +","; query += QString::number(properties.contrast) +","; query += QString::number(properties.gamma) +","; query += QString::number(properties.wb_red) +","; query += QString::number(properties.wb_green) +","; query += QString::number(properties.wb_blue) +");"; m_database->exec( query ); m_database->close(); }