diff --git a/ChangeLog b/ChangeLog index 39a13612..a5f67493 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23511,3 +23511,7 @@ 2022-10-14 Fred Gleason * Added a 'Trans' column to the 'Imported Events' list in the 'Test Music Import' list in rdadmin(1). +2022-10-14 Fred Gleason + * Fixed a regression in the 'Test Music Import' dialog that caused + the 'Imported Events' list to fail to be cleared when starting a + new test. diff --git a/lib/rdlogimportmodel.cpp b/lib/rdlogimportmodel.cpp index 839f5a66..4892e1dd 100644 --- a/lib/rdlogimportmodel.cpp +++ b/lib/rdlogimportmodel.cpp @@ -168,6 +168,16 @@ void RDLogImportModel::refresh() } +void RDLogImportModel::clear() +{ + beginResetModel(); + d_texts.clear(); + d_icons.clear(); + d_ids.clear(); + endResetModel(); +} + + void RDLogImportModel::updateModel() { QList texts; diff --git a/lib/rdlogimportmodel.h b/lib/rdlogimportmodel.h index c8574e1e..5d14025e 100644 --- a/lib/rdlogimportmodel.h +++ b/lib/rdlogimportmodel.h @@ -2,7 +2,7 @@ // // Data model for Rivendell log imports // -// (C) Copyright 2021 Fred Gleason +// (C) Copyright 2021-2022 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 @@ -46,6 +46,7 @@ class RDLogImportModel : public QAbstractTableModel QVariant data(const QModelIndex &index,int role=Qt::DisplayRole) const; int lineId(const QModelIndex &row) const; void refresh(); + void clear(); protected: void updateModel(); diff --git a/rdadmin/edit_svc.cpp b/rdadmin/edit_svc.cpp index 5e7b7e67..3e001585 100644 --- a/rdadmin/edit_svc.cpp +++ b/rdadmin/edit_svc.cpp @@ -58,6 +58,11 @@ EditSvc::EditSvc(QString svc,QWidget *parent) RDIdValidator *log_validator=new RDIdValidator(this); log_validator->addBannedChar(' '); + // + // Dialogs + // + svc_test_import_dialog=new TestImport(this); + // // General Section // @@ -583,6 +588,7 @@ EditSvc::~EditSvc() { delete svc_name_edit; delete svc_description_edit; + delete svc_test_import_dialog; } @@ -754,9 +760,7 @@ void EditSvc::TestDataImport(RDSvc::ImportSource src) } Save(); } - TestImport *testimport=new TestImport(svc_svc,src,this); - testimport->exec(); - delete testimport; + svc_test_import_dialog->exec(svc_svc,src); } diff --git a/rdadmin/edit_svc.h b/rdadmin/edit_svc.h index bb47884f..7a35ea29 100644 --- a/rdadmin/edit_svc.h +++ b/rdadmin/edit_svc.h @@ -31,6 +31,7 @@ #include #include "importfields.h" +#include "test_import.h" class EditSvc : public RDDialog { @@ -63,9 +64,7 @@ class EditSvc : public RDDialog QLineEdit *svc_program_code_edit; QLineEdit *svc_name_template_edit; QLineEdit *svc_description_template_edit; - QComboBox *svc_bypass_box; - QComboBox *svc_sub_event_inheritance_box; QComboBox *svc_voice_group_box; QComboBox *svc_autospot_group_box; @@ -95,6 +94,7 @@ class EditSvc : public RDDialog QPushButton *svc_tfc_copy_button; QPushButton *svc_mus_copy_button; bool import_changed; + TestImport *svc_test_import_dialog; }; diff --git a/rdadmin/test_import.cpp b/rdadmin/test_import.cpp index 9731d675..b41888cc 100644 --- a/rdadmin/test_import.cpp +++ b/rdadmin/test_import.cpp @@ -33,30 +33,16 @@ #include "globals.h" #include "test_import.h" -TestImport::TestImport(RDSvc *svc,RDSvc::ImportSource src,QWidget *parent) +TestImport::TestImport(QWidget *parent) : RDDialog(parent) { QString sql; - QDate current_date=QDate::currentDate(); - - test_svc=svc; - test_src=src; // // Fix the Window Size // setMinimumSize(sizeHint()); - switch(test_src) { - case RDSvc::Traffic: - setWindowTitle("RDAdmin - "+tr("Test Traffic Import")); - break; - - case RDSvc::Music: - setWindowTitle("RDAdmin - "+tr("Test Music Import")); - break; - } - // // Date Selector // @@ -64,7 +50,6 @@ TestImport::TestImport(RDSvc *svc,RDSvc::ImportSource src,QWidget *parent) test_date_label=new QLabel(tr("Test Date:"),this); test_date_label->setFont(labelFont()); test_date_label->setAlignment(Qt::AlignVCenter|Qt::AlignRight); - test_date_edit->setDate(current_date); connect(test_date_edit,SIGNAL(dateChanged(const QDate &)), this,SLOT(dateChangedData(const QDate &))); @@ -75,6 +60,7 @@ TestImport::TestImport(RDSvc *svc,RDSvc::ImportSource src,QWidget *parent) button->setGeometry(200,5,60,30); button->setFont(subButtonFont()); button->setText(tr("Select")); + test_date_edit->setDate(QDate::currentDate()); connect(button,SIGNAL(clicked()),this,SLOT(selectData())); // @@ -114,8 +100,6 @@ TestImport::TestImport(RDSvc *svc,RDSvc::ImportSource src,QWidget *parent) test_close_button->setFont(buttonFont()); test_close_button->setText(tr("Close")); connect(test_close_button,SIGNAL(clicked()),this,SLOT(closeData())); - - dateChangedData(current_date); } @@ -136,6 +120,28 @@ QSizePolicy TestImport::sizePolicy() const } +int TestImport::exec(RDSvc *svc,RDSvc::ImportSource src) +{ + test_svc=svc; + test_src=src; + + switch(test_src) { + case RDSvc::Traffic: + setWindowTitle("RDAdmin - "+tr("Test Traffic Import")); + break; + + case RDSvc::Music: + setWindowTitle("RDAdmin - "+tr("Test Music Import")); + break; + } + + test_events_model->clear(); + dateChangedData(test_date_edit->date()); + + return QDialog::exec(); +} + + void TestImport::selectData() { RDDateDialog *datedialog= @@ -171,9 +177,11 @@ void TestImport::importData() void TestImport::dateChangedData(const QDate &date) { - test_filename_edit-> - setText(RDDateDecode(test_svc->importPath(test_src),date, - rda->station(),rda->config(),test_svc->name())); + if(test_svc!=NULL) { + test_filename_edit-> + setText(RDDateDecode(test_svc->importPath(test_src),date, + rda->station(),rda->config(),test_svc->name())); + } } diff --git a/rdadmin/test_import.h b/rdadmin/test_import.h index d141a1cf..d4a2bfcd 100644 --- a/rdadmin/test_import.h +++ b/rdadmin/test_import.h @@ -2,7 +2,7 @@ // // Test a Rivendell Log Import // -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2022 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 @@ -35,11 +35,14 @@ class TestImport : public RDDialog { Q_OBJECT public: - TestImport(RDSvc *svc,RDSvc::ImportSource src,QWidget *parent=0); + TestImport(QWidget *parent=0); ~TestImport(); QSize sizeHint() const; QSizePolicy sizePolicy() const; + public slots: + int exec(RDSvc *svc,RDSvc::ImportSource src); + private slots: void selectData(); void importData();