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

* Added 'RDServiceListModel' class
	* Refactored the 'List Services' 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-22 09:06:47 -05:00
parent a3525c88e2
commit 52cb6be95f
23 changed files with 770 additions and 97 deletions

View File

@ -20860,3 +20860,7 @@
2021-01-20 Fred Gleason <fredg@paravelsystems.com> 2021-01-20 Fred Gleason <fredg@paravelsystems.com>
* Split the 'RDApplication' class into the base class * Split the 'RDApplication' class into the base class
'RDCoreApplication' and 'RDApplication'. 'RDCoreApplication' and 'RDApplication'.
2021-01-22 Fred Gleason <fredg@paravelsystems.com>
* Added 'RDServiceListModel' class
* Refactored the 'List Services' dialog in rdadmin(1) to use the
model-based API.

View File

@ -216,6 +216,7 @@ dist_librd_la_SOURCES = dbversion.h\
rdschedruleslist.cpp rdschedruleslist.h\ rdschedruleslist.cpp rdschedruleslist.h\
rdsegmeter.cpp rdsegmeter.h\ rdsegmeter.cpp rdsegmeter.h\
rdsendmail.cpp rdsendmail.h\ rdsendmail.cpp rdsendmail.h\
rdservicelistmodel.cpp rdservicelistmodel.h\
rdsettings.cpp rdsettings.h\ rdsettings.cpp rdsettings.h\
rdsimpleplayer.cpp rdsimpleplayer.h\ rdsimpleplayer.cpp rdsimpleplayer.h\
rdslider.cpp rdslider.h\ rdslider.cpp rdslider.h\
@ -346,6 +347,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\
moc_rdschedcodes_dialog.cpp\ moc_rdschedcodes_dialog.cpp\
moc_rdrsscategorybox.cpp\ moc_rdrsscategorybox.cpp\
moc_rdsegmeter.cpp\ moc_rdsegmeter.cpp\
moc_rdservicelistmodel.cpp\
moc_rdsimpleplayer.cpp\ moc_rdsimpleplayer.cpp\
moc_rdslider.cpp\ moc_rdslider.cpp\
moc_rdsocket.cpp\ moc_rdsocket.cpp\

View File

@ -157,6 +157,7 @@ SOURCES += rdschedcode.cpp
SOURCES += rdsegmeter.cpp SOURCES += rdsegmeter.cpp
SOURCES += rdsendmail.cpp SOURCES += rdsendmail.cpp
SOURCES += rdsettings.cpp SOURCES += rdsettings.cpp
SOURCES += rdservicelistmodel.cpp
SOURCES += rdsimpleplayer.cpp SOURCES += rdsimpleplayer.cpp
SOURCES += rdslider.cpp SOURCES += rdslider.cpp
SOURCES += rdsocket.cpp SOURCES += rdsocket.cpp
@ -309,6 +310,7 @@ HEADERS += rdrsscategorybox.h
HEADERS += rdschedcode.h HEADERS += rdschedcode.h
HEADERS += rdsegmeter.h HEADERS += rdsegmeter.h
HEADERS += rdsendmail.h HEADERS += rdsendmail.h
HEADERS += rdservicelistmodel.h
HEADERS += rdsettings.h HEADERS += rdsettings.h
HEADERS += rdsimpleplayer.h HEADERS += rdsimpleplayer.h
HEADERS += rdslider.h HEADERS += rdslider.h

View File

@ -3441,6 +3441,45 @@ Zkuste to, prosím, znovu!</translation>
<translation type="obsolete">Music1 Reconciliation</translation> <translation type="obsolete">Music1 Reconciliation</translation>
</message> </message>
</context> </context>
<context>
<name>RDServiceListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pgm Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Track Group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ELR Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Auto Refresh</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Chain Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import Markers</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RDSoundPanel</name> <name>RDSoundPanel</name>
<message> <message>

View File

@ -3422,6 +3422,45 @@ bitte erneut versuchen!</translation>
<translation type="obsolete">Music1 Reconciliation</translation> <translation type="obsolete">Music1 Reconciliation</translation>
</message> </message>
</context> </context>
<context>
<name>RDServiceListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pgm Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Track Group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ELR Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Auto Refresh</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Chain Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import Markers</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RDSoundPanel</name> <name>RDSoundPanel</name>
<message> <message>

View File

@ -3401,6 +3401,45 @@ please try again!</source>
<translation type="obsolete">Reconciliación Music1</translation> <translation type="obsolete">Reconciliación Music1</translation>
</message> </message>
</context> </context>
<context>
<name>RDServiceListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pgm Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Track Group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ELR Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Auto Refresh</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Chain Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import Markers</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RDSoundPanel</name> <name>RDSoundPanel</name>
<message> <message>

View File

@ -2702,6 +2702,45 @@ please try again!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>RDServiceListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pgm Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Track Group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ELR Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Auto Refresh</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Chain Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import Markers</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RDSoundPanel</name> <name>RDSoundPanel</name>
<message> <message>

View File

@ -3304,6 +3304,45 @@ prøv ein gong til!</translation>
<translation type="obsolete">Greidde ikkje opna rapportfil!</translation> <translation type="obsolete">Greidde ikkje opna rapportfil!</translation>
</message> </message>
</context> </context>
<context>
<name>RDServiceListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pgm Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Track Group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ELR Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Auto Refresh</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Chain Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import Markers</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RDSoundPanel</name> <name>RDSoundPanel</name>
<message> <message>

View File

@ -3304,6 +3304,45 @@ prøv ein gong til!</translation>
<translation type="obsolete">Greidde ikkje opna rapportfil!</translation> <translation type="obsolete">Greidde ikkje opna rapportfil!</translation>
</message> </message>
</context> </context>
<context>
<name>RDServiceListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pgm Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Track Group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ELR Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Auto Refresh</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Chain Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import Markers</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RDSoundPanel</name> <name>RDSoundPanel</name>
<message> <message>

View File

@ -3355,6 +3355,45 @@ por favor, tente novamente!</translation>
<translation type="obsolete">Não foi possível abrir o Relatório!</translation> <translation type="obsolete">Não foi possível abrir o Relatório!</translation>
</message> </message>
</context> </context>
<context>
<name>RDServiceListModel</name>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pgm Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Track Group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ELR Shelf Life</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Auto Refresh</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Chain Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import Markers</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>RDSoundPanel</name> <name>RDSoundPanel</name>
<message> <message>

320
lib/rdservicelistmodel.cpp Normal file
View File

@ -0,0 +1,320 @@
// rdservicelistmodel.cpp
//
// Data model for Rivendell services
//
// (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 "rdservicelistmodel.h"
RDServiceListModel::RDServiceListModel(QObject *parent)
: QAbstractTableModel(parent)
{
//
// Column Attributes
//
unsigned left=Qt::AlignLeft|Qt::AlignVCenter;
unsigned center=Qt::AlignCenter;
unsigned right=Qt::AlignRight|Qt::AlignVCenter;
d_headers.push_back(tr("Name"));
d_alignments.push_back(left);
d_headers.push_back(tr("Description"));
d_alignments.push_back(left);
d_headers.push_back(tr("Pgm Code"));
d_alignments.push_back(left);
d_headers.push_back(tr("Track Group"));
d_alignments.push_back(left);
d_headers.push_back(tr("Log Shelf Life"));
d_alignments.push_back(right);
d_headers.push_back(tr("ELR Shelf Life"));
d_alignments.push_back(right);
d_headers.push_back(tr("Auto Refresh"));
d_alignments.push_back(center);
d_headers.push_back(tr("Chain Log"));
d_alignments.push_back(center);
d_headers.push_back(tr("Import Markers"));
d_alignments.push_back(center);
updateModel();
}
RDServiceListModel::~RDServiceListModel()
{
}
QPalette RDServiceListModel::palette()
{
return d_palette;
}
void RDServiceListModel::setPalette(const QPalette &pal)
{
d_palette=pal;
}
void RDServiceListModel::setFont(const QFont &font)
{
d_font=font;
d_bold_font=font;
d_bold_font.setWeight(QFont::Bold);
}
int RDServiceListModel::columnCount(const QModelIndex &parent) const
{
return d_headers.size();
}
int RDServiceListModel::rowCount(const QModelIndex &parent) const
{
return d_texts.size();
}
QVariant RDServiceListModel::headerData(int section,Qt::Orientation orient,
int role) const
{
if((orient==Qt::Horizontal)&&(role==Qt::DisplayRole)) {
return d_headers.at(section);
}
return QVariant();
}
QVariant RDServiceListModel::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==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();
}
QString RDServiceListModel::serviceName(const QModelIndex &row) const
{
return d_texts.at(row.row()).at(0).toString();
}
QModelIndex RDServiceListModel::addService(const QString &svcname)
{
//
// Find the insertion offset
//
int offset=d_texts.size();
for(int i=0;i<d_texts.size();i++) {
if(svcname.toLower()<d_texts.at(i).at(0).toString().toLower()) {
offset=i;
break;
}
}
beginInsertRows(QModelIndex(),offset,offset);
QList<QVariant> list;
for(int i=0;i<columnCount();i++) {
list.push_back(QVariant());
}
list[0]=svcname;
d_texts.insert(offset,list);
updateRowLine(offset);
endInsertRows();
return createIndex(offset,0);
}
void RDServiceListModel::removeService(const QModelIndex &row)
{
beginRemoveRows(QModelIndex(),row.row(),row.row());
d_texts.removeAt(row.row());
endRemoveRows();
}
void RDServiceListModel::removeService(const QString &svcname)
{
for(int i=0;i<d_texts.size();i++) {
if(d_texts.at(i).at(0)==svcname) {
removeService(createIndex(i,0));
return;
}
}
}
void RDServiceListModel::refresh(const QModelIndex &row)
{
if(row.row()<d_texts.size()) {
QString sql=sqlFields()+
"where SERVICES.NAME=\""+
RDEscapeString(d_texts.at(row.row()).at(0).toString())+
"\"";
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 RDServiceListModel::refresh(const QString &grpname)
{
for(int i=0;i<d_texts.size();i++) {
if(d_texts.at(i).at(0)==grpname) {
updateRowLine(i);
return;
}
}
}
void RDServiceListModel::updateModel()
{
QList<QVariant> texts;
QList<QVariant> icons;
RDSqlQuery *q=NULL;
QString sql=sqlFields();
sql+="order by NAME ";
beginResetModel();
d_texts.clear();
q=new RDSqlQuery(sql);
while(q->next()) {
d_texts.push_back(texts);
updateRow(d_texts.size()-1,q);
}
delete q;
endResetModel();
}
void RDServiceListModel::updateRowLine(int line)
{
if(line<d_texts.size()) {
QString sql=sqlFields()+
"where NAME=\""+RDEscapeString(d_texts.at(line).at(0).toString())+"\"";
RDSqlQuery *q=new RDSqlQuery(sql);
if(q->first()) {
updateRow(line,q);
}
delete q;
}
}
void RDServiceListModel::updateRow(int row,RDSqlQuery *q)
{
QList<QVariant> texts;
// Login Name
texts.push_back(q->value(0));
// Description
texts.push_back(q->value(1));
// Program Code
texts.push_back(q->value(2));
// Track Group
texts.push_back(q->value(3));
// Log Shelf Life
texts.push_back(q->value(4));
// ELR Shelf Life
texts.push_back(q->value(5));
// Auto Refresh
texts.push_back(q->value(6));
// Chain Log
texts.push_back(q->value(7));
// Import Markers
texts.push_back(q->value(8));
d_texts[row]=texts;
}
QString RDServiceListModel::sqlFields() const
{
QString sql=QString("select ")+
"SERVICES.NAME,"+ // 00
"SERVICES.DESCRIPTION,"+ // 01
"SERVICES.PROGRAM_CODE,"+ // 02
"SERVICES.TRACK_GROUP,"+ // 03
"SERVICES.DEFAULT_LOG_SHELFLIFE,"+ // 04
"SERVICES.ELR_SHELFLIFE,"+ // 05
"SERVICES.AUTO_REFRESH,"+ // 06
"SERVICES.CHAIN_LOG,"+ // 07
"SERVICES.INCLUDE_IMPORT_MARKERS "+ // 08
"from SERVICES ";
return sql;
}

78
lib/rdservicelistmodel.h Normal file
View File

@ -0,0 +1,78 @@
// rdservicelistmodel.h
//
// Data model for Rivendell services
//
// (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 RDSERVICELISTMODEL_H
#define RDSERVICELISTMODEL_H
#include <QAbstractTableModel>
#include <QFont>
#include <QList>
#include <QPalette>
#include <rddb.h>
#include <rdnotification.h>
#include <rduser.h>
//
// MAINTAINERS NOTE
//
// We could arguably just use a QSqlQueryModel for this, but rolling our own
// lets us use the same backend-facing API pattern as the other Rivendell
// models.
//
class RDServiceListModel : public QAbstractTableModel
{
Q_OBJECT
public:
RDServiceListModel(QObject *parent=0);
~RDServiceListModel();
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;
QString serviceName(const QModelIndex &row) const;
QModelIndex addService(const QString &name);
void removeService(const QModelIndex &row);
void removeService(const QString &svcname);
void refresh(const QModelIndex &row);
void refresh(const QString &username);
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;
QStringList d_service_names;
QList<QVariant> d_headers;
QList<QVariant> d_alignments;
QList<QList<QVariant> > d_texts;
};
#endif // RDSERVICELISTMODEL_H

View File

@ -174,15 +174,15 @@ void AddSvc::okData()
EditSvc *edit_svc=new EditSvc(svc_name_edit->text(),this); EditSvc *edit_svc=new EditSvc(svc_name_edit->text(),this);
if(edit_svc->exec()<0) { if(edit_svc->exec()<0) {
delete edit_svc; delete edit_svc;
done(-1); done(false);
return; return;
} }
delete edit_svc; delete edit_svc;
done(0); done(true);
} }
void AddSvc::cancelData() void AddSvc::cancelData()
{ {
done(-1); done(false);
} }

View File

@ -706,13 +706,13 @@ void EditSvc::musTemplateActivatedData(int index)
void EditSvc::okData() void EditSvc::okData()
{ {
Save(); Save();
done(0); done(true);
} }
void EditSvc::cancelData() void EditSvc::cancelData()
{ {
done(-1); done(false);
} }

View File

@ -2,7 +2,7 @@
// //
// List Rivendell Services // List Rivendell Services
// //
// (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
@ -18,15 +18,11 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// //
#include <qdialog.h> #include <QPainter>
#include <qstring.h> #include <QEvent>
#include <qpushbutton.h> #include <QMessageBox>
#include <q3listbox.h>
#include <q3textedit.h> #include <q3textedit.h>
#include <qlabel.h>
#include <qpainter.h>
#include <qevent.h>
#include <qmessagebox.h>
#include <q3buttongroup.h> #include <q3buttongroup.h>
#include <rdapplication.h> #include <rdapplication.h>
@ -41,8 +37,6 @@
ListSvcs::ListSvcs(QWidget *parent) ListSvcs::ListSvcs(QWidget *parent)
: RDDialog(parent) : RDDialog(parent)
{ {
setModal(true);
// //
// Fix the Window Size // Fix the Window Size
// //
@ -86,20 +80,31 @@ ListSvcs::ListSvcs(QWidget *parent)
// //
// Services List Box // Services List Box
// //
list_box=new Q3ListBox(this); list_services_view=new QTableView(this);
list_title_label=new QLabel(list_box,tr("&Services:"),this); list_title_label=new QLabel(list_services_view,tr("&Services:"),this);
list_title_label->setFont(labelFont()); list_title_label->setFont(labelFont());
list_title_label->setGeometry(14,11,85,19); list_title_label->setGeometry(14,11,85,19);
connect(list_box,SIGNAL(doubleClicked(Q3ListBoxItem *)), list_services_view->setSelectionBehavior(QAbstractItemView::SelectRows);
this,SLOT(doubleClickedData(Q3ListBoxItem *))); list_services_view->setSelectionMode(QAbstractItemView::SingleSelection);
list_services_view->setShowGrid(false);
RefreshList(); list_services_view->setSortingEnabled(false);
list_services_view->setWordWrap(false);
list_services_model=new RDServiceListModel(this);
list_services_model->setFont(defaultFont());
list_services_model->setPalette(palette());
list_services_view->setModel(list_services_model);
connect(list_services_view,SIGNAL(doubleClicked(const QModelIndex &)),
this,SLOT(doubleClickedData(const QModelIndex &)));
connect(list_services_model,SIGNAL(modelReset()),
list_services_view,SLOT(resizeColumnsToContents()));
list_services_view->resizeColumnsToContents();
} }
ListSvcs::~ListSvcs() ListSvcs::~ListSvcs()
{ {
delete list_box; delete list_services_model;
delete list_services_view;
} }
@ -119,24 +124,27 @@ void ListSvcs::addData()
{ {
QString svcname; QString svcname;
AddSvc *add_svc=new AddSvc(&svcname,this); AddSvc *d=new AddSvc(&svcname,this);
if(add_svc->exec()<0) { if(d->exec()) {
delete add_svc; QModelIndex index=list_services_model->addService(svcname);
return; list_services_view->selectRow(index.row());
} }
delete add_svc; delete d;
RefreshList(svcname);
} }
void ListSvcs::editData() void ListSvcs::editData()
{ {
if(list_box->currentItem()<0) { QModelIndexList rows=list_services_view->selectionModel()->selectedRows();
if(rows.size()!=1) {
return; return;
} }
EditSvc *edit_svc=new EditSvc(list_box->currentText(),this); EditSvc *d=new EditSvc(list_services_model->serviceName(rows.first()),this);
edit_svc->exec(); if(d->exec()) {
delete edit_svc; list_services_model->refresh(rows.first());
}
delete d;
} }
@ -144,15 +152,21 @@ void ListSvcs::deleteData()
{ {
QString sql; QString sql;
RDSqlQuery *q; RDSqlQuery *q;
QModelIndexList rows=list_services_view->selectionModel()->selectedRows();
if(rows.size()!=1) {
return;
}
QString svcname=list_services_model->serviceName(rows.first());
if(QMessageBox::warning(this,"RDAdmin- "+tr("Delete Service"), if(QMessageBox::warning(this,"RDAdmin- "+tr("Delete Service"),
tr("Are you sure you want to delete service")+ tr("Are you sure you want to delete service")+
" \""+list_box->currentText()+"\"?", " \""+svcname+"\"?",
QMessageBox::Yes,QMessageBox::No)!=QMessageBox::Yes) { QMessageBox::Yes,QMessageBox::No)!=QMessageBox::Yes) {
return; return;
} }
sql=QString("select NAME from LOGS where ")+ sql=QString("select NAME from LOGS where ")+
"SERVICE=\""+RDEscapeString(list_box->currentText())+"\""; "SERVICE=\""+RDEscapeString(svcname)+"\"";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
if(q->first()) { if(q->first()) {
if(QMessageBox::warning(this,"RDAdmin - "+tr("Logs Exist"), if(QMessageBox::warning(this,"RDAdmin - "+tr("Logs Exist"),
@ -165,23 +179,20 @@ void ListSvcs::deleteData()
} }
} }
delete q; delete q;
RDSvc *svc=new RDSvc(list_box->currentText(),rda->station(),rda->config()); RDSvc *svc=new RDSvc(svcname,rda->station(),rda->config());
svc->remove(); svc->remove();
delete svc; delete svc;
list_box->removeItem(list_box->currentItem()); list_services_model->removeService(svcname);
if(list_box->currentItem()>=0) {
list_box->setSelected(list_box->currentItem(),true);
}
} }
void ListSvcs::closeData() void ListSvcs::closeData()
{ {
done(0); done(true);
} }
void ListSvcs::doubleClickedData(Q3ListBoxItem *item) void ListSvcs::doubleClickedData(const QModelIndex &index)
{ {
editData(); editData();
} }
@ -193,22 +204,5 @@ void ListSvcs::resizeEvent(QResizeEvent *e)
list_edit_button->setGeometry(size().width()-90,90,80,50); list_edit_button->setGeometry(size().width()-90,90,80,50);
list_delete_button->setGeometry(size().width()-90,150,80,50); list_delete_button->setGeometry(size().width()-90,150,80,50);
list_close_button->setGeometry(size().width()-90,size().height()-60,80,50); list_close_button->setGeometry(size().width()-90,size().height()-60,80,50);
list_box->setGeometry(10,30,size().width()-110,size().height()-40); list_services_view->setGeometry(10,30,size().width()-110,size().height()-40);
}
void ListSvcs::RefreshList(QString svcname)
{
QString sql;
RDSqlQuery *q;
list_box->clear();
q=new RDSqlQuery("select NAME from SERVICES");
while (q->next()) {
list_box->insertItem(q->value(0).toString());
if(svcname==list_box->text(list_box->count()-1)) {
list_box->setCurrentItem(list_box->count()-1);
}
}
delete q;
} }

View File

@ -2,7 +2,7 @@
// //
// List Rivendell Services // List Rivendell Services
// //
// (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,12 +21,12 @@
#ifndef LIST_SVCS_H #ifndef LIST_SVCS_H
#define LIST_SVCS_H #define LIST_SVCS_H
#include <q3listbox.h> #include <QLabel>
#include <QPushButton>
#include <qlabel.h> #include <QTableView>
#include <qpushbutton.h>
#include <rddialog.h> #include <rddialog.h>
#include <rdservicelistmodel.h>
class ListSvcs : public RDDialog class ListSvcs : public RDDialog
{ {
@ -41,16 +41,16 @@ class ListSvcs : public RDDialog
void addData(); void addData();
void editData(); void editData();
void deleteData(); void deleteData();
void doubleClickedData(Q3ListBoxItem *); void doubleClickedData(const QModelIndex &index);
void closeData(); void closeData();
protected: protected:
void resizeEvent(QResizeEvent *e); void resizeEvent(QResizeEvent *e);
private: private:
void RefreshList(QString svcname="");
QLabel *list_title_label; QLabel *list_title_label;
Q3ListBox *list_box; QTableView *list_services_view;
RDServiceListModel *list_services_model;
QPushButton *list_add_button; QPushButton *list_add_button;
QPushButton *list_edit_button; QPushButton *list_edit_button;
QPushButton *list_delete_button; QPushButton *list_delete_button;

View File

@ -6144,15 +6144,15 @@ vozíky</translation>
</message> </message>
<message> <message>
<source>Are you sure you want to delete service</source> <source>Are you sure you want to delete service</source>
<translation>Opravdu chcete smazat tuto službu</translation> <translation type="unfinished">Opravdu chcete smazat tuto službu</translation>
</message> </message>
<message> <message>
<source>Delete Service</source> <source>Delete Service</source>
<translation>Smazat službu</translation> <translation type="unfinished">Smazat službu</translation>
</message> </message>
<message> <message>
<source>There are</source> <source>There are</source>
<translation>Jsou tu</translation> <translation type="unfinished">Jsou tu</translation>
</message> </message>
<message> <message>
<source>logs owned by this service that will also be deleted. <source>logs owned by this service that will also be deleted.
@ -6162,7 +6162,7 @@ Stále ještě chcete pokračovat?</translation>
</message> </message>
<message> <message>
<source>Logs Exist</source> <source>Logs Exist</source>
<translation>Zápisy existují</translation> <translation type="unfinished">Zápisy existují</translation>
</message> </message>
<message> <message>
<source>logs owned by this service that will also be deleted.</source> <source>logs owned by this service that will also be deleted.</source>

View File

@ -5840,15 +5840,15 @@ Carts</source>
</message> </message>
<message> <message>
<source>Are you sure you want to delete service</source> <source>Are you sure you want to delete service</source>
<translation>Sind Sie sicher, daß sie den Service löschen wollen</translation> <translation type="unfinished">Sind Sie sicher, daß sie den Service löschen wollen</translation>
</message> </message>
<message> <message>
<source>Delete Service</source> <source>Delete Service</source>
<translation>Service löschen</translation> <translation type="unfinished">Service löschen</translation>
</message> </message>
<message> <message>
<source>There are</source> <source>There are</source>
<translation>Es gibt</translation> <translation type="unfinished">Es gibt</translation>
</message> </message>
<message> <message>
<source>logs owned by this service that will also be deleted. <source>logs owned by this service that will also be deleted.
@ -5858,7 +5858,7 @@ Wollen Sie immernoch fortfahren?</translation>
</message> </message>
<message> <message>
<source>Logs Exist</source> <source>Logs Exist</source>
<translation>Logs existieren</translation> <translation type="unfinished">Logs existieren</translation>
</message> </message>
<message> <message>
<source>logs owned by this service that will also be deleted.</source> <source>logs owned by this service that will also be deleted.</source>

View File

@ -6098,15 +6098,15 @@ Cartuchos</translation>
</message> </message>
<message> <message>
<source>Are you sure you want to delete service</source> <source>Are you sure you want to delete service</source>
<translation>Está seguro de querer eliminar este servicio</translation> <translation type="unfinished">Está seguro de querer eliminar este servicio</translation>
</message> </message>
<message> <message>
<source>Delete Service</source> <source>Delete Service</source>
<translation>Eliminar un servicio</translation> <translation type="unfinished">Eliminar un servicio</translation>
</message> </message>
<message> <message>
<source>There are</source> <source>There are</source>
<translation>Hay </translation> <translation type="unfinished">Hay </translation>
</message> </message>
<message> <message>
<source>logs owned by this service that will also be deleted. <source>logs owned by this service that will also be deleted.
@ -6116,7 +6116,7 @@ Do you still want to proceed?</source>
</message> </message>
<message> <message>
<source>Logs Exist</source> <source>Logs Exist</source>
<translation>El PlayList ya existe</translation> <translation type="unfinished">El PlayList ya existe</translation>
</message> </message>
<message> <message>
<source>logs owned by this service that will also be deleted.</source> <source>logs owned by this service that will also be deleted.</source>

View File

@ -4832,22 +4832,22 @@ Carts</source>
<source>&amp;Services:</source> <source>&amp;Services:</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Are you sure you want to delete service</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Delete Service</source> <source>Delete Service</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>There are</source> <source>Are you sure you want to delete service</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Logs Exist</source> <source>Logs Exist</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>There are</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>logs owned by this service that will also be deleted.</source> <source>logs owned by this service that will also be deleted.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>

View File

@ -5701,15 +5701,15 @@ Carts</source>
</message> </message>
<message> <message>
<source>Are you sure you want to delete service</source> <source>Are you sure you want to delete service</source>
<translation>Er du sikker at du vil sletta tenesta</translation> <translation type="unfinished">Er du sikker at du vil sletta tenesta</translation>
</message> </message>
<message> <message>
<source>Delete Service</source> <source>Delete Service</source>
<translation>Slett tenesta</translation> <translation type="unfinished">Slett tenesta</translation>
</message> </message>
<message> <message>
<source>There are</source> <source>There are</source>
<translation>Denne tenesta eig</translation> <translation type="unfinished">Denne tenesta eig</translation>
</message> </message>
<message> <message>
<source>logs owned by this service that will also be deleted. <source>logs owned by this service that will also be deleted.
@ -5719,7 +5719,7 @@ Er du sikker på at du vil halda fram?</translation>
</message> </message>
<message> <message>
<source>Logs Exist</source> <source>Logs Exist</source>
<translation>Loggen eksisterer</translation> <translation type="unfinished">Loggen eksisterer</translation>
</message> </message>
<message> <message>
<source>logs owned by this service that will also be deleted.</source> <source>logs owned by this service that will also be deleted.</source>

View File

@ -5701,15 +5701,15 @@ Carts</source>
</message> </message>
<message> <message>
<source>Are you sure you want to delete service</source> <source>Are you sure you want to delete service</source>
<translation>Er du sikker at du vil sletta tenesta</translation> <translation type="unfinished">Er du sikker at du vil sletta tenesta</translation>
</message> </message>
<message> <message>
<source>Delete Service</source> <source>Delete Service</source>
<translation>Slett tenesta</translation> <translation type="unfinished">Slett tenesta</translation>
</message> </message>
<message> <message>
<source>There are</source> <source>There are</source>
<translation>Denne tenesta eig</translation> <translation type="unfinished">Denne tenesta eig</translation>
</message> </message>
<message> <message>
<source>logs owned by this service that will also be deleted. <source>logs owned by this service that will also be deleted.
@ -5719,7 +5719,7 @@ Er du sikker på at du vil halda fram?</translation>
</message> </message>
<message> <message>
<source>Logs Exist</source> <source>Logs Exist</source>
<translation>Loggen eksisterer</translation> <translation type="unfinished">Loggen eksisterer</translation>
</message> </message>
<message> <message>
<source>logs owned by this service that will also be deleted.</source> <source>logs owned by this service that will also be deleted.</source>

View File

@ -5812,15 +5812,15 @@ Carts</source>
</message> </message>
<message> <message>
<source>Are you sure you want to delete service</source> <source>Are you sure you want to delete service</source>
<translation>Tem certeza que quer deletar este Serviço?</translation> <translation type="unfinished">Tem certeza que quer deletar este Serviço?</translation>
</message> </message>
<message> <message>
<source>Delete Service</source> <source>Delete Service</source>
<translation>Deletar Serviço</translation> <translation type="unfinished">Deletar Serviço</translation>
</message> </message>
<message> <message>
<source>There are</source> <source>There are</source>
<translation></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>logs owned by this service that will also be deleted. <source>logs owned by this service that will also be deleted.
@ -5830,7 +5830,7 @@ Você quer proceder?</translation>
</message> </message>
<message> <message>
<source>Logs Exist</source> <source>Logs Exist</source>
<translation>Lista Existente</translation> <translation type="unfinished">Lista Existente</translation>
</message> </message>
<message> <message>
<source>logs owned by this service that will also be deleted.</source> <source>logs owned by this service that will also be deleted.</source>