2021-09-21 Fred Gleason <fredg@paravelsystems.com>

* Fixed a regression in rdlibrary(1) that failed to update the
	length of macro carts after editing.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2021-09-21 11:55:42 -04:00
parent acd80bcd65
commit bf1d015cb4
6 changed files with 40 additions and 12 deletions

View File

@@ -22450,3 +22450,6 @@
* Enabled column sorting in the Library List in rdlibrary(1).
* Enabled column sorting in the 'Select Cart' dialog.
* Enabled column sorting in the 'Select Cut' dialog.
2021-09-21 Fred Gleason <fredg@paravelsystems.com>
* Fixed a regression in rdlibrary(1) that failed to update the
length of macro carts after editing.

View File

@@ -166,6 +166,27 @@ QString RDMacroCartModel::allCode() const
}
int RDMacroCartModel::totalLength() const
{
int ret=0;
bool ok=false;
for(int i=0;i<lineCount();i++) {
QStringList f0=
d_texts.at(i).at(1).toString().split(" ",QString::SkipEmptyParts);
if((f0.size()==2)&&(f0.at(0)=="SP")) {
f0[1].remove("!");
int msec=f0.at(1).toInt(&ok);
if(ok&&(msec>=0)) {
ret+=msec;
}
}
}
return ret;
}
QModelIndex RDMacroCartModel::addLine(const QModelIndex &row,const QString &rml)
{
//
@@ -207,8 +228,12 @@ void RDMacroCartModel::refresh(const QModelIndex &row,const QString &rml)
void RDMacroCartModel::save() const
{
int len=totalLength();
QString sql=QString("update `CART` set ")+
"`MACROS`=\""+RDEscapeString(allCode())+"\" where "+
"`MACROS`='"+RDEscapeString(allCode())+"',"+
QString::asprintf("`FORCED_LENGTH`=%d,",len)+
QString::asprintf("`AVERAGE_LENGTH`=%d ",len)+
"where "+
QString::asprintf("`NUMBER`=%u",d_cart_number);
RDSqlQuery::apply(sql);
}

View File

@@ -48,6 +48,7 @@ class RDMacroCartModel : public QAbstractTableModel
bool isEndHandle(const QModelIndex &row) const;
QString code(const QModelIndex &row) const;
QString allCode() const;
int totalLength() const;
QModelIndex addLine(const QModelIndex &row,const QString &rml);
void removeLine(const QModelIndex &row);
void refresh(const QModelIndex &row,const QString &rml);

View File

@@ -736,13 +736,12 @@ void EditCart::lengthChangedData(unsigned len)
void EditCart::okData()
{
// RDSystem *system;
QString sql;
RDSqlQuery *q;
if(rdcart_cart_numbers.size()==1) { // Single Edit
if(rdcart_controls.title_edit->text().isEmpty()) {
QMessageBox::warning(this,tr("Missing Title"),
QMessageBox::warning(this,"RDLibrary - "+tr("Missing Title"),
tr("You must provide at least a Cart Title!"));
return;
}
@@ -752,7 +751,7 @@ void EditCart::okData()
QString::asprintf("(`NUMBER`!=%u)",rdcart_cart->number());
q=new RDSqlQuery(sql);
if(q->first()) {
QMessageBox::warning(this,tr("Duplicate Title"),
QMessageBox::warning(this,"RDLibrary - "+tr("Duplicate Title"),
tr("The cart title must be unique!"));
delete q;
return;
@@ -761,7 +760,7 @@ void EditCart::okData()
}
if(rdcart_controls.enforce_length_box->isChecked()) {
if(!ValidateLengths()) {
switch(QMessageBox::warning(this,tr("Length Mismatch"),
switch(QMessageBox::warning(this,"RDLibrary - "+tr("Length Mismatch"),
tr("One or more cut lengths exceed the timescaling\nlimits of the system! Do you still want to save?"),QMessageBox::Yes,QMessageBox::No)) {
case QMessageBox::No:
case QMessageBox::NoButton:

View File

@@ -18,8 +18,6 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <qstring.h>
#include "cdripper.h"
#include "edit_macro.h"
#include "globals.h"
@@ -300,8 +298,10 @@ void MacroCart::doubleClickedData(const QModelIndex &index)
void MacroCart::UpdateLength()
{
if(rdcart_events->length()!=rdcart_length) {
rdcart_length=rdcart_events->length();
emit lengthChanged(rdcart_length);
unsigned len=rdcart_macro_model->totalLength();
if(len!=rdcart_length) {
rdcart_length=len;
emit lengthChanged(len);
}
}

View File

@@ -21,8 +21,8 @@
#ifndef MACRO_CART_H
#define MACRO_CART_H
#include <qcombobox.h>
#include <qpushbutton.h>
#include <QComboBox>
#include <QPushButton>
#include <rdmacro_event.h>
#include <rdmacrocartmodel.h>