fixing images not updating after items being deleted in middle
This commit is contained in:
parent
893c32ea6f
commit
cf15949347
2 changed files with 41 additions and 9 deletions
|
@ -122,12 +122,24 @@ void ImageSqlModel::setTitle(const QString &title) {
|
||||||
// This function is for updating the title from outside the delegate
|
// This function is for updating the title from outside the delegate
|
||||||
void ImageSqlModel::updateTitle(const int &row, const QString &title) {
|
void ImageSqlModel::updateTitle(const int &row, const QString &title) {
|
||||||
qDebug() << "Row is " << row;
|
qDebug() << "Row is " << row;
|
||||||
QSqlRecord rowdata = record(row);
|
QSqlQuery query("select id from images");
|
||||||
qDebug() << rowdata;
|
QList<int> ids;
|
||||||
|
while (query.next()) {
|
||||||
|
ids.append(query.value(0).toInt());
|
||||||
|
// qDebug() << ids;
|
||||||
|
}
|
||||||
|
int id = ids.indexOf(row,0);
|
||||||
|
|
||||||
|
QSqlRecord rowdata = record(id);
|
||||||
|
// qDebug() << rowdata.value(0);
|
||||||
rowdata.setValue("title", title);
|
rowdata.setValue("title", title);
|
||||||
setRecord(row, rowdata);
|
bool suc = setRecord(id, rowdata);
|
||||||
qDebug() << rowdata;
|
qDebug() << "#############";
|
||||||
submitAll();
|
qDebug() << rowdata.value("title");
|
||||||
|
qDebug() << "was it successful? " << suc;
|
||||||
|
qDebug() << "#############";
|
||||||
|
bool suca = submitAll();
|
||||||
|
// qDebug() << suca;
|
||||||
emit titleChanged();
|
emit titleChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,10 +160,18 @@ void ImageSqlModel::setFilePath(const QUrl &filePath) {
|
||||||
// This function is for updating the filepath from outside the delegate
|
// This function is for updating the filepath from outside the delegate
|
||||||
void ImageSqlModel::updateFilePath(const int &row, const QUrl &filePath) {
|
void ImageSqlModel::updateFilePath(const int &row, const QUrl &filePath) {
|
||||||
qDebug() << "Row is " << row;
|
qDebug() << "Row is " << row;
|
||||||
QSqlRecord rowdata = record(row);
|
QSqlQuery query("select id from images");
|
||||||
|
QList<int> ids;
|
||||||
|
while (query.next()) {
|
||||||
|
ids.append(query.value(0).toInt());
|
||||||
|
// qDebug() << ids;
|
||||||
|
}
|
||||||
|
int id = ids.indexOf(row,0);
|
||||||
|
|
||||||
|
QSqlRecord rowdata = record(id);
|
||||||
qDebug() << rowdata;
|
qDebug() << rowdata;
|
||||||
rowdata.setValue("filePath", filePath);
|
rowdata.setValue("filePath", filePath);
|
||||||
setRecord(row, rowdata);
|
setRecord(id, rowdata);
|
||||||
qDebug() << rowdata;
|
qDebug() << rowdata;
|
||||||
submitAll();
|
submitAll();
|
||||||
emit filePathChanged();
|
emit filePathChanged();
|
||||||
|
|
|
@ -123,10 +123,10 @@ Item {
|
||||||
Layout.leftMargin: 20
|
Layout.leftMargin: 20
|
||||||
Layout.rightMargin: 20
|
Layout.rightMargin: 20
|
||||||
|
|
||||||
placeholderText: "Song Title..."
|
placeholderText: "Image Title..."
|
||||||
text: image.title
|
text: image.title
|
||||||
padding: 10
|
padding: 10
|
||||||
/* onEditingFinished: updateTitle(text); */
|
onEditingFinished: updateTitle(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
@ -166,4 +166,16 @@ Item {
|
||||||
root.image = image;
|
root.image = image;
|
||||||
print(image.filePath.toString());
|
print(image.filePath.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateTitle(text) {
|
||||||
|
changeTitle(text, false);
|
||||||
|
imagesqlmodel.updateTitle(image.id, text);
|
||||||
|
showPassiveNotification(image.title);
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeTitle(text, updateBox) {
|
||||||
|
if (updateBox)
|
||||||
|
imageTitleField.text = text;
|
||||||
|
image.title = text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue