From bb5da3950fa49845916988207f1285d524d57f7d Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Sun, 27 Dec 2020 11:37:30 -0500 Subject: [PATCH] 2020-12-27 Fred Gleason * Refactored 'RDListLogs' dialog to use 'RDLogListModel'. * Added a 'caption' argument to the constructor of the 'RDListLogs' dialog. Signed-off-by: Fred Gleason --- ChangeLog | 4 ++ lib/librd_cs.ts | 12 ---- lib/librd_de.ts | 12 ---- lib/librd_es.ts | 12 ---- lib/librd_fr.ts | 12 ---- lib/librd_nb.ts | 12 ---- lib/librd_nn.ts | 12 ---- lib/librd_pt_BR.ts | 12 ---- lib/rdlist_logs.cpp | 103 +++++++++++------------------------ lib/rdlist_logs.h | 19 ++++--- rdadmin/edit_rdairplay.cpp | 2 +- rdcastmanager/list_casts.cpp | 3 +- rdlogedit/edit_chain.cpp | 2 +- 13 files changed, 51 insertions(+), 166 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf968b86..d25fdbca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20747,3 +20747,7 @@ * Removed dependency on 'Q3PointArray' from rdlogedit(1). 2020-12-26 Fred Gleason * Removed dependency on 'Q3PointArray' from 'RDWavePainter'. +2020-12-27 Fred Gleason + * Refactored 'RDListLogs' dialog to use 'RDLogListModel'. + * Added a 'caption' argument to the constructor of the + 'RDListLogs' dialog. diff --git a/lib/librd_cs.ts b/lib/librd_cs.ts index 2def18f0..1adbe655 100644 --- a/lib/librd_cs.ts +++ b/lib/librd_cs.ts @@ -2529,18 +2529,6 @@ Bitte Kofiguration prüfen und erneut versuchen. Cancel Zrušit - - Name - - - - Description - - - - Service - - RDListSelector diff --git a/lib/librd_de.ts b/lib/librd_de.ts index 793b72d8..489d260f 100644 --- a/lib/librd_de.ts +++ b/lib/librd_de.ts @@ -2524,18 +2524,6 @@ Bitte Kofiguration prüfen und erneut versuchen. ALL ALLE - - Name - - - - Description - - - - Service - - RDListSelector diff --git a/lib/librd_es.ts b/lib/librd_es.ts index fa2a48b7..e0d47a68 100644 --- a/lib/librd_es.ts +++ b/lib/librd_es.ts @@ -2518,18 +2518,6 @@ Do you still want to proceed? Cancel Cancelar - - Name - - - - Description - - - - Service - - RDListSelector diff --git a/lib/librd_fr.ts b/lib/librd_fr.ts index 04394db9..39672afc 100644 --- a/lib/librd_fr.ts +++ b/lib/librd_fr.ts @@ -2120,18 +2120,6 @@ Do you want to overwrite it? Select Log - - Name - - - - Description - - - - Service - - RDListSelector diff --git a/lib/librd_nb.ts b/lib/librd_nb.ts index eefad80b..f615021f 100644 --- a/lib/librd_nb.ts +++ b/lib/librd_nb.ts @@ -2491,18 +2491,6 @@ Sjekk eksportoppsettet ditt og prøv att. ALL ALLE - - Name - - - - Description - - - - Service - - RDListSelector diff --git a/lib/librd_nn.ts b/lib/librd_nn.ts index eefad80b..f615021f 100644 --- a/lib/librd_nn.ts +++ b/lib/librd_nn.ts @@ -2491,18 +2491,6 @@ Sjekk eksportoppsettet ditt og prøv att. ALL ALLE - - Name - - - - Description - - - - Service - - RDListSelector diff --git a/lib/librd_pt_BR.ts b/lib/librd_pt_BR.ts index 25c7740d..6a80f1c3 100644 --- a/lib/librd_pt_BR.ts +++ b/lib/librd_pt_BR.ts @@ -2528,18 +2528,6 @@ Por Favor, cheque suas configurações e tenbte outra vez. ALL TODOS - - Name - - - - Description - - - - Service - - RDListSelector diff --git a/lib/rdlist_logs.cpp b/lib/rdlist_logs.cpp index 75913345..f7e01f05 100644 --- a/lib/rdlist_logs.cpp +++ b/lib/rdlist_logs.cpp @@ -2,7 +2,7 @@ // // Select a Rivendell Log // -// (C) Copyright 2002-2019 Fred Gleason +// (C) Copyright 2002-2020 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 @@ -24,7 +24,7 @@ #include "rdlist_logs.h" RDListLogs::RDListLogs(QString *logname,RDLogFilter::FilterMode mode, - QWidget *parent) + const QString &caption,QWidget *parent) : RDDialog(parent) { list_logname=logname; @@ -34,32 +34,32 @@ RDListLogs::RDListLogs(QString *logname,RDLogFilter::FilterMode mode, // setMinimumSize(sizeHint()); - setWindowTitle(tr("Select Log")); + setWindowTitle(caption+" - "+tr("Select Log")); // // Log Filter // list_filter_widget=new RDLogFilter(mode,this); - connect(list_filter_widget,SIGNAL(filterChanged(const QString &)), - this,SLOT(filterChangedData(const QString &))); // // Log List // - list_log_list=new Q3ListView(this); - list_log_list->setAllColumnsShowFocus(true); - list_log_list->setItemMargin(5); - list_log_list->setSelectionMode(Q3ListView::Single); - connect(list_log_list, - SIGNAL(doubleClicked(Q3ListViewItem *,const QPoint &,int)), - this, - SLOT(doubleClickedData(Q3ListViewItem *,const QPoint &,int))); - list_log_list->addColumn(tr("Name")); - list_log_list->setColumnAlignment(0,Qt::AlignLeft); - list_log_list->addColumn(tr("Description")); - list_log_list->setColumnAlignment(1,Qt::AlignLeft); - list_log_list->addColumn(tr("Service")); - list_log_list->setColumnAlignment(2,Qt::AlignLeft); + list_log_view=new QTableView(this); + list_log_view->setSelectionBehavior(QAbstractItemView::SelectRows); + list_log_view->setSelectionMode(QAbstractItemView::SingleSelection); + list_log_view->setShowGrid(false); + list_log_view->setSortingEnabled(false); + list_log_view->setWordWrap(false); + list_log_model=new RDLogListModel(this); + list_log_model->setFont(defaultFont()); + list_log_model->setPalette(palette()); + list_log_view->setModel(list_log_model); + list_log_view->resizeColumnsToContents(); + connect(list_filter_widget,SIGNAL(filterChanged(const QString &)), + list_log_model,SLOT(setFilterSql(const QString &))); + connect(list_log_view,SIGNAL(doubleClicked(const QModelIndex &)), + this,SLOT(doubleClickedData(const QModelIndex &))); + connect(list_log_model,SIGNAL(modelReset()),this,SLOT(modelResetData())); // // OK Button @@ -78,13 +78,13 @@ RDListLogs::RDListLogs(QString *logname,RDLogFilter::FilterMode mode, list_cancel_button->setDefault(true); connect(list_cancel_button,SIGNAL(clicked()),this,SLOT(cancelButtonData())); - RefreshList(); + list_log_model->setFilterSql(list_filter_widget->whereSql()); } QSize RDListLogs::sizeHint() const { - return QSize(500,300); + return QSize(600,400); } @@ -96,29 +96,29 @@ QSizePolicy RDListLogs::sizePolicy() const void RDListLogs::closeEvent(QCloseEvent *e) { - done(1); + cancelButtonData(); } -void RDListLogs::filterChangedData(const QString &where_sql) -{ - RefreshList(); -} - - -void RDListLogs::doubleClickedData(Q3ListViewItem *,const QPoint &,int) +void RDListLogs::doubleClickedData(const QModelIndex &index) { okButtonData(); } +void RDListLogs::modelResetData() +{ + list_log_view->resizeColumnsToContents(); +} + + void RDListLogs::okButtonData() { - Q3ListViewItem *item=list_log_list->selectedItem(); - if(item==NULL) { + if(list_log_view->selectionModel()->selectedRows().size()!=1) { return; } - *list_logname=item->text(0); + *list_logname=list_log_model->logName(list_log_view->selectionModel()->selectedRows().at(0).row()); + done(true); } @@ -134,7 +134,7 @@ void RDListLogs::resizeEvent(QResizeEvent *e) list_filter_widget-> setGeometry(10,10,size().width()-10, list_filter_widget->sizeHint().height()); - list_log_list-> + list_log_view-> setGeometry(10,list_filter_widget->sizeHint().height(), size().width()-20, size().height()-list_filter_widget->sizeHint().height()-70); @@ -143,40 +143,3 @@ void RDListLogs::resizeEvent(QResizeEvent *e) list_cancel_button-> setGeometry(size().width()-90,size().height()-60,80,50); } - - -void RDListLogs::RefreshList() -{ - RDSqlQuery *q; - QString sql; - Q3ListViewItem *l; - Q3ListViewItem *view_item=NULL; - QDate current_date=QDate::currentDate(); - - list_log_list->clear(); - sql=QString("select NAME,DESCRIPTION,SERVICE from LOGS ")+ - "where (TYPE=0)&&(LOG_EXISTS=\"Y\")&&"+ - "((START_DATE<=\""+current_date.toString("yyyy-MM-dd")+"\")||"+ - "(START_DATE=\"0000-00-00\")||"+ - "(START_DATE is null))&&"+ - "((END_DATE>=\""+current_date.toString("yyyy-MM-dd")+"\")||"+ - "(END_DATE=\"0000-00-00\")||"+ - "(END_DATE is null))"+ - list_filter_widget->whereSql(); - - q=new RDSqlQuery(sql); - while(q->next()) { - l=new Q3ListViewItem(list_log_list); - l->setText(0,q->value(0).toString()); - l->setText(1,q->value(1).toString()); - l->setText(2,q->value(2).toString()); - if(l->text(0)==*list_logname) { - view_item=l; - } - } - delete q; - if(view_item!=NULL) { - list_log_list->setCurrentItem(view_item); - list_log_list->ensureItemVisible(view_item); - } -} diff --git a/lib/rdlist_logs.h b/lib/rdlist_logs.h index 6bccdb45..726dec8c 100644 --- a/lib/rdlist_logs.h +++ b/lib/rdlist_logs.h @@ -2,7 +2,7 @@ // // Select a Rivendell Log // -// (C) Copyright 2007-2019 Fred Gleason +// (C) Copyright 2007-2020 Fred Gleason // // The RDListLogs class creates a basic dialog that displays a list of logs // (log name, description, and service) and allows the user to select one. If @@ -26,25 +26,26 @@ #ifndef RDLIST_LOGS_H #define RDLIST_LOGS_H -#include -#include +#include +#include #include #include +#include class RDListLogs : public RDDialog { Q_OBJECT - public: - RDListLogs(QString *logname,RDLogFilter::FilterMode mode,QWidget *parent=0); + RDListLogs(QString *logname,RDLogFilter::FilterMode mode, + const QString &caption,QWidget *parent=0); QSize sizeHint() const; QSizePolicy sizePolicy() const; private slots: - void filterChangedData(const QString &where_sql); - void doubleClickedData(Q3ListViewItem *,const QPoint &,int); + void doubleClickedData(const QModelIndex &index); void closeEvent(QCloseEvent *); + void modelResetData(); void okButtonData(); void cancelButtonData(); @@ -52,8 +53,8 @@ class RDListLogs : public RDDialog void resizeEvent(QResizeEvent *e); private: - void RefreshList(); - Q3ListView *list_log_list; + QTableView *list_log_view; + RDLogListModel *list_log_model; QString *list_logname; QPushButton *list_ok_button; QPushButton *list_cancel_button; diff --git a/rdadmin/edit_rdairplay.cpp b/rdadmin/edit_rdairplay.cpp index 508eb8b1..9bcd9c52 100644 --- a/rdadmin/edit_rdairplay.cpp +++ b/rdadmin/edit_rdairplay.cpp @@ -1167,7 +1167,7 @@ void EditRDAirPlay::selectData() { QString logname=air_startlog_edit->text(); - RDListLogs *ll=new RDListLogs(&logname,RDLogFilter::NoFilter,this); + RDListLogs *ll=new RDListLogs(&logname,RDLogFilter::NoFilter,"RDAdmin",this); if(ll->exec()) { air_startlog_edit->setText(logname); } diff --git a/rdcastmanager/list_casts.cpp b/rdcastmanager/list_casts.cpp index a5756b4b..7a75913d 100644 --- a/rdcastmanager/list_casts.cpp +++ b/rdcastmanager/list_casts.cpp @@ -306,7 +306,8 @@ void ListCasts::addLogData() RDFeed::Error err=RDFeed::ErrorOk; unsigned cast_id=0; - RDListLogs *d=new RDListLogs(&logname,RDLogFilter::UserFilter,this); + RDListLogs *d= + new RDListLogs(&logname,RDLogFilter::UserFilter,"RDCastManager",this); if(d->exec()) { RDLogModel *model=new RDLogModel(logname,true,this); model->load(); diff --git a/rdlogedit/edit_chain.cpp b/rdlogedit/edit_chain.cpp index 588f17bf..98b7c2b9 100644 --- a/rdlogedit/edit_chain.cpp +++ b/rdlogedit/edit_chain.cpp @@ -92,7 +92,7 @@ void EditChain::selectLogData() QString logname; RDListLogs *d= - new RDListLogs(&logname,RDLogFilter::UserFilter,this); + new RDListLogs(&logname,RDLogFilter::UserFilter,"RDLogEdit",this); if(!d->exec()) { delete d; return;