mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-20 06:58:01 +02:00
2021-01-15 Fred Gleason <fredg@paravelsystems.com>
* Modified 'RDCutList::cutName()'to take 'QModelIndex' instead of 'int'. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
3536c8b151
commit
d6b2b22462
@ -20796,3 +20796,6 @@
|
||||
rather than 'int'.
|
||||
* Renamed 'RDLibraryModel::refreshCartLine()' to
|
||||
'RDLibrary::updateCartLine()' and made it protected.
|
||||
2021-01-15 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Modified 'RDCutList::cutName()'to take 'QModelIndex' instead of
|
||||
'int'.
|
||||
|
@ -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<QVariant> 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;i<d_row_index.size();i++) {
|
||||
if(d_row_index.at(i)==(d_row_index.size()-1)) {
|
||||
return i;
|
||||
return createIndex(i,0);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
|
||||
void RDCutListModel::removeCut(int row)
|
||||
void RDCutListModel::removeCut(const QModelIndex &row)
|
||||
{
|
||||
beginResetModel();
|
||||
d_texts.removeAt(d_row_index.at(row));
|
||||
d_colors.removeAt(d_row_index.at(row));
|
||||
d_row_index.removeAt(row);
|
||||
d_texts.removeAt(d_row_index.at(row.row()));
|
||||
d_colors.removeAt(d_row_index.at(row.row()));
|
||||
d_row_index.removeAt(row.row());
|
||||
for(int i=0;i<d_row_index.size();i++) {
|
||||
if(d_row_index.at(i)>row) {
|
||||
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;i<d_texts.size();i++) {
|
||||
if(cutName(i)==cutname) {
|
||||
removeCut(i);
|
||||
if(d_texts.at(i).at(12)==cutname) {
|
||||
removeCut(createIndex(i,0));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RDCutListModel::refresh(int row)
|
||||
void RDCutListModel::refresh(const QModelIndex &row)
|
||||
{
|
||||
if(row<d_texts.size()) {
|
||||
QString sql=sqlFields()+
|
||||
"where CUT_NAME=\""+RDEscapeString(d_texts.at(d_row_index.at(row)).at(12).toString())+
|
||||
"\"";
|
||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||
if(q->first()) {
|
||||
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;i<d_texts.size();i++) {
|
||||
if(d_texts.at(d_row_index.at(i)).at(12)==cutname) {
|
||||
refresh(i);
|
||||
updateCutLine(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -251,14 +240,14 @@ unsigned RDCutListModel::cartNumber() const
|
||||
}
|
||||
|
||||
|
||||
int RDCutListModel::row(const QString &cutname) const
|
||||
QModelIndex RDCutListModel::row(const QString &cutname) const
|
||||
{
|
||||
for(int i=0;i<d_row_index.size();i++) {
|
||||
if(d_texts.at(d_row_index.at(i)).at(12).toString()==cutname) {
|
||||
return i;
|
||||
return createIndex(i,0);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
|
||||
@ -424,6 +413,23 @@ void RDCutListModel::updateRow(int row,RDSqlQuery *q)
|
||||
}
|
||||
|
||||
|
||||
void RDCutListModel::updateCutLine(int line)
|
||||
{
|
||||
if(line<d_texts.size()) {
|
||||
QString sql=sqlFields()+
|
||||
"where CUT_NAME=\""+RDEscapeString(d_texts.at(d_row_index.at(line)).
|
||||
at(12).toString())+"\"";
|
||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||
if(q->first()) {
|
||||
beginResetModel();
|
||||
updateRow(line,q);
|
||||
sortRows(d_use_weighting);
|
||||
endResetModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString RDCutListModel::sqlFields() const
|
||||
{
|
||||
QString sql;
|
||||
|
@ -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<int> *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);
|
||||
|
||||
|
@ -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;i<rows.size();i++) {
|
||||
cutnames.push_back(rdcart_cut_model->cutName(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<QString> 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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user