2024-04-25 Fred Gleason <fredg@paravelsystems.com>

* Fixed a regression in rdlibrary(1) that caused output of the Cart
	Report to not reflect the current filter and sorting state of the
	library list.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2024-04-25 17:22:05 -04:00
parent 8f82adbd7b
commit 43761e9508
6 changed files with 34 additions and 15 deletions

View File

@@ -2,7 +2,7 @@
//
// Data model for the Rivendell cart library
//
// (C) Copyright 2021-2022 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2021-2024 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -556,6 +556,12 @@ int RDLibraryModel::cartLimit() const
}
QString RDLibraryModel::orderBySql() const
{
return d_order_by_sql;
}
void RDLibraryModel::setShowNotes(int state)
{
d_show_notes=state;
@@ -564,19 +570,20 @@ void RDLibraryModel::setShowNotes(int state)
void RDLibraryModel::setFilterSql(const QString &sql,int cart_limit)
{
// printf("FILTER SQL: %s\n",sql.toUtf8().constData());
d_filter_sql=sql;
d_cart_limit=cart_limit;
d_order_by_sql="";
QString fsql=sql;
if(d_sort_column<0) { // Use "natural" sort order
fsql+=" order by `CART`.`NUMBER` asc ";
d_order_by_sql+=" order by `CART`.`NUMBER` asc ";
}
else {
fsql+=" order by "+d_order_columns.at(d_sort_column)+" "+
d_order_by_sql+=" order by "+d_order_columns.at(d_sort_column)+" "+
d_sort_clauses.value(d_sort_order);
}
fsql+=", `CUTS`.`PLAY_ORDER` asc ";
d_order_by_sql+=", `CUTS`.`PLAY_ORDER` asc ";
fsql+=d_order_by_sql;
d_filter_set=true;
updateModel(fsql);

View File

@@ -2,7 +2,7 @@
//
// Data model for the Rivendell cart library
//
// (C) Copyright 2021 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2021-2024 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -67,6 +67,7 @@ class RDLibraryModel : public QAbstractItemModel
QModelIndex refreshCart(unsigned cartnum);
bool showNotes() const;
int cartLimit() const;
QString orderBySql() const;
signals:
void rowCountChanged(int rows);
@@ -88,6 +89,7 @@ class RDLibraryModel : public QAbstractItemModel
QByteArray DumpIndex(const QModelIndex &index,const QString &caption="") const;
bool d_show_notes;
QString d_filter_sql;
QString d_order_by_sql;
int d_cart_limit;
int d_sort_column;
Qt::SortOrder d_sort_order;