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

* Fixed a regression in rdlibrary(1) that could cause less than
	100 carts to be displayed when the 'Show Only First 100 Matches'
	box was ticked.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2021-09-13 12:33:12 -04:00
parent 76548116e5
commit 7bd18d2ea5
10 changed files with 44 additions and 24 deletions

View File

@ -22417,3 +22417,7 @@
* Added an 'RDBiPushButton' widget. * Added an 'RDBiPushButton' widget.
* Modified the behavior of the buttons in the 'Edit Cart' dialog in * Modified the behavior of the buttons in the 'Edit Cart' dialog in
rdlibrary(1) to grey-out when there is no cut selected. rdlibrary(1) to grey-out when there is no cut selected.
2021-09-13 Fred Gleason <fredg@paravelsystems.com>
* Fixed a regression in rdlibrary(1) that could cause less than
100 carts to be displayed when the 'Show Only First 100 Matches'
box was ticked.

View File

@ -248,18 +248,19 @@ QString RDCartFilter::filterSql(const QStringList &and_fields) const
sql+="order by `CART`.`NUMBER` "; sql+="order by `CART`.`NUMBER` ";
//
// Return Size Limit
//
if(d_showmatches_box->isChecked()) {
sql+=QString::asprintf("limit %d ",RD_LIMITED_CART_SEARCH_QUANTITY);
}
// printf("FILTER SQL: %s\n",sql.toUtf8().constData());
return sql; return sql;
} }
int RDCartFilter::cartLimit() const
{
if(d_showmatches_box->isChecked()) {
return RD_LIMITED_CART_SEARCH_QUANTITY;
}
return RD_MAX_CART_NUMBER+1; // Effectively "unlimited"
}
QString RDCartFilter::filterText() const QString RDCartFilter::filterText() const
{ {
return d_filter_edit->text(); return d_filter_edit->text();
@ -313,7 +314,7 @@ void RDCartFilter::setShowCartType(RDCart::Type type)
} }
d_show_cart_type=type; d_show_cart_type=type;
emit filterChanged(filterSql()); emit filterChanged(filterSql(),cartLimit());
} }
} }
@ -328,7 +329,7 @@ void RDCartFilter::setShowTrackCarts(bool state)
{ {
if(state!=d_show_track_carts) { if(state!=d_show_track_carts) {
d_show_track_carts=state; d_show_track_carts=state;
emit filterChanged(filterSql()); emit filterChanged(filterSql(),cartLimit());
} }
} }
@ -359,7 +360,7 @@ void RDCartFilter::setService(const QString &svc)
if(!d_service.isEmpty()) { if(!d_service.isEmpty()) {
LoadServiceGroups(); LoadServiceGroups();
} }
emit filterChanged(filterSql()); emit filterChanged(filterSql(),cartLimit());
} }
} }
@ -384,8 +385,8 @@ void RDCartFilter::setShowNoteBubbles(bool state)
void RDCartFilter::setModel(RDLibraryModel *model) void RDCartFilter::setModel(RDLibraryModel *model)
{ {
connect(this,SIGNAL(filterChanged(const QString &)), connect(this,SIGNAL(filterChanged(const QString &,int)),
model,SLOT(setFilterSql(const QString &))); model,SLOT(setFilterSql(const QString &,int)));
connect(d_shownotes_box,SIGNAL(stateChanged(int)), connect(d_shownotes_box,SIGNAL(stateChanged(int)),
model,SLOT(setShowNotes(int))); model,SLOT(setShowNotes(int)));
connect(model,SIGNAL(rowCountChanged(int)),this,SLOT(setMatchCount(int))); connect(model,SIGNAL(rowCountChanged(int)),this,SLOT(setMatchCount(int)));
@ -431,7 +432,7 @@ void RDCartFilter::changeUser()
delete q; delete q;
d_search_button->setDisabled(true); d_search_button->setDisabled(true);
emit filterChanged(filterSql()); emit filterChanged(filterSql(),cartLimit());
} }
@ -461,7 +462,7 @@ void RDCartFilter::searchClickedData()
else { else {
d_clear_button->setEnabled(true); d_clear_button->setEnabled(true);
} }
emit filterChanged(filterSql()); emit filterChanged(filterSql(),cartLimit());
} }

View File

@ -42,6 +42,7 @@ class RDCartFilter : public RDWidget
QSize sizeHint() const; QSize sizeHint() const;
QSizePolicy sizePolicy() const; QSizePolicy sizePolicy() const;
QString filterSql(const QStringList &and_fields=QStringList()) const; QString filterSql(const QStringList &and_fields=QStringList()) const;
int cartLimit() const;
QString filterText() const; QString filterText() const;
QString selectedGroup() const; QString selectedGroup() const;
QString selectedSchedCode() const; QString selectedSchedCode() const;
@ -70,7 +71,7 @@ class RDCartFilter : public RDWidget
signals: signals:
void selectedGroupChanged(const QString &grpname); void selectedGroupChanged(const QString &grpname);
void filterChanged(const QString &where_sql); void filterChanged(const QString &where_sql,int cart_limit);
void dragEnabledChanged(bool state); void dragEnabledChanged(bool state);
private slots: private slots:

View File

@ -145,7 +145,8 @@ RDCutDialog::RDCutDialog(QString *filter,QString *group,QString *schedcode,
cart_cancel_button->setFont(buttonFont()); cart_cancel_button->setFont(buttonFont());
connect(cart_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData())); connect(cart_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));
cart_cart_model->setFilterSql(cart_cart_filter->filterSql()); cart_cart_model->
setFilterSql(cart_cart_filter->filterSql(),cart_cart_filter->cartLimit());
// //
// Fix the Window Size // Fix the Window Size

View File

@ -29,6 +29,7 @@ RDLibraryModel::RDLibraryModel(QObject *parent)
d_font_metrics=NULL; d_font_metrics=NULL;
d_bold_font_metrics=NULL; d_bold_font_metrics=NULL;
d_show_notes=false; d_show_notes=false;
d_cart_limit=RD_MAX_CART_NUMBER+1; // Effectively "unlimited"
// //
// Column Attributes // Column Attributes
@ -478,15 +479,22 @@ bool RDLibraryModel::showNotes() const
} }
int RDLibraryModel::cartLimit() const
{
return d_cart_limit;
}
void RDLibraryModel::setShowNotes(int state) void RDLibraryModel::setShowNotes(int state)
{ {
d_show_notes=state; d_show_notes=state;
} }
void RDLibraryModel::setFilterSql(const QString &sql) void RDLibraryModel::setFilterSql(const QString &sql,int cart_limit)
{ {
// printf("FILTER SQL: %s\n",sql.toUtf8().constData()); // printf("FILTER SQL: %s\n",sql.toUtf8().constData());
d_cart_limit=cart_limit;
updateModel(sql); updateModel(sql);
} }
@ -534,8 +542,9 @@ void RDLibraryModel::updateModel(const QString &filter_sql)
d_cart_types.clear(); d_cart_types.clear();
d_icons.clear(); d_icons.clear();
unsigned prev_cartnum=0; unsigned prev_cartnum=0;
int carts_loaded=0;
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
while(q->next()) { while(q->next()&&(carts_loaded<d_cart_limit)) {
if(q->value(0).toUInt()!=prev_cartnum) { if(q->value(0).toUInt()!=prev_cartnum) {
d_texts.push_back(list); d_texts.push_back(list);
d_notes.push_back(QVariant()); d_notes.push_back(QVariant());
@ -547,6 +556,7 @@ void RDLibraryModel::updateModel(const QString &filter_sql)
d_icons.push_back(icons); d_icons.push_back(icons);
updateRow(d_texts.size()-1,q); updateRow(d_texts.size()-1,q);
prev_cartnum=q->value(0).toUInt(); prev_cartnum=q->value(0).toUInt();
carts_loaded++;
} }
} }
delete q; delete q;

View File

@ -65,13 +65,14 @@ class RDLibraryModel : public QAbstractItemModel
void refreshRow(const QModelIndex &index); void refreshRow(const QModelIndex &index);
void refreshCart(unsigned cartnum); void refreshCart(unsigned cartnum);
bool showNotes() const; bool showNotes() const;
int cartLimit() const;
signals: signals:
void rowCountChanged(int rows); void rowCountChanged(int rows);
public slots: public slots:
void setShowNotes(int state); void setShowNotes(int state);
void setFilterSql(const QString &sql); void setFilterSql(const QString &sql,int cart_limit);
protected: protected:
void updateModel(const QString &filter_sql); void updateModel(const QString &filter_sql);
@ -82,6 +83,7 @@ class RDLibraryModel : public QAbstractItemModel
private: private:
QByteArray DumpIndex(const QModelIndex &index,const QString &caption="") const; QByteArray DumpIndex(const QModelIndex &index,const QString &caption="") const;
bool d_show_notes; bool d_show_notes;
int d_cart_limit;
QPalette d_palette; QPalette d_palette;
QFont d_font; QFont d_font;
QFontMetrics *d_font_metrics; QFontMetrics *d_font_metrics;

View File

@ -80,7 +80,7 @@ AutofillCarts::AutofillCarts(RDSvc *svc,QWidget *parent)
QString sql=QString("left join `AUTOFILLS` ")+ QString sql=QString("left join `AUTOFILLS` ")+
"on `CART`.`NUMBER`=`AUTOFILLS`.`CART_NUMBER` where "+ "on `CART`.`NUMBER`=`AUTOFILLS`.`CART_NUMBER` where "+
"`AUTOFILLS`.`SERVICE`='"+RDEscapeString(svc_svc->name())+"'"; "`AUTOFILLS`.`SERVICE`='"+RDEscapeString(svc_svc->name())+"'";
svc_cart_model->setFilterSql(sql); svc_cart_model->setFilterSql(sql,RD_MAX_CART_NUMBER+1);
} }

View File

@ -481,7 +481,7 @@ void EditSystem::okData()
} }
filter_sql=filter_sql.left(filter_sql.length()-2)+ filter_sql=filter_sql.left(filter_sql.length()-2)+
") order by `CART`.`TITLE` "; ") order by `CART`.`TITLE` ";
edit_duplicate_model->setFilterSql(filter_sql); edit_duplicate_model->setFilterSql(filter_sql,RD_MAX_CART_NUMBER+1);
return; return;
} }

View File

@ -274,7 +274,8 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
lib_macro_events=new RDMacroEvent(rda->station()->address(),rda->ripc(),this); lib_macro_events=new RDMacroEvent(rda->station()->address(),rda->ripc(),this);
dragsChangedData(lib_cart_filter->dragEnabled()); dragsChangedData(lib_cart_filter->dragEnabled());
lib_cart_model->setFilterSql(lib_cart_filter->filterSql()); lib_cart_model->
setFilterSql(lib_cart_filter->filterSql(),lib_cart_model->cartLimit());
LoadGeometry(); LoadGeometry();
} }

View File

@ -1264,7 +1264,7 @@ void EditEvent::RefreshLibrary()
RDCartFilter::groupFilter(event_group_box->currentText(), RDCartFilter::groupFilter(event_group_box->currentText(),
event_group_model->allGroupNames()); event_group_model->allGroupNames());
sql=sql.left(sql.length()-3); sql=sql.left(sql.length()-3);
event_lib_model->setFilterSql(sql); event_lib_model->setFilterSql(sql,RD_MAX_CART_NUMBER+1);
} }