2021-01-27 Fred Gleason <fredg@paravelsystems.com>

* Added a 'RDMatrix::id()' method.
	* Added 'RDIconEngine::Switcher', 'RDIconEngine::Record',
	'RDIconEngine::Download' and 'RDIconEngine::Upload' icons to
	'RDIconEngine.
	* Added 'RDMatrixListModel'.
	* Refactored the 'Rivendell Switcher List' dialog in rdadmin(1) to
	use the	model-based API.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2021-01-27 14:04:59 -05:00
parent 040711e1d8
commit d5f0792db9
26 changed files with 887 additions and 131 deletions

View File

@ -20926,3 +20926,11 @@
* Added 'RDReplicatorListModel'.
* Refactored the 'Rivendell Replicators' dialog in rdadmin(1) to
use the model-based API.
2021-01-27 Fred Gleason <fredg@paravelsystems.com>
* Added a 'RDMatrix::id()' method.
* Added 'RDIconEngine::Switcher', 'RDIconEngine::Record',
'RDIconEngine::Download' and 'RDIconEngine::Upload' icons to
'RDIconEngine.
* Added 'RDMatrixListModel'.
* Refactored the 'Rivendell Switcher List' dialog in rdadmin(1) to
use the model-based API.

View File

@ -186,6 +186,7 @@ dist_librd_la_SOURCES = dbversion.h\
rdmarker_button.cpp rdmarker_button.h\
rdmarker_edit.cpp rdmarker_edit.h\
rdmatrix.cpp rdmatrix.h\
rdmatrixlistmodel.cpp rdmatrixlistmodel.h\
rdmblookup.cpp rdmblookup.h\
rdmeteraverage.cpp rdmeteraverage.h\
rdmixer.cpp rdmixer.h\
@ -347,6 +348,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\
moc_rdmacro_event.cpp\
moc_rdmarker_bar.cpp\
moc_rdmarker_edit.cpp\
moc_rdmatrixlistmodel.cpp\
moc_rdmblookup.cpp\
moc_rdmulticaster.cpp\
moc_rdoneshot.cpp\

View File

@ -139,6 +139,7 @@ SOURCES += rdmacro_event.cpp
SOURCES += rdmarker_button.cpp
SOURCES += rdmarker_edit.cpp
SOURCES += rdmatrix.cpp
SOURCES += rdmatrixlistmodel.cpp
SOURCES += rdmblookup.cpp
SOURCES += rdmonitor_config.cpp
SOURCES += rdnotification.cpp
@ -303,6 +304,7 @@ HEADERS += rdmacro_event.h
HEADERS += rdmarker_button.h
HEADERS += rdmarker_edit.h
HEADERS += rdmatrix.h
HEADERS += rdmatrixlistmodel.h
HEADERS += rdmblookup.h
HEADERS += rdmonitor_config.h
HEADERS += rdnotification.h

View File

@ -3239,6 +3239,41 @@ Bitte Kofiguration prüfen und erneut versuchen.</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMatrixListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Matrix</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Outputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPIs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPOs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMbLookup</name>
<message>

View File

@ -3220,6 +3220,41 @@ Bitte Kofiguration prüfen und erneut versuchen.</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMatrixListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Matrix</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Outputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPIs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPOs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMbLookup</name>
<message>

View File

@ -3207,6 +3207,41 @@ Do you still want to proceed?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMatrixListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Matrix</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Outputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPIs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPOs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMbLookup</name>
<message>

View File

@ -2643,6 +2643,41 @@ Do you want to overwrite it?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMatrixListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Matrix</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Outputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPIs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPOs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMbLookup</name>
<message>

View File

@ -3174,6 +3174,41 @@ Sjekk eksportoppsettet ditt og prøv att.</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMatrixListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Matrix</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Outputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPIs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPOs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMbLookup</name>
<message>

View File

@ -3174,6 +3174,41 @@ Sjekk eksportoppsettet ditt og prøv att.</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMatrixListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Matrix</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Outputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPIs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPOs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMbLookup</name>
<message>

View File

@ -3209,6 +3209,41 @@ Por Favor, cheque suas configurações e tenbte outra vez.</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMatrixListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Matrix</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Outputs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPIs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GPOs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[none]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDMbLookup</name>
<message>

View File

@ -111,6 +111,10 @@
#include "../icons/greenball.xpm"
#include "../icons/redball.xpm"
#include "../icons/whiteball.xpm"
#include "../icons/switch3.xpm"
#include "../icons/record.xpm"
#include "../icons/upload.xpm"
#include "../icons/download.xpm"
#include "../icons/host-16x16.xpm"
@ -256,6 +260,11 @@ RDIconEngine::RDIconEngine()
d_list_icons.push_back(QPixmap(redball_xpm));
d_list_icons.push_back(QPixmap(whiteball_xpm));
d_list_icons.push_back(QPixmap(blueball_xpm));
d_list_icons.push_back(QPixmap(switch3_xpm));
d_list_icons.push_back(QPixmap(record_xpm));
d_list_icons.push_back(QPixmap(rss_xpm));
d_list_icons.push_back(QPixmap(upload_xpm));
d_list_icons.push_back(QPixmap(download_xpm));
//
// Create Station Icon

View File

@ -31,7 +31,7 @@ class RDIconEngine
{
public:
enum IconType {GreenCheck=0,RedX=1,GreenBall=2,RedBall=3,WhiteBall=4,
BlueBall=5};
BlueBall=5,Switcher=6,Record=7,Download=8,Upload=9};
enum Application {Rivendell=0,RdAdmin=1,RdAirPlay=2,RdCartSlots=3,
RdCastManager=4,RdCatch=5,RdLibrary=6,RdLogEdit=7,
RdLogManager=8,RdPanel=9,LastApplication=10};

View File

@ -179,8 +179,56 @@ int __mx_default_values[RDMatrix::LastType][RDMatrix::LastControl]=
RDMatrix::RDMatrix(const QString &station,int matrix)
{
QString sql;
RDSqlQuery *q=NULL;
sql=QString("select ")+
"ID "+ // 00
"from MATRICES where "+
"STATION_NAME=\""+RDEscapeString(station)+"\" && "+
QString().sprintf("MATRIX=%d",matrix);
q=new RDSqlQuery(sql);
if(q->first()) {
mx_id=q->value(0).toInt();
}
else {
mx_id=-1;
}
delete q;
mx_station=station;
mx_number=matrix;
}
RDMatrix::RDMatrix(int matrix_id)
{
QString sql;
RDSqlQuery *q=NULL;
sql=QString("select ")+
"STATION_NAME," // 00
"MATRIX "+ /// 01
"from MATRICES where "+
QString().sprintf("ID=%d",matrix_id);
q=new RDSqlQuery(sql);
if(q->first()) {
mx_station=q->value(0).toString();
mx_number=q->value(1).toInt();
}
else {
mx_number=-1;
}
delete q;
mx_id=matrix_id;
}
int RDMatrix::id() const
{
return mx_id;
}
@ -198,12 +246,7 @@ int RDMatrix::matrix() const
bool RDMatrix::exists() const
{
QString sql=QString().sprintf("select TYPE from MATRICES where MATRIX=%d",
mx_number);
RDSqlQuery *q=new RDSqlQuery(sql);
bool result=q->first();
delete q;
return result;
return (mx_id>=0)&&(mx_number>=0);
}

View File

@ -62,6 +62,8 @@ class RDMatrix
DynamicGpioControl=26,GpioStepSize=27,
LivewireGpioButtonControl=28,LastControl=29};
RDMatrix(const QString &station,int matrix);
RDMatrix(int matrix_id);
int id() const;
QString station() const;
int matrix() const;
bool exists() const;
@ -119,6 +121,7 @@ class RDMatrix
void SetRow(const QString &param,const QString &value) const;
void SetRow(const QString &param,int value) const;
void SetRow(const QString &param,unsigned value) const;
int mx_id;
QString mx_station;
int mx_number;
};

335
lib/rdmatrixlistmodel.cpp Normal file
View File

@ -0,0 +1,335 @@
// rdmatrixlistmodel.cpp
//
// Data model for Rivendell matrix devices
//
// (C) Copyright 2021 Fred Gleason <fredg@paravelsystems.com>
//
// 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
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include "rdapplication.h"
#include "rdescape_string.h"
#include "rdmatrix.h"
#include "rdmatrixlistmodel.h"
RDMatrixListModel::RDMatrixListModel(const QString &hostname,bool incl_none,
QObject *parent)
: QAbstractTableModel(parent)
{
d_station_name=hostname;
d_include_none=incl_none;
//
// Column Attributes
//
unsigned left=Qt::AlignLeft|Qt::AlignVCenter;
// unsigned center=Qt::AlignCenter;
unsigned right=Qt::AlignRight|Qt::AlignVCenter;
d_headers.push_back(tr("Description"));
d_alignments.push_back(left);
d_headers.push_back(tr("Matrix"));
d_alignments.push_back(right);
d_headers.push_back(tr("Type"));
d_alignments.push_back(left);
d_headers.push_back(tr("Inputs"));
d_alignments.push_back(right);
d_headers.push_back(tr("Outputs"));
d_alignments.push_back(right);
d_headers.push_back(tr("GPIs"));
d_alignments.push_back(right);
d_headers.push_back(tr("GPOs"));
d_alignments.push_back(right);
updateModel();
}
RDMatrixListModel::~RDMatrixListModel()
{
}
QPalette RDMatrixListModel::palette()
{
return d_palette;
}
void RDMatrixListModel::setPalette(const QPalette &pal)
{
d_palette=pal;
}
void RDMatrixListModel::setFont(const QFont &font)
{
d_font=font;
d_bold_font=font;
d_bold_font.setWeight(QFont::Bold);
}
int RDMatrixListModel::columnCount(const QModelIndex &parent) const
{
return d_headers.size();
}
int RDMatrixListModel::rowCount(const QModelIndex &parent) const
{
return d_texts.size();
}
QVariant RDMatrixListModel::headerData(int section,Qt::Orientation orient,
int role) const
{
if((orient==Qt::Horizontal)&&(role==Qt::DisplayRole)) {
return d_headers.at(section);
}
return QVariant();
}
QVariant RDMatrixListModel::data(const QModelIndex &index,int role) const
{
QString str;
int col=index.column();
int row=index.row();
if(row<d_texts.size()) {
switch((Qt::ItemDataRole)role) {
case Qt::DisplayRole:
return d_texts.at(row).at(col);
case Qt::DecorationRole:
if(col==0) {
return rda->iconEngine()->listIcon(RDIconEngine::Switcher);
}
break;
case Qt::TextAlignmentRole:
return d_alignments.at(col);
case Qt::FontRole:
if(col==0) {
return d_bold_font;
}
return d_font;
case Qt::TextColorRole:
// Nothing to do!
break;
case Qt::BackgroundRole:
// Nothing to do!
break;
default:
break;
}
}
return QVariant();
}
int RDMatrixListModel::matrixId(const QModelIndex &row) const
{
return d_ids.at(row.row());
}
int RDMatrixListModel::matrixNumber(const QModelIndex &row) const
{
return d_texts.at(row.row()).at(1).toInt();
}
QModelIndex RDMatrixListModel::addMatrix(RDMatrix *mtx)
{
//
// Find the insertion offset
//
QString name=mtx->name();
int offset=d_texts.size();
for(int i=0;i<d_texts.size();i++) {
if(name.toLower()<d_texts.at(i).at(0).toString().toLower()) {
offset=i;
break;
}
}
beginInsertRows(QModelIndex(),offset,offset);
QList<QVariant> list;
for(int i=0;i<columnCount();i++) {
list.push_back(QVariant());
}
d_ids.insert(offset,mtx->id());
d_texts.insert(offset,list);
updateRowLine(offset);
endInsertRows();
return createIndex(offset,0);
}
void RDMatrixListModel::removeMatrix(const QModelIndex &row)
{
beginRemoveRows(QModelIndex(),row.row(),row.row());
d_ids.removeAt(row.row());
d_texts.removeAt(row.row());
endRemoveRows();
}
void RDMatrixListModel::removeMatrix(int id)
{
for(int i=0;i<d_texts.size();i++) {
if(d_ids.at(i)==id) {
removeMatrix(createIndex(i,0));
return;
}
}
}
void RDMatrixListModel::refresh(const QModelIndex &row)
{
if(row.row()<d_texts.size()) {
QString sql=sqlFields()+
"where "+
QString().sprintf("MATRICES.ID=%d ",d_ids.at(row.row()));
RDSqlQuery *q=new RDSqlQuery(sql);
if(q->first()) {
updateRow(row.row(),q);
emit dataChanged(createIndex(row.row(),0),
createIndex(row.row(),columnCount()));
}
delete q;
}
}
void RDMatrixListModel::refresh(int id)
{
for(int i=0;i<d_texts.size();i++) {
if(d_texts.at(i).at(0)==id) {
updateRowLine(i);
return;
}
}
}
void RDMatrixListModel::updateModel()
{
QList<QVariant> texts;
RDSqlQuery *q=NULL;
QString sql=sqlFields()+
"where "+
"STATION_NAME=\""+RDEscapeString(d_station_name)+"\" "+
"order by MATRICES.NAME ";
beginResetModel();
d_ids.clear();
d_texts.clear();
if(d_include_none) {
d_ids.push_back(-1);
d_texts.push_back(texts);
d_texts.back().push_back(tr("[none]"));
for(int i=1;i<columnCount();i++) {
d_texts.back().push_back(QVariant());
}
}
q=new RDSqlQuery(sql);
while(q->next()) {
d_ids.push_back(-1);
d_texts.push_back(texts);
updateRow(d_texts.size()-1,q);
}
delete q;
endResetModel();
}
void RDMatrixListModel::updateRowLine(int line)
{
if(line<d_texts.size()) {
QString sql=sqlFields()+
"where "+
QString().sprintf("MATRICES.ID=%d ",d_ids.at(line));
RDSqlQuery *q=new RDSqlQuery(sql);
if(q->first()) {
updateRow(line,q);
}
delete q;
}
}
void RDMatrixListModel::updateRow(int row,RDSqlQuery *q)
{
QList<QVariant> texts;
d_ids.back()=q->value(0).toInt();
// Description
texts.push_back(q->value(1));
// Matrix Number
texts.push_back(QString().sprintf("%d",q->value(2).toInt()));
// Type
texts.push_back(RDMatrix::typeString((RDMatrix::Type)q->value(3).toUInt()));
// Inputs
texts.push_back(QString().sprintf("%d",q->value(4).toInt()));
// Outputs
texts.push_back(QString().sprintf("%d",q->value(5).toInt()));
// GPIs
texts.push_back(QString().sprintf("%d",q->value(6).toInt()));
// GPOs
texts.push_back(QString().sprintf("%d",q->value(7).toInt()));
d_texts[row]=texts;
}
QString RDMatrixListModel::sqlFields() const
{
QString sql=QString("select ")+
"MATRICES.ID,"+ // 00
"MATRICES.NAME,"+ // 01
"MATRICES.MATRIX,"+ // 02
"MATRICES.TYPE,"+ // 03
"MATRICES.INPUTS,"+ // 04
"MATRICES.OUTPUTS,"+ // 05
"MATRICES.GPIS,"+ // 06
"MATRICES.GPOS "+ // 07
"from MATRICES ";
return sql;
}

82
lib/rdmatrixlistmodel.h Normal file
View File

@ -0,0 +1,82 @@
// rdmatrixlistmodel.h
//
// Data model for Rivendell matrix devices
//
// (C) Copyright 2021 Fred Gleason <fredg@paravelsystems.com>
//
// 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
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef RDMATRIXLISTMODEL_H
#define RDMATRIXLISTMODEL_H
#include <QAbstractTableModel>
#include <QFont>
#include <QList>
#include <QPalette>
#include <rddb.h>
#include <rdmatrix.h>
#include <rdnotification.h>
#include <rduser.h>
//
// MAINTAINERS NOTE
//
// We could arguably just use a QSqlQueryModel for this, but rolling our own
// lets us use the same backend-facing API pattern as the other Rivendell
// models.
//
class RDMatrixListModel : public QAbstractTableModel
{
Q_OBJECT
public:
RDMatrixListModel(const QString &hostname,bool incl_none,QObject *parent=0);
~RDMatrixListModel();
QPalette palette();
void setPalette(const QPalette &pal);
void setFont(const QFont &font);
int columnCount(const QModelIndex &parent=QModelIndex()) const;
int rowCount(const QModelIndex &parent=QModelIndex()) const;
QVariant headerData(int section,Qt::Orientation orient,
int role=Qt::DisplayRole) const;
QVariant data(const QModelIndex &index,int role=Qt::DisplayRole) const;
int matrixId(const QModelIndex &row) const;
int matrixNumber(const QModelIndex &row) const;
QModelIndex addMatrix(RDMatrix *mtx);
void removeMatrix(const QModelIndex &row);
void removeMatrix(int id);
void refresh(const QModelIndex &row);
void refresh(int id);
protected:
void updateModel();
void updateRowLine(int line);
void updateRow(int row,RDSqlQuery *q);
QString sqlFields() const;
private:
QPalette d_palette;
QFont d_font;
QFont d_bold_font;
QList<QVariant> d_headers;
QList<QVariant> d_alignments;
QList<QList<QVariant> > d_texts;
QList<int> d_ids;
bool d_include_none;
QString d_station_name;
};
#endif // RDMATRIXLISTMODEL_H

View File

@ -1167,13 +1167,13 @@ void EditMatrix::okData()
if(!WriteMatrix()) {
return;
}
done(0);
done(true);
}
void EditMatrix::cancelData()
{
done(1);
done(false);
}

View File

@ -2,7 +2,7 @@
//
// List Rivendell Matrices
//
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -18,10 +18,9 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <qmessagebox.h>
#include <QMessageBox>
#include <rdapplication.h>
#include <rddb.h>
#include <rdescape_string.h>
#include "add_matrix.h"
@ -32,8 +31,6 @@
ListMatrices::ListMatrices(QString station,QWidget *parent)
: RDDialog(parent)
{
setModal(true);
//
// Fix the Window Size
//
@ -52,6 +49,21 @@ ListMatrices::ListMatrices(QString station,QWidget *parent)
//
// Matrix List Box
//
list_view=new RDTableView(this);
list_model=new RDMatrixListModel(station,false,this);
list_model->setFont(defaultFont());
list_model->setPalette(palette());
list_view->setModel(list_model);
list_title_label=
new QLabel(list_view,tr("&Replicators:"),this);
list_title_label->setFont(labelFont());
connect(list_view,SIGNAL(doubleClicked(const QModelIndex &)),
this,SLOT(doubleClickedData(const QModelIndex &)));
connect(list_model,SIGNAL(modelReset()),
list_view,SLOT(resizeColumnsToContents()));
list_view->resizeColumnsToContents();
/*
list_view=new Q3ListView(this,"list_box");
list_title_label=new QLabel(list_view,tr("Switchers:"),this);
list_title_label->setFont(labelFont());
@ -67,7 +79,7 @@ ListMatrices::ListMatrices(QString station,QWidget *parent)
this,SLOT(doubleClickedData(Q3ListViewItem *,const QPoint &,int)));
RefreshList();
*/
//
// Add Button
//
@ -131,47 +143,53 @@ void ListMatrices::addData()
return;
}
delete add;
RDMatrix *matrix=new RDMatrix(list_station,matrix_num);
EditMatrix *edit=new EditMatrix(matrix,this);
if(edit->exec()!=0) {
DeleteMatrix(matrix_num);
RDMatrix *mtx=new RDMatrix(list_station,matrix_num);
EditMatrix *edit=new EditMatrix(mtx,this);
if(edit->exec()) {
list_matrix_modified[matrix_num]=true;
QModelIndex row=list_model->addMatrix(mtx);
if(row.isValid()) {
list_view->selectRow(row.row());
}
}
else {
list_matrix_modified[matrix_num]=true;
AddList(matrix_num);
DeleteMatrix(mtx);
}
delete edit;
delete matrix;
delete mtx;
}
void ListMatrices::editData()
{
if(list_view->selectedItem()==NULL) {
QModelIndexList rows=list_view->selectionModel()->selectedRows();
if(rows.size()!=1) {
return;
}
int matrix_num=list_view->currentItem()->text(0).toInt();
RDMatrix *matrix=new RDMatrix(list_station,matrix_num);
Q3ListViewItem *item=list_view->selectedItem();
EditMatrix *edit=new EditMatrix(matrix,this);
if(edit->exec()==0) {
RefreshRecord(item);
list_matrix_modified[matrix_num]=true;
int matrix_id=list_model->matrixId(rows.first());
RDMatrix *mtx=new RDMatrix(matrix_id);
EditMatrix *d=new EditMatrix(mtx,this);
if(d->exec()) {
list_matrix_modified[mtx->matrix()]=true;
list_model->refresh(rows.first());
}
delete edit;
delete matrix;
delete d;
delete mtx;
}
void ListMatrices::deleteData()
{
if(list_view->currentItem()==NULL) {
QModelIndexList rows=list_view->selectionModel()->selectedRows();
if(rows.size()!=1) {
return;
}
int matrix=list_view->currentItem()->text(0).toInt();
RDMatrix *mtx=new RDMatrix(list_model->matrixId(rows.first()));
QString msg=tr("Are you sure you want to delete switcher")+
" \""+list_view->currentItem()->text(0)+":"+list_view->currentItem()->text(1)+"\" "+
" \""+QString().sprintf("%d",mtx->matrix())+":"+
mtx->name()+"\" "+
tr("on")+" \""+list_station+"\"?"+"\n"+
tr("ALL references to this switcher will be deleted!");
if(QMessageBox::warning(this,tr("Deleting Switcher"),msg,
@ -179,14 +197,12 @@ void ListMatrices::deleteData()
QMessageBox::Yes) {
return;
}
DeleteMatrix(matrix);
list_matrix_modified[matrix]=true;
RefreshList();
DeleteMatrix(mtx);
list_matrix_modified[mtx->matrix()]=true;
}
void ListMatrices::doubleClickedData(Q3ListViewItem *item,const QPoint &pt,
int col)
void ListMatrices::doubleClickedData(const QModelIndex &index)
{
editData();
}
@ -224,46 +240,48 @@ void ListMatrices::resizeEvent(QResizeEvent *e)
}
void ListMatrices::DeleteMatrix(int matrix)
void ListMatrices::DeleteMatrix(RDMatrix *mtx)
{
QString sql=QString("delete from MATRICES where ")+
"STATION_NAME=\""+RDEscapeString(list_station)+"\" && "+
QString().sprintf("MATRIX=%d",matrix);
QString().sprintf("MATRIX=%d",mtx->matrix());
RDSqlQuery *q=new RDSqlQuery(sql);
delete q;
sql=QString("delete from INPUTS where ")+
"STATION_NAME=\""+RDEscapeString(list_station)+"\" && "+
QString().sprintf("MATRIX=%d",matrix);
QString().sprintf("MATRIX=%d",mtx->matrix());
q=new RDSqlQuery(sql);
delete q;
sql=QString("delete from OUTPUTS where ")+
"STATION_NAME=\""+RDEscapeString(list_station)+"\" && "+
QString().sprintf("MATRIX=%d",matrix);
QString().sprintf("MATRIX=%d",mtx->matrix());
q=new RDSqlQuery(sql);
delete q;
sql=QString("delete from SWITCHER_NODES where ")+
"STATION_NAME=\""+RDEscapeString(list_station)+"\" && "+
QString().sprintf("MATRIX=%d",matrix);
QString().sprintf("MATRIX=%d",mtx->matrix());
q=new RDSqlQuery(sql);
delete q;
sql=QString("delete from GPIS where ")+
"STATION_NAME=\""+RDEscapeString(list_station)+"\" && "+
QString().sprintf("MATRIX=%d",matrix);
QString().sprintf("MATRIX=%d",mtx->matrix());
q=new RDSqlQuery(sql);
delete q;
sql=QString("delete from GPOS where ")+
"STATION_NAME=\""+RDEscapeString(list_station)+"\" && "+
QString().sprintf("MATRIX=%d",matrix);
QString().sprintf("MATRIX=%d",mtx->matrix());
q=new RDSqlQuery(sql);
delete q;
sql=QString("delete from VGUEST_RESOURCES where ")+
"STATION_NAME=\""+RDEscapeString(list_station)+"\" && "+
QString().sprintf("MATRIX_NUM=%d",matrix);
QString().sprintf("MATRIX_NUM=%d",mtx->matrix());
q=new RDSqlQuery(sql);
delete q;
list_model->removeMatrix(mtx->id());
}
/*
void ListMatrices::RefreshList()
{
Q3ListViewItem *l;
@ -285,10 +303,11 @@ void ListMatrices::RefreshList()
}
delete q;
}
*/
void ListMatrices::AddList(int matrix_num)
{
/*
RDMatrix *matrix=new RDMatrix(list_station,matrix_num);
Q3ListViewItem *item=new Q3ListViewItem(list_view);
item->setText(0,QString().sprintf("%d",matrix_num));
@ -297,12 +316,14 @@ void ListMatrices::AddList(int matrix_num)
delete matrix;
list_view->setCurrentItem(item);
list_view->setSelected(item,true);
*/
}
/*
void ListMatrices::RefreshRecord(Q3ListViewItem *item)
{
RDMatrix *matrix=new RDMatrix(list_station,item->text(0).toInt());
item->setText(1,matrix->name());
delete matrix;
}
*/

View File

@ -2,7 +2,7 @@
//
// List Rivendell Matrices
//
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -21,14 +21,14 @@
#ifndef LIST_MATRICES_H
#define LIST_MATRICES_H
#include <q3listview.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <QLabel>
#include <QPushButton>
#include <rd.h>
#include <rddialog.h>
#include <rdmatrix.h>
#include <rdmatrixlistmodel.h>
#include <rdtableview.h>
class ListMatrices : public RDDialog
{
@ -43,19 +43,18 @@ class ListMatrices : public RDDialog
void addData();
void editData();
void deleteData();
void doubleClickedData(Q3ListViewItem *item,const QPoint &pt,int col);
void doubleClickedData(const QModelIndex &);
void closeData();
protected:
void resizeEvent(QResizeEvent *e);
private:
void DeleteMatrix(int matrix);
void RefreshList();
void DeleteMatrix(RDMatrix *mtx);
void AddList(int matrix_num);
void RefreshRecord(Q3ListViewItem *item);
QLabel *list_title_label;
Q3ListView *list_view;
RDTableView *list_view;
RDMatrixListModel *list_model;
QPushButton *list_add_button;
QPushButton *list_edit_button;
QPushButton *list_delete_button;
@ -65,5 +64,4 @@ class ListMatrices : public RDDialog
};
#endif
#endif // LIST_MATRICES_H

View File

@ -5761,19 +5761,19 @@ Stále ještě jej chcete smazat?</translation>
</message>
<message>
<source>Switchers:</source>
<translation>Přepínače:</translation>
<translation type="obsolete">Přepínače:</translation>
</message>
<message>
<source>MATRIX</source>
<translation>MATICE</translation>
<translation type="obsolete">MATICE</translation>
</message>
<message>
<source>DESCRIPTION</source>
<translation>POPIS</translation>
<translation type="obsolete">POPIS</translation>
</message>
<message>
<source>TYPE</source>
<translation>TYP</translation>
<translation type="obsolete">TYP</translation>
</message>
<message>
<source>&amp;Add</source>
@ -5793,19 +5793,19 @@ Stále ještě jej chcete smazat?</translation>
</message>
<message>
<source>Are you sure you want to delete switcher</source>
<translation>Opravdu chcete smazat tento přepínač</translation>
<translation type="unfinished">Opravdu chcete smazat tento přepínač</translation>
</message>
<message>
<source>on</source>
<translation>na</translation>
<translation type="unfinished">na</translation>
</message>
<message>
<source>ALL references to this switcher will be deleted!</source>
<translation>VŠECHNY odkazy na tento přepínač budou smazány!</translation>
<translation type="unfinished">VŠECHNY odkazy na tento přepínač budou smazány!</translation>
</message>
<message>
<source>Deleting Switcher</source>
<translation>Mazání přepínače</translation>
<translation type="unfinished">Mazání přepínače</translation>
</message>
<message>
<source>Local GPIO</source>
@ -5863,6 +5863,10 @@ Stále ještě jej chcete smazat?</translation>
<source>BroadcastTools SRC-16</source>
<translation type="obsolete">BroadcastTools SRC-16</translation>
</message>
<message>
<source>&amp;Replicators:</source>
<translation type="unfinished">&amp;Zopakování:</translation>
</message>
</context>
<context>
<name>ListPypads</name>

View File

@ -5407,19 +5407,19 @@ Generieren</translation>
</message>
<message>
<source>Switchers:</source>
<translation>Schalter:</translation>
<translation type="obsolete">Schalter:</translation>
</message>
<message>
<source>MATRIX</source>
<translation>MATRIX</translation>
<translation type="obsolete">MATRIX</translation>
</message>
<message>
<source>DESCRIPTION</source>
<translation>BESCHREIBUNG</translation>
<translation type="obsolete">BESCHREIBUNG</translation>
</message>
<message>
<source>TYPE</source>
<translation>TYP</translation>
<translation type="obsolete">TYP</translation>
</message>
<message>
<source>&amp;Add</source>
@ -5439,19 +5439,19 @@ Generieren</translation>
</message>
<message>
<source>Are you sure you want to delete switcher</source>
<translation>Sind Sie sicher, daß sie diesen Schalter löschen wollen</translation>
<translation type="unfinished">Sind Sie sicher, daß sie diesen Schalter löschen wollen</translation>
</message>
<message>
<source>on</source>
<translation>An</translation>
<translation type="unfinished">An</translation>
</message>
<message>
<source>ALL references to this switcher will be deleted!</source>
<translation>ALLE Referenzen zu diesem Switcher werden gelöscht!</translation>
<translation type="unfinished">ALLE Referenzen zu diesem Switcher werden gelöscht!</translation>
</message>
<message>
<source>Deleting Switcher</source>
<translation>Lösche Schalter</translation>
<translation type="unfinished">Lösche Schalter</translation>
</message>
<message>
<source>Local GPIO</source>
@ -5509,6 +5509,10 @@ Generieren</translation>
<source>BroadcastTools SRC-16</source>
<translation type="obsolete">BroadcastTools SRC-16</translation>
</message>
<message>
<source>&amp;Replicators:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ListPypads</name>

View File

@ -5712,19 +5712,15 @@ Do you still want to delete it?</source>
</message>
<message>
<source>Switchers:</source>
<translation>Suicheras:</translation>
</message>
<message>
<source>MATRIX</source>
<translation></translation>
<translation type="obsolete">Suicheras:</translation>
</message>
<message>
<source>DESCRIPTION</source>
<translation>DESCRIPCIÓN</translation>
<translation type="obsolete">DESCRIPCIÓN</translation>
</message>
<message>
<source>TYPE</source>
<translation>TIPO</translation>
<translation type="obsolete">TIPO</translation>
</message>
<message>
<source>&amp;Add</source>
@ -5744,19 +5740,19 @@ Do you still want to delete it?</source>
</message>
<message>
<source>Are you sure you want to delete switcher</source>
<translation>¿Está seguro de borrar la suichera</translation>
<translation type="unfinished">¿Está seguro de borrar la suichera</translation>
</message>
<message>
<source>on</source>
<translation>en</translation>
<translation type="unfinished">en</translation>
</message>
<message>
<source>ALL references to this switcher will be deleted!</source>
<translation>¡TODAS las referencias a esta suichera serán borradas!</translation>
<translation type="unfinished">¡TODAS las referencias a esta suichera serán borradas!</translation>
</message>
<message>
<source>Deleting Switcher</source>
<translation>Borrando suichera</translation>
<translation type="unfinished">Borrando suichera</translation>
</message>
<message>
<source>Local GPIO</source>
@ -5774,6 +5770,10 @@ Do you still want to delete it?</source>
<source>Local Audio Adapter</source>
<translation type="obsolete">Adaptador de Audio Local</translation>
</message>
<message>
<source>&amp;Replicators:</source>
<translation type="unfinished">&amp;Replicadores:</translation>
</message>
</context>
<context>
<name>ListPypads</name>

View File

@ -4435,22 +4435,6 @@ Permissions</source>
<source>Rivendell Switcher List</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switchers:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MATRIX</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DESCRIPTION</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TYPE</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Add</source>
<translation type="unfinished"></translation>
@ -4467,6 +4451,10 @@ Permissions</source>
<source>&amp;Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Replicators:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to delete switcher</source>
<translation type="unfinished"></translation>

View File

@ -5272,19 +5272,19 @@ Klikk på &quot;Lisens&quot;-knappen for fleire opplysningar.</translation>
</message>
<message>
<source>Switchers:</source>
<translation>Svitsjarar:</translation>
<translation type="obsolete">Svitsjarar:</translation>
</message>
<message>
<source>MATRIX</source>
<translation>MATRISE</translation>
<translation type="obsolete">MATRISE</translation>
</message>
<message>
<source>DESCRIPTION</source>
<translation>SKILDRING</translation>
<translation type="obsolete">SKILDRING</translation>
</message>
<message>
<source>TYPE</source>
<translation>TYPE</translation>
<translation type="obsolete">TYPE</translation>
</message>
<message>
<source>&amp;Add</source>
@ -5304,19 +5304,19 @@ Klikk på &quot;Lisens&quot;-knappen for fleire opplysningar.</translation>
</message>
<message>
<source>Are you sure you want to delete switcher</source>
<translation>Er du sikker at du vil sletta svitsjaren</translation>
<translation type="unfinished">Er du sikker at du vil sletta svitsjaren</translation>
</message>
<message>
<source>on</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>ALL references to this switcher will be deleted!</source>
<translation>ALLE referansar til denne svitsjaren blir sletta!</translation>
<translation type="unfinished">ALLE referansar til denne svitsjaren blir sletta!</translation>
</message>
<message>
<source>Deleting Switcher</source>
<translation>Slettar svitsjar</translation>
<translation type="unfinished">Slettar svitsjar</translation>
</message>
<message>
<source>Local GPIO</source>
@ -5366,6 +5366,10 @@ Klikk på &quot;Lisens&quot;-knappen for fleire opplysningar.</translation>
<source>BroadcastTools SS4.4</source>
<translation type="obsolete">BroadcastTools SS4.4</translation>
</message>
<message>
<source>&amp;Replicators:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ListPypads</name>

View File

@ -5272,19 +5272,19 @@ Klikk på &quot;Lisens&quot;-knappen for fleire opplysningar.</translation>
</message>
<message>
<source>Switchers:</source>
<translation>Svitsjarar:</translation>
<translation type="obsolete">Svitsjarar:</translation>
</message>
<message>
<source>MATRIX</source>
<translation>MATRISE</translation>
<translation type="obsolete">MATRISE</translation>
</message>
<message>
<source>DESCRIPTION</source>
<translation>SKILDRING</translation>
<translation type="obsolete">SKILDRING</translation>
</message>
<message>
<source>TYPE</source>
<translation>TYPE</translation>
<translation type="obsolete">TYPE</translation>
</message>
<message>
<source>&amp;Add</source>
@ -5304,19 +5304,19 @@ Klikk på &quot;Lisens&quot;-knappen for fleire opplysningar.</translation>
</message>
<message>
<source>Are you sure you want to delete switcher</source>
<translation>Er du sikker at du vil sletta svitsjaren</translation>
<translation type="unfinished">Er du sikker at du vil sletta svitsjaren</translation>
</message>
<message>
<source>on</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>ALL references to this switcher will be deleted!</source>
<translation>ALLE referansar til denne svitsjaren blir sletta!</translation>
<translation type="unfinished">ALLE referansar til denne svitsjaren blir sletta!</translation>
</message>
<message>
<source>Deleting Switcher</source>
<translation>Slettar svitsjar</translation>
<translation type="unfinished">Slettar svitsjar</translation>
</message>
<message>
<source>Local GPIO</source>
@ -5366,6 +5366,10 @@ Klikk på &quot;Lisens&quot;-knappen for fleire opplysningar.</translation>
<source>BroadcastTools SS4.4</source>
<translation type="obsolete">BroadcastTools SS4.4</translation>
</message>
<message>
<source>&amp;Replicators:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ListPypads</name>

View File

@ -5387,19 +5387,19 @@ Você ainda quer Deletar?</translation>
</message>
<message>
<source>Switchers:</source>
<translation>Switchers:</translation>
<translation type="obsolete">Switchers:</translation>
</message>
<message>
<source>MATRIX</source>
<translation>MATRIX</translation>
<translation type="obsolete">MATRIX</translation>
</message>
<message>
<source>DESCRIPTION</source>
<translation>DESCRIÇÃO</translation>
<translation type="obsolete">DESCRIÇÃO</translation>
</message>
<message>
<source>TYPE</source>
<translation>TIPO</translation>
<translation type="obsolete">TIPO</translation>
</message>
<message>
<source>&amp;Add</source>
@ -5419,19 +5419,19 @@ Você ainda quer Deletar?</translation>
</message>
<message>
<source>Are you sure you want to delete switcher</source>
<translation>Tem certeza que quer deletar este switcher?</translation>
<translation type="unfinished">Tem certeza que quer deletar este switcher?</translation>
</message>
<message>
<source>on</source>
<translation>Ligado</translation>
<translation type="unfinished">Ligado</translation>
</message>
<message>
<source>ALL references to this switcher will be deleted!</source>
<translation>TODAS as referências deste switcher serão deletadas</translation>
<translation type="unfinished">TODAS as referências deste switcher serão deletadas</translation>
</message>
<message>
<source>Deleting Switcher</source>
<translation>Deletando Switcher</translation>
<translation type="unfinished">Deletando Switcher</translation>
</message>
<message>
<source>Local GPIO</source>
@ -5481,6 +5481,10 @@ Você ainda quer Deletar?</translation>
<source>BroadcastTools SS4.4</source>
<translation type="obsolete">BroadcastTools SS4.4</translation>
</message>
<message>
<source>&amp;Replicators:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ListPypads</name>