diff --git a/src/qml/presenter/Library.qml b/src/qml/presenter/Library.qml index f68aa81..9178605 100644 --- a/src/qml/presenter/Library.qml +++ b/src/qml/presenter/Library.qml @@ -241,12 +241,12 @@ Item { if(mouse.button == Qt.RightButton) rightClickSongMenu.popup() else{ - showPassiveNotification(title, 3000) - songLibraryList.currentIndex = index + showPassiveNotification(title + id, 3000); + songLibraryList.currentIndex = index; if (!editMode) editMode = true; editType = "song"; - editSwitch(index); + editSwitch(id); } } diff --git a/src/qml/presenter/SongEditor.qml b/src/qml/presenter/SongEditor.qml index b514068..2346ee8 100644 --- a/src/qml/presenter/SongEditor.qml +++ b/src/qml/presenter/SongEditor.qml @@ -320,6 +320,7 @@ Item { function changeSong(index) { clearSlides(); + print(index); const s = songsqlmodel.getSong(index); song = s; songLyrics = s.lyrics; diff --git a/src/songsqlmodel.cpp b/src/songsqlmodel.cpp index fececd8..2152c2a 100644 --- a/src/songsqlmodel.cpp +++ b/src/songsqlmodel.cpp @@ -133,9 +133,21 @@ QVariantMap SongSqlModel::getSong(const int &row) { // this whole function returns all data in the song // regardless of it's length. When new things are added // it will still work without refactoring. + const QModelIndex &parent = QModelIndex(); QVariantMap data; - const QModelIndex idx = this->index(row,0); - // qDebug() << idx; + QSqlQuery query("select id from songs"); + QList 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() ) return data; const QHash rn = roleNames(); @@ -150,7 +162,19 @@ QVariantMap SongSqlModel::getSong(const int &row) { } QStringList SongSqlModel::getLyricList(const int &row) { - QSqlRecord recordData = record(row); + QSqlQuery query("select id from songs"); + QList 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()) { qDebug() << "this is not a song"; QStringList empty;