From 43761e9508f977506f15cdf9d7dfa3411495fe20 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Thu, 25 Apr 2024 17:22:05 -0400 Subject: [PATCH] 2024-04-25 Fred Gleason * 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 --- ChangeLog | 4 ++++ lib/rdlibrarymodel.cpp | 17 ++++++++++++----- lib/rdlibrarymodel.h | 4 +++- rdlibrary/list_reports.cpp | 12 ++++++++---- rdlibrary/list_reports.h | 6 +++--- rdlibrary/rdlibrary.cpp | 6 ++++-- 6 files changed, 34 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 94ea1da2..7bf714c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24722,3 +24722,7 @@ * Fixed a bug in the build system that failed to package 'Appendix I. Library Text Searches' in the HTML version of the Operations Guide. +2024-04-25 Fred Gleason + * 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. diff --git a/lib/rdlibrarymodel.cpp b/lib/rdlibrarymodel.cpp index 5e86d1df..7efee358 100644 --- a/lib/rdlibrarymodel.cpp +++ b/lib/rdlibrarymodel.cpp @@ -2,7 +2,7 @@ // // Data model for the Rivendell cart library // -// (C) Copyright 2021-2022 Fred Gleason +// (C) Copyright 2021-2024 Fred Gleason // // 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); diff --git a/lib/rdlibrarymodel.h b/lib/rdlibrarymodel.h index 26dd7afd..656712d2 100644 --- a/lib/rdlibrarymodel.h +++ b/lib/rdlibrarymodel.h @@ -2,7 +2,7 @@ // // Data model for the Rivendell cart library // -// (C) Copyright 2021 Fred Gleason +// (C) Copyright 2021-2024 Fred Gleason // // 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; diff --git a/rdlibrary/list_reports.cpp b/rdlibrary/list_reports.cpp index 817c5af2..aa0b4b41 100644 --- a/rdlibrary/list_reports.cpp +++ b/rdlibrary/list_reports.cpp @@ -2,7 +2,7 @@ // // List RDLibrary Reports // -// (C) Copyright 2002-2022 Fred Gleason +// (C) Copyright 2002-2024 Fred Gleason // // 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 @@ -29,11 +29,13 @@ #include "list_reports.h" ListReports::ListReports(const QString &filter,const QString &grpname, - const QString &filter_sql,QWidget *parent) + const QString &filter_sql,int cart_limit, + QWidget *parent) { list_filter=filter; list_group=grpname; list_filter_sql=filter_sql; + list_cart_limit=cart_limit; setWindowTitle("RDLibrary - "+tr("Select Report")); @@ -190,11 +192,13 @@ void ListReports::GenerateCartReport(QString *report) "left join `CUTS` on `CART`.`NUMBER`=`CUTS`.`CART_NUMBER` "; sql+=list_filter_sql; unsigned prev_cartnum=0; + int cart_count=list_cart_limit; q=new RDSqlQuery(sql); - while(q->next()) { + while(q->next()&&(cart_count>0)) { if(q->value(1).toUInt()!=prev_cartnum) { // So we don't show duplicates prev_cartnum=q->value(1).toUInt(); - + cart_count--; + // // Cart Type // diff --git a/rdlibrary/list_reports.h b/rdlibrary/list_reports.h index e9f9e7a7..261fefe4 100644 --- a/rdlibrary/list_reports.h +++ b/rdlibrary/list_reports.h @@ -2,7 +2,7 @@ // // List and Generate RDLibrary Reports // -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2024 Fred Gleason // // 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 @@ -32,7 +32,7 @@ class ListReports : public RDDialog Q_OBJECT public: ListReports(const QString &filter,const QString &grpname, - const QString &filter_sql,QWidget *parent); + const QString &filter_sql,int cart_limit,QWidget *parent); ~ListReports(); QSize sizeHint() const; QSizePolicy sizePolicy() const; @@ -54,8 +54,8 @@ class ListReports : public RDDialog QString list_type_filter; QString list_group; QString list_schedcode; - QString list_filter_sql; + int list_cart_limit; }; diff --git a/rdlibrary/rdlibrary.cpp b/rdlibrary/rdlibrary.cpp index 02eaafb8..65f7f6da 100644 --- a/rdlibrary/rdlibrary.cpp +++ b/rdlibrary/rdlibrary.cpp @@ -2,7 +2,7 @@ // // The Library Utility for Rivendell. // -// (C) Copyright 2002-2023 Fred Gleason +// (C) Copyright 2002-2024 Fred Gleason // // 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 @@ -584,7 +584,9 @@ void MainWidget::reportsData() ListReports *lr= new ListReports(lib_cart_filter->filterText(), lib_cart_filter->selectedGroup(), - lib_cart_filter->filterSql(),this); + lib_cart_filter->filterSql()+" "+ + lib_cart_model->orderBySql(), + lib_cart_model->cartLimit(),this); lr->exec(); delete lr;