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

* Added 'RDPypadListModel'.
	* Refactored the 'Encoder 'PyPAD Instances' 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-26 17:47:37 -05:00
parent af5e3753b6
commit db1f03e7cb
21 changed files with 627 additions and 295 deletions

View File

@ -20912,3 +20912,7 @@
* Added 'RDJackClientListModel'.
* Refactored the 'Encoder 'Jack Configuration' dialog in rdadmin(1)
to use the model-based API.
2021-01-26 Fred Gleason <fredg@paravelsystems.com>
* Added 'RDPypadListModel'.
* Refactored the 'Encoder 'PyPAD Instances' dialog in rdadmin(1)
to use the model-based API.

View File

@ -206,6 +206,7 @@ dist_librd_la_SOURCES = dbversion.h\
rdprocess.cpp rdprocess.h\
rdprofile.cpp rdprofile.h\
rdpushbutton.cpp rdpushbutton.h\
rdpypadlistmodel.cpp rdpypadlistmodel.h\
rdrecording.cpp rdrecording.h\
rdrehash.cpp rdrehash.h\
rdrenderer.cpp rdrenderer.h\
@ -352,6 +353,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\
moc_rdpodcastlistmodel.cpp\
moc_rdprocess.cpp\
moc_rdpushbutton.cpp\
moc_rdpypadlistmodel.cpp\
moc_rdrehash.cpp\
moc_rdrenderer.cpp\
moc_rdripc.cpp\

View File

@ -151,6 +151,7 @@ SOURCES += rdpodcastlistmodel.cpp
SOURCES += rdprocess.cpp
SOURCES += rdprofile.cpp
SOURCES += rdpushbutton.cpp
SOURCES += rdpypadlistmodel.cpp
SOURCES += rdrecording.cpp
SOURCES += rdrehash.cpp
SOURCES += rdrenderer.cpp
@ -311,6 +312,7 @@ HEADERS += rdpodcastlistmodel.h
HEADERS += rdprocess.h
HEADERS += rdprofile.h
HEADERS += rdpushbutton.h
HEADERS += rdpypadlistmodel.h
HEADERS += rdrecording.h
HEADERS += rdrehash.h
HEADERS += rdrenderer.h

View File

@ -3368,6 +3368,25 @@ Zkuste to, prosím, znovu!</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDPypadListModel</name>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDRecording</name>
<message>

View File

@ -3349,6 +3349,25 @@ bitte erneut versuchen!</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDPypadListModel</name>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDRecording</name>
<message>

View File

@ -3336,6 +3336,25 @@ please try again!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDPypadListModel</name>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDRecording</name>
<message>

View File

@ -2771,6 +2771,25 @@ please try again!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDPypadListModel</name>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDRehash</name>
<message>

View File

@ -3303,6 +3303,25 @@ prøv ein gong til!</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDPypadListModel</name>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDRecording</name>
<message>

View File

@ -3303,6 +3303,25 @@ prøv ein gong til!</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDPypadListModel</name>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDRecording</name>
<message>

View File

@ -3338,6 +3338,25 @@ por favor, tente novamente!</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDPypadListModel</name>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDRecording</name>
<message>

356
lib/rdpypadlistmodel.cpp Normal file
View File

@ -0,0 +1,356 @@
// rdpypadlistmodel.cpp
//
// Data model for Rivendell PyPAD instances
//
// (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 "rdpypadlistmodel.h"
RDPypadListModel::RDPypadListModel(const QString &hostname,QObject *parent)
: QAbstractTableModel(parent)
{
d_station_name=hostname;
//
// Column Attributes
//
unsigned left=Qt::AlignLeft|Qt::AlignVCenter;
// unsigned center=Qt::AlignCenter;
unsigned right=Qt::AlignRight|Qt::AlignVCenter;
d_headers.push_back(tr("ID"));
d_alignments.push_back(left);
d_headers.push_back(tr("Description"));
d_alignments.push_back(left);
d_headers.push_back(tr("Script Path"));
d_alignments.push_back(left);
d_headers.push_back(tr("Exit Code"));
d_alignments.push_back(right);
d_state_timer=new QTimer(this);
d_state_timer->setSingleShot(true);
connect(d_state_timer,SIGNAL(timeout()),this,SLOT(stateTimeoutData()));
d_state_timer->start(0);
updateModel();
}
RDPypadListModel::~RDPypadListModel()
{
delete d_state_timer;
}
QPalette RDPypadListModel::palette()
{
return d_palette;
}
void RDPypadListModel::setPalette(const QPalette &pal)
{
d_palette=pal;
}
void RDPypadListModel::setFont(const QFont &font)
{
d_font=font;
d_bold_font=font;
d_bold_font.setWeight(QFont::Bold);
}
int RDPypadListModel::columnCount(const QModelIndex &parent) const
{
return d_headers.size();
}
int RDPypadListModel::rowCount(const QModelIndex &parent) const
{
return d_texts.size();
}
QVariant RDPypadListModel::headerData(int section,Qt::Orientation orient,
int role) const
{
if((orient==Qt::Horizontal)&&(role==Qt::DisplayRole)) {
return d_headers.at(section);
}
return QVariant();
}
QVariant RDPypadListModel::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 d_state_icons.at(row);
}
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 RDPypadListModel::instanceId(const QModelIndex &row) const
{
return d_ids.at(row.row());
}
QModelIndex RDPypadListModel::addInstance(int id)
{
//
// Find the insertion offset
//
int offset=d_ids.size();
for(int i=0;i<d_ids.size();i++) {
if(id<d_ids.at(i)) {
offset=i;
break;
}
}
beginInsertRows(QModelIndex(),offset,offset);
QList<QVariant> list;
for(int i=0;i<columnCount();i++) {
list.push_back(QVariant());
}
d_texts.insert(offset,list);
d_ids.insert(offset,id);
d_state_icons.
insert(offset,rda->iconEngine()->listIcon(RDIconEngine::RedBall));
d_states.insert(offset,false);
updateRowLine(offset);
endInsertRows();
return createIndex(offset,0);
}
void RDPypadListModel::removeInstance(const QModelIndex &row)
{
beginRemoveRows(QModelIndex(),row.row(),row.row());
d_ids.removeAt(row.row());
d_state_icons.removeAt(row.row());
d_states.removeAt(row.row());
d_texts.removeAt(row.row());
endRemoveRows();
}
void RDPypadListModel::removeInstance(int id)
{
for(int i=0;i<d_ids.size();i++) {
if(d_ids.at(i)==id) {
removeInstance(createIndex(i,0));
return;
}
}
}
void RDPypadListModel::refresh(const QModelIndex &row)
{
if(row.row()<d_texts.size()) {
QString sql=sqlFields()+
"where "+
QString().sprintf("PYPAD_INSTANCES.ID=%u",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 RDPypadListModel::refresh(int id)
{
for(int i=0;i<d_texts.size();i++) {
if(d_ids.at(i)==id) {
updateRowLine(i);
return;
}
}
}
bool RDPypadListModel::isActive(int id) const
{
int index=d_ids.indexOf(id);
if(index>=0) {
return d_states.at(index);
}
return false;
}
void RDPypadListModel::stateTimeoutData()
{
QString sql;
RDSqlQuery *q;
int line=-1;
sql=QString("select ")+
"ID,"+ // 00
"IS_RUNNING,"+ // 01
"EXIT_CODE "+ // 02
"from PYPAD_INSTANCES where "+
"STATION_NAME=\""+RDEscapeString(d_station_name)+"\"";
q=new RDSqlQuery(sql);
while(q->next()) {
if((line=d_ids.indexOf(q->value(0).toInt()))>=0) {
if((q->value(1).toString()=="Y")!=d_states.at(line)) {
if(d_states.at(line)) {
d_state_icons[line]=
rda->iconEngine()->listIcon(RDIconEngine::RedBall);
}
else {
d_state_icons[line]=
rda->iconEngine()->listIcon(RDIconEngine::GreenBall);
}
d_states[line]=!d_states.at(line);
emit dataChanged(createIndex(line,0),createIndex(line,0));
}
if(d_texts.at(line).at(3)!=
QString().sprintf("%d",q->value(2).toInt())) {
d_texts[line][3]=QString().sprintf("%d",q->value(2).toInt());
emit dataChanged(createIndex(line,3),createIndex(line,3));
}
}
}
delete q;
d_state_timer->start(3000);
}
void RDPypadListModel::updateModel()
{
QList<QVariant> texts;
RDSqlQuery *q=NULL;
QString sql=sqlFields()+
"where "+
"PYPAD_INSTANCES.STATION_NAME=\""+RDEscapeString(d_station_name)+"\" "+
"order by PYPAD_INSTANCES.ID ";
beginResetModel();
d_texts.clear();
q=new RDSqlQuery(sql);
while(q->next()) {
d_ids.push_back(0);
d_state_icons.
push_back(rda->iconEngine()->listIcon(RDIconEngine::RedBall));
d_states.push_back(false);
d_texts.push_back(texts);
updateRow(d_texts.size()-1,q);
}
delete q;
endResetModel();
}
void RDPypadListModel::updateRowLine(int line)
{
if(line<d_texts.size()) {
QString sql=sqlFields()+
"where "+
QString().sprintf("PYPAD_INSTANCES.ID=%u",d_ids.at(line));
RDSqlQuery *q=new RDSqlQuery(sql);
if(q->first()) {
updateRow(line,q);
}
delete q;
}
}
void RDPypadListModel::updateRow(int row,RDSqlQuery *q)
{
QList<QVariant> texts;
// ID
texts.push_back(QString().sprintf("%d",q->value(0).toInt()));
// Description
texts.push_back(q->value(1));
// Script Path
texts.push_back(q->value(2));
// Exit Code
texts.push_back(QString().sprintf("%d",q->value(3).toInt()));
d_ids[row]=q->value(0).toInt();
d_texts[row]=texts;
}
QString RDPypadListModel::sqlFields() const
{
QString sql=QString("select ")+
"PYPAD_INSTANCES.ID," // 00
"PYPAD_INSTANCES.DESCRIPTION,"+ // 01
"PYPAD_INSTANCES.SCRIPT_PATH," // 02
"PYPAD_INSTANCES.EXIT_CODE "+ // 03
"from PYPAD_INSTANCES ";
return sql;
}

80
lib/rdpypadlistmodel.h Normal file
View File

@ -0,0 +1,80 @@
// rdpypadlistmodel.h
//
// Data model for Rivendell PyPAD instances
//
// (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 RDPYPADLISTMODEL_H
#define RDPYPADLISTMODEL_H
#include <QAbstractTableModel>
#include <QFont>
#include <QList>
#include <QPalette>
#include <QTimer>
#include <rddb.h>
#include <rdnotification.h>
#include <rduser.h>
class RDPypadListModel : public QAbstractTableModel
{
Q_OBJECT
public:
RDPypadListModel(const QString &hostname,QObject *parent=0);
~RDPypadListModel();
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 instanceId(const QModelIndex &row) const;
QModelIndex addInstance(int id);
void removeInstance(const QModelIndex &row);
void removeInstance(int id);
void refresh(const QModelIndex &row);
void refresh(int id);
bool isActive(int id) const;
private slots:
void stateTimeoutData();
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<QVariant> d_state_icons;
QList<bool> d_states;
QList<int> d_ids;
QString d_station_name;
QTimer *d_state_timer;
};
#endif // RDPYPADLISTMODEL_H

View File

@ -2,7 +2,7 @@
//
// List PyPAD Instances
//
// (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2018-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,34 +18,24 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <qfile.h>
#include <qfiledialog.h>
#include <qmessagebox.h>
#include <qstringlist.h>
#include <QFileDialog>
#include <QHeaderView>
#include <QMessageBox>
#include <rd.h>
#include <rdapplication.h>
#include <rddb.h>
#include <rdescape_string.h>
#include <rdpasswd.h>
#include <rdpaths.h>
#include "edit_pypad.h"
#include "list_pypads.h"
#include "view_pypad_errors.h"
//
// Icons
//
#include "../icons/greenball.xpm"
#include "../icons/redball.xpm"
ListPypads::ListPypads(RDStation *station,QWidget *parent)
: RDDialog(parent)
{
list_station=station;
setModal(true);
setMinimumSize(sizeHint());
setWindowTitle("RDAdmin - "+tr("PyPAD Instances on")+" "+
@ -57,33 +47,23 @@ ListPypads::ListPypads(RDStation *station,QWidget *parent)
setMinimumWidth(sizeHint().width());
setMinimumHeight(sizeHint().height());
//
// Icons
//
list_greenball_pixmap=new QPixmap(greenball_xpm);
list_redball_pixmap=new QPixmap(redball_xpm);
//
// Instances List Box
//
list_list_view=new RDListView(this);
list_list_view->setSelectionMode(Q3ListView::Single);
list_list_view->setAllColumnsShowFocus(true);
list_list_view->setItemMargin(5);
list_list_view->addColumn(" ");
list_list_view->setColumnAlignment(0,Qt::AlignCenter);
list_list_view->addColumn(tr("ID"));
list_list_view->setColumnAlignment(1,Qt::AlignRight);
list_list_view->addColumn(tr("Description"));
list_list_view->setColumnAlignment(2,Qt::AlignLeft);
list_list_view->addColumn(tr("Script Path"));
list_list_view->setColumnAlignment(3,Qt::AlignLeft);
list_list_view->addColumn(tr("Exit Code"));
list_list_view->setColumnAlignment(4,Qt::AlignRight);
connect(list_list_view,
SIGNAL(doubleClicked(Q3ListViewItem *,const QPoint &,int)),
this,
SLOT(doubleClickedData(Q3ListViewItem *,const QPoint &,int)));
list_list_view=new QTableView(this);
list_list_view->setSelectionBehavior(QAbstractItemView::SelectRows);
list_list_view->setSelectionMode(QAbstractItemView::SingleSelection);
list_list_view->setShowGrid(false);
list_list_view->setSortingEnabled(false);
list_list_view->setWordWrap(false);
list_list_view->verticalHeader()->setVisible(false);
list_list_model=new RDPypadListModel(station->name(),this);
list_list_view->setModel(list_list_model);
connect(list_list_view,SIGNAL(doubleClicked(const QModelIndex &)),
this,SLOT(doubleClickedData(const QModelIndex &)));
connect(list_list_model,SIGNAL(modelReset()),
list_list_view,SLOT(resizeColumnsToContents()));
list_list_view->resizeColumnsToContents();
//
// Add Button
@ -125,19 +105,6 @@ ListPypads::ListPypads(RDStation *station,QWidget *parent)
list_close_button->setFont(buttonFont());
list_close_button->setText(tr("&Close"));
connect(list_close_button,SIGNAL(clicked()),this,SLOT(closeData()));
//
// Load Values
//
RefreshList();
//
// Update Timer
//
list_update_timer=new QTimer(this);
list_update_timer->setSingleShot(true);
connect(list_update_timer,SIGNAL(timeout()),this,SLOT(updateData()));
list_update_timer->start(3000);
}
@ -188,13 +155,10 @@ void ListPypads::addData()
int id=RDSqlQuery::run(sql).toInt();
EditPypad *d=new EditPypad(id,this);
if(d->exec()) {
RDListViewItem *item=new RDListViewItem(list_list_view);
item->setId(id);
RefreshItem(item);
list_list_view->clearSelection();
list_list_view->ensureItemVisible(item);
list_list_view->setCurrentItem(item);
item->setSelected(true);
QModelIndex row=list_list_model->addInstance(id);
if(row.isValid()) {
list_list_view->selectRow(row.row());
}
RDNotification notify=RDNotification(RDNotification::PypadType,
RDNotification::AddAction,id);
rda->ripc()->sendNotification(notify);
@ -210,17 +174,17 @@ void ListPypads::addData()
void ListPypads::editData()
{
RDListViewItem *item;
QModelIndexList rows=list_list_view->selectionModel()->selectedRows();
if((item=(RDListViewItem *)list_list_view->selectedItem())==NULL) {
if(rows.size()!=1) {
return;
}
EditPypad *d=new EditPypad(item->id(),this);
EditPypad *d=new EditPypad(list_list_model->instanceId(rows.first()),this);
if(d->exec()) {
RefreshItem(item);
RDNotification notify=RDNotification(RDNotification::PypadType,
RDNotification::ModifyAction,
item->id());
list_list_model->refresh(rows.first());
RDNotification notify=
RDNotification(RDNotification::PypadType,RDNotification::ModifyAction,
list_list_model->instanceId(rows.first()));
rda->ripc()->sendNotification(notify);
}
delete d;
@ -230,42 +194,43 @@ void ListPypads::editData()
void ListPypads::deleteData()
{
QString sql;
RDListViewItem *item;
QModelIndexList rows=list_list_view->selectionModel()->selectedRows();
if((item=(RDListViewItem *)list_list_view->selectedItem())==NULL) {
if(rows.size()!=1) {
return;
}
int id=list_list_model->instanceId(rows.first());
if(QMessageBox::question(this,tr("Delete Instance"),
tr("Are your sure you want to delete this instance?"),
tr("Are your sure you want to delete this instance?"),
QMessageBox::Yes,QMessageBox::No)==
QMessageBox::No) {
return;
}
sql=QString("delete from PYPAD_INSTANCES where ")+
QString().sprintf("ID=%d",item->id());
QString().sprintf("ID=%d",id);
RDSqlQuery::apply(sql);
RDNotification notify=RDNotification(RDNotification::PypadType,
RDNotification::DeleteAction,item->id());
list_list_model->removeInstance(id);
RDNotification notify=
RDNotification(RDNotification::PypadType,RDNotification::DeleteAction,id);
rda->ripc()->sendNotification(notify);
delete item;
}
void ListPypads::errorData()
{
RDListViewItem *item;
QModelIndexList rows=list_list_view->selectionModel()->selectedRows();
if((item=(RDListViewItem *)list_list_view->selectedItem())==NULL) {
if(rows.size()!=1) {
return;
}
ViewPypadErrors *d=new ViewPypadErrors(item->id(),this);
ViewPypadErrors *d=
new ViewPypadErrors(list_list_model->instanceId(rows.first()),this);
d->exec();
delete d;
}
void ListPypads::doubleClickedData(Q3ListViewItem *item,const QPoint &pt,
int col)
void ListPypads::doubleClickedData(const QModelIndex &index)
{
editData();
}
@ -273,36 +238,7 @@ void ListPypads::doubleClickedData(Q3ListViewItem *item,const QPoint &pt,
void ListPypads::closeData()
{
done(0);
}
void ListPypads::updateData()
{
QString sql;
RDSqlQuery *q;
RDListViewItem *item=(RDListViewItem *)list_list_view->firstChild();
while(item!=NULL) {
sql=QString("select ")+
"IS_RUNNING,"+ // 00
"EXIT_CODE "+ // 01
"from PYPAD_INSTANCES where "+
QString().sprintf("ID=%d",item->id());
q=new RDSqlQuery(sql);
if(q->first()) {
if(q->value(0).toString()=="Y") {
item->setPixmap(0,*list_greenball_pixmap);
}
else {
item->setPixmap(0,*list_redball_pixmap);
}
item->setText(4,QString().sprintf("%d",q->value(1).toInt()));
}
delete q;
item=(RDListViewItem *)item->nextSibling();
}
list_update_timer->start(3000);
done(true);
}
@ -318,66 +254,3 @@ void ListPypads::resizeEvent(QResizeEvent *e)
list_close_button->setGeometry(size().width()-90,size().height()-60,80,50);
}
void ListPypads::RefreshList()
{
QString sql;
RDSqlQuery *q;
RDListViewItem *item;
list_list_view->clear();
sql=QString("select ")+
"ID,"+ // 00
"IS_RUNNING,"+ // 01
"DESCRIPTION,"+ // 02
"SCRIPT_PATH,"+ // 03
"EXIT_CODE "+ // 04
"from PYPAD_INSTANCES where "+
"STATION_NAME=\""+RDEscapeString(list_station->name())+"\"";
q=new RDSqlQuery(sql);
while(q->next()) {
item=new RDListViewItem(list_list_view);
item->setId(q->value(0).toInt());
if(q->value(1).toString()=="Y") {
item->setPixmap(0,*list_greenball_pixmap);
}
else {
item->setPixmap(0,*list_redball_pixmap);
}
item->setText(1,QString().sprintf("%u",q->value(0).toUInt()));
item->setText(2,q->value(2).toString());
item->setText(3,q->value(3).toString());
item->setText(4,QString().sprintf("%d",q->value(4).toInt()));
}
delete q;
}
void ListPypads::RefreshItem(RDListViewItem *item)
{
QString sql;
RDSqlQuery *q;
sql=QString("select ")+
"IS_RUNNING,"+ // 00
"DESCRIPTION,"+ // 01
"SCRIPT_PATH,"+ // 02
"EXIT_CODE "+ //03
"from PYPAD_INSTANCES where "+
QString().sprintf("ID=%u",item->id());
q=new RDSqlQuery(sql);
if(q->first()) {
if(q->value(0).toString()=="Y") {
item->setPixmap(0,*list_greenball_pixmap);
}
else {
item->setPixmap(0,*list_redball_pixmap);
}
item->setText(1,QString().sprintf("%u",item->id()));
item->setText(2,q->value(1).toString());
item->setText(3,q->value(2).toString());
item->setText(4,QString().sprintf("%d",q->value(3).toInt()));
}
delete q;
}

View File

@ -2,7 +2,7 @@
//
// List PyPAD Instances
//
// (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2018-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,13 +21,12 @@
#ifndef LIST_PYPADS_H
#define LIST_PYPADS_H
#include <qpixmap.h>
#include <qpushbutton.h>
#include <qtimer.h>
#include <QPushButton>
#include <QTableView>
#include <rddialog.h>
#include <rdlistview.h>
#include <rdlistviewitem.h>
#include <rdpypadlistmodel.h>
#include <rdstation.h>
class ListPypads : public RDDialog
@ -43,26 +42,21 @@ class ListPypads : public RDDialog
void editData();
void deleteData();
void errorData();
void doubleClickedData(Q3ListViewItem *item,const QPoint &pt,int col);
void doubleClickedData(const QModelIndex &index);
void closeData();
void updateData();
protected:
void resizeEvent(QResizeEvent *e);
private:
void RefreshList();
void RefreshItem(RDListViewItem *item);
RDListView *list_list_view;
QTableView *list_list_view;
RDPypadListModel *list_list_model;
QPushButton *list_add_button;
QPushButton *list_edit_button;
QPushButton *list_delete_button;
QPushButton *list_error_button;
QPushButton *list_close_button;
QPixmap *list_greenball_pixmap;
QPixmap *list_redball_pixmap;
RDStation *list_station;
QTimer *list_update_timer;
};

View File

@ -5870,22 +5870,6 @@ Stále ještě jej chcete smazat?</translation>
<source>PyPAD Instances on</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Add</source>
<translation type="unfinished">&amp;Přidat</translation>

View File

@ -5516,22 +5516,6 @@ Generieren</translation>
<source>PyPAD Instances on</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Add</source>
<translation type="unfinished">&amp;Hinzufügen</translation>

View File

@ -5781,22 +5781,6 @@ Do you still want to delete it?</source>
<source>PyPAD Instances on</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Add</source>
<translation type="unfinished"></translation>

View File

@ -4490,22 +4490,6 @@ Permissions</source>
<source>PyPAD Instances on</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Add</source>
<translation type="unfinished"></translation>

View File

@ -5373,22 +5373,6 @@ Klikk på &quot;Lisens&quot;-knappen for fleire opplysningar.</translation>
<source>PyPAD Instances on</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Add</source>
<translation type="unfinished">&amp;Legg til</translation>

View File

@ -5373,22 +5373,6 @@ Klikk på &quot;Lisens&quot;-knappen for fleire opplysningar.</translation>
<source>PyPAD Instances on</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Add</source>
<translation type="unfinished">&amp;Legg til</translation>

View File

@ -5488,22 +5488,6 @@ Você ainda quer Deletar?</translation>
<source>PyPAD Instances on</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Script Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exit Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Add</source>
<translation type="unfinished">&amp;Adicionar</translation>