fixing getSong not working after deleting songs
This commit is contained in:
parent
8b6e5e2ad3
commit
4d9236e02c
3 changed files with 31 additions and 6 deletions
|
@ -241,12 +241,12 @@ Item {
|
||||||
if(mouse.button == Qt.RightButton)
|
if(mouse.button == Qt.RightButton)
|
||||||
rightClickSongMenu.popup()
|
rightClickSongMenu.popup()
|
||||||
else{
|
else{
|
||||||
showPassiveNotification(title, 3000)
|
showPassiveNotification(title + id, 3000);
|
||||||
songLibraryList.currentIndex = index
|
songLibraryList.currentIndex = index;
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
editType = "song";
|
editType = "song";
|
||||||
editSwitch(index);
|
editSwitch(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -320,6 +320,7 @@ Item {
|
||||||
|
|
||||||
function changeSong(index) {
|
function changeSong(index) {
|
||||||
clearSlides();
|
clearSlides();
|
||||||
|
print(index);
|
||||||
const s = songsqlmodel.getSong(index);
|
const s = songsqlmodel.getSong(index);
|
||||||
song = s;
|
song = s;
|
||||||
songLyrics = s.lyrics;
|
songLyrics = s.lyrics;
|
||||||
|
|
|
@ -133,9 +133,21 @@ QVariantMap SongSqlModel::getSong(const int &row) {
|
||||||
// this whole function returns all data in the song
|
// this whole function returns all data in the song
|
||||||
// regardless of it's length. When new things are added
|
// regardless of it's length. When new things are added
|
||||||
// it will still work without refactoring.
|
// it will still work without refactoring.
|
||||||
|
const QModelIndex &parent = QModelIndex();
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
const QModelIndex idx = this->index(row,0);
|
QSqlQuery query("select id from songs");
|
||||||
// qDebug() << idx;
|
QList<int> ids;
|
||||||
|
while (query.next()) {
|
||||||
|
ids.append(query.value(0).toInt());
|
||||||
|
// qDebug() << ids;
|
||||||
|
}
|
||||||
|
int id = ids.indexOf(row,0);
|
||||||
|
|
||||||
|
const QModelIndex idx = this->index(id, 0, parent);
|
||||||
|
qDebug() << "%%%%%%%%%";
|
||||||
|
qDebug() << row;
|
||||||
|
qDebug() << idx;
|
||||||
|
qDebug() << "%%%%%%%%%";
|
||||||
if( !idx.isValid() )
|
if( !idx.isValid() )
|
||||||
return data;
|
return data;
|
||||||
const QHash<int,QByteArray> rn = roleNames();
|
const QHash<int,QByteArray> rn = roleNames();
|
||||||
|
@ -150,7 +162,19 @@ QVariantMap SongSqlModel::getSong(const int &row) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList SongSqlModel::getLyricList(const int &row) {
|
QStringList SongSqlModel::getLyricList(const int &row) {
|
||||||
QSqlRecord recordData = record(row);
|
QSqlQuery query("select id from songs");
|
||||||
|
QList<int> ids;
|
||||||
|
qDebug() << row;
|
||||||
|
while (query.next()) {
|
||||||
|
ids.append(query.value(0).toInt());
|
||||||
|
qDebug() << ids;
|
||||||
|
}
|
||||||
|
int id = ids.indexOf(row,0);
|
||||||
|
|
||||||
|
qDebug() << "@@@@@@@@@@@@@@";
|
||||||
|
qDebug() << id;
|
||||||
|
qDebug() << "@@@@@@@@@@@@@@";
|
||||||
|
QSqlRecord recordData = record(id);
|
||||||
if (recordData.isEmpty()) {
|
if (recordData.isEmpty()) {
|
||||||
qDebug() << "this is not a song";
|
qDebug() << "this is not a song";
|
||||||
QStringList empty;
|
QStringList empty;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue