a working multi delete in libraries

This commit is contained in:
Chris Cochrun 2023-03-05 06:51:47 -06:00
parent 8eeb3b5151
commit 6c33e52ea3
10 changed files with 51 additions and 14 deletions

View file

@ -235,3 +235,12 @@ void ImageProxyModel::deleteImage(const int &row) {
auto model = qobject_cast<ImageSqlModel *>(sourceModel()); auto model = qobject_cast<ImageSqlModel *>(sourceModel());
model->deleteImage(row); model->deleteImage(row);
} }
void ImageProxyModel::deleteImages(const QVector<int> &rows) {
auto model = qobject_cast<ImageSqlModel *>(sourceModel());
qDebug() << "DELETING!!!!!!!!!!!!!!!!!!!!!!!" << rows;
for (int i = rows.size() - 1; i >= 0; i--) {
qDebug() << "deleting" << rows.at(i);
model->deleteImage(rows.at(i));
}
}

View file

@ -62,6 +62,7 @@ public:
public slots: public slots:
Q_INVOKABLE QVariantMap getImage(const int &row); Q_INVOKABLE QVariantMap getImage(const int &row);
Q_INVOKABLE void deleteImage(const int &row); Q_INVOKABLE void deleteImage(const int &row);
Q_INVOKABLE void deleteImages(const QVector<int> &rows);
private: private:
ImageSqlModel *m_imageModel; ImageSqlModel *m_imageModel;

View file

@ -270,3 +270,12 @@ void PresentationProxyModel::deletePresentation(const int &row) {
auto model = qobject_cast<PresentationSqlModel *>(sourceModel()); auto model = qobject_cast<PresentationSqlModel *>(sourceModel());
model->deletePresentation(row); model->deletePresentation(row);
} }
void PresentationProxyModel::deletePresentations(const QVector<int> &rows) {
auto model = qobject_cast<PresentationSqlModel *>(sourceModel());
qDebug() << "DELETING!!!!!!!!!!!!!!!!!!!!!!!" << rows;
for (int i = rows.size() - 1; i >= 0; i--) {
qDebug() << "deleting" << rows.at(i);
model->deletePresentation(rows.at(i));
}
}

View file

@ -69,6 +69,7 @@ public:
public slots: public slots:
Q_INVOKABLE QVariantMap getPresentation(const int &row); Q_INVOKABLE QVariantMap getPresentation(const int &row);
Q_INVOKABLE void deletePresentation(const int &row); Q_INVOKABLE void deletePresentation(const int &row);
Q_INVOKABLE void deletePresentations(const QVector<int> &row);
private: private:
PresentationSqlModel *m_presentationModel; PresentationSqlModel *m_presentationModel;

View file

@ -760,3 +760,13 @@ void SongProxyModel::deleteSong(const int &row) {
auto model = qobject_cast<SongSqlModel *>(sourceModel()); auto model = qobject_cast<SongSqlModel *>(sourceModel());
model->deleteSong(row); model->deleteSong(row);
} }
void SongProxyModel::deleteSongs(const QVector<int> &rows) {
auto model = qobject_cast<SongSqlModel *>(sourceModel());
qDebug() << "DELETING!!!!!!!!!!!!!!!!!!!!!!!" << rows;
for (int i = rows.size() - 1; i >= 0; i--) {
qDebug() << "deleting" << rows.at(i);
model->deleteSong(rows.at(i));
}
}

View file

@ -131,6 +131,7 @@ public:
public slots: public slots:
Q_INVOKABLE QVariantMap getSong(const int &row); Q_INVOKABLE QVariantMap getSong(const int &row);
Q_INVOKABLE void deleteSong(const int &row); Q_INVOKABLE void deleteSong(const int &row);
Q_INVOKABLE void deleteSongs(const QVector<int> &rows);
Q_INVOKABLE QStringList getLyricList(const int &row); Q_INVOKABLE QStringList getLyricList(const int &row);
// Q_INVOKABLE void select(int row); // Q_INVOKABLE void select(int row);
// Q_INVOKABLE void selectSongs(int row); // Q_INVOKABLE void selectSongs(int row);

View file

@ -351,3 +351,12 @@ void VideoProxyModel::deleteVideo(const int &row) {
auto model = qobject_cast<VideoSqlModel *>(sourceModel()); auto model = qobject_cast<VideoSqlModel *>(sourceModel());
model->deleteVideo(mapToSource(index(row,0)).row()); model->deleteVideo(mapToSource(index(row,0)).row());
} }
void VideoProxyModel::deleteVideos(const QVector<int> &rows) {
auto model = qobject_cast<VideoSqlModel *>(sourceModel());
qDebug() << "DELETING!!!!!!!!!!!!!!!!!!!!!!!" << rows;
for (int i = rows.size() - 1; i >= 0; i--) {
qDebug() << "deleting" << rows.at(i);
model->deleteVideo(rows.at(i));
}
}

View file

@ -80,6 +80,7 @@ public:
public slots: public slots:
Q_INVOKABLE QVariantMap getVideo(const int &row); Q_INVOKABLE QVariantMap getVideo(const int &row);
Q_INVOKABLE void deleteVideo(const int &row); Q_INVOKABLE void deleteVideo(const int &row);
Q_INVOKABLE void deleteVideos(const QVector<int> &row);
private: private:
VideoSqlModel *m_videoModel; VideoSqlModel *m_videoModel;

View file

@ -46,8 +46,8 @@ Item {
editType = "song"; editType = "song";
editSwitch(libraryList.currentIndex); editSwitch(libraryList.currentIndex);
}) })
deleteItemFunction: (function(index) { deleteItemFunction: (function(rows) {
songProxyModel.deleteSong(index) songProxyModel.deleteSongs(rows)
}) })
Component.onCompleted: selectedLibrary = "song"; Component.onCompleted: selectedLibrary = "song";
@ -72,8 +72,8 @@ Item {
newItemFunction: (function() { newItemFunction: (function() {
videoProxyModel.setFilterRegularExpression(""); videoProxyModel.setFilterRegularExpression("");
}) })
deleteItemFunction: (function(index) { deleteItemFunction: (function(rows) {
videoProxyModel.deleteVideo(index) videoProxyModel.deleteVideos(rows)
}) })
} }
@ -97,8 +97,8 @@ Item {
newItemFunction: (function() { newItemFunction: (function() {
imageProxyModel.setFilterRegularExpression(""); imageProxyModel.setFilterRegularExpression("");
}) })
deleteItemFunction: (function(index) { deleteItemFunction: (function(rows) {
imageProxyModel.deleteImage(index) imageProxyModel.deleteImages(rows)
}) })
} }
@ -122,8 +122,8 @@ Item {
newItemFunction: (function() { newItemFunction: (function() {
presProxyModel.setFilterRegularExpression(""); presProxyModel.setFilterRegularExpression("");
}) })
deleteItemFunction: (function(index) { deleteItemFunction: (function(rows) {
presProxyModel.deletePresentation(index) presProxyModel.deletePresentations(rows)
}) })
} }

View file

@ -360,13 +360,9 @@ ColumnLayout {
var selection = []; var selection = [];
var length = selectionModel.selectedIndexes.length; var length = selectionModel.selectedIndexes.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
selection.push(selectionModel.selectedIndexes[i]); selection.push(selectionModel.selectedIndexes[i].row);
console.log(selection[i].row);
/* root.deleteItemFunction(selection[i].row); */
}
for (let i = 0; i < length; i++) {
root.deleteItemFunction(selection[i].row);
} }
root.deleteItemFunction(selection);
} }
} }
} }