2021-02-05 Fred Gleason <fredg@paravelsystems.com>

* Added 'RDGpioLogModel'.
	* Refactored rdgpimon(1) to use the model-based API.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2021-02-05 20:25:12 -05:00
parent 200d986549
commit d2a7c00fc1
21 changed files with 595 additions and 150 deletions

View File

@ -21017,3 +21017,6 @@
* Removed vestigal 'LibListview' class from rdairplay(1).
2021-02-05 Fred Gleason <fredg@paravelsystems.com>
* Removed the rddiscimport(1) utility.
2021-02-05 Fred Gleason <fredg@paravelsystems.com>
* Added 'RDGpioLogModel'.
* Refactored rdgpimon(1) to use the model-based API.

View File

@ -146,6 +146,7 @@ dist_librd_la_SOURCES = dbversion.h\
rdgetpasswd.cpp rdgetpasswd.h\
rdgpio.cpp rdgpio.h\
rdgpiolistmodel.cpp rdgpiolistmodel.h\
rdgpiologmodel.cpp rdgpiologmodel.h\
rdgpioselector.cpp rdgpioselector.h\
rdgpioslotsmodel.cpp rdgpioslotsmodel.h\
rdgrid.cpp rdgrid.h\
@ -336,6 +337,7 @@ nodist_librd_la_SOURCES = moc_rd3emptycart.cpp\
moc_rdgetpasswd.cpp\
moc_rdgpio.cpp\
moc_rdgpiolistmodel.cpp\
moc_rdgpiologmodel.cpp\
moc_rdgpioselector.cpp\
moc_rdgpioslotsmodel.cpp\
moc_rdgrouplistmodel.cpp\

View File

@ -107,6 +107,7 @@ SOURCES += rdframe.cpp
SOURCES += rdget_ath.cpp
SOURCES += rdgetpasswd.cpp
SOURCES += rdgpiolistmodel.cpp
SOURCES += rdgpiologmodel.cpp
SOURCES += rdgpioselector.cpp
SOURCES += rdgpioslotsmodel.cpp
SOURCES += rdgrid.cpp
@ -282,6 +283,7 @@ HEADERS += rdframe.h
HEADERS += rdget_ath.h
HEADERS += rdgetpasswd.h
HEADERS += rdgpiolistmodel.h
HEADERS += rdgpiologmodel.h
HEADERS += rdgpioselector.h
HEADERS += rdgpioslotsmodel.h
HEADERS += rdgrid.h

View File

@ -2572,6 +2572,29 @@ pro dobu zprávy.
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioLogModel</name>
<message>
<source>Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>On</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Off</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioSelector</name>
<message>

View File

@ -2557,6 +2557,29 @@ figure for the report period.
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioLogModel</name>
<message>
<source>Time</source>
<translation type="unfinished">Zeit</translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>On</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Off</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioSelector</name>
<message>

View File

@ -2552,6 +2552,29 @@ para el período a reportar.
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioLogModel</name>
<message>
<source>Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>On</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Off</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioSelector</name>
<message>

View File

@ -2195,6 +2195,29 @@ figure for the report period.
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioLogModel</name>
<message>
<source>Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>On</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Off</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioSelector</name>
<message>

View File

@ -2538,6 +2538,29 @@ for rapportperioden.
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioLogModel</name>
<message>
<source>Time</source>
<translation type="unfinished">Tid</translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>On</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Off</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioSelector</name>
<message>

View File

@ -2538,6 +2538,29 @@ for rapportperioden.
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioLogModel</name>
<message>
<source>Time</source>
<translation type="unfinished">Tid</translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>On</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Off</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioSelector</name>
<message>

View File

@ -2545,6 +2545,29 @@ para o período do relatório
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioLogModel</name>
<message>
<source>Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>On</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Off</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDGpioSelector</name>
<message>

300
lib/rdgpiologmodel.cpp Normal file
View File

@ -0,0 +1,300 @@
// rdgpiologmodel.cpp
//
// Data model for Rivendell GPIO log records
//
// (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 "rdgpiologmodel.h"
RDGpioLogModel::RDGpioLogModel(QObject *parent)
: QAbstractTableModel(parent)
{
d_matrix_number=0;
d_gpio_type=RDMatrix::GpioInput;
d_date_filter=QDate::currentDate();
d_state_filter=tr("On");
//
// Column Attributes
//
// unsigned left=Qt::AlignLeft|Qt::AlignVCenter;
unsigned center=Qt::AlignCenter;
unsigned right=Qt::AlignRight|Qt::AlignVCenter;
d_headers.push_back(tr("Time"));
d_alignments.push_back(center);
d_headers.push_back(tr("Line"));
d_alignments.push_back(right);
d_headers.push_back(tr("State"));
d_alignments.push_back(center);
updateModel();
}
RDGpioLogModel::~RDGpioLogModel()
{
}
QPalette RDGpioLogModel::palette()
{
return d_palette;
}
void RDGpioLogModel::setPalette(const QPalette &pal)
{
d_palette=pal;
}
void RDGpioLogModel::setFont(const QFont &font)
{
d_font=font;
d_bold_font=font;
d_bold_font.setWeight(QFont::Bold);
}
int RDGpioLogModel::columnCount(const QModelIndex &parent) const
{
return d_headers.size();
}
int RDGpioLogModel::rowCount(const QModelIndex &parent) const
{
return d_texts.size();
}
QVariant RDGpioLogModel::headerData(int section,Qt::Orientation orient,
int role) const
{
if((orient==Qt::Horizontal)&&(role==Qt::DisplayRole)) {
return d_headers.at(section);
}
return QVariant();
}
QVariant RDGpioLogModel::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:
// Nothing to do!
break;
case Qt::TextAlignmentRole:
return d_alignments.at(col);
case Qt::FontRole:
if(col==2) {
return d_bold_font;
}
return d_font;
case Qt::TextColorRole:
return d_text_colors.at(row);
case Qt::BackgroundRole:
// Nothing to do!
break;
default:
break;
}
}
return QVariant();
}
RDMatrix::GpioType RDGpioLogModel::gpioType() const
{
return d_gpio_type;
}
int RDGpioLogModel::matrixNumber() const
{
return d_matrix_number;
}
QDate RDGpioLogModel::dateFilter() const
{
return d_date_filter;
}
QString RDGpioLogModel::stateFilter() const
{
return d_state_filter;
}
void RDGpioLogModel::addEvent(int line,bool state)
{
if((d_state_filter==tr("Off")&&state)||
(d_state_filter==tr("On")&&(!state))) {
return;
}
beginInsertRows(QModelIndex(),d_texts.size(),d_texts.size());
QList<QVariant> texts;
// Time
texts.push_back(QTime::currentTime().toString("hh:mm:ss"));
// Line
texts.push_back(QString().sprintf("%d",line+1));
// State
if(state) {
texts.push_back(tr("On"));
d_text_colors.push_back(Qt::darkGreen);
}
else {
texts.push_back(tr("Off"));
d_text_colors.push_back(Qt::darkRed);
}
d_texts.push_back(texts);
endInsertRows();
}
void RDGpioLogModel::setGpioType(RDMatrix::GpioType type)
{
if(type!=d_gpio_type) {
d_gpio_type=type;
updateModel();
}
}
void RDGpioLogModel::setMatrixNumber(int matrix_num)
{
if(matrix_num!=d_matrix_number) {
d_matrix_number=matrix_num;
updateModel();
}
}
void RDGpioLogModel::setDateFilter(const QDate &date)
{
if(date!=d_date_filter) {
d_date_filter=date;
updateModel();
}
}
void RDGpioLogModel::setStateFilter(const QString &str)
{
if(str!=d_state_filter) {
d_state_filter=str;
updateModel();
}
}
void RDGpioLogModel::updateModel()
{
QList<QVariant> texts;
RDSqlQuery *q=NULL;
QString sql=sqlFields()+
"where "+
"(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
QString().sprintf("(MATRIX=%d)&&",d_matrix_number)+
QString().sprintf("(TYPE=%d)&&",d_gpio_type)+
"(EVENT_DATETIME>=\""+d_date_filter.toString("yyyy-MM-dd")+
" 00:00:00\")&&"+
"(EVENT_DATETIME<\""+d_date_filter.addDays(1).
toString("yyyy-MM-dd")+" 00:00:00\")";
if(d_state_filter==tr("On")) {
sql+="&&(EDGE=1)";
}
if(d_state_filter==tr("Off")) {
sql+="&&(EDGE=0)";
}
sql+="order by EVENT_DATETIME ";
beginResetModel();
d_texts.clear();
d_text_colors.clear();
q=new RDSqlQuery(sql);
while(q->next()) {
d_texts.push_back(texts);
d_text_colors.push_back(QVariant());
updateRow(d_texts.size()-1,q);
}
delete q;
endResetModel();
}
void RDGpioLogModel::updateRow(int row,RDSqlQuery *q)
{
QList<QVariant> texts;
// Time
texts.push_back(q->value(0).toDateTime().toString("hh:mm:ss"));
// Line
texts.push_back(QString().sprintf("%d",q->value(1).toInt()));
// State
if(q->value(2).toUInt()==0) {
texts.push_back(tr("Off"));
d_text_colors[row]=Qt::darkRed;
}
else {
texts.push_back(tr("On"));
d_text_colors[row]=Qt::darkGreen;
}
d_texts[row]=texts;
}
QString RDGpioLogModel::sqlFields() const
{
QString sql=QString("select ")+
"EVENT_DATETIME,"+ // 00
"NUMBER,"+ // 01
"EDGE "+ // 02
"from GPIO_EVENTS ";
return sql;
}

81
lib/rdgpiologmodel.h Normal file
View File

@ -0,0 +1,81 @@
// rdgpiologmodel.h
//
// Data model for Rivendell GPIO log records
//
// (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 RDGPIOLOGMODEL_H
#define RDGPIOLOGMODEL_H
#include <QAbstractTableModel>
#include <QFont>
#include <QList>
#include <QPalette>
#include <rddb.h>
#include <rdmatrix.h>
#include <rdnotification.h>
#include <rduser.h>
class RDGpioLogModel : public QAbstractTableModel
{
Q_OBJECT
public:
RDGpioLogModel(QObject *parent=0);
~RDGpioLogModel();
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;
RDMatrix::GpioType gpioType() const;
int matrixNumber() const;
QDate dateFilter() const;
QString stateFilter() const;
void addEvent(int line,bool state);
public slots:
void setGpioType(RDMatrix::GpioType type);
void setMatrixNumber(int matrix_num);
void setDateFilter(const QDate &date);
void setStateFilter(const QString &str);
protected:
void updateModel();
void updateRow(int row,RDSqlQuery *q);
QString sqlFields() const;
private:
QPalette d_palette;
QFont d_font;
QFont d_bold_font;
bool d_include_none;
QList<QVariant> d_headers;
QList<QVariant> d_alignments;
QList<QList<QVariant> > d_texts;
QList<QVariant> d_text_colors;
int d_matrix_number;
RDMatrix::GpioType d_gpio_type;
QDate d_date_filter;
QString d_state_filter;
};
#endif // RDGPIOLOGMODEL_H

View File

@ -2,7 +2,7 @@
//
// A Qt-based application for testing General Purpose Input (GPI) devices.
//
// (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
@ -28,11 +28,6 @@
#include "rdgpimon.h"
//
// Icons
//
#include "../icons/rivendell-22x22.xpm"
MainWidget::MainWidget(RDConfig *c,QWidget *parent)
: RDWidget(c,parent)
{
@ -66,12 +61,7 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
//
setMinimumSize(sizeHint());
setMaximumSize(sizeHint());
//
// Create And Set Icon
//
gpi_rivendell_map=new QPixmap(rivendell_22x22_xpm);
setWindowIcon(*gpi_rivendell_map);
setWindowIcon(rda->iconEngine()->applicationIcon(RDIconEngine::Rivendell,22));
//
// RIPC Connection
@ -186,11 +176,10 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
label->setAlignment(Qt::AlignCenter);
label->setGeometry(110,423,sizeHint().width()-220,30);
gpi_events_date_edit=new Q3DateEdit(this);
gpi_events_date_edit=new QDateEdit(this);
gpi_events_date_edit->setDisplayFormat("dd/MM/yyyy");
gpi_events_date_edit->setGeometry(155,453,100,20);
gpi_events_date_edit->setDate(QDate::currentDate());
connect(gpi_events_date_edit,SIGNAL(valueChanged(const QDate &)),
this,SLOT(eventsDateChangedData(const QDate &)));
gpi_events_date_label=new QLabel(gpi_events_date_edit,tr("Date")+":",this);
gpi_events_date_label->setGeometry(100,453,50,20);
gpi_events_date_label->setFont(labelFont());
@ -201,29 +190,27 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
gpi_events_state_box->insertItem(tr("On"));
gpi_events_state_box->insertItem(tr("Off"));
gpi_events_state_box->insertItem(tr("Both"));
connect(gpi_events_state_box,SIGNAL(activated(int)),
this,SLOT(eventsStateChangedData(int)));
gpi_events_state_label=new QLabel(gpi_events_state_box,tr("State")+":",this);
gpi_events_state_label->setGeometry(275,453,50,20);
gpi_events_state_label->setFont(labelFont());
gpi_events_state_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
gpi_events_list=new RDListView(this);
gpi_events_list->setGeometry(110,480,sizeHint().width()-220,230);
gpi_events_list->setItemMargin(5);
gpi_events_list->setSelectionMode(Q3ListView::NoSelection);
gpi_events_list->addColumn("Time");
gpi_events_list->setColumnAlignment(0,Qt::AlignHCenter);
gpi_events_list->setColumnSortType(1,RDListView::TimeSort);
gpi_events_list->addColumn(tr("Line"));
gpi_events_list->setColumnAlignment(1,Qt::AlignHCenter);
gpi_events_list->setColumnSortType(1,RDListView::GpioSort);
gpi_events_list->addColumn(tr("State"));
gpi_events_list->setColumnAlignment(2,Qt::AlignHCenter);
gpi_events_view=new RDTableView(this);
gpi_events_view->setGeometry(110,480,sizeHint().width()-220,230);
gpi_events_view->setSelectionMode(QAbstractItemView::NoSelection);
gpi_events_model=new RDGpioLogModel(this);
gpi_events_model->setFont(defaultFont());
gpi_events_model->setPalette(palette());
gpi_events_view->setModel(gpi_events_model);
connect(gpi_events_model,SIGNAL(modelReset()),
gpi_events_view,SLOT(resizeColumnsToContents()));
connect(gpi_events_date_edit,SIGNAL(dateChanged(const QDate &)),
gpi_events_model,SLOT(setDateFilter(const QDate &)));
connect(gpi_events_state_box,SIGNAL(activated(const QString &)),
gpi_events_model,SLOT(setStateFilter(const QString &)));
connect(gpi_events_model,SIGNAL(rowsInserted(const QModelIndex &,int,int)),
this,SLOT(rowsInsertedData(const QModelIndex &,int,int)));
gpi_events_view->resizeColumnsToContents();
gpi_events_scroll_button=new QPushButton(tr("Scroll"),this);
gpi_events_scroll_button->setGeometry(sizeHint().width()-100,510,80,50);
gpi_events_scroll_button->setFont(buttonFont());
@ -298,23 +285,15 @@ void MainWidget::matrixActivatedData(int index)
new RDMatrix(rda->config()->stationName(),gpi_matrix_box->currentItem());
UpdateLabelsDown(0);
gpi_up_button->setDisabled(true);
RefreshEventsList();
// RefreshEventsList();
gpi_events_model->
setGpioType((RDMatrix::GpioType)gpi_type_box->currentIndex());
gpi_events_model->setMatrixNumber(index);
gpi_events_startup_timer->start(1000,true);
}
void MainWidget::eventsDateChangedData(const QDate &date)
{
RefreshEventsList();
}
void MainWidget::eventsStateChangedData(int n)
{
RefreshEventsList();
}
void MainWidget::eventsScrollData()
{
if(gpi_scroll_mode) {
@ -324,15 +303,8 @@ void MainWidget::eventsScrollData()
else {
gpi_events_scroll_button->setPalette(gpi_scroll_color);
gpi_scroll_mode=true;
RDListViewItem *item=(RDListViewItem *)gpi_events_list->firstChild();
RDListViewItem *last=NULL;
while(item!=NULL) {
last=item;
item=(RDListViewItem *)item->nextSibling();
}
if(last!=NULL) {
gpi_events_list->ensureItemVisible(last);
}
gpi_events_view->
scrollTo(gpi_events_model->index(gpi_events_model->rowCount()-1,0));
}
}
@ -390,6 +362,14 @@ void MainWidget::eventsReportData()
}
void MainWidget::rowsInsertedData(const QModelIndex &parent,int start,int end)
{
if(gpi_scroll_mode) {
gpi_events_view->scrollTo(gpi_events_model->index(end,0));
}
}
void MainWidget::gpiStateChangedData(int matrix,int line,bool state)
{
// printf("gpiStateChanged(%d,%d,%d)\n",matrix,line,state);
@ -669,48 +649,6 @@ void MainWidget::RefreshGpioStates()
}
void MainWidget::RefreshEventsList()
{
QString sql;
RDSqlQuery *q;
sql=QString("select EVENT_DATETIME,NUMBER,EDGE from GPIO_EVENTS where ")+
"(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
QString().sprintf("(MATRIX=%d)&&",gpi_matrix_box->currentItem())+
QString().sprintf("(TYPE=%d)&&",gpi_type_box->currentItem())+
"(EVENT_DATETIME>=\""+gpi_events_date_edit->date().toString("yyyy-MM-dd")+
" 00:00:00\")&&"+
"(EVENT_DATETIME<\""+gpi_events_date_edit->date().addDays(1).
toString("yyyy-MM-dd")+" 00:00:00\")";
if(gpi_events_state_box->currentItem()==0) {
sql+="&&(EDGE=1)";
}
if(gpi_events_state_box->currentItem()==1) {
sql+="&&(EDGE=0)";
}
q=new RDSqlQuery(sql);
gpi_events_list->clear();
RDListViewItem *item=NULL;
while(q->next()) {
item=new RDListViewItem(gpi_events_list);
item->setText(0,q->value(0).toDateTime().toString("hh:mm:ss"));
item->setText(1,QString().sprintf("%d",q->value(1).toInt()));
if(q->value(2).toInt()==0) {
item->setText(2,tr("Off"));
item->setTextColor(Qt::darkRed);
}
else {
item->setText(2,tr("On"));
item->setTextColor(Qt::darkGreen);
}
}
if(gpi_scroll_mode&&(item!=NULL)) {
gpi_events_list->ensureItemVisible(item);
}
delete q;
}
void MainWidget::AddEventsItem(int line,bool state)
{
if(gpi_events_startup_timer->isActive()) {
@ -722,20 +660,7 @@ void MainWidget::AddEventsItem(int line,bool state)
if((gpi_events_state_box->currentItem()==1)&&state) {
return;
}
RDListViewItem *item=new RDListViewItem(gpi_events_list);
item->setText(0,QTime::currentTime().toString("hh:mm:ss"));
item->setText(1,QString().sprintf("%d",line+1));
if(state) {
item->setText(2,tr("On"));
item->setTextColor(Qt::darkGreen);
}
else {
item->setText(2,tr("Off"));
item->setTextColor(Qt::darkRed);
}
if(gpi_scroll_mode) {
gpi_events_list->ensureItemVisible(item);
}
gpi_events_model->addEvent(line,state);
}

View File

@ -1,8 +1,8 @@
// rdgpimon.h
//
// A Qt-based application for testing general purpose input (GPI) devices.
// A Qt-based application for monitoring general purpose input (GPI) devices.
//
// (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,12 +21,13 @@
#ifndef RDGPIMON_H
#define RDGPIMON_H
#include <q3datetimeedit.h>
#include <qcombobox.h>
#include <QComboBox>
#include <QDateTimeEdit>
#include <rdmatrix.h>
#include <rdtransportbutton.h>
#include <rdgpiologmodel.h>
#include <rdtableview.h>
#include <rdwidget.h>
#include "gpi_label.h"
@ -49,10 +50,9 @@ class MainWidget : public RDWidget
void userData();
void typeActivatedData(int index);
void matrixActivatedData(int index);
void eventsDateChangedData(const QDate &date);
void eventsStateChangedData(int n);
void eventsScrollData();
void eventsReportData();
void rowsInsertedData(const QModelIndex &parent,int start,int end);
void gpiStateChangedData(int matrix,int line,bool state);
void gpoStateChangedData(int matrix,int line,bool state);
void gpiMaskChangedData(int matrix,int line,bool state);
@ -68,23 +68,22 @@ class MainWidget : public RDWidget
void UpdateLabelsUp(int last_line);
void UpdateLabelsDown(int first_line);
void RefreshGpioStates();
void RefreshEventsList();
void AddEventsItem(int line,bool state);
RDMatrix *gpi_matrix;
QComboBox *gpi_type_box;
QComboBox *gpi_matrix_box;
QPixmap *gpi_rivendell_map;
GpiLabel *gpi_labels[GPIMON_ROWS*GPIMON_COLS];
RDTransportButton *gpi_up_button;
RDTransportButton *gpi_down_button;
int gpi_first_line;
int gpi_last_line;
QLabel *gpi_events_date_label;
Q3DateEdit *gpi_events_date_edit;
QDateEdit *gpi_events_date_edit;
QLabel *gpi_events_state_label;
QComboBox *gpi_events_state_box;
QPushButton *gpi_events_scroll_button;
RDListView *gpi_events_list;
RDTableView *gpi_events_view;
RDGpioLogModel *gpi_events_model;
QTimer *gpi_events_startup_timer;
bool gpi_scroll_mode;
QPalette gpi_scroll_color;

View File

@ -31,10 +31,6 @@
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>

View File

@ -56,10 +56,6 @@
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>

View File

@ -56,10 +56,6 @@
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>

View File

@ -31,10 +31,6 @@
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>

View File

@ -56,10 +56,6 @@
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>

View File

@ -56,10 +56,6 @@
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>

View File

@ -31,10 +31,6 @@
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>