diff --git a/ChangeLog b/ChangeLog index f0cbb923..af920222 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20796,3 +20796,6 @@ rather than 'int'. * Renamed 'RDLibraryModel::refreshCartLine()' to 'RDLibrary::updateCartLine()' and made it protected. +2021-01-15 Fred Gleason + * Modified 'RDCutList::cutName()'to take 'QModelIndex' instead of + 'int'. diff --git a/lib/rdcutlistmodel.cpp b/lib/rdcutlistmodel.cpp index be1cd86b..f0727925 100644 --- a/lib/rdcutlistmodel.cpp +++ b/lib/rdcutlistmodel.cpp @@ -35,7 +35,7 @@ RDCutListModel::RDCutListModel(bool use_weighting,QObject *parent) unsigned center=Qt::AlignCenter; unsigned right=Qt::AlignRight|Qt::AlignVCenter; - if(d_use_weighting) { + if(d_use_weighting) { // 00 d_headers.push_back(tr("Wt")); d_alignments.push_back(right); } @@ -44,43 +44,43 @@ RDCutListModel::RDCutListModel(bool use_weighting,QObject *parent) d_alignments.push_back(right); } - d_headers.push_back(tr("Description")); + d_headers.push_back(tr("Description")); // 01 d_alignments.push_back(left); - d_headers.push_back(tr("Length")); + d_headers.push_back(tr("Length")); // 02 d_alignments.push_back(right); - d_headers.push_back(tr("Last Played")); + d_headers.push_back(tr("Last Played")); // 03 d_alignments.push_back(center); - d_headers.push_back(tr("# of Plays")); + d_headers.push_back(tr("# of Plays")); // 04 d_alignments.push_back(right); - d_headers.push_back(tr("Source")); + d_headers.push_back(tr("Source")); // 05 d_alignments.push_back(left); - d_headers.push_back(tr("Ingest")); + d_headers.push_back(tr("Ingest")); // 06 d_alignments.push_back(left); - d_headers.push_back(tr("Outcue")); + d_headers.push_back(tr("Outcue")); // 07 d_alignments.push_back(left); - d_headers.push_back(tr("Start Date")); + d_headers.push_back(tr("Start Date")); // 08 d_alignments.push_back(center); - d_headers.push_back(tr("End Date")); + d_headers.push_back(tr("End Date")); // 09 d_alignments.push_back(center); - d_headers.push_back(tr("Daypart Start")); + d_headers.push_back(tr("Daypart Start")); // 10 d_alignments.push_back(left); - d_headers.push_back(tr("Daypart End")); + d_headers.push_back(tr("Daypart End")); // 11 d_alignments.push_back(left); - d_headers.push_back(tr("Name")); + d_headers.push_back(tr("Name")); // 12 d_alignments.push_back(left); - d_headers.push_back(tr("SHA1")); + d_headers.push_back(tr("SHA1")); // 13 d_alignments.push_back(left); } @@ -158,13 +158,13 @@ QVariant RDCutListModel::data(const QModelIndex &index,int role) const } -QString RDCutListModel::cutName(int row) const +QString RDCutListModel::cutName(const QModelIndex &row) const { - return d_texts.at(d_row_index.at(row)).at(12).toString(); + return d_texts.at(d_row_index.at(row.row())).at(12).toString(); } -int RDCutListModel::addCut(const QString &name) +QModelIndex RDCutListModel::addCut(const QString &name) { QList list; @@ -177,27 +177,27 @@ int RDCutListModel::addCut(const QString &name) d_texts.push_back(list); d_colors.push_back(d_palette.color(QPalette::Background)); d_row_index.push_back(d_row_index.size()); - refresh(d_texts.size()-1); + updateCutLine(d_texts.size()-1); sortRows(d_use_weighting); endResetModel(); for(int i=0;irow) { + if(d_row_index.at(i)>row.row()) { d_row_index[i]--; } } @@ -209,28 +209,17 @@ void RDCutListModel::removeCut(int row) void RDCutListModel::removeCut(const QString &cutname) { for(int i=0;ifirst()) { - beginResetModel(); - updateRow(row,q); - sortRows(d_use_weighting); - endResetModel(); - } - } + updateCutLine(row.row()); } @@ -238,7 +227,7 @@ void RDCutListModel::refresh(const QString &cutname) { for(int i=0;ifirst()) { + beginResetModel(); + updateRow(line,q); + sortRows(d_use_weighting); + endResetModel(); + } + } +} + + QString RDCutListModel::sqlFields() const { QString sql; diff --git a/lib/rdcutlistmodel.h b/lib/rdcutlistmodel.h index ce353d53..e9356823 100644 --- a/lib/rdcutlistmodel.h +++ b/lib/rdcutlistmodel.h @@ -44,14 +44,14 @@ class RDCutListModel : public QAbstractTableModel QVariant headerData(int section,Qt::Orientation orient, int role=Qt::DisplayRole) const; QVariant data(const QModelIndex &index,int role=Qt::DisplayRole) const; - QString cutName(int row) const; - int addCut(const QString &name); - void removeCut(int row); + QString cutName(const QModelIndex &row) const; + QModelIndex addCut(const QString &name); + void removeCut(const QModelIndex &index); void removeCut(const QString &cutname); - void refresh(int row); + void refresh(const QModelIndex &index); void refresh(const QString &cutname); unsigned cartNumber() const; - int row(const QString &cutname) const; + QModelIndex row(const QString &cutname) const; bool playOrderDuplicates(QList *values) const; public slots: @@ -60,6 +60,7 @@ class RDCutListModel : public QAbstractTableModel protected: void updateRow(int row,RDSqlQuery *q); + void updateCutLine(int line); QString sqlFields() const; void sortRows(int use_weighting); diff --git a/rdlibrary/audio_cart.cpp b/rdlibrary/audio_cart.cpp index 5451ac8f..f2c449f5 100644 --- a/rdlibrary/audio_cart.cpp +++ b/rdlibrary/audio_cart.cpp @@ -248,9 +248,9 @@ void AudioCart::addCutData() } rdcart_cut_view->clearSelection(); - int row=rdcart_cut_model->addCut(next_name); - rdcart_cut_view->selectRow(row); - rdcart_cut_view->scrollTo(rdcart_cut_model->index(row,0)); + QModelIndex row=rdcart_cut_model->addCut(next_name); + rdcart_cut_view->selectRow(row.row()); + rdcart_cut_view->scrollTo(row); disk_gauge->update(); emit cartDataChanged(); @@ -266,7 +266,7 @@ void AudioCart::deleteCutData() QStringList cutnames; for(int i=0;icutName(rows.at(i).row())); + cutnames.push_back(rdcart_cut_model->cutName(rows.at(i))); } // @@ -357,9 +357,8 @@ void AudioCart::deleteCutData() void AudioCart::copyCutData() { - int row; - - if((row=SingleSelectedLine())<0) { + QModelIndex row=SingleSelectedLine(); + if(!row.isValid()) { return; } if(cut_clipboard!=NULL) { @@ -372,9 +371,9 @@ void AudioCart::copyCutData() void AudioCart::pasteCutData() { - int row; + QModelIndex row=SingleSelectedLine(); - if((row=SingleSelectedLine())<0) { + if(!row.isValid()) { return; } if(!cut_clipboard->exists()) { @@ -410,9 +409,9 @@ void AudioCart::pasteCutData() void AudioCart::extEditorCutData() { - int row; + QModelIndex row=SingleSelectedLine(); - if((row=SingleSelectedLine())<0) { + if(!row.isValid()) { return; } @@ -432,26 +431,27 @@ void AudioCart::extEditorCutData() void AudioCart::editCutData() { - int row; + QModelIndex row=SingleSelectedLine(); - if((row=SingleSelectedLine())<0) { + if(!row.isValid()) { return; } QString cutname=rdcart_cut_model->cutName(row); if(!RDAudioExists(cutname)) { QMessageBox::information(this,"RDLibrary", - tr("No audio is present in the cut!")); + tr("No audio is present in the cut!")); return; } RDEditAudio *edit= new RDEditAudio(rdcart_cart,cutname,rda->libraryConf()->outputCard(), - rda->libraryConf()->outputPort(),rda->libraryConf()->tailPreroll(), + rda->libraryConf()->outputPort(), + rda->libraryConf()->tailPreroll(), rda->libraryConf()->trimThreshold(),this); if(edit->exec()!=-1) { emit cartDataChanged(); rdcart_cart->updateLength(rdcart_controls->enforce_length_box->isChecked(), - QTime().msecsTo(rdcart_controls-> - forced_length_edit->time())); + QTime().msecsTo(rdcart_controls-> + forced_length_edit->time())); rdcart_cut_model->refresh(row); } delete edit; @@ -460,9 +460,9 @@ void AudioCart::editCutData() void AudioCart::recordCutData() { - int row; + QModelIndex row=SingleSelectedLine(); - if((row=SingleSelectedLine())<0) { + if(!row.isValid()) { return; } QString cutname=rdcart_cut_model->cutName(row); @@ -470,7 +470,7 @@ void AudioCart::recordCutData() cut->exec(); delete cut; rdcart_cut_model->refresh(cutname); - rdcart_cut_view->selectRow(rdcart_cut_model->row(cutname)); + rdcart_cut_view->selectRow(rdcart_cut_model->row(cutname).row()); if(cut_clipboard==NULL) { paste_cut_button->setDisabled(true); } @@ -496,9 +496,10 @@ void AudioCart::ripCutData() QString artist; QString album; QString label; - int row; - if((row=SingleSelectedLine())<0) { + QModelIndex row=SingleSelectedLine(); + + if(!row.isValid()) { return; } @@ -539,9 +540,10 @@ void AudioCart::importCutData() QString cutname; RDWaveData wavedata; std::vector cutnames; - int row; - if((row=SingleSelectedLine())<0) { + QModelIndex row=SingleSelectedLine(); + + if(!row.isValid()) { return; } @@ -618,10 +620,10 @@ void AudioCart::copyProgressData(const QVariant &step) } -int AudioCart::SingleSelectedLine() const +QModelIndex AudioCart::SingleSelectedLine() const { if(rdcart_cut_view->selectionModel()->selectedRows().size()!=1) { - return -1; + return QModelIndex(); } - return rdcart_cut_view->selectionModel()->selectedRows().first().row(); + return rdcart_cut_view->selectionModel()->selectedRows().first(); } diff --git a/rdlibrary/audio_cart.h b/rdlibrary/audio_cart.h index 1300fca5..aa3b7638 100644 --- a/rdlibrary/audio_cart.h +++ b/rdlibrary/audio_cart.h @@ -69,7 +69,7 @@ class AudioCart : public RDWidget void audioChanged(); private: - int SingleSelectedLine() const; + QModelIndex SingleSelectedLine() const; RDCart *rdcart_cart; QTableView *rdcart_cut_view; RDCutListModel *rdcart_cut_model;