2018-02-06 Fred Gleason <fredg@paravelsystems.com>

* Refactored the RDSoundPanel class to use RDApplication.
This commit is contained in:
Fred Gleason 2018-02-06 07:14:13 -05:00
parent 56ed436dc4
commit ed4fe367a8
5 changed files with 57 additions and 69 deletions

View File

@ -16691,3 +16691,5 @@
* Refactored the RDExportSettingDialog class to use RDApplication. * Refactored the RDExportSettingDialog class to use RDApplication.
2018-02-06 Fred Gleason <fredg@paravelsystems.com> 2018-02-06 Fred Gleason <fredg@paravelsystems.com>
* Refactored the RDPeaksExport class to use RDApplication. * Refactored the RDPeaksExport class to use RDApplication.
2018-02-06 Fred Gleason <fredg@paravelsystems.com>
* Refactored the RDSoundPanel class to use RDApplication.

View File

@ -2,7 +2,7 @@
// //
// The sound panel widget for RDAirPlay // The sound panel widget for RDAirPlay
// //
// (C) Copyright 2002-2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2016-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@ -19,21 +19,22 @@
// //
#include <qsignalmapper.h> #include <qsignalmapper.h>
#include <rddb.h>
#include <rdlog_line.h> #include "rdapplication.h"
#include <rdsound_panel.h> #include "rdbutton_dialog.h"
#include <rdbutton_dialog.h> #include "rdcut.h"
#include <rdmacro.h> #include "rdconf.h"
#include <rdcut.h> #include "rddb.h"
#include <rdedit_panel_name.h> #include "rdedit_panel_name.h"
#include <rdescape_string.h> #include "rdescape_string.h"
#include <rdconf.h> #include "rdlog_line.h"
#include "rdmacro.h"
#include "rdsound_panel.h"
RDSoundPanel::RDSoundPanel(int cols,int rows,int station_panels, RDSoundPanel::RDSoundPanel(int cols,int rows,int station_panels,
int user_panels,bool flash, int user_panels,bool flash,
const QString &label_template,bool extended, const QString &label_template,bool extended,
RDEventPlayer *player,RDRipc *ripc,RDCae *cae, RDEventPlayer *player,RDCartDialog *cart_dialog,
RDStation *station,RDCartDialog *cart_dialog,
QWidget *parent) QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
@ -56,10 +57,6 @@ RDSoundPanel::RDSoundPanel(int cols,int rows,int station_panels,
panel_setup_mode=false; panel_setup_mode=false;
panel_reset_mode=false; panel_reset_mode=false;
panel_parent=parent; panel_parent=parent;
panel_cae=cae;
panel_user=NULL;
panel_ripc=ripc;
panel_station=station;
panel_station_panels=station_panels; panel_station_panels=station_panels;
panel_user_panels=user_panels; panel_user_panels=user_panels;
panel_event_player=player; panel_event_player=player;
@ -188,19 +185,19 @@ RDSoundPanel::RDSoundPanel(int cols,int rows,int station_panels,
// Button Dialog Box // Button Dialog Box
// //
panel_button_dialog= panel_button_dialog=
new RDButtonDialog(panel_station->name(),panel_label_template, new RDButtonDialog(rda->station()->name(),panel_label_template,
panel_cart_dialog,panel_svcname,this); panel_cart_dialog,panel_svcname,this);
// //
// CAE Setup // CAE Setup
// //
connect(panel_cae,SIGNAL(timescalingSupported(int,bool)), connect(rda->cae(),SIGNAL(timescalingSupported(int,bool)),
this,SLOT(timescalingSupportedData(int,bool))); this,SLOT(timescalingSupportedData(int,bool)));
// //
// RIPC Setup // RIPC Setup
// //
connect(panel_ripc,SIGNAL(onairFlagChanged(bool)), connect(rda->ripc(),SIGNAL(onairFlagChanged(bool)),
this,SLOT(onairFlagChangedData(bool))); this,SLOT(onairFlagChangedData(bool)));
// //
@ -210,7 +207,7 @@ RDSoundPanel::RDSoundPanel(int cols,int rows,int station_panels,
QString sql; QString sql;
sql=QString("select PANEL_NO,NAME from ")+panel_name_tablename+" where "+ sql=QString("select PANEL_NO,NAME from ")+panel_name_tablename+" where "+
QString().sprintf("(TYPE=%d)&&",RDAirPlayConf::StationPanel)+ QString().sprintf("(TYPE=%d)&&",RDAirPlayConf::StationPanel)+
"(OWNER=\""+RDEscapeString(panel_station->name())+"\") "+ "(OWNER=\""+RDEscapeString(rda->station()->name())+"\") "+
"order by PANEL_NO"; "order by PANEL_NO";
RDSqlQuery *q=new RDSqlQuery(sql); RDSqlQuery *q=new RDSqlQuery(sql);
q->first(); q->first();
@ -268,7 +265,7 @@ int RDSoundPanel::card(int outnum) const
void RDSoundPanel::setCard(int outnum,int card) void RDSoundPanel::setCard(int outnum,int card)
{ {
panel_card[outnum]=card; panel_card[outnum]=card;
panel_cae->requestTimescale(card); rda->cae()->requestTimescale(card);
} }
@ -572,11 +569,13 @@ void RDSoundPanel::acceptCartDrop(int row,int col,unsigned cartnum,
void RDSoundPanel::changeUser() void RDSoundPanel::changeUser()
{ {
/*
if(panel_user!=NULL) { if(panel_user!=NULL) {
delete panel_user; delete panel_user;
} }
panel_user=new RDUser(panel_ripc->user()); panel_user=new RDUser(rda->ripc->user());
panel_config_panels=panel_user->configPanels(); */
panel_config_panels=rda->user()->configPanels();
LoadPanels(); LoadPanels();
panel_buttons[PanelOffset(panel_type,panel_number)]->show(); panel_buttons[PanelOffset(panel_type,panel_number)]->show();
@ -594,7 +593,7 @@ void RDSoundPanel::changeUser()
QString sql; QString sql;
sql=QString("select PANEL_NO,NAME from ")+panel_name_tablename+" where "+ sql=QString("select PANEL_NO,NAME from ")+panel_name_tablename+" where "+
QString().sprintf("(TYPE=%d)&&",RDAirPlayConf::UserPanel)+ QString().sprintf("(TYPE=%d)&&",RDAirPlayConf::UserPanel)+
"(OWNER=\""+RDEscapeString(panel_user->name())+"\") "+ "(OWNER=\""+RDEscapeString(rda->user()->name())+"\") "+
"order by PANEL_NO"; "order by PANEL_NO";
RDSqlQuery *q=new RDSqlQuery(sql); RDSqlQuery *q=new RDSqlQuery(sql);
q->first(); q->first();
@ -685,7 +684,7 @@ void RDSoundPanel::setupClickedData()
panel_reset_button->setDisabled(true); panel_reset_button->setDisabled(true);
panel_playmode_box->setDisabled(true); panel_playmode_box->setDisabled(true);
} }
if(panel_station->enableDragdrop()&&(panel_station->enforcePanelSetup())) { if(rda->station()->enableDragdrop()&&(rda->station()->enforcePanelSetup())) {
for(unsigned i=0;i<panel_buttons.size();i++) { for(unsigned i=0;i<panel_buttons.size();i++) {
if(panel_buttons[i]!=NULL) { if(panel_buttons[i]!=NULL) {
panel_buttons[i]->setAcceptDrops(panel_setup_mode); panel_buttons[i]->setAcceptDrops(panel_setup_mode);
@ -747,7 +746,7 @@ void RDSoundPanel::buttonMapperData(int id)
if(panel_button_dialog-> if(panel_button_dialog->
exec(panel_buttons[PanelOffset(panel_type,panel_number)]-> exec(panel_buttons[PanelOffset(panel_type,panel_number)]->
panelButton(row,col),panel_playmode_box->currentItem()==1, panelButton(row,col),panel_playmode_box->currentItem()==1,
panel_user->name(),panel_user->password()) rda->user()->name(),rda->user()->password())
==0) { ==0) {
SaveButton(panel_type,panel_number,row,col); SaveButton(panel_type,panel_number,row,col);
} }
@ -842,7 +841,7 @@ void RDSoundPanel::timescalingSupportedData(int card,bool state)
void RDSoundPanel::panelSetupData() void RDSoundPanel::panelSetupData()
{ {
if(panel_user->configPanels()||(panel_type==RDAirPlayConf::UserPanel)) { if(rda->user()->configPanels()||(panel_type==RDAirPlayConf::UserPanel)) {
QString sql; QString sql;
RDSqlQuery *q; RDSqlQuery *q;
int cutpt=panel_selector_box->currentText().find(" "); int cutpt=panel_selector_box->currentText().find(" ");
@ -922,13 +921,13 @@ void RDSoundPanel::PlayButton(RDAirPlayConf::PanelType type,int panel,
deck->play(deck->currentPosition()); deck->play(deck->currentPosition());
if(button->hookMode()) { if(button->hookMode()) {
button->setStartTime(QTime::currentTime(). button->setStartTime(QTime::currentTime().
addMSecs(panel_station->timeOffset()). addMSecs(rda->station()->timeOffset()).
addMSecs(-deck->currentPosition()+ addMSecs(-deck->currentPosition()+
deck->cut()->hookStartPoint())); deck->cut()->hookStartPoint()));
} }
else { else {
button->setStartTime(QTime::currentTime(). button->setStartTime(QTime::currentTime().
addMSecs(panel_station->timeOffset()). addMSecs(rda->station()->timeOffset()).
addMSecs(-deck->currentPosition())); addMSecs(-deck->currentPosition()));
} }
return; return;
@ -990,7 +989,7 @@ bool RDSoundPanel::PlayAudio(RDPanelButton *button,RDCart *cart,bool hookmode,in
} }
button->setOutputText(panel_output_text[button->output()]); button->setOutputText(panel_output_text[button->output()]);
button->setHookMode(hookmode); button->setHookMode(hookmode);
button->setPlayDeck(new RDPlayDeck(panel_cae,button_deck,this)); button->setPlayDeck(new RDPlayDeck(rda->cae(),button_deck,this));
button->playDeck()->setCard(panel_card[button->output()]); button->playDeck()->setCard(panel_card[button->output()]);
button->playDeck()->setPort(panel_port[button->output()]); button->playDeck()->setPort(panel_port[button->output()]);
button->playDeck()->duckVolume(button->duckVolume(),0); button->playDeck()->duckVolume(button->duckVolume(),0);
@ -1035,7 +1034,7 @@ bool RDSoundPanel::PlayAudio(RDPanelButton *button,RDCart *cart,bool hookmode,in
// Start Playout // Start Playout
// //
button-> button->
setStartTime(QTime::currentTime().addMSecs(panel_station->timeOffset())); setStartTime(QTime::currentTime().addMSecs(rda->station()->timeOffset()));
if(hookmode&&(button->playDeck()->cut()->hookStartPoint()>=0)) { if(hookmode&&(button->playDeck()->cut()->hookStartPoint()>=0)) {
button->setActiveLength(button->playDeck()->cut()->hookEndPoint()- button->setActiveLength(button->playDeck()->cut()->hookEndPoint()-
button->playDeck()->cut()->hookStartPoint()); button->playDeck()->cut()->hookStartPoint());
@ -1061,12 +1060,12 @@ void RDSoundPanel::PlayMacro(RDPanelButton *button,RDCart *cart)
{ {
RDMacro rml; RDMacro rml;
rml.setRole(RDMacro::Cmd); rml.setRole(RDMacro::Cmd);
rml.setAddress(panel_station->address()); rml.setAddress(rda->station()->address());
rml.setEchoRequested(false); rml.setEchoRequested(false);
rml.setCommand(RDMacro::EX); rml.setCommand(RDMacro::EX);
rml.setArgQuantity(1); rml.setArgQuantity(1);
rml.setArg(0,cart->number()); rml.setArg(0,cart->number());
panel_ripc->sendRml(&rml); rda->ripc()->sendRml(&rml);
if(!panel_svcname.isEmpty()) { if(!panel_svcname.isEmpty()) {
LogTrafficMacro(button); LogTrafficMacro(button);
} }
@ -1197,7 +1196,7 @@ void RDSoundPanel::LoadPanels()
for(int i=0;i<panel_station_panels;i++) { for(int i=0;i<panel_station_panels;i++) {
panel_buttons.push_back(new RDButtonPanel(panel_type,i,panel_button_columns, panel_buttons.push_back(new RDButtonPanel(panel_type,i,panel_button_columns,
panel_button_rows, panel_button_rows,
panel_station,panel_flash,this)); rda->station(),panel_flash,this));
for(int j=0;j<panel_button_rows;j++) { for(int j=0;j<panel_button_rows;j++) {
for(int k=0;k<panel_button_columns;k++) { for(int k=0;k<panel_button_columns;k++) {
connect(panel_buttons.back()->panelButton(j,k),SIGNAL(clicked()), connect(panel_buttons.back()->panelButton(j,k),SIGNAL(clicked()),
@ -1207,12 +1206,12 @@ void RDSoundPanel::LoadPanels()
} }
} }
LoadPanel(RDAirPlayConf::StationPanel,i); LoadPanel(RDAirPlayConf::StationPanel,i);
panel_buttons.back()->setAllowDrags(panel_station->enableDragdrop()); panel_buttons.back()->setAllowDrags(rda->station()->enableDragdrop());
} }
for(int i=0;i<panel_user_panels;i++) { for(int i=0;i<panel_user_panels;i++) {
panel_buttons.push_back(new RDButtonPanel(panel_type,i,panel_button_columns, panel_buttons.push_back(new RDButtonPanel(panel_type,i,panel_button_columns,
panel_button_rows, panel_button_rows,
panel_station,panel_flash,this)); rda->station(),panel_flash,this));
for(int j=0;j<panel_button_rows;j++) { for(int j=0;j<panel_button_rows;j++) {
for(int k=0;k<panel_button_columns;k++) { for(int k=0;k<panel_button_columns;k++) {
connect(panel_buttons.back()->panelButton(j,k),SIGNAL(clicked()), connect(panel_buttons.back()->panelButton(j,k),SIGNAL(clicked()),
@ -1221,7 +1220,7 @@ void RDSoundPanel::LoadPanels()
j*panel_button_columns+k); j*panel_button_columns+k);
} }
} }
panel_buttons.back()->setAllowDrags(panel_station->enableDragdrop()); panel_buttons.back()->setAllowDrags(rda->station()->enableDragdrop());
LoadPanel(RDAirPlayConf::UserPanel,i); LoadPanel(RDAirPlayConf::UserPanel,i);
} }
} }
@ -1234,15 +1233,12 @@ void RDSoundPanel::LoadPanel(RDAirPlayConf::PanelType type,int panel)
switch(type) { switch(type) {
case RDAirPlayConf::UserPanel: case RDAirPlayConf::UserPanel:
if(panel_user==NULL) { owner=rda->user()->name();
return;
}
owner=panel_user->name();
offset=panel_station_panels+panel; offset=panel_station_panels+panel;
break; break;
case RDAirPlayConf::StationPanel: case RDAirPlayConf::StationPanel:
owner=panel_station->name(); owner=rda->station()->name();
offset=panel; offset=panel;
break; break;
} }
@ -1332,12 +1328,12 @@ void RDSoundPanel::SaveButton(RDAirPlayConf::PanelType type,
switch(type) { switch(type) {
case RDAirPlayConf::UserPanel: case RDAirPlayConf::UserPanel:
owner=panel_user->name(); owner=rda->user()->name();
offset=panel_station_panels+panel; offset=panel_station_panels+panel;
break; break;
case RDAirPlayConf::StationPanel: case RDAirPlayConf::StationPanel:
owner=panel_station->name(); owner=rda->station()->name();
offset=panel; offset=panel;
break; break;
} }
@ -1496,7 +1492,7 @@ void RDSoundPanel::LogTraffic(RDPanelButton *button)
QString().sprintf("LENGTH=%d,",button->startTime(). QString().sprintf("LENGTH=%d,",button->startTime().
msecsTo(datetime.time()))+ msecsTo(datetime.time()))+
QString().sprintf("CART_NUMBER=%u,",button->cart())+ QString().sprintf("CART_NUMBER=%u,",button->cart())+
"STATION_NAME=\""+RDEscapeString(panel_station->name().utf8())+"\","+ "STATION_NAME=\""+RDEscapeString(rda->station()->name().utf8())+"\","+
"EVENT_DATETIME="+eventDateTimeSQL+","+ "EVENT_DATETIME="+eventDateTimeSQL+","+
QString().sprintf("EVENT_TYPE=%d,",RDAirPlayConf::TrafficStop)+ QString().sprintf("EVENT_TYPE=%d,",RDAirPlayConf::TrafficStop)+
QString().sprintf("EVENT_SOURCE=%d,",RDLogLine::SoundPanel)+ QString().sprintf("EVENT_SOURCE=%d,",RDLogLine::SoundPanel)+
@ -1539,7 +1535,7 @@ void RDSoundPanel::LogTrafficMacro(RDPanelButton *button)
sql=QString("insert into `")+panel_svcname+"_SRT` set "+ sql=QString("insert into `")+panel_svcname+"_SRT` set "+
QString().sprintf("LENGTH=%d,",q->value(5).toUInt())+ QString().sprintf("LENGTH=%d,",q->value(5).toUInt())+
QString().sprintf("CART_NUMBER=%u,",button->cart())+ QString().sprintf("CART_NUMBER=%u,",button->cart())+
"STATION_NAME=\""+RDEscapeString(panel_station->name().utf8())+"\","+ "STATION_NAME=\""+RDEscapeString(rda->station()->name().utf8())+"\","+
"EVENT_DATETIME=\""+datetime.toString("yyyy-MM-dd hh:mm:ss")+"\","+ "EVENT_DATETIME=\""+datetime.toString("yyyy-MM-dd hh:mm:ss")+"\","+
QString().sprintf("EVENT_TYPE=%d,",RDAirPlayConf::TrafficMacro)+ QString().sprintf("EVENT_TYPE=%d,",RDAirPlayConf::TrafficMacro)+
QString().sprintf("EVENT_SOURCE=%d,",RDLogLine::SoundPanel)+ QString().sprintf("EVENT_SOURCE=%d,",RDLogLine::SoundPanel)+
@ -1653,7 +1649,7 @@ void RDSoundPanel::Stopped(int id)
void RDSoundPanel::ClearChannel(int id) void RDSoundPanel::ClearChannel(int id)
{ {
RDPlayDeck *playdeck=panel_active_buttons[id]->playDeck(); RDPlayDeck *playdeck=panel_active_buttons[id]->playDeck();
if(panel_cae-> if(rda->cae()->
playPortActive(playdeck->card(),playdeck->port(),playdeck->stream())) { playPortActive(playdeck->card(),playdeck->port(),playdeck->stream())) {
return; return;
} }
@ -1684,12 +1680,10 @@ QString RDSoundPanel::PanelOwner(RDAirPlayConf::PanelType type)
{ {
switch(type) { switch(type) {
case RDAirPlayConf::StationPanel: case RDAirPlayConf::StationPanel:
return panel_station->name(); return rda->station()->name();
case RDAirPlayConf::UserPanel: case RDAirPlayConf::UserPanel:
if(panel_user!=NULL) { return rda->user()->name();
return panel_user->name();
}
} }
return QString(); return QString();
} }

View File

@ -2,7 +2,7 @@
// //
// The sound panel widget for RDAirPlay // The sound panel widget for RDAirPlay
// //
// (C) Copyright 2002-2004,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2004,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@ -30,16 +30,13 @@
#include <rdpushbutton.h> #include <rdpushbutton.h>
#include <rdcart_dialog.h>
#include <rdcart.h>
#include <rduser.h>
#include <rdairplay_conf.h>
#include <rdpanel_button.h>
#include <rdbutton_dialog.h> #include <rdbutton_dialog.h>
#include <rdbutton_panel.h> #include <rdbutton_panel.h>
#include <rdripc.h> #include <rdcart.h>
#include <rdevent_player.h> #include <rdcart_dialog.h>
#include <rdcombobox.h> #include <rdcombobox.h>
#include <rdevent_player.h>
#include <rdpanel_button.h>
// //
// Widget Settings // Widget Settings
@ -55,8 +52,8 @@ class RDSoundPanel : public QWidget
public: public:
RDSoundPanel(int cols,int rows,int station_panels,int user_panels,bool flash, RDSoundPanel(int cols,int rows,int station_panels,int user_panels,bool flash,
const QString &label_template,bool extended, const QString &label_template,bool extended,
RDEventPlayer *player,RDRipc *ripc,RDCae *cae, RDEventPlayer *player,RDCartDialog *cart_dialog,
RDStation *station,RDCartDialog *cart_dialog,QWidget *parent=0); QWidget *parent=0);
~RDSoundPanel(); ~RDSoundPanel();
QSize sizeHint() const; QSize sizeHint() const;
QSizePolicy sizePolicy() const; QSizePolicy sizePolicy() const;
@ -147,8 +144,6 @@ class RDSoundPanel : public QWidget
QString PanelTag(int index); QString PanelTag(int index);
QString PanelOwner(RDAirPlayConf::PanelType type); QString PanelOwner(RDAirPlayConf::PanelType type);
std::vector<RDButtonPanel *> panel_buttons; std::vector<RDButtonPanel *> panel_buttons;
RDCae *panel_cae;
RDUser *panel_user;
RDComboBox *panel_selector_box; RDComboBox *panel_selector_box;
QComboBox *panel_playmode_box; QComboBox *panel_playmode_box;
RDPushButton *panel_setup_button; RDPushButton *panel_setup_button;
@ -166,8 +161,6 @@ class RDSoundPanel : public QWidget
bool panel_setup_mode; bool panel_setup_mode;
bool panel_reset_mode; bool panel_reset_mode;
QWidget *panel_parent; QWidget *panel_parent;
RDRipc *panel_ripc;
RDStation *panel_station;
int panel_card[PANEL_MAX_OUTPUTS]; int panel_card[PANEL_MAX_OUTPUTS];
int panel_port[PANEL_MAX_OUTPUTS]; int panel_port[PANEL_MAX_OUTPUTS];
int panel_cue_card; int panel_cue_card;

View File

@ -608,8 +608,7 @@ MainWidget::MainWidget(QWidget *parent)
rda->airplayConf()->panels(RDAirPlayConf::UserPanel), rda->airplayConf()->panels(RDAirPlayConf::UserPanel),
rda->airplayConf()->flashPanel(), rda->airplayConf()->flashPanel(),
rda->airplayConf()->buttonLabelTemplate(),false, rda->airplayConf()->buttonLabelTemplate(),false,
rdevent_player,rda->ripc(),rda->cae(),rda->station(), rdevent_player,rdcart_dialog,this);
rdcart_dialog,this);
air_panel->setLogfile(rda->config()->airplayLogname()); air_panel->setLogfile(rda->config()->airplayLogname());
air_panel->setGeometry(510,140,air_panel->sizeHint().width(), air_panel->setGeometry(510,140,air_panel->sizeHint().width(),
air_panel->sizeHint().height()); air_panel->sizeHint().height());

View File

@ -183,8 +183,8 @@ MainWidget::MainWidget(QWidget *parent)
rda->panelConf()->panels(RDAirPlayConf::StationPanel), rda->panelConf()->panels(RDAirPlayConf::StationPanel),
rda->panelConf()->panels(RDAirPlayConf::UserPanel), rda->panelConf()->panels(RDAirPlayConf::UserPanel),
rda->panelConf()->flashPanel(), rda->panelConf()->flashPanel(),
rda->panelConf()->buttonLabelTemplate(),true,panel_player, rda->panelConf()->buttonLabelTemplate(),true,
rda->ripc(),rda->cae(),rda->station(),panel_cart_dialog,this); panel_player,panel_cart_dialog,this);
panel_panel->setLogfile(rda->config()->airplayLogname()); panel_panel->setLogfile(rda->config()->airplayLogname());
panel_panel->setGeometry(10,10,panel_panel->sizeHint().width(), panel_panel->setGeometry(10,10,panel_panel->sizeHint().width(),
panel_panel->sizeHint().height()); panel_panel->sizeHint().height());