mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-09-17 17:00:27 +02:00
2021-01-31 Fred Gleason <fredg@paravelsystems.com>
* Refactored the 'SAS Switches' dialog in rdadmin(1) to use the model-based API. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
f942c448d6
commit
8b3987857b
@ -20952,3 +20952,8 @@
|
|||||||
2021-01-31 Fred Gleason <fredg@paravelsystems.com>
|
2021-01-31 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Renamed the 'RDVguestResourceListModel' model class to
|
* Renamed the 'RDVguestResourceListModel' model class to
|
||||||
'RDResourceListModel'.
|
'RDResourceListModel'.
|
||||||
|
2021-01-31 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added 'VguestTypeNone' to the 'RDMatrix::VguestType' enumeration.
|
||||||
|
2021-01-31 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Refactored the 'SAS Switches' dialog in rdadmin(1) to use the
|
||||||
|
model-based API.
|
||||||
|
@ -3834,7 +3834,19 @@ Zkuste to, prosím, znovu!</translation>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>[none]</source>
|
<source>Line</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Console</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Source</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Opto/Relay</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
@ -3815,7 +3815,19 @@ bitte erneut versuchen!</translation>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>[none]</source>
|
<source>Line</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Console</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Source</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Opto/Relay</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
@ -3794,7 +3794,19 @@ please try again!</source>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>[none]</source>
|
<source>Line</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Console</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Source</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Opto/Relay</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
@ -3087,7 +3087,19 @@ please try again!</source>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>[none]</source>
|
<source>Line</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Console</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Source</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Opto/Relay</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
@ -3697,7 +3697,19 @@ prøv ein gong til!</translation>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>[none]</source>
|
<source>Line</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Console</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Source</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Opto/Relay</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
@ -3697,7 +3697,19 @@ prøv ein gong til!</translation>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>[none]</source>
|
<source>Line</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Console</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Source</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Opto/Relay</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
@ -3748,7 +3748,19 @@ por favor, tente novamente!</translation>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>[none]</source>
|
<source>Line</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Console</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Source</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Opto/Relay</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
@ -44,7 +44,7 @@ class RDMatrix
|
|||||||
enum Mode {Stereo=0,Left=1,Right=2};
|
enum Mode {Stereo=0,Left=1,Right=2};
|
||||||
enum VguestAttribute {VguestEngine=0,VguestDevice=1,VguestSurface=2,
|
enum VguestAttribute {VguestEngine=0,VguestDevice=1,VguestSurface=2,
|
||||||
VguestRelay=3,VguestBuss=4};
|
VguestRelay=3,VguestBuss=4};
|
||||||
enum VguestType {VguestTypeRelay=0,VguestTypeDisplay=2};
|
enum VguestType {VguestTypeRelay=0,VguestTypeDisplay=2,VguestTypeNone=255};
|
||||||
enum GpioType {GpioInput=0,GpioOutput=1};
|
enum GpioType {GpioInput=0,GpioOutput=1};
|
||||||
enum Control {PortTypeControl=0,SerialPortControl=1,
|
enum Control {PortTypeControl=0,SerialPortControl=1,
|
||||||
IpAddressControl=2,IpPortControl=3,
|
IpAddressControl=2,IpPortControl=3,
|
||||||
|
@ -24,12 +24,13 @@
|
|||||||
#include "rdresourcelistmodel.h"
|
#include "rdresourcelistmodel.h"
|
||||||
|
|
||||||
RDResourceListModel::RDResourceListModel(RDMatrix *mtx,
|
RDResourceListModel::RDResourceListModel(RDMatrix *mtx,
|
||||||
RDMatrix::VguestType type,
|
RDMatrix::VguestType vguest_type,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: QAbstractTableModel(parent)
|
: QAbstractTableModel(parent)
|
||||||
{
|
{
|
||||||
d_mtx=mtx;
|
d_mtx=mtx;
|
||||||
d_vguest_type=type;
|
d_type=mtx->type();
|
||||||
|
d_vguest_type=vguest_type;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Column Attributes
|
// Column Attributes
|
||||||
@ -38,37 +39,56 @@ RDResourceListModel::RDResourceListModel(RDMatrix *mtx,
|
|||||||
unsigned center=Qt::AlignCenter;
|
unsigned center=Qt::AlignCenter;
|
||||||
// unsigned right=Qt::AlignRight|Qt::AlignVCenter;
|
// unsigned right=Qt::AlignRight|Qt::AlignVCenter;
|
||||||
|
|
||||||
switch(d_vguest_type) {
|
if(d_type==RDMatrix::LogitekVguest) {
|
||||||
case RDMatrix::VguestTypeRelay:
|
switch(d_vguest_type) {
|
||||||
d_headers.push_back(tr("GPIO Line"));
|
case RDMatrix::VguestTypeRelay:
|
||||||
d_alignments.push_back(center);
|
d_headers.push_back(tr("GPIO Line"));
|
||||||
|
d_alignments.push_back(center);
|
||||||
|
|
||||||
d_headers.push_back(tr("Engine"));
|
d_headers.push_back(tr("Engine"));
|
||||||
d_alignments.push_back(center);
|
d_alignments.push_back(center);
|
||||||
|
|
||||||
d_headers.push_back(tr("Device (Hex)"));
|
d_headers.push_back(tr("Device (Hex)"));
|
||||||
d_alignments.push_back(center);
|
d_alignments.push_back(center);
|
||||||
|
|
||||||
d_headers.push_back(tr("Surface"));
|
d_headers.push_back(tr("Surface"));
|
||||||
d_alignments.push_back(center);
|
d_alignments.push_back(center);
|
||||||
|
|
||||||
d_headers.push_back(tr("Bus/Relay"));
|
d_headers.push_back(tr("Bus/Relay"));
|
||||||
d_alignments.push_back(center);
|
d_alignments.push_back(center);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RDMatrix::VguestTypeDisplay:
|
case RDMatrix::VguestTypeDisplay:
|
||||||
d_headers.push_back(tr("Display"));
|
d_headers.push_back(tr("Display"));
|
||||||
|
d_alignments.push_back(center);
|
||||||
|
|
||||||
|
d_headers.push_back(tr("Engine"));
|
||||||
|
d_alignments.push_back(center);
|
||||||
|
|
||||||
|
d_headers.push_back(tr("Device (Hex)"));
|
||||||
|
d_alignments.push_back(center);
|
||||||
|
|
||||||
|
d_headers.push_back(tr("Surface"));
|
||||||
|
d_alignments.push_back(center);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RDMatrix::VguestTypeNone:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(d_type==RDMatrix::SasUsi) {
|
||||||
|
d_headers.push_back(tr("Line"));
|
||||||
d_alignments.push_back(center);
|
d_alignments.push_back(center);
|
||||||
|
|
||||||
d_headers.push_back(tr("Engine"));
|
d_headers.push_back(tr("Console"));
|
||||||
d_alignments.push_back(center);
|
d_alignments.push_back(center);
|
||||||
|
|
||||||
d_headers.push_back(tr("Device (Hex)"));
|
d_headers.push_back(tr("Source"));
|
||||||
d_alignments.push_back(center);
|
d_alignments.push_back(center);
|
||||||
|
|
||||||
d_headers.push_back(tr("Surface"));
|
d_headers.push_back(tr("Opto/Relay"));
|
||||||
d_alignments.push_back(center);
|
d_alignments.push_back(center);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateModel();
|
updateModel();
|
||||||
@ -207,25 +227,27 @@ void RDResourceListModel::refresh(int id)
|
|||||||
void RDResourceListModel::updateModel()
|
void RDResourceListModel::updateModel()
|
||||||
{
|
{
|
||||||
QList<QVariant> texts;
|
QList<QVariant> texts;
|
||||||
|
QString sql;
|
||||||
|
|
||||||
RDSqlQuery *q=NULL;
|
RDSqlQuery *q=NULL;
|
||||||
QString sql=sqlFields()+
|
if(d_type==RDMatrix::LogitekVguest) {
|
||||||
"where "+
|
sql=sqlFields()+
|
||||||
"STATION_NAME=\""+RDEscapeString(d_mtx->station())+"\" && "+
|
"where "+
|
||||||
QString().sprintf("MATRIX_NUM=%d && ",d_mtx->matrix())+
|
"STATION_NAME=\""+RDEscapeString(d_mtx->station())+"\" && "+
|
||||||
QString().sprintf("VGUEST_TYPE=%u ",d_vguest_type)+
|
QString().sprintf("MATRIX_NUM=%d && ",d_mtx->matrix())+
|
||||||
"order by NUMBER ";
|
QString().sprintf("VGUEST_TYPE=%u ",d_vguest_type)+
|
||||||
|
"order by NUMBER ";
|
||||||
|
}
|
||||||
|
if(d_type==RDMatrix::SasUsi) {
|
||||||
|
sql=sqlFields()+
|
||||||
|
"where "+
|
||||||
|
"STATION_NAME=\""+RDEscapeString(d_mtx->station())+"\" && "+
|
||||||
|
QString().sprintf("MATRIX_NUM=%d ",d_mtx->matrix())+
|
||||||
|
"order by NUMBER ";
|
||||||
|
}
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
d_ids.clear();
|
d_ids.clear();
|
||||||
d_texts.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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// printf("SQL: %s\n",sql.toUtf8().constData());
|
// printf("SQL: %s\n",sql.toUtf8().constData());
|
||||||
q=new RDSqlQuery(sql);
|
q=new RDSqlQuery(sql);
|
||||||
while(q->next()) {
|
while(q->next()) {
|
||||||
@ -272,19 +294,54 @@ void RDResourceListModel::updateRow(int row,RDSqlQuery *q)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Device Number
|
// Device Number
|
||||||
if(q->value(3).toInt()>=0) {
|
if(d_type==RDMatrix::LogitekVguest) {
|
||||||
texts.push_back(QString().sprintf("%04X",q->value(3).toInt()));
|
if(q->value(3).toInt()>=0) {
|
||||||
}
|
texts.push_back(QString().sprintf("%04X",q->value(3).toInt()));
|
||||||
else {
|
}
|
||||||
texts.push_back("");
|
else {
|
||||||
|
texts.push_back("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Surface Number
|
|
||||||
if(q->value(4).toInt()>=0) {
|
switch(d_type) {
|
||||||
texts.push_back(QString().sprintf("%d",q->value(4).toInt()));
|
case RDMatrix::LogitekVguest:
|
||||||
}
|
// Device Number
|
||||||
else {
|
if(q->value(3).toInt()>=0) {
|
||||||
texts.push_back("");
|
texts.push_back(QString().sprintf("%04X",q->value(3).toInt()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
texts.push_back("");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Surface Number
|
||||||
|
if(q->value(4).toInt()>=0) {
|
||||||
|
texts.push_back(QString().sprintf("%d",q->value(4).toInt()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
texts.push_back("");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RDMatrix::SasUsi:
|
||||||
|
// Source
|
||||||
|
if(q->value(3).toInt()>=0) {
|
||||||
|
texts.push_back(QString().sprintf("%d",q->value(3).toInt()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
texts.push_back("");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(q->value(5).toInt()>=0) {
|
||||||
|
texts.push_back(QString().sprintf("%d",q->value(5).toInt()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
texts.push_back("");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(d_vguest_type) {
|
switch(d_vguest_type) {
|
||||||
@ -299,6 +356,9 @@ void RDResourceListModel::updateRow(int row,RDSqlQuery *q)
|
|||||||
|
|
||||||
case RDMatrix::VguestTypeDisplay:
|
case RDMatrix::VguestTypeDisplay:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RDMatrix::VguestTypeNone:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
d_texts[row]=texts;
|
d_texts[row]=texts;
|
||||||
|
@ -35,8 +35,8 @@ class RDResourceListModel : public QAbstractTableModel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
RDResourceListModel(RDMatrix *mtx,RDMatrix::VguestType type,
|
RDResourceListModel(RDMatrix *mtx,RDMatrix::VguestType vguest_type,
|
||||||
QObject *parent=0);
|
QObject *parent=0);
|
||||||
~RDResourceListModel();
|
~RDResourceListModel();
|
||||||
QPalette palette();
|
QPalette palette();
|
||||||
void setPalette(const QPalette &pal);
|
void setPalette(const QPalette &pal);
|
||||||
@ -66,8 +66,8 @@ class RDResourceListModel : public QAbstractTableModel
|
|||||||
QList<QList<QVariant> > d_texts;
|
QList<QList<QVariant> > d_texts;
|
||||||
QList<int> d_ids;
|
QList<int> d_ids;
|
||||||
RDMatrix *d_mtx;
|
RDMatrix *d_mtx;
|
||||||
|
RDMatrix::Type d_type;
|
||||||
RDMatrix::VguestType d_vguest_type;
|
RDMatrix::VguestType d_vguest_type;
|
||||||
bool d_include_none;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1077,7 +1077,7 @@ void EditMatrix::livewireGpioButtonData()
|
|||||||
|
|
||||||
void EditMatrix::vguestRelaysButtonData()
|
void EditMatrix::vguestRelaysButtonData()
|
||||||
{
|
{
|
||||||
AddVguest(RDMatrix::VguestTypeRelay);
|
AddResources(RDMatrix::VguestTypeRelay);
|
||||||
ListVguestResources *dialog=
|
ListVguestResources *dialog=
|
||||||
new ListVguestResources(edit_matrix,RDMatrix::VguestTypeRelay,
|
new ListVguestResources(edit_matrix,RDMatrix::VguestTypeRelay,
|
||||||
edit_gpos_box->value(),this);
|
edit_gpos_box->value(),this);
|
||||||
@ -1088,7 +1088,7 @@ void EditMatrix::vguestRelaysButtonData()
|
|||||||
|
|
||||||
void EditMatrix::vguestDisplaysButtonData()
|
void EditMatrix::vguestDisplaysButtonData()
|
||||||
{
|
{
|
||||||
AddVguest(RDMatrix::VguestTypeDisplay);
|
AddResources(RDMatrix::VguestTypeDisplay);
|
||||||
ListVguestResources *dialog=
|
ListVguestResources *dialog=
|
||||||
new ListVguestResources(edit_matrix,RDMatrix::VguestTypeDisplay,
|
new ListVguestResources(edit_matrix,RDMatrix::VguestTypeDisplay,
|
||||||
edit_displays_box->value(),this);
|
edit_displays_box->value(),this);
|
||||||
@ -1164,16 +1164,29 @@ void EditMatrix::stopCart2Data()
|
|||||||
|
|
||||||
void EditMatrix::okData()
|
void EditMatrix::okData()
|
||||||
{
|
{
|
||||||
if((!ConfirmPruneEndpoints(RDMatrix::Input))||
|
if(edit_matrix->type()==RDMatrix::LogitekVguest) {
|
||||||
(!ConfirmPruneEndpoints(RDMatrix::Output))||
|
if((!ConfirmPruneEndpoints(RDMatrix::Input))||
|
||||||
(!ConfirmPruneVguest(RDMatrix::VguestTypeRelay))||
|
(!ConfirmPruneEndpoints(RDMatrix::Output))||
|
||||||
(!ConfirmPruneVguest(RDMatrix::VguestTypeDisplay))) {
|
(!ConfirmPruneResources(RDMatrix::VguestTypeRelay))||
|
||||||
return;
|
(!ConfirmPruneResources(RDMatrix::VguestTypeDisplay))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PruneEndpoints(RDMatrix::Input);
|
||||||
|
PruneEndpoints(RDMatrix::Output);
|
||||||
|
PruneResources(RDMatrix::VguestTypeRelay);
|
||||||
|
PruneResources(RDMatrix::VguestTypeDisplay);
|
||||||
}
|
}
|
||||||
PruneEndpoints(RDMatrix::Input);
|
if(edit_matrix->type()==RDMatrix::SasUsi) {
|
||||||
PruneEndpoints(RDMatrix::Output);
|
if((!ConfirmPruneEndpoints(RDMatrix::Input))||
|
||||||
PruneVguest(RDMatrix::VguestTypeRelay);
|
(!ConfirmPruneEndpoints(RDMatrix::Output))||
|
||||||
PruneVguest(RDMatrix::VguestTypeDisplay);
|
(!ConfirmPruneResources(RDMatrix::VguestTypeNone))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PruneEndpoints(RDMatrix::Input);
|
||||||
|
PruneEndpoints(RDMatrix::Output);
|
||||||
|
PruneResources(RDMatrix::VguestTypeNone);
|
||||||
|
}
|
||||||
|
|
||||||
if(!WriteMatrix()) {
|
if(!WriteMatrix()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1311,8 +1324,8 @@ bool EditMatrix::WriteMatrix()
|
|||||||
//
|
//
|
||||||
AddEndpoints(RDMatrix::Input);
|
AddEndpoints(RDMatrix::Input);
|
||||||
AddEndpoints(RDMatrix::Output);
|
AddEndpoints(RDMatrix::Output);
|
||||||
AddVguest(RDMatrix::VguestTypeRelay);
|
AddResources(RDMatrix::VguestTypeRelay);
|
||||||
AddVguest(RDMatrix::VguestTypeDisplay);
|
AddResources(RDMatrix::VguestTypeDisplay);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update GPIO Tables
|
// Update GPIO Tables
|
||||||
@ -1496,7 +1509,7 @@ bool EditMatrix::ConfirmPruneEndpoints(RDMatrix::Endpoint ep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EditMatrix::AddVguest(RDMatrix::VguestType type) const
|
void EditMatrix::AddResources(RDMatrix::VguestType type) const
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Ensure that we have data entries for at least the number of
|
// Ensure that we have data entries for at least the number of
|
||||||
@ -1515,16 +1528,20 @@ void EditMatrix::AddVguest(RDMatrix::VguestType type) const
|
|||||||
"ID "+ // 00
|
"ID "+ // 00
|
||||||
"from VGUEST_RESOURCES where "+
|
"from VGUEST_RESOURCES where "+
|
||||||
"STATION_NAME=\""+RDEscapeString(edit_matrix->station())+"\" && "+
|
"STATION_NAME=\""+RDEscapeString(edit_matrix->station())+"\" && "+
|
||||||
QString().sprintf("MATRIX_NUM=%d && ",edit_matrix->matrix())+
|
QString().sprintf("MATRIX_NUM=%d && ",edit_matrix->matrix());
|
||||||
QString().sprintf("VGUEST_TYPE=%d && ",type)+
|
if(edit_matrix->type()==RDMatrix::LogitekVguest) {
|
||||||
QString().sprintf("NUMBER=%d",i+1);
|
sql+=QString().sprintf("VGUEST_TYPE=%d && ",type);
|
||||||
|
}
|
||||||
|
sql+=QString().sprintf("NUMBER=%d",i+1);
|
||||||
q=new RDSqlQuery(sql);
|
q=new RDSqlQuery(sql);
|
||||||
if(!q->first()) {
|
if(!q->first()) {
|
||||||
sql=QString("insert into VGUEST_RESOURCES set ")+
|
sql=QString("insert into VGUEST_RESOURCES set ")+
|
||||||
"STATION_NAME=\""+RDEscapeString(edit_matrix->station())+"\","+
|
"STATION_NAME=\""+RDEscapeString(edit_matrix->station())+"\","+
|
||||||
QString().sprintf("MATRIX_NUM=%d,",edit_matrix->matrix())+
|
QString().sprintf("MATRIX_NUM=%d,",edit_matrix->matrix());
|
||||||
QString().sprintf("VGUEST_TYPE=%d,",type)+
|
if(edit_matrix->type()==RDMatrix::LogitekVguest) {
|
||||||
QString().sprintf("NUMBER=%d",i+1);
|
sql+=QString().sprintf("VGUEST_TYPE=%d,",type);
|
||||||
|
}
|
||||||
|
sql+=QString().sprintf("NUMBER=%d",i+1);
|
||||||
RDSqlQuery::apply(sql);
|
RDSqlQuery::apply(sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1532,7 +1549,7 @@ void EditMatrix::AddVguest(RDMatrix::VguestType type) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EditMatrix::PruneVguest(RDMatrix::VguestType type) const
|
void EditMatrix::PruneResources(RDMatrix::VguestType type) const
|
||||||
{
|
{
|
||||||
QString sql;
|
QString sql;
|
||||||
|
|
||||||
@ -1543,14 +1560,16 @@ void EditMatrix::PruneVguest(RDMatrix::VguestType type) const
|
|||||||
|
|
||||||
sql=QString("delete from VGUEST_RESOURCES where ")+
|
sql=QString("delete from VGUEST_RESOURCES where ")+
|
||||||
"STATION_NAME=\""+RDEscapeString(edit_matrix->station())+"\" && "+
|
"STATION_NAME=\""+RDEscapeString(edit_matrix->station())+"\" && "+
|
||||||
QString().sprintf("MATRIX_NUM=%d && ",edit_matrix->matrix())+
|
QString().sprintf("MATRIX_NUM=%d && ",edit_matrix->matrix());
|
||||||
QString().sprintf("VGUEST_TYPE=%d && ",type)+
|
if(edit_matrix->type()==RDMatrix::LogitekVguest) {
|
||||||
QString().sprintf("NUMBER>%d",entry_quan);
|
sql+=QString().sprintf("VGUEST_TYPE=%d && ",type);
|
||||||
|
}
|
||||||
|
sql+=QString().sprintf("NUMBER>%d",entry_quan);
|
||||||
RDSqlQuery::apply(sql);
|
RDSqlQuery::apply(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EditMatrix::ConfirmPruneVguest(RDMatrix::VguestType type)
|
bool EditMatrix::ConfirmPruneResources(RDMatrix::VguestType type)
|
||||||
{
|
{
|
||||||
QString sql;
|
QString sql;
|
||||||
RDSqlQuery *q=NULL;
|
RDSqlQuery *q=NULL;
|
||||||
@ -1566,9 +1585,11 @@ bool EditMatrix::ConfirmPruneVguest(RDMatrix::VguestType type)
|
|||||||
"ID "+ // 00
|
"ID "+ // 00
|
||||||
"from VGUEST_RESOURCES where "+
|
"from VGUEST_RESOURCES where "+
|
||||||
"STATION_NAME=\""+RDEscapeString(edit_matrix->station())+"\" && "+
|
"STATION_NAME=\""+RDEscapeString(edit_matrix->station())+"\" && "+
|
||||||
QString().sprintf("MATRIX_NUM=%d && ",edit_matrix->matrix())+
|
QString().sprintf("MATRIX_NUM=%d && ",edit_matrix->matrix());
|
||||||
QString().sprintf("VGUEST_TYPE=%d && ",type)+
|
if(edit_matrix->type()==RDMatrix::LogitekVguest) {
|
||||||
QString().sprintf("NUMBER>%d",entry_quan);
|
sql+=QString().sprintf("VGUEST_TYPE=%d && ",type);
|
||||||
|
}
|
||||||
|
sql+=QString().sprintf("NUMBER>%d",entry_quan);
|
||||||
q=new RDSqlQuery(sql);
|
q=new RDSqlQuery(sql);
|
||||||
if(q->first()) {
|
if(q->first()) {
|
||||||
if(QMessageBox::warning(this,"RDAdmin - "+tr("Warning"),
|
if(QMessageBox::warning(this,"RDAdmin - "+tr("Warning"),
|
||||||
|
@ -73,9 +73,9 @@ class EditMatrix : public RDDialog
|
|||||||
void PruneEndpoints(RDMatrix::Endpoint ep) const;
|
void PruneEndpoints(RDMatrix::Endpoint ep) const;
|
||||||
bool ConfirmPruneEndpoints(RDMatrix::Endpoint ep);
|
bool ConfirmPruneEndpoints(RDMatrix::Endpoint ep);
|
||||||
|
|
||||||
void AddVguest(RDMatrix::VguestType type) const;
|
void AddResources(RDMatrix::VguestType type) const;
|
||||||
void PruneVguest(RDMatrix::VguestType type) const;
|
void PruneResources(RDMatrix::VguestType type) const;
|
||||||
bool ConfirmPruneVguest(RDMatrix::VguestType type);
|
bool ConfirmPruneResources(RDMatrix::VguestType type);
|
||||||
|
|
||||||
RDMatrix *edit_matrix;
|
RDMatrix *edit_matrix;
|
||||||
QString edit_stationname;
|
QString edit_stationname;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Edit an SAS Resource Record.
|
// Edit an SAS Resource Record.
|
||||||
//
|
//
|
||||||
// (C) Copyright 2002-2018 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
|
// 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
|
||||||
@ -18,21 +18,13 @@
|
|||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <qmessagebox.h>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <rdtextvalidator.h>
|
#include "edit_sas_resource.h"
|
||||||
|
|
||||||
#include <edit_sas_resource.h>
|
EditSasResource::EditSasResource(QWidget *parent)
|
||||||
|
|
||||||
EditSasResource::EditSasResource(int *enginenum,int *devicenum,int *relaynum,
|
|
||||||
QWidget *parent)
|
|
||||||
: RDDialog(parent)
|
: RDDialog(parent)
|
||||||
{
|
{
|
||||||
setModal(true);
|
|
||||||
|
|
||||||
edit_enginenum=enginenum;
|
|
||||||
edit_devicenum=devicenum;
|
|
||||||
edit_relaynum=relaynum;
|
|
||||||
setWindowTitle("RDAdmin - "+tr("Edit SAS Switch"));
|
setWindowTitle("RDAdmin - "+tr("Edit SAS Switch"));
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -91,19 +83,6 @@ EditSasResource::EditSasResource(int *enginenum,int *devicenum,int *relaynum,
|
|||||||
button->setFont(buttonFont());
|
button->setFont(buttonFont());
|
||||||
button->setText(tr("&Cancel"));
|
button->setText(tr("&Cancel"));
|
||||||
connect(button,SIGNAL(clicked()),this,SLOT(cancelData()));
|
connect(button,SIGNAL(clicked()),this,SLOT(cancelData()));
|
||||||
|
|
||||||
//
|
|
||||||
// Load Data
|
|
||||||
//
|
|
||||||
if(*enginenum>=0) {
|
|
||||||
edit_enginenum_edit->setText(QString().sprintf("%d",*enginenum));
|
|
||||||
}
|
|
||||||
if(*devicenum>=0) {
|
|
||||||
edit_devicenum_edit->setText(QString().sprintf("%d",*devicenum));
|
|
||||||
}
|
|
||||||
if(*relaynum>=0) {
|
|
||||||
edit_relaynum_edit->setText(QString().sprintf("%d",*relaynum));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -119,6 +98,43 @@ QSizePolicy EditSasResource::sizePolicy() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int EditSasResource::exec(unsigned id)
|
||||||
|
{
|
||||||
|
edit_id=id;
|
||||||
|
|
||||||
|
QString sql=QString("select ")+
|
||||||
|
"NUMBER,"+ // 00
|
||||||
|
"ENGINE_NUM,"+ // 01
|
||||||
|
"DEVICE_NUM,"+ // 02
|
||||||
|
"RELAY_NUM "+ // 03
|
||||||
|
"from VGUEST_RESOURCES where "+
|
||||||
|
QString().sprintf("ID=%u",edit_id);
|
||||||
|
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||||
|
if(q->first()) {
|
||||||
|
if(q->value(1).toInt()>=0) {
|
||||||
|
edit_enginenum_edit->setText(QString().sprintf("%d",q->value(1).toInt()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
edit_enginenum_edit->setText("");
|
||||||
|
}
|
||||||
|
if(q->value(2).toInt()>=0) {
|
||||||
|
edit_devicenum_edit->setText(QString().sprintf("%d",q->value(2).toInt()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
edit_devicenum_edit->setText("");
|
||||||
|
}
|
||||||
|
if(q->value(3).toInt()>=0) {
|
||||||
|
edit_relaynum_edit->setText(QString().sprintf("%d",q->value(3).toInt()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
edit_relaynum_edit->setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete q;
|
||||||
|
return QDialog::exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EditSasResource::okData()
|
void EditSasResource::okData()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
@ -155,14 +171,19 @@ void EditSasResource::okData()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*edit_enginenum=enginenum;
|
|
||||||
*edit_devicenum=devicenum;
|
QString sql=QString("update VGUEST_RESOURCES set ")+
|
||||||
*edit_relaynum=relaynum;
|
QString().sprintf("ENGINE_NUM=%d,",enginenum)+
|
||||||
done(0);
|
QString().sprintf("DEVICE_NUM=%d,",devicenum)+
|
||||||
|
QString().sprintf("RELAY_NUM=%d ",relaynum)+
|
||||||
|
QString().sprintf("where ID=%u",edit_id);
|
||||||
|
RDSqlQuery::apply(sql);
|
||||||
|
|
||||||
|
done(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EditSasResource::cancelData()
|
void EditSasResource::cancelData()
|
||||||
{
|
{
|
||||||
done(1);
|
done(false);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Edit an SAS Resource Record.
|
// Edit an SAS Resource Record.
|
||||||
//
|
//
|
||||||
// (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
|
// 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,35 +21,33 @@
|
|||||||
#ifndef EDIT_SAS_RESOURCE_H
|
#ifndef EDIT_SAS_RESOURCE_H
|
||||||
#define EDIT_SAS_RESOURCE_H
|
#define EDIT_SAS_RESOURCE_H
|
||||||
|
|
||||||
#include <qcombobox.h>
|
#include <QLineEdit>
|
||||||
#include <qlabel.h>
|
#include <QPushButton>
|
||||||
#include <qlineedit.h>
|
|
||||||
#include <qpushbutton.h>
|
|
||||||
|
|
||||||
#include <rddialog.h>
|
#include <rddialog.h>
|
||||||
#include <rdmatrix.h>
|
#include <rdmatrix.h>
|
||||||
#include <rduser.h>
|
|
||||||
|
|
||||||
class EditSasResource : public RDDialog
|
class EditSasResource : public RDDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
EditSasResource(int *enginenum,int *devicenum,int *relaynum,QWidget *parent=0);
|
EditSasResource(QWidget *parent=0);
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
QSizePolicy sizePolicy() const;
|
QSizePolicy sizePolicy() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
int exec(unsigned id);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void okData();
|
void okData();
|
||||||
void cancelData();
|
void cancelData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int *edit_enginenum;
|
|
||||||
int *edit_devicenum;
|
|
||||||
int *edit_relaynum;
|
|
||||||
QLineEdit *edit_enginenum_edit;
|
QLineEdit *edit_enginenum_edit;
|
||||||
QLineEdit *edit_devicenum_edit;
|
QLineEdit *edit_devicenum_edit;
|
||||||
QLabel *edit_relaynum_label;
|
QLabel *edit_relaynum_label;
|
||||||
QLineEdit *edit_relaynum_edit;
|
QLineEdit *edit_relaynum_edit;
|
||||||
|
unsigned edit_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// List SAS Resources.
|
// List SAS Resources.
|
||||||
//
|
//
|
||||||
// (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
|
// 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
|
||||||
@ -29,8 +29,6 @@
|
|||||||
ListSasResources::ListSasResources(RDMatrix *matrix,int size,QWidget *parent)
|
ListSasResources::ListSasResources(RDMatrix *matrix,int size,QWidget *parent)
|
||||||
: RDDialog(parent)
|
: RDDialog(parent)
|
||||||
{
|
{
|
||||||
setModal(true);
|
|
||||||
|
|
||||||
QString sql;
|
QString sql;
|
||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
@ -43,27 +41,30 @@ ListSasResources::ListSasResources(RDMatrix *matrix,int size,QWidget *parent)
|
|||||||
//
|
//
|
||||||
setMinimumSize(sizeHint());
|
setMinimumSize(sizeHint());
|
||||||
|
|
||||||
|
//
|
||||||
|
// Dialogs
|
||||||
|
//
|
||||||
|
list_edit_resource_dialog=new EditSasResource(this);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Resources List Box
|
// Resources List Box
|
||||||
//
|
//
|
||||||
list_list_view=new Q3ListView(this);
|
//
|
||||||
list_title_label=
|
// Resources List Box
|
||||||
new QLabel(list_list_view,tr("SAS Switches"),this);
|
//
|
||||||
|
list_list_view=new RDTableView(this);
|
||||||
|
list_list_model=
|
||||||
|
new RDResourceListModel(list_matrix,RDMatrix::VguestTypeNone,this);
|
||||||
|
list_list_model->setFont(defaultFont());
|
||||||
|
list_list_model->setPalette(palette());
|
||||||
|
list_list_view->setModel(list_list_model);
|
||||||
|
list_title_label=new QLabel(list_list_view,tr("SAS Switches"),this);
|
||||||
list_title_label->setFont(labelFont());
|
list_title_label->setFont(labelFont());
|
||||||
list_list_view->setAllColumnsShowFocus(true);
|
connect(list_list_view,SIGNAL(doubleClicked(const QModelIndex &)),
|
||||||
list_list_view->setItemMargin(5);
|
this,SLOT(doubleClickedData(const QModelIndex &)));
|
||||||
list_list_view->addColumn(tr("GPIO Line"));
|
connect(list_list_model,SIGNAL(modelReset()),
|
||||||
list_list_view->setColumnAlignment(0,Qt::AlignHCenter);
|
list_list_view,SLOT(resizeColumnsToContents()));
|
||||||
list_list_view->addColumn(tr("Console"));
|
list_list_view->resizeColumnsToContents();
|
||||||
list_list_view->setColumnAlignment(1,Qt::AlignHCenter);
|
|
||||||
list_list_view->addColumn(tr("Source"));
|
|
||||||
list_list_view->setColumnAlignment(2,Qt::AlignHCenter);
|
|
||||||
list_list_view->addColumn(tr("Opto/Relay"));
|
|
||||||
list_list_view->setColumnAlignment(3,Qt::AlignHCenter);
|
|
||||||
connect(list_list_view,
|
|
||||||
SIGNAL(doubleClicked(Q3ListViewItem *,const QPoint &,int)),
|
|
||||||
this,
|
|
||||||
SLOT(doubleClickedData(Q3ListViewItem *,const QPoint &,int)));
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Edit Button
|
// Edit Button
|
||||||
@ -74,26 +75,18 @@ ListSasResources::ListSasResources(RDMatrix *matrix,int size,QWidget *parent)
|
|||||||
connect(list_edit_button,SIGNAL(clicked()),this,SLOT(editData()));
|
connect(list_edit_button,SIGNAL(clicked()),this,SLOT(editData()));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Ok Button
|
// Close Button
|
||||||
//
|
//
|
||||||
list_ok_button=new QPushButton(this);
|
list_close_button=new QPushButton(this);
|
||||||
list_ok_button->setDefault(true);
|
list_close_button->setFont(buttonFont());
|
||||||
list_ok_button->setFont(buttonFont());
|
list_close_button->setText(tr("&Close"));
|
||||||
list_ok_button->setText(tr("&OK"));
|
connect(list_close_button,SIGNAL(clicked()),this,SLOT(closeData()));
|
||||||
connect(list_ok_button,SIGNAL(clicked()),this,SLOT(okData()));
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Cancel Button
|
|
||||||
//
|
|
||||||
list_cancel_button=new QPushButton(this);
|
|
||||||
list_cancel_button->setFont(buttonFont());
|
|
||||||
list_cancel_button->setText(tr("&Cancel"));
|
|
||||||
connect(list_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));
|
|
||||||
|
|
||||||
//
|
ListSasResources::~ListSasResources()
|
||||||
// Load Values
|
{
|
||||||
//
|
delete list_edit_resource_dialog;
|
||||||
RefreshList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -111,116 +104,28 @@ QSizePolicy ListSasResources::sizePolicy() const
|
|||||||
|
|
||||||
void ListSasResources::editData()
|
void ListSasResources::editData()
|
||||||
{
|
{
|
||||||
int engine_num=-1;
|
QModelIndexList rows=list_list_view->selectionModel()->selectedRows();
|
||||||
int device_num=-1;
|
|
||||||
int relay_num=-1;
|
|
||||||
|
|
||||||
Q3ListViewItem *item=list_list_view->selectedItem();
|
if(rows.size()!=1) {
|
||||||
if(item==NULL) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!item->text(1).isEmpty()) {
|
|
||||||
engine_num=item->text(1).toInt();
|
if(list_edit_resource_dialog->
|
||||||
|
exec(list_list_model->resourceId(rows.first()))) {
|
||||||
|
list_list_model->refresh(rows.first());
|
||||||
}
|
}
|
||||||
if(!item->text(2).isEmpty()) {
|
|
||||||
device_num=item->text(2).toInt();
|
|
||||||
}
|
|
||||||
if(!item->text(3).isEmpty()) {
|
|
||||||
relay_num=item->text(3).toInt();
|
|
||||||
}
|
|
||||||
EditSasResource *dialog=
|
|
||||||
new EditSasResource(&engine_num,&device_num,&relay_num,this);
|
|
||||||
if(dialog->exec()==0) {
|
|
||||||
if(engine_num>=0) {
|
|
||||||
item->setText(1,QString().sprintf("%d",engine_num));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
item->setText(1,"");
|
|
||||||
}
|
|
||||||
if(device_num>=0) {
|
|
||||||
item->setText(2,QString().sprintf("%d",device_num));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
item->setText(2,"");
|
|
||||||
}
|
|
||||||
if(relay_num>=0) {
|
|
||||||
item->setText(3,QString().sprintf("%d",relay_num));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
item->setText(3,"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete dialog;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ListSasResources::doubleClickedData(Q3ListViewItem *item,
|
void ListSasResources::doubleClickedData(const QModelIndex &index)
|
||||||
const QPoint &pt,int col)
|
|
||||||
{
|
{
|
||||||
editData();
|
editData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ListSasResources::okData()
|
void ListSasResources::closeData()
|
||||||
{
|
{
|
||||||
QString sql;
|
done(true);
|
||||||
RDSqlQuery *q;
|
|
||||||
int engine_num=-1;
|
|
||||||
int device_num=-1;
|
|
||||||
int surface_num=-1;
|
|
||||||
int relay_num=-1;
|
|
||||||
|
|
||||||
Q3ListViewItem *item=list_list_view->firstChild();
|
|
||||||
while(item!=NULL) {
|
|
||||||
engine_num=-1;
|
|
||||||
device_num=-1;
|
|
||||||
surface_num=-1;
|
|
||||||
relay_num=-1;
|
|
||||||
if(!item->text(1).isEmpty()) {
|
|
||||||
engine_num=item->text(1).toInt();
|
|
||||||
}
|
|
||||||
if(!item->text(2).isEmpty()) {
|
|
||||||
device_num=item->text(2).toInt();
|
|
||||||
}
|
|
||||||
if(!item->text(3).isEmpty()) {
|
|
||||||
relay_num=item->text(3).toInt();
|
|
||||||
}
|
|
||||||
sql=QString("select ID from VGUEST_RESOURCES where" )+
|
|
||||||
"(STATION_NAME=\""+RDEscapeString(list_matrix->station())+"\")&&"+
|
|
||||||
QString().sprintf("(MATRIX_NUM=%d)&&",list_matrix->matrix())+
|
|
||||||
QString().sprintf("(NUMBER=%d)",item->text(0).toInt());
|
|
||||||
q=new RDSqlQuery(sql);
|
|
||||||
if(q->first()) {
|
|
||||||
sql=QString("update VGUEST_RESOURCES set ")+
|
|
||||||
QString().sprintf("ENGINE_NUM=%d,",engine_num)+
|
|
||||||
QString().sprintf("DEVICE_NUM=%d,",device_num)+
|
|
||||||
QString().sprintf("SURFACE_NUM=%d,",surface_num)+
|
|
||||||
QString().sprintf("RELAY_NUM=%d where ",relay_num)+
|
|
||||||
"(STATION_NAME=\""+RDEscapeString(list_matrix->station())+"\")&&"+
|
|
||||||
QString().sprintf("(MATRIX_NUM=%d)&&",list_matrix->matrix())+
|
|
||||||
QString().sprintf("(NUMBER=%d)",item->text(0).toInt());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql=QString("insert into VGUEST_RESOURCES set ")+
|
|
||||||
"STATION_NAME=\""+RDEscapeString(list_matrix->station())+"\","+
|
|
||||||
QString().sprintf("MATRIX_NUM=%d,",list_matrix->matrix())+
|
|
||||||
QString().sprintf("NUMBER=%d,",item->text(0).toInt())+
|
|
||||||
QString().sprintf("ENGINE_NUM=%d,",engine_num)+
|
|
||||||
QString().sprintf("DEVICE_NUM=%d,",device_num)+
|
|
||||||
QString().sprintf("SURFACE_NUM=%d,",surface_num)+
|
|
||||||
QString().sprintf("RELAY_NUM=%d",relay_num);
|
|
||||||
}
|
|
||||||
q=new RDSqlQuery(sql);
|
|
||||||
delete q;
|
|
||||||
item=item->nextSibling();
|
|
||||||
}
|
|
||||||
done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ListSasResources::cancelData()
|
|
||||||
{
|
|
||||||
done(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -229,82 +134,5 @@ void ListSasResources::resizeEvent(QResizeEvent *e)
|
|||||||
list_list_view->setGeometry(10,24,size().width()-20,size().height()-94);
|
list_list_view->setGeometry(10,24,size().width()-20,size().height()-94);
|
||||||
list_title_label->setGeometry(14,5,85,19);
|
list_title_label->setGeometry(14,5,85,19);
|
||||||
list_edit_button->setGeometry(10,size().height()-60,80,50);
|
list_edit_button->setGeometry(10,size().height()-60,80,50);
|
||||||
list_ok_button->setGeometry(size().width()-180,size().height()-60,80,50);
|
list_close_button->setGeometry(size().width()-90,size().height()-60,80,50);
|
||||||
list_cancel_button->setGeometry(size().width()-90,size().height()-60,80,50);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ListSasResources::RefreshList()
|
|
||||||
{
|
|
||||||
QString sql;
|
|
||||||
RDSqlQuery *q;
|
|
||||||
RDSqlQuery *q1;
|
|
||||||
Q3ListViewItem *item;
|
|
||||||
int n=1;
|
|
||||||
int gpis;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Populate Resource Records
|
|
||||||
//
|
|
||||||
sql=QString("select GPIS from MATRICES where ")+
|
|
||||||
"(STATION_NAME=\""+RDEscapeString(list_matrix->station())+"\")&&"+
|
|
||||||
QString().sprintf("(MATRIX=%d)",list_matrix->matrix());
|
|
||||||
q=new RDSqlQuery(sql);
|
|
||||||
if(!q->first()) {
|
|
||||||
delete q;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gpis=q->value(0).toInt();
|
|
||||||
delete q;
|
|
||||||
for(int i=0;i<gpis;i++) {
|
|
||||||
sql=QString("select NUMBER from VGUEST_RESOURCES where ")+
|
|
||||||
"(STATION_NAME=\""+RDEscapeString(list_matrix->station())+"\")&&"+
|
|
||||||
QString().sprintf("(MATRIX_NUM=%d)&&",list_matrix->matrix())+
|
|
||||||
QString().sprintf("(NUMBER=%d)",i+1);
|
|
||||||
q=new RDSqlQuery(sql);
|
|
||||||
if(!q->first()) {
|
|
||||||
sql=QString("insert into VGUEST_RESOURCES set ")+
|
|
||||||
QString().sprintf("NUMBER=%d,",i+1)+
|
|
||||||
"STATION_NAME=\""+RDEscapeString(list_matrix->station())+"\","+
|
|
||||||
QString().sprintf("MATRIX_NUM=%d",list_matrix->matrix());
|
|
||||||
q1=new RDSqlQuery(sql);
|
|
||||||
delete q1;
|
|
||||||
}
|
|
||||||
delete q;
|
|
||||||
}
|
|
||||||
|
|
||||||
sql=QString("select ")+
|
|
||||||
"NUMBER,"+
|
|
||||||
"ENGINE_NUM,"+
|
|
||||||
"DEVICE_NUM,"+
|
|
||||||
"RELAY_NUM "+
|
|
||||||
"from VGUEST_RESOURCES where "+
|
|
||||||
"(STATION_NAME=\""+RDEscapeString(list_matrix->station())+"\")&&"+
|
|
||||||
QString().sprintf("(MATRIX_NUM=%d)",list_matrix->matrix())+
|
|
||||||
"order by NUMBER";
|
|
||||||
q=new RDSqlQuery(sql);
|
|
||||||
list_list_view->clear();
|
|
||||||
while(q->next()) {
|
|
||||||
while(q->value(0).toInt()>n) {
|
|
||||||
item=new Q3ListViewItem(list_list_view);
|
|
||||||
item->setText(0,QString().sprintf("%03d",n++));
|
|
||||||
}
|
|
||||||
item=new Q3ListViewItem(list_list_view);
|
|
||||||
item->setText(0,QString().sprintf("%03d",q->value(0).toInt()));
|
|
||||||
if(q->value(1).toInt()>=0) {
|
|
||||||
item->setText(1,QString().sprintf("%d",q->value(1).toInt()));
|
|
||||||
}
|
|
||||||
if(q->value(2).toInt()>=0) {
|
|
||||||
item->setText(2,QString().sprintf("%d",q->value(2).toInt()));
|
|
||||||
}
|
|
||||||
if(q->value(3).toInt()>=0) {
|
|
||||||
item->setText(3,QString().sprintf("%d",q->value(3).toInt()));
|
|
||||||
}
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
for(int i=n;i<(list_size+1);i++) {
|
|
||||||
item=new Q3ListViewItem(list_list_view);
|
|
||||||
item->setText(0,QString().sprintf("%03d",i));
|
|
||||||
}
|
|
||||||
delete q;
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// List SAS Resources
|
// List SAS Resources
|
||||||
//
|
//
|
||||||
// (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
|
// 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,39 +21,38 @@
|
|||||||
#ifndef LIST_SAS_RESOURCES_H
|
#ifndef LIST_SAS_RESOURCES_H
|
||||||
#define LIST_SAS_RESOURCES_H
|
#define LIST_SAS_RESOURCES_H
|
||||||
|
|
||||||
#include <qlabel.h>
|
|
||||||
#include <qpushbutton.h>
|
|
||||||
#include <q3listview.h>
|
|
||||||
|
|
||||||
#include <rddialog.h>
|
#include <rddialog.h>
|
||||||
#include <rdmatrix.h>
|
#include <rdmatrix.h>
|
||||||
#include <rduser.h>
|
#include <rdresourcelistmodel.h>
|
||||||
|
#include <rdtableview.h>
|
||||||
|
|
||||||
|
#include "edit_sas_resource.h"
|
||||||
|
|
||||||
class ListSasResources : public RDDialog
|
class ListSasResources : public RDDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ListSasResources(RDMatrix *matrix,int size,QWidget *parent=0);
|
ListSasResources(RDMatrix *matrix,int size,QWidget *parent=0);
|
||||||
|
~ListSasResources();
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
QSizePolicy sizePolicy() const;
|
QSizePolicy sizePolicy() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void editData();
|
void editData();
|
||||||
void doubleClickedData(Q3ListViewItem *item,const QPoint &pt,int col);
|
void doubleClickedData(const QModelIndex &index);
|
||||||
void okData();
|
void closeData();
|
||||||
void cancelData();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RefreshList();
|
EditSasResource *list_edit_resource_dialog;
|
||||||
RDMatrix *list_matrix;
|
RDMatrix *list_matrix;
|
||||||
QLabel *list_title_label;
|
QLabel *list_title_label;
|
||||||
Q3ListView *list_list_view;
|
RDTableView *list_list_view;
|
||||||
|
RDResourceListModel *list_list_model;
|
||||||
QPushButton *list_edit_button;
|
QPushButton *list_edit_button;
|
||||||
QPushButton *list_ok_button;
|
QPushButton *list_close_button;
|
||||||
QPushButton *list_cancel_button;
|
|
||||||
int list_size;
|
int list_size;
|
||||||
QString list_table;
|
QString list_table;
|
||||||
};
|
};
|
||||||
|
@ -57,6 +57,9 @@ ListVguestResources::ListVguestResources(RDMatrix *matrix,
|
|||||||
case RDMatrix::VguestTypeRelay:
|
case RDMatrix::VguestTypeRelay:
|
||||||
setWindowTitle("RDAdmin - "+tr("vGuest Switches"));
|
setWindowTitle("RDAdmin - "+tr("vGuest Switches"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RDMatrix::VguestTypeNone:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user