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.
* Modified the behavior of the buttons in the 'Edit Cart' dialog in
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` ";
//
// 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;
}
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
{
return d_filter_edit->text();
@ -313,7 +314,7 @@ void RDCartFilter::setShowCartType(RDCart::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) {
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()) {
LoadServiceGroups();
}
emit filterChanged(filterSql());
emit filterChanged(filterSql(),cartLimit());
}
}
@ -384,8 +385,8 @@ void RDCartFilter::setShowNoteBubbles(bool state)
void RDCartFilter::setModel(RDLibraryModel *model)
{
connect(this,SIGNAL(filterChanged(const QString &)),
model,SLOT(setFilterSql(const QString &)));
connect(this,SIGNAL(filterChanged(const QString &,int)),
model,SLOT(setFilterSql(const QString &,int)));
connect(d_shownotes_box,SIGNAL(stateChanged(int)),
model,SLOT(setShowNotes(int)));
connect(model,SIGNAL(rowCountChanged(int)),this,SLOT(setMatchCount(int)));
@ -431,7 +432,7 @@ void RDCartFilter::changeUser()
delete q;
d_search_button->setDisabled(true);
emit filterChanged(filterSql());
emit filterChanged(filterSql(),cartLimit());
}
@ -461,7 +462,7 @@ void RDCartFilter::searchClickedData()
else {
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;
QSizePolicy sizePolicy() const;
QString filterSql(const QStringList &and_fields=QStringList()) const;
int cartLimit() const;
QString filterText() const;
QString selectedGroup() const;
QString selectedSchedCode() const;
@ -70,7 +71,7 @@ class RDCartFilter : public RDWidget
signals:
void selectedGroupChanged(const QString &grpname);
void filterChanged(const QString &where_sql);
void filterChanged(const QString &where_sql,int cart_limit);
void dragEnabledChanged(bool state);
private slots:

View File

@ -145,7 +145,8 @@ RDCutDialog::RDCutDialog(QString *filter,QString *group,QString *schedcode,
cart_cancel_button->setFont(buttonFont());
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

View File

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

View File

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

View File

@ -80,7 +80,7 @@ AutofillCarts::AutofillCarts(RDSvc *svc,QWidget *parent)
QString sql=QString("left join `AUTOFILLS` ")+
"on `CART`.`NUMBER`=`AUTOFILLS`.`CART_NUMBER` where "+
"`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)+
") order by `CART`.`TITLE` ";
edit_duplicate_model->setFilterSql(filter_sql);
edit_duplicate_model->setFilterSql(filter_sql,RD_MAX_CART_NUMBER+1);
return;
}

View File

@ -274,7 +274,8 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
lib_macro_events=new RDMacroEvent(rda->station()->address(),rda->ripc(),this);
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();
}

View File

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