From 42e1358386f05abf898fc8d1e4422423fdec25c1 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Fri, 15 Jan 2021 07:35:15 -0500 Subject: [PATCH] 2021-01-15 Fred Gleason * Modified the 'RDLibraryModel::addCart()' to return 'QModelIndex' rather than 'int'. Signed-off-by: Fred Gleason --- ChangeLog | 3 +++ lib/rdlibrarymodel.cpp | 4 ++-- lib/rdlibrarymodel.h | 2 +- rdlibrary/rdlibrary.cpp | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 41d2d2e8..ac5148ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20791,3 +20791,6 @@ 2021-01-14 Fred Gleason * Fixed a bug in rdlibrary(1) that caused a SQL error to be generated when neither audio nor macro carts were selected in the cart filter. +2021-01-15 Fred Gleason + * Modified the 'RDLibraryModel::addCart()' to return 'QModelIndex' + rather than 'int'. diff --git a/lib/rdlibrarymodel.cpp b/lib/rdlibrarymodel.cpp index fdeaf741..194d6480 100644 --- a/lib/rdlibrarymodel.cpp +++ b/lib/rdlibrarymodel.cpp @@ -334,7 +334,7 @@ QString RDLibraryModel::cartOwnedBy(const QModelIndex &index) } -int RDLibraryModel::addCart(unsigned cartnum) +QModelIndex RDLibraryModel::addCart(unsigned cartnum) { // // Find the insertion offset @@ -372,7 +372,7 @@ int RDLibraryModel::addCart(unsigned cartnum) endInsertRows(); emit rowCountChanged(d_texts.size()); - return offset; + return createIndex(offset,0,0); } diff --git a/lib/rdlibrarymodel.h b/lib/rdlibrarymodel.h index f77fb9a9..70a13dac 100644 --- a/lib/rdlibrarymodel.h +++ b/lib/rdlibrarymodel.h @@ -58,7 +58,7 @@ class RDLibraryModel : public QAbstractItemModel RDCart::Type cartType(const QModelIndex &index) const; QString cutName(const QModelIndex &index) const; QString cartOwnedBy(const QModelIndex &index); - int addCart(unsigned cartnum); + QModelIndex addCart(unsigned cartnum); void removeCart(unsigned cartnum); void refreshRow(const QModelIndex &index); void refreshCart(unsigned cartnum); diff --git a/rdlibrary/rdlibrary.cpp b/rdlibrary/rdlibrary.cpp index 8d5b3dd5..2a5a47cf 100644 --- a/rdlibrary/rdlibrary.cpp +++ b/rdlibrary/rdlibrary.cpp @@ -377,8 +377,8 @@ void MainWidget::addData() EditCart *cart= new EditCart(cartnums,&lib_import_path,true,profile_ripping,this); if(cart->exec()) { - int row=lib_cart_model->addCart(cart_num); - lib_cart_view->scrollTo(lib_cart_model->index(row,0)); + QModelIndex row=lib_cart_model->addCart(cart_num); + SelectRow(row); SendNotification(RDNotification::AddAction,cart_num); } else {