2023-09-27 Fred Gleason <fredg@paravelsystems.com>

* Refactored the 'RDSoundPanel', 'RDPanelButton' and 'RDButtonPanel'
	classes to avoid races when changing the current Rivendell user.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2023-09-27 13:07:42 -04:00
parent 85984a33ca
commit 2f995c509b
7 changed files with 367 additions and 188 deletions

View File

@ -24385,3 +24385,6 @@
'Insert Cart' ['PX'] RML in the Operations Guide. 'Insert Cart' ['PX'] RML in the Operations Guide.
2023-09-08 Fred Gleason <fredg@paravelsystems.com> 2023-09-08 Fred Gleason <fredg@paravelsystems.com>
* Incremented the package version to 4.1.0int0. * Incremented the package version to 4.1.0int0.
2023-09-27 Fred Gleason <fredg@paravelsystems.com>
* Refactored the 'RDSoundPanel', 'RDPanelButton' and 'RDButtonPanel'
classes to avoid races when changing the current Rivendell user.

View File

@ -23,18 +23,16 @@
#include <rdbutton_panel.h> #include <rdbutton_panel.h>
#include <rdbutton_dialog.h> #include <rdbutton_dialog.h>
RDButtonPanel::RDButtonPanel(RDAirPlayConf::PanelType type,int panel,int cols, RDButtonPanel::RDButtonPanel(RDAirPlayConf::PanelType type,QWidget *parent)
int rows,RDStation *station,bool flash, : RDWidget(parent)
QWidget *parent)
{ {
panel_button_columns=cols; for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
panel_button_rows=rows; for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
panel_station=station;
for(int i=0;i<panel_button_rows;i++) {
for(int j=0;j<panel_button_columns;j++) {
panel_button[i][j]= panel_button[i][j]=
new RDPanelButton(i,j,panel_station,flash,parent); new RDPanelButton(i,j,rda->station(),rda->panelConf()->flashPanel(),
if(station->enableDragdrop()&&(!station->enforcePanelSetup())) { parent);
if(rda->station()->enableDragdrop()&&
(!rda->station()->enforcePanelSetup())) {
panel_button[i][j]->setAcceptDrops(true); panel_button[i][j]->setAcceptDrops(true);
} }
panel_button[i][j]->setGeometry((15+PANEL_BUTTON_SIZE_X)*j, panel_button[i][j]->setGeometry((15+PANEL_BUTTON_SIZE_X)*j,
@ -56,8 +54,8 @@ RDButtonPanel::RDButtonPanel(RDAirPlayConf::PanelType type,int panel,int cols,
RDButtonPanel::~RDButtonPanel() RDButtonPanel::~RDButtonPanel()
{ {
for(int i=0;i<panel_button_rows;i++) { for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<panel_button_columns;j++) { for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
delete panel_button[i][j]; delete panel_button[i][j];
} }
} }
@ -86,8 +84,8 @@ void RDButtonPanel::setActionMode(RDAirPlayConf::ActionMode mode)
{ {
switch(mode) { switch(mode) {
case RDAirPlayConf::CopyFrom: case RDAirPlayConf::CopyFrom:
for(int i=0;i<panel_button_rows;i++) { for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<panel_button_columns;j++) { for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
if(panel_button[i][j]->cart()!=0) { if(panel_button[i][j]->cart()!=0) {
panel_button[i][j]->setColor(BUTTON_FROM_BACKGROUND_COLOR); panel_button[i][j]->setColor(BUTTON_FROM_BACKGROUND_COLOR);
} }
@ -96,8 +94,8 @@ void RDButtonPanel::setActionMode(RDAirPlayConf::ActionMode mode)
break; break;
case RDAirPlayConf::CopyTo: case RDAirPlayConf::CopyTo:
for(int i=0;i<panel_button_rows;i++) { for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<panel_button_columns;j++) { for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
if(panel_button[i][j]->playDeck()!=NULL) { if(panel_button[i][j]->playDeck()!=NULL) {
if(panel_button[i][j]->playDeck()->state()==RDPlayDeck::Paused) { if(panel_button[i][j]->playDeck()->state()==RDPlayDeck::Paused) {
panel_button[i][j]->setColor(RDPANEL_PAUSED_BACKGROUND_COLOR); panel_button[i][j]->setColor(RDPANEL_PAUSED_BACKGROUND_COLOR);
@ -114,8 +112,8 @@ void RDButtonPanel::setActionMode(RDAirPlayConf::ActionMode mode)
break; break;
case RDAirPlayConf::AddTo: case RDAirPlayConf::AddTo:
for(int i=0;i<panel_button_rows;i++) { for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<panel_button_columns;j++) { for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
if(panel_button[i][j]->playDeck()==NULL) { if(panel_button[i][j]->playDeck()==NULL) {
panel_button[i][j]->setColor(BUTTON_TO_BACKGROUND_COLOR); panel_button[i][j]->setColor(BUTTON_TO_BACKGROUND_COLOR);
} }
@ -124,8 +122,8 @@ void RDButtonPanel::setActionMode(RDAirPlayConf::ActionMode mode)
break; break;
case RDAirPlayConf::DeleteFrom: case RDAirPlayConf::DeleteFrom:
for(int i=0;i<panel_button_rows;i++) { for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<panel_button_columns;j++) { for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
if(panel_button[i][j]->playDeck()==NULL) { if(panel_button[i][j]->playDeck()==NULL) {
panel_button[i][j]->setColor(BUTTON_FROM_BACKGROUND_COLOR); panel_button[i][j]->setColor(BUTTON_FROM_BACKGROUND_COLOR);
} }
@ -134,8 +132,8 @@ void RDButtonPanel::setActionMode(RDAirPlayConf::ActionMode mode)
break; break;
default: default:
for(int i=0;i<panel_button_rows;i++) { for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<panel_button_columns;j++) { for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
// if(panel_button[i][j]->cart()!=0) { // if(panel_button[i][j]->cart()!=0) {
if(panel_button[i][j]->playDeck()!=NULL) { if(panel_button[i][j]->playDeck()!=NULL) {
if(panel_button[i][j]->playDeck()->state()==RDPlayDeck::Paused) { if(panel_button[i][j]->playDeck()->state()==RDPlayDeck::Paused) {
@ -163,8 +161,8 @@ void RDButtonPanel::setActionMode(RDAirPlayConf::ActionMode mode)
void RDButtonPanel::setAllowDrags(bool state) void RDButtonPanel::setAllowDrags(bool state)
{ {
for(int i=0;i<panel_button_rows;i++) { for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<panel_button_columns;j++) { for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
panel_button[i][j]->setAllowDrags(state); panel_button[i][j]->setAllowDrags(state);
} }
} }
@ -173,8 +171,8 @@ void RDButtonPanel::setAllowDrags(bool state)
void RDButtonPanel::setAcceptDrops(bool state) void RDButtonPanel::setAcceptDrops(bool state)
{ {
for(int i=0;i<panel_button_rows;i++) { for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<panel_button_columns;j++) { for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
panel_button[i][j]->setAcceptDrops(state); panel_button[i][j]->setAcceptDrops(state);
} }
} }
@ -183,8 +181,8 @@ void RDButtonPanel::setAcceptDrops(bool state)
void RDButtonPanel::hide() void RDButtonPanel::hide()
{ {
for(int i=0;i<panel_button_rows;i++) { for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<panel_button_columns;j++) { for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
panel_button[i][j]->hide(); panel_button[i][j]->hide();
} }
} }
@ -193,8 +191,8 @@ void RDButtonPanel::hide()
void RDButtonPanel::show() void RDButtonPanel::show()
{ {
for(int i=0;i<panel_button_rows;i++) { for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<panel_button_columns;j++) { for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
panel_button[i][j]->show(); panel_button[i][j]->show();
} }
} }
@ -203,8 +201,8 @@ void RDButtonPanel::show()
void RDButtonPanel::clear() void RDButtonPanel::clear()
{ {
for(int i=0;i<panel_button_rows;i++) { for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<panel_button_columns;j++) { for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
panel_button[i][j]->clear(); panel_button[i][j]->clear();
} }
} }

View File

@ -2,7 +2,7 @@
// //
// The sound panel widget for RDAirPlay // The sound panel widget for RDAirPlay
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2023 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
@ -23,13 +23,13 @@
#include <QDateTime> #include <QDateTime>
#include <QLabel> #include <QLabel>
#include <QWidget>
#include <rdairplay_conf.h> #include <rdairplay_conf.h>
#include <rdstation.h> #include <rdstation.h>
#include <rduser.h> #include <rduser.h>
#include <rdpanel_button.h> #include <rdpanel_button.h>
#include <rdbutton_dialog.h> #include <rdbutton_dialog.h>
#include <rdwidget.h>
// //
// Widget Settings // Widget Settings
@ -40,11 +40,10 @@
#define PANEL_BUTTON_SIZE_Y 80 #define PANEL_BUTTON_SIZE_Y 80
class RDButtonPanel class RDButtonPanel : public RDWidget
{ {
public: public:
RDButtonPanel(RDAirPlayConf::PanelType type,int panel,int cols,int rows, RDButtonPanel(RDAirPlayConf::PanelType type,QWidget *parent);
RDStation *station,bool flash,QWidget *parent);
~RDButtonPanel(); ~RDButtonPanel();
QSize sizeHint() const; QSize sizeHint() const;
QSizePolicy sizePolicy() const; QSizePolicy sizePolicy() const;
@ -58,9 +57,6 @@ class RDButtonPanel
private: private:
RDPanelButton *panel_button[PANEL_MAX_BUTTON_ROWS][PANEL_MAX_BUTTON_COLUMNS]; RDPanelButton *panel_button[PANEL_MAX_BUTTON_ROWS][PANEL_MAX_BUTTON_COLUMNS];
RDStation *panel_station;
int panel_button_columns;
int panel_button_rows;
}; };
#endif #endif // RDPANEL_BUTTON_H

View File

@ -70,6 +70,18 @@ void RDPanelButton::clear()
} }
int RDPanelButton::row() const
{
return button_row;
}
int RDPanelButton::column() const
{
return button_col;
}
QString RDPanelButton::text() const QString RDPanelButton::text() const
{ {
return button_text; return button_text;

View File

@ -33,6 +33,8 @@ class RDPanelButton : public RDPushButton
RDPanelButton(int row,int col,RDStation *station,bool flash, RDPanelButton(int row,int col,RDStation *station,bool flash,
QWidget *parent=0); QWidget *parent=0);
void clear(); void clear();
int row() const;
int column() const;
QString text() const; QString text() const;
void setText(const QString &text); void setText(const QString &text);
QString outputText() const; QString outputText() const;

View File

@ -2,7 +2,7 @@
// //
// The sound panel widget for RDAirPlay // The sound panel widget for RDAirPlay
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2023 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
@ -83,7 +83,7 @@ RDSoundPanel::RDSoundPanel(int station_panels,int user_panels,bool flash,
panel_mapper=new QSignalMapper(this); panel_mapper=new QSignalMapper(this);
connect(panel_mapper,SIGNAL(mapped(int)),this,SLOT(buttonMapperData(int))); connect(panel_mapper,SIGNAL(mapped(int)),this,SLOT(buttonMapperData(int)));
LoadPanels(); UpdatePanels(""); // Load Host (Station) Panels
// //
// Panel Selector // Panel Selector
@ -99,13 +99,13 @@ RDSoundPanel::RDSoundPanel(int station_panels,int user_panels,bool flash,
if(panel_station_panels>0) { if(panel_station_panels>0) {
panel_number=0; panel_number=0;
panel_type=RDAirPlayConf::StationPanel; panel_type=RDAirPlayConf::StationPanel;
panel_buttons[0]->show(); panel_panels.value("").at(0)->show();
} }
else { else {
if(panel_user_panels>0) { if(panel_user_panels>0) {
panel_number=0; panel_number=0;
panel_type=RDAirPlayConf::UserPanel; panel_type=RDAirPlayConf::UserPanel;
panel_buttons[0]->show(); panel_panels.value(rda->user()->name()).at(0)->show();
} }
else { else {
setDisabled(true); setDisabled(true);
@ -213,10 +213,13 @@ RDSoundPanel::RDSoundPanel(int station_panels,int user_panels,bool flash,
RDSoundPanel::~RDSoundPanel() RDSoundPanel::~RDSoundPanel()
{ {
for(unsigned i=0;i<panel_buttons.size();i++) { for(QMap<QString,QList<RDButtonPanel *> >::const_iterator it=panel_panels.begin();it!=panel_panels.end();it++) {
delete panel_buttons[i]; for(int i=0;i<it.value().size();i++) {
delete it.value().at(i);
} }
} }
panel_panels.clear();
}
QSize RDSoundPanel::sizeHint() const QSize RDSoundPanel::sizeHint() const
@ -333,8 +336,12 @@ void RDSoundPanel::channelStop(int mport)
void RDSoundPanel::setText(RDAirPlayConf::PanelType type,int panel,int row, void RDSoundPanel::setText(RDAirPlayConf::PanelType type,int panel,int row,
int col,const QString &str) int col,const QString &str)
{ {
QString username;
if(type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
RDPanelButton *button= RDPanelButton *button=
panel_buttons[PanelOffset(type,panel)]->panelButton(row,col); panel_panels.value(username).at(panel)->panelButton(row,col);
button->setText(str); button->setText(str);
SaveButton(type,panel,row,col); SaveButton(type,panel,row,col);
} }
@ -343,8 +350,12 @@ void RDSoundPanel::setText(RDAirPlayConf::PanelType type,int panel,int row,
void RDSoundPanel::setColor(RDAirPlayConf::PanelType type,int panel,int row, void RDSoundPanel::setColor(RDAirPlayConf::PanelType type,int panel,int row,
int col,const QColor &color) int col,const QColor &color)
{ {
QString username;
if(type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
RDPanelButton *button= RDPanelButton *button=
panel_buttons[PanelOffset(type,panel)]->panelButton(row,col); panel_panels.value(username).at(panel)->panelButton(row,col);
button->setDefaultColor(color); button->setDefaultColor(color);
SaveButton(type,panel,row,col); SaveButton(type,panel,row,col);
} }
@ -353,6 +364,10 @@ void RDSoundPanel::setColor(RDAirPlayConf::PanelType type,int panel,int row,
void RDSoundPanel::duckVolume(RDAirPlayConf::PanelType type,int panel,int row, void RDSoundPanel::duckVolume(RDAirPlayConf::PanelType type,int panel,int row,
int col,int level,int fade,int mport) int col,int level,int fade,int mport)
{ {
QString username;
if(type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
int edit_mport=mport; int edit_mport=mport;
if (edit_mport==0) { if (edit_mport==0) {
edit_mport=-1; edit_mport=-1;
@ -360,15 +375,16 @@ void RDSoundPanel::duckVolume(RDAirPlayConf::PanelType type,int panel,int row,
for(int i=0;i<panel_button_columns;i++) { for(int i=0;i<panel_button_columns;i++) {
for(int j=0;j<panel_button_rows;j++) { for(int j=0;j<panel_button_rows;j++) {
RDPlayDeck *deck= RDPlayDeck *deck=
panel_buttons[PanelOffset(type,panel)]->panelButton(j,i)->playDeck(); panel_panels.value(username).at(panel)->panelButton(j,i)->playDeck();
if((row==j || row==-1) && (col==i || col==-1)) { if((row==j || row==-1) && (col==i || col==-1)) {
if(mport==-1) { if(mport==-1) {
panel_buttons[PanelOffset(type,panel)]->panelButton(j,i)-> panel_panels.value(username).at(panel)->
setDuckVolume(level); panelButton(j,i)->setDuckVolume(level);
} }
if(deck!=NULL) { if(deck!=NULL) {
if(edit_mport==-1 || if(edit_mport==-1 ||
edit_mport==panel_buttons[PanelOffset(type,panel)]-> edit_mport==
panel_panels.value(username).at(panel)->
panelButton(j,i)->outputText().toInt()) { panelButton(j,i)->outputText().toInt()) {
deck->duckVolume(level,fade); deck->duckVolume(level,fade);
} }
@ -414,14 +430,16 @@ void RDSoundPanel::setActionMode(RDAirPlayConf::ActionMode mode)
if(mode!=panel_action_mode) { if(mode!=panel_action_mode) {
panel_action_mode=mode; panel_action_mode=mode;
panel_setup_button->setEnabled(panel_action_mode==RDAirPlayConf::Normal); panel_setup_button->setEnabled(panel_action_mode==RDAirPlayConf::Normal);
for(unsigned i=0;i<panel_buttons.size();i++) { for(QMap<QString,QList<RDButtonPanel *> >::const_iterator it=panel_panels.begin();it!=panel_panels.end();it++) {
if(i<(unsigned)panel_station_panels && for(int i=0;i<it.value().size();i++) {
if(i<panel_station_panels &&
(!panel_config_panels) && (!panel_config_panels) &&
(mode==RDAirPlayConf::AddTo || mode==RDAirPlayConf::CopyTo || mode==RDAirPlayConf::DeleteFrom)) { (mode==RDAirPlayConf::AddTo || mode==RDAirPlayConf::CopyTo || mode==RDAirPlayConf::DeleteFrom)) {
panel_buttons[i]->setActionMode(RDAirPlayConf::Normal); it.value().at(i)->setActionMode(RDAirPlayConf::Normal);
} }
else { else {
panel_buttons[i]->setActionMode(panel_action_mode); it.value().at(i)->setActionMode(panel_action_mode);
}
} }
} }
} }
@ -464,8 +482,12 @@ void RDSoundPanel::setButton(RDAirPlayConf::PanelType type,int panel,
{ {
QString str; QString str;
QString username;
if(type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
RDPanelButton *button= RDPanelButton *button=
panel_buttons[PanelOffset(type,panel)]->panelButton(row,col); panel_panels.value(username).at(panel)->panelButton(row,col);
if(button->playDeck()!=NULL) { if(button->playDeck()!=NULL) {
return; return;
} }
@ -535,8 +557,7 @@ void RDSoundPanel::acceptCartDrop(int row,int col,unsigned cartnum,
void RDSoundPanel::changeUser() void RDSoundPanel::changeUser()
{ {
panel_config_panels=rda->user()->configPanels(); panel_config_panels=rda->user()->configPanels();
LoadPanels(); UpdatePanels(rda->user()->name());
panel_buttons[PanelOffset(panel_type,panel_number)]->show();
// //
// Remove Old Panel Names // Remove Old Panel Names
@ -614,16 +635,22 @@ void RDSoundPanel::panelDown()
void RDSoundPanel::panelActivatedData(int n) void RDSoundPanel::panelActivatedData(int n)
{ {
panel_buttons[PanelOffset(panel_type,panel_number)]->hide(); QString username;
if(panel_type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
panel_panels.value(username).at(panel_number)->hide();
if(n<panel_station_panels) { if(n<panel_station_panels) {
panel_type=RDAirPlayConf::StationPanel; panel_type=RDAirPlayConf::StationPanel;
panel_number=n; panel_number=n;
username="";
} }
else { else {
panel_type=RDAirPlayConf::UserPanel; panel_type=RDAirPlayConf::UserPanel;
panel_number=n-panel_station_panels; panel_number=n-panel_station_panels;
username=rda->user()->name();
} }
panel_buttons[PanelOffset(panel_type,panel_number)]->show(); panel_panels.value(username).at(panel_number)->show();
UpdateButtonViewport(); UpdateButtonViewport();
} }
@ -654,12 +681,16 @@ void RDSoundPanel::allClickedData()
void RDSoundPanel::playmodeActivatedData(int n) void RDSoundPanel::playmodeActivatedData(int n)
{ {
LoadPanel(panel_type,panel_number); ShowPanel(panel_type,panel_number);
} }
void RDSoundPanel::setupClickedData() void RDSoundPanel::setupClickedData()
{ {
QString username;
if(panel_type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
if(panel_setup_mode) { if(panel_setup_mode) {
panel_setup_mode=false; panel_setup_mode=false;
panel_setup_button->setFlashingEnabled(false); panel_setup_button->setFlashingEnabled(false);
@ -673,9 +704,9 @@ void RDSoundPanel::setupClickedData()
panel_playmode_box->setDisabled(true); panel_playmode_box->setDisabled(true);
} }
if(rda->station()->enableDragdrop()&&(rda->station()->enforcePanelSetup())) { if(rda->station()->enableDragdrop()&&(rda->station()->enforcePanelSetup())) {
for(unsigned i=0;i<panel_buttons.size();i++) { for(int i=0;i<panel_panels.size();i++) {
if(panel_buttons[i]!=NULL) { if(panel_panels.value(username).at(i)!=NULL) {
panel_buttons[i]->setAcceptDrops(panel_setup_mode); panel_panels.value(username).at(i)->setAcceptDrops(panel_setup_mode);
} }
} }
} }
@ -683,44 +714,41 @@ void RDSoundPanel::setupClickedData()
} }
void RDSoundPanel::buttonMapperData(int id) void RDSoundPanel::buttonMapperData(int grid_pos)
{ {
int row=id/panel_button_columns; RDPanelButton *button=GetCurrentPanel()->
int col=id-row*panel_button_columns; panelButton(grid_pos/PANEL_MAX_BUTTON_COLUMNS,
grid_pos%PANEL_MAX_BUTTON_COLUMNS);
unsigned cartnum; unsigned cartnum;
switch(panel_action_mode) { switch(panel_action_mode) {
case RDAirPlayConf::CopyFrom: case RDAirPlayConf::CopyFrom:
if((cartnum=panel_buttons[PanelOffset(panel_type,panel_number)]-> if((cartnum=button->cart())>0) {
panelButton(row,col)->cart())>0) {
emit selectClicked(cartnum,0,0); emit selectClicked(cartnum,0,0);
} }
break; break;
case RDAirPlayConf::CopyTo: case RDAirPlayConf::CopyTo:
if(panel_buttons[PanelOffset(panel_type,panel_number)]-> if(button->playDeck()==NULL
panelButton(row,col)->playDeck()==NULL
&& ((panel_type==RDAirPlayConf::UserPanel) || && ((panel_type==RDAirPlayConf::UserPanel) ||
panel_config_panels)) { panel_config_panels)) {
emit selectClicked(0,row,col); emit selectClicked(0,button->row(),button->column());
} }
break; break;
case RDAirPlayConf::AddTo: case RDAirPlayConf::AddTo:
if(panel_buttons[PanelOffset(panel_type,panel_number)]-> if(button->playDeck()==NULL
panelButton(row,col)->playDeck()==NULL
&& ((panel_type==RDAirPlayConf::UserPanel) || && ((panel_type==RDAirPlayConf::UserPanel) ||
panel_config_panels)) { panel_config_panels)) {
emit selectClicked(0,row,col); emit selectClicked(0,button->row(),button->column());
} }
break; break;
case RDAirPlayConf::DeleteFrom: case RDAirPlayConf::DeleteFrom:
if(panel_buttons[PanelOffset(panel_type,panel_number)]-> if(button->playDeck()==NULL
panelButton(row,col)->playDeck()==NULL
&& ((panel_type==RDAirPlayConf::UserPanel) || && ((panel_type==RDAirPlayConf::UserPanel) ||
panel_config_panels)) { panel_config_panels)) {
emit selectClicked(0,row,col); emit selectClicked(0,button->row(),button->column());
} }
break; break;
@ -732,38 +760,34 @@ void RDSoundPanel::buttonMapperData(int id)
return; return;
} }
if(panel_button_dialog-> if(panel_button_dialog->
exec(panel_buttons[PanelOffset(panel_type,panel_number)]-> exec(button,panel_playmode_box->currentIndex()==1,
panelButton(row,col),panel_playmode_box->currentIndex()==1,
rda->user()->name(),rda->user()->password())) { rda->user()->name(),rda->user()->password())) {
SaveButton(panel_type,panel_number,row,col); SaveButton(panel_type,panel_number,button->row(),button->column());
} }
} }
else { else {
RDPanelButton *button=
panel_buttons[PanelOffset(panel_type,panel_number)]->
panelButton(row,col);
RDPlayDeck *deck=button->playDeck(); RDPlayDeck *deck=button->playDeck();
if(panel_reset_mode) { if(panel_reset_mode) {
StopButton(panel_type,panel_number,row,col); StopButton(panel_type,panel_number,button->row(),button->column());
} }
else { else {
if(deck==NULL) { if(deck==NULL) {
PlayButton(panel_type,panel_number,row,col, PlayButton(panel_type,panel_number,button->row(),button->column(),
RDLogLine::StartManual, RDLogLine::StartManual,
panel_playmode_box->currentIndex()==1); panel_playmode_box->currentIndex()==1);
} }
else { else {
if(panel_pause_enabled) { if(panel_pause_enabled) {
if(deck->state()!=RDPlayDeck::Paused) { if(deck->state()!=RDPlayDeck::Paused) {
PauseButton(panel_type,panel_number,row,col); PauseButton(panel_type,panel_number,button->row(),button->column());
} }
else { else {
PlayButton(panel_type,panel_number,row,col, PlayButton(panel_type,panel_number,button->row(),button->column(),
RDLogLine::StartManual,button->hookMode()); RDLogLine::StartManual,button->hookMode());
} }
} }
else { else {
StopButton(panel_type,panel_number,row,col); StopButton(panel_type,panel_number,button->row(),button->column());
} }
} }
} }
@ -873,7 +897,7 @@ void RDSoundPanel::onairFlagChangedData(bool state)
void RDSoundPanel::scanPanelData() void RDSoundPanel::scanPanelData()
{ {
if(panel_action_mode==RDAirPlayConf::Normal) { if(panel_action_mode==RDAirPlayConf::Normal) {
LoadPanel(panel_type,panel_number); ShowPanel(panel_type,panel_number);
} }
} }
@ -913,8 +937,12 @@ void RDSoundPanel::wheelEvent(QWheelEvent *e)
void RDSoundPanel::UpdateButtonViewport() void RDSoundPanel::UpdateButtonViewport()
{ {
QString username;
if(panel_type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
QRect viewport(0,0,size().width()-5,size().height()-60); QRect viewport(0,0,size().width()-5,size().height()-60);
RDButtonPanel *panel=panel_buttons[PanelOffset(panel_type,panel_number)]; RDButtonPanel *panel=panel_panels.value(username).at(panel_number);
for(int i=0;i<panel_button_rows;i++) { for(int i=0;i<panel_button_rows;i++) {
for(int j=0;j<panel_button_columns;j++) { for(int j=0;j<panel_button_columns;j++) {
RDPanelButton *button=panel->panelButton(i,j); RDPanelButton *button=panel->panelButton(i,j);
@ -930,12 +958,15 @@ void RDSoundPanel::PlayButton(RDAirPlayConf::PanelType type,int panel,
{ {
int edit_row=row; int edit_row=row;
int edit_col=col; int edit_col=col;
QString username;
if(type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
for(int i=0;i<panel_button_columns;i++) { for(int i=0;i<panel_button_columns;i++) {
for(int j=0;j<panel_button_rows;j++) { for(int j=0;j<panel_button_rows;j++) {
if(panel_buttons[PanelOffset(type,panel)]-> if(panel_panels.value(username).at(panel)->panelButton(j,i)->cart()>0 &&
panelButton(j,i)->cart()>0 && panel_panels.value(username).at(panel)->
panel_buttons[PanelOffset(type,panel)]->
panelButton(j,i)->state()==false) { panelButton(j,i)->state()==false) {
if(edit_col==-1 || col==i) { if(edit_col==-1 || col==i) {
edit_col=i; edit_col=i;
@ -951,7 +982,7 @@ void RDSoundPanel::PlayButton(RDAirPlayConf::PanelType type,int panel,
} }
RDPanelButton *button= RDPanelButton *button=
panel_buttons[PanelOffset(type,panel)]->panelButton(edit_row,edit_col); panel_panels.value(username).at(panel)->panelButton(edit_row,edit_col);
RDPlayDeck *deck=button->playDeck(); RDPlayDeck *deck=button->playDeck();
if(deck!=NULL) { if(deck!=NULL) {
deck->play(deck->currentPosition()); deck->play(deck->currentPosition());
@ -1115,18 +1146,22 @@ void RDSoundPanel::PlayMacro(RDPanelButton *button,RDCart *cart)
void RDSoundPanel::PauseButton(RDAirPlayConf::PanelType type,int panel, void RDSoundPanel::PauseButton(RDAirPlayConf::PanelType type,int panel,
int row,int col,int mport) int row,int col,int mport)
{ {
QString username;
if(type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
for(int i=0;i<panel_button_columns;i++) { for(int i=0;i<panel_button_columns;i++) {
for(int j=0;j<panel_button_rows;j++) { for(int j=0;j<panel_button_rows;j++) {
RDPlayDeck *deck= RDPlayDeck *deck=
panel_buttons[PanelOffset(type,panel)]->panelButton(j,i)->playDeck(); panel_panels.value(username).at(panel)->panelButton(j,i)->playDeck();
if(deck!=NULL && (row==j || row==-1) && (col==i || col==-1)) { if(deck!=NULL && (row==j || row==-1) && (col==i || col==-1)) {
if(mport==-1 || if(mport==-1 ||
mport==panel_buttons[PanelOffset(type,panel)]-> mport==panel_panels.value(username).at(panel)->
panelButton(j,i)->outputText().toInt()) { panelButton(j,i)->outputText().toInt()) {
deck->pause(); deck->pause();
panel_buttons[PanelOffset(type,panel)]->panelButton(j,i)-> panel_panels.value(username).at(panel)->
setStartTime(QTime()); panelButton(j,i)->setStartTime(QTime());
} }
} }
} }
@ -1138,26 +1173,30 @@ void RDSoundPanel::StopButton(RDAirPlayConf::PanelType type,int panel,
int row,int col,int mport, int row,int col,int mport,
bool pause_when_finished,int fade_out) bool pause_when_finished,int fade_out)
{ {
QString username;
if(type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
int edit_mport=mport; int edit_mport=mport;
if (edit_mport==0) { if (edit_mport==0) {
edit_mport=-1; edit_mport=-1;
} }
for(int i=0;i<panel_button_columns;i++) { for(int i=0;i<panel_button_columns;i++) {
for(int j=0;j<panel_button_rows;j++) { for(int j=0;j<panel_button_rows;j++) {
RDPlayDeck *deck= RDPlayDeck *deck=panel_panels.value(username).at(panel)->
panel_buttons[PanelOffset(type,panel)]->panelButton(j,i)->playDeck(); panelButton(j,i)->playDeck();
if((row==j || row==-1) && (col==i || col==-1)) { if((row==j || row==-1) && (col==i || col==-1)) {
if(deck!=NULL) { if(deck!=NULL) {
if(edit_mport==-1 || if(edit_mport==-1 ||
edit_mport==panel_buttons[PanelOffset(type,panel)]->panelButton(j,i)-> edit_mport==panel_panels.value(username).
outputText().toInt()) { at(panel)->panelButton(j,i)->outputText().toInt()) {
if(panel_pause_enabled) { if(panel_pause_enabled) {
panel_buttons[PanelOffset(type,panel)]->panelButton(j,i)-> panel_panels.value(username).at(panel)->
setPauseWhenFinished(pause_when_finished); panelButton(j,i)->setPauseWhenFinished(pause_when_finished);
} }
else { else {
panel_buttons[PanelOffset(type,panel)]->panelButton(j,i)-> panel_panels.value(username).at(panel)->
setPauseWhenFinished(false); panelButton(j,i)->setPauseWhenFinished(false);
} }
switch(deck->state()) { switch(deck->state()) {
case RDPlayDeck::Playing: case RDPlayDeck::Playing:
@ -1176,10 +1215,11 @@ void RDSoundPanel::StopButton(RDAirPlayConf::PanelType type,int panel,
} }
else { else {
if(!pause_when_finished && panel_pause_enabled) { if(!pause_when_finished && panel_pause_enabled) {
panel_buttons[PanelOffset(type,panel)]->panelButton(j,i)->setState(false); panel_panels.value(username).at(panel)->
panel_buttons[PanelOffset(type,panel)]->panelButton(j,i)-> panelButton(j,i)->setState(false);
setPauseWhenFinished(false); panel_panels.value(username).at(panel)->
panel_buttons[PanelOffset(type,panel)]->panelButton(j,i)->reset(); panelButton(j,i)->setPauseWhenFinished(false);
panel_panels.value(username).at(panel)->panelButton(j,i)->reset();
} }
} }
} }
@ -1217,45 +1257,45 @@ void RDSoundPanel::StopButton(RDPlayDeck *deck)
} }
} }
/*
void RDSoundPanel::LoadPanels() void RDSoundPanel::LoadPanels()
{ {
for(unsigned i=0;i<panel_buttons.size();i++) { for(unsigned i=0;i<panel_panels.size();i++) {
delete panel_buttons[i]; delete panel_panels[i];
} }
panel_buttons.clear(); panel_panels.clear();
// //
// Load Buttons // Load Buttons
// //
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_panels.push_back(new RDButtonPanel(panel_type,i,panel_button_columns,
panel_button_rows, panel_button_rows,
rda->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_panels.back()->panelButton(j,k),SIGNAL(clicked()),
panel_mapper,SLOT(map())); panel_mapper,SLOT(map()));
panel_mapper->setMapping(panel_buttons.back()->panelButton(j,k), panel_mapper->setMapping(panel_panels.back()->panelButton(j,k),
j*panel_button_columns+k); j*panel_button_columns+k);
} }
} }
LoadPanel(RDAirPlayConf::StationPanel,i); LoadPanel(RDAirPlayConf::StationPanel,i);
panel_buttons.back()->setAllowDrags(rda->station()->enableDragdrop()); panel_panels.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_panels.push_back(new RDButtonPanel(panel_type,i,panel_button_columns,
panel_button_rows, panel_button_rows,
rda->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_panels.back()->panelButton(j,k),SIGNAL(clicked()),
panel_mapper,SLOT(map())); panel_mapper,SLOT(map()));
panel_mapper->setMapping(panel_buttons.back()->panelButton(j,k), panel_mapper->setMapping(panel_panels.back()->panelButton(j,k),
j*panel_button_columns+k); j*panel_button_columns+k);
} }
} }
panel_buttons.back()->setAllowDrags(rda->station()->enableDragdrop()); panel_panels.back()->setAllowDrags(rda->station()->enableDragdrop());
LoadPanel(RDAirPlayConf::UserPanel,i); LoadPanel(RDAirPlayConf::UserPanel,i);
} }
} }
@ -1295,58 +1335,58 @@ void RDSoundPanel::LoadPanel(RDAirPlayConf::PanelType type,int panel)
"order by "+panel_tablename+".`COLUMN_NO`,"+panel_tablename+".`ROW_NO`"; "order by "+panel_tablename+".`COLUMN_NO`,"+panel_tablename+".`ROW_NO`";
RDSqlQuery *q=new RDSqlQuery(sql); RDSqlQuery *q=new RDSqlQuery(sql);
while(q->next()) { while(q->next()) {
if(panel_buttons[offset]->panelButton(q->value(0).toInt(), if(panel_panels[offset]->panelButton(q->value(0).toInt(),
q->value(1).toInt())->playDeck()==NULL) { q->value(1).toInt())->playDeck()==NULL) {
panel_buttons[offset]-> panel_panels[offset]->
panelButton(q->value(0).toInt(),q->value(1).toInt())-> panelButton(q->value(0).toInt(),q->value(1).toInt())->
setText(q->value(2).toString()); setText(q->value(2).toString());
panel_buttons[offset]-> panel_panels[offset]->
panelButton(q->value(0).toInt(),q->value(1).toInt())-> panelButton(q->value(0).toInt(),q->value(1).toInt())->
setCart(q->value(3).toInt()); setCart(q->value(3).toInt());
panel_buttons[offset]-> panel_panels[offset]->
panelButton(q->value(0).toInt(),q->value(1).toInt())-> panelButton(q->value(0).toInt(),q->value(1).toInt())->
setLength(false,q->value(5).toInt()); setLength(false,q->value(5).toInt());
panel_buttons[offset]-> panel_panels[offset]->
panelButton(q->value(0).toInt(),q->value(1).toInt())-> panelButton(q->value(0).toInt(),q->value(1).toInt())->
setLength(true,q->value(6).toInt()); setLength(true,q->value(6).toInt());
if((panel_playmode_box!=NULL)&&(panel_playmode_box->currentIndex()==1)&& if((panel_playmode_box!=NULL)&&(panel_playmode_box->currentIndex()==1)&&
(q->value(6).toUInt()>0)) { (q->value(6).toUInt()>0)) {
panel_buttons[offset]-> panel_panels[offset]->
panelButton(q->value(0).toInt(),q->value(1).toInt())-> panelButton(q->value(0).toInt(),q->value(1).toInt())->
setActiveLength(q->value(6).toInt()); setActiveLength(q->value(6).toInt());
} }
else { else {
if(q->value(7).toInt()==RDCart::Macro) { if(q->value(7).toInt()==RDCart::Macro) {
panel_buttons[offset]-> panel_panels[offset]->
panelButton(q->value(0).toInt(),q->value(1).toInt())-> panelButton(q->value(0).toInt(),q->value(1).toInt())->
setActiveLength(q->value(5).toInt()); setActiveLength(q->value(5).toInt());
} }
else { else {
if(q->value(5).toInt()>0) { if(q->value(5).toInt()>0) {
panel_buttons[offset]-> panel_panels[offset]->
panelButton(q->value(0).toInt(),q->value(1).toInt())-> panelButton(q->value(0).toInt(),q->value(1).toInt())->
setActiveLength(q->value(5).toInt()); setActiveLength(q->value(5).toInt());
} }
else { else {
panel_buttons[offset]-> panel_panels[offset]->
panelButton(q->value(0).toInt(),q->value(1).toInt())-> panelButton(q->value(0).toInt(),q->value(1).toInt())->
setActiveLength(-1); setActiveLength(-1);
} }
} }
} }
if(q->value(4).toString().isEmpty()) { if(q->value(4).toString().isEmpty()) {
panel_buttons[offset]-> panel_panels[offset]->
panelButton(q->value(0).toInt(),q->value(1).toInt())-> panelButton(q->value(0).toInt(),q->value(1).toInt())->
setColor(palette().color(QPalette::Background)); setColor(palette().color(QPalette::Background));
panel_buttons[offset]-> panel_panels[offset]->
panelButton(q->value(0).toInt(),q->value(1).toInt())-> panelButton(q->value(0).toInt(),q->value(1).toInt())->
setDefaultColor(palette().color(QPalette::Background)); setDefaultColor(palette().color(QPalette::Background));
} }
else { else {
panel_buttons[offset]-> panel_panels[offset]->
panelButton(q->value(0).toInt(),q->value(1).toInt())-> panelButton(q->value(0).toInt(),q->value(1).toInt())->
setColor(QColor(q->value(4).toString())); setColor(QColor(q->value(4).toString()));
panel_buttons[offset]-> panel_panels[offset]->
panelButton(q->value(0).toInt(),q->value(1).toInt())-> panelButton(q->value(0).toInt(),q->value(1).toInt())->
setDefaultColor(QColor(q->value(4).toString())); setDefaultColor(QColor(q->value(4).toString()));
} }
@ -1356,6 +1396,122 @@ void RDSoundPanel::LoadPanel(RDAirPlayConf::PanelType type,int panel)
UpdateButtonViewport(); UpdateButtonViewport();
} }
*/
void RDSoundPanel::UpdatePanels(const QString &username)
{
QString owner=username;
RDAirPlayConf::PanelType type=RDAirPlayConf::UserPanel;
int size=panel_user_panels;
if(username.isEmpty()) {
owner=rda->station()->name();
type=RDAirPlayConf::StationPanel;
size=panel_station_panels;
}
//
// Create the panel
//
if(size>0) {
QList<RDButtonPanel *> list;
if(panel_panels.value(username).size()>0) {
list=panel_panels.value(username);
}
for(int i=panel_panels.value(username).size();i<size;i++) {
list.push_back(new RDButtonPanel(type,this));
}
panel_panels[username]=list;
}
QString sql=QString("select ")+
panel_tablename+".`PANEL_NO`,"+ // 00
panel_tablename+".`ROW_NO`,"+ // 01
panel_tablename+".`COLUMN_NO`,"+ // 02
panel_tablename+".`LABEL`,"+ // 03
panel_tablename+".`CART`,"+ // 04
panel_tablename+".`DEFAULT_COLOR`,"+ // 05
"`CART`.`FORCED_LENGTH`,"+ // 06
"`CART`.`AVERAGE_HOOK_LENGTH`,"+ // 07
"`CART`.`TYPE` "+ // 08
"from "+panel_tablename+" "+ // 09
"left join `CART` on "+panel_tablename+".`CART`=`CART`.`NUMBER` "+
"where "+panel_tablename+QString::asprintf(".`TYPE`=%d && ",type)+
panel_tablename+".`OWNER`='"+RDEscapeString(owner)+"' "+
"order by "+
panel_tablename+".`PANEL_NO`,"+
panel_tablename+".`COLUMN_NO`,"+
panel_tablename+".`ROW_NO`";
RDSqlQuery *q=new RDSqlQuery(sql);
while(q->next()) {
RDPanelButton *button=panel_panels.value(username).at(q->value(0).toInt())->
panelButton(q->value(1).toInt(),q->value(2).toInt());
if(button->playDeck()==NULL) {
button->setText(q->value(3).toString());
button->setCart(q->value(4).toInt());
button->setLength(false,q->value(6).toInt());
button->setLength(true,q->value(7).toInt());
if((panel_playmode_box!=NULL)&&(panel_playmode_box->currentIndex()==1)&&
(q->value(7).toUInt()>0)) {
button->setActiveLength(q->value(7).toInt());
}
else {
if(q->value(8).toInt()==RDCart::Macro) {
button->setActiveLength(q->value(6).toInt());
}
else {
if(q->value(6).toInt()>0) {
button->setActiveLength(q->value(6).toInt());
}
else {
button->setActiveLength(-1);
}
}
}
if(q->value(5).toString().isEmpty()) {
button->setColor(palette().color(QPalette::Background));
button->setDefaultColor(palette().color(QPalette::Background));
}
else {
button->setColor(QColor(q->value(5).toString()));
button->setDefaultColor(QColor(q->value(5).toString()));
}
connect(button,SIGNAL(clicked()),panel_mapper,SLOT(map()));
panel_mapper->setMapping(button,
q->value(1).toInt()*PANEL_MAX_BUTTON_COLUMNS+q->value(2).toInt());
}
}
delete q;
}
void RDSoundPanel::ShowPanel(RDAirPlayConf::PanelType type,int offset)
{
QString username;
if(type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
for(QMap<QString,QList<RDButtonPanel *> >::const_iterator it=
panel_panels.begin();it!=panel_panels.end();it++) {
if(it.key()==username) {
for(int i=0;i<it.value().size();i++) {
if(offset==i) {
it.value().at(i)->show();
}
else {
it.value().at(i)->hide();
}
}
}
else {
for(int i=0;i<it.value().size();i++) {
it.value().at(i)->hide();
}
}
}
UpdateButtonViewport();
}
void RDSoundPanel::SaveButton(RDAirPlayConf::PanelType type, void RDSoundPanel::SaveButton(RDAirPlayConf::PanelType type,
@ -1366,6 +1522,10 @@ void RDSoundPanel::SaveButton(RDAirPlayConf::PanelType type,
RDSqlQuery *q; RDSqlQuery *q;
QString owner; QString owner;
int offset=0; int offset=0;
QString username;
if(type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
switch(type) { switch(type) {
case RDAirPlayConf::UserPanel: case RDAirPlayConf::UserPanel:
@ -1395,13 +1555,14 @@ void RDSoundPanel::SaveButton(RDAirPlayConf::PanelType type,
// //
delete q; delete q;
sql1=QString("update ")+panel_tablename+" set "+ sql1=QString("update ")+panel_tablename+" set "+
"`LABEL`='"+RDEscapeString(panel_buttons[offset]->panelButton(row,col)-> "`LABEL`='"+RDEscapeString(panel_panels.value(username).at(offset)->
text())+"',"+ panelButton(row,col)->text())+"',"+
QString::asprintf("`CART`=%d,", QString::asprintf("`CART`=%d,",
panel_buttons[PanelOffset(panel_type,panel_number)]-> panel_panels.value(username).
panelButton(row,col)->cart())+ // at(PanelOffset(panel_type,panel_number))->
"`DEFAULT_COLOR`='"+panel_buttons[offset]->panelButton(row,col)-> at(panel_number)->panelButton(row,col)->cart())+
defaultColor().name()+"' where "+ "`DEFAULT_COLOR`='"+panel_panels.value(username).at(offset)->
panelButton(row,col)->defaultColor().name()+"' where "+
QString::asprintf("(`TYPE`=%d)&&",type)+ QString::asprintf("(`TYPE`=%d)&&",type)+
"(`OWNER`='"+RDEscapeString(owner)+"')&&"+ "(`OWNER`='"+RDEscapeString(owner)+"')&&"+
QString::asprintf("(`PANEL_NO`=%d)&&",panel)+ QString::asprintf("(`PANEL_NO`=%d)&&",panel)+
@ -1432,34 +1593,19 @@ void RDSoundPanel::SaveButton(RDAirPlayConf::PanelType type,
QString::asprintf("values (%d,",type)+ QString::asprintf("values (%d,",type)+
"'"+RDEscapeString(owner)+"',"+ "'"+RDEscapeString(owner)+"',"+
QString::asprintf("%d,%d,%d,",panel,row,col)+ QString::asprintf("%d,%d,%d,",panel,row,col)+
"'"+RDEscapeString(panel_buttons[offset]-> "'"+RDEscapeString(panel_panels.value(username).at(offset)->
panelButton(row,col)->text())+"',"+ panelButton(row,col)->text())+"',"+
QString::asprintf("%d,", QString::asprintf("%d,",
panel_buttons[PanelOffset(panel_type,panel_number)]-> panel_panels.value(username).
panelButton(row,col)->cart())+ // at(PanelOffset(panel_type,panel_number))->
"'"+RDEscapeString(panel_buttons[offset]-> at(panel_number)->panelButton(row,col)->cart())+
"'"+RDEscapeString(panel_panels.value(username).at(offset)->
panelButton(row,col)->defaultColor().name())+"')"; panelButton(row,col)->defaultColor().name())+"')";
q=new RDSqlQuery(sql1); RDSqlQuery::apply(sql1);
delete q;
} }
} }
int RDSoundPanel::PanelOffset(RDAirPlayConf::PanelType type,int panel)
{
switch(type) {
case RDAirPlayConf::StationPanel:
return panel;
break;
case RDAirPlayConf::UserPanel:
return panel_station_panels+panel;
break;
}
return 0;
}
int RDSoundPanel::GetFreeButtonDeck() int RDSoundPanel::GetFreeButtonDeck()
{ {
for(int i=0;i<RD_MAX_STREAMS;i++) { for(int i=0;i<RD_MAX_STREAMS;i++) {
@ -1737,3 +1883,20 @@ QString RDSoundPanel::PanelOwner(RDAirPlayConf::PanelType type)
} }
return QString(); return QString();
} }
RDButtonPanel *RDSoundPanel::GetCurrentPanel() const
{
QString username;
if(panel_type==RDAirPlayConf::UserPanel) {
username=rda->user()->name();
}
return panel_panels.value(username).at(panel_number);
}
RDPanelButton *RDSoundPanel::GetVisibleButton(int row,int col) const
{
return NULL;
}

View File

@ -2,7 +2,7 @@
// //
// The sound panel widget // The sound panel widget
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2023 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
@ -21,10 +21,10 @@
#ifndef RDSOUND_PANEL_H #ifndef RDSOUND_PANEL_H
#define RDSOUND_PANEL_H #define RDSOUND_PANEL_H
#include <vector>
#include <QDateTime> #include <QDateTime>
#include <QLabel> #include <QLabel>
#include <QList>
#include <QMap>
#include <QSignalMapper> #include <QSignalMapper>
#include <rdbutton_dialog.h> #include <rdbutton_dialog.h>
@ -108,7 +108,8 @@ class RDSoundPanel : public RDWidget
void resetClickedData(); void resetClickedData();
void allClickedData(); void allClickedData();
void setupClickedData(); void setupClickedData();
void buttonMapperData(int id); void buttonMapperData(int grid_pos);
// void buttonMapperData(QWidget *w);
void stateChangedData(int id,RDPlayDeck::State state); void stateChangedData(int id,RDPlayDeck::State state);
void hookEndData(int id); void hookEndData(int id);
void timescalingSupportedData(int card,bool state); void timescalingSupportedData(int card,bool state);
@ -133,10 +134,12 @@ class RDSoundPanel : public RDWidget
int mport=-1,bool pause_when_finished=false,int fade_out=0); int mport=-1,bool pause_when_finished=false,int fade_out=0);
void StopButton(int id); void StopButton(int id);
void StopButton(RDPlayDeck *deck); void StopButton(RDPlayDeck *deck);
void LoadPanels(); // void LoadPanels();
void LoadPanel(RDAirPlayConf::PanelType type,int panel); // void LoadPanel(RDAirPlayConf::PanelType type,int panel);
void UpdatePanels(const QString &username);
void ShowPanel(RDAirPlayConf::PanelType type,int offset);
void SaveButton(RDAirPlayConf::PanelType type,int panel,int row,int col); void SaveButton(RDAirPlayConf::PanelType type,int panel,int row,int col);
int PanelOffset(RDAirPlayConf::PanelType type,int panel); // int PanelOffset(RDAirPlayConf::PanelType type,int panel);
int GetFreeButtonDeck(); int GetFreeButtonDeck();
int GetFreeOutput(); int GetFreeOutput();
void LogPlayEvent(unsigned cartnum,int cutnum); void LogPlayEvent(unsigned cartnum,int cutnum);
@ -150,7 +153,9 @@ class RDSoundPanel : public RDWidget
void ClearReset(); void ClearReset();
QString PanelTag(int index); QString PanelTag(int index);
QString PanelOwner(RDAirPlayConf::PanelType type); QString PanelOwner(RDAirPlayConf::PanelType type);
std::vector<RDButtonPanel *> panel_buttons; RDButtonPanel *GetCurrentPanel() const;
RDPanelButton *GetVisibleButton(int row,int col) const;
QMap<QString,QList<RDButtonPanel *> > panel_panels;
RDComboBox *panel_selector_box; RDComboBox *panel_selector_box;
QComboBox *panel_playmode_box; QComboBox *panel_playmode_box;
RDPushButton *panel_setup_button; RDPushButton *panel_setup_button;