2022-03-09 Fred Gleason <fredg@paravelsystems.com>

* Refactored the 'RDAddLog' dialog to allow for instance reuse.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2022-03-09 15:42:55 -05:00
parent 0c8acd502a
commit 3a41e13afd
25 changed files with 166 additions and 167 deletions

View File

@ -22941,3 +22941,5 @@
* Fixed a regression in rdlogedit(1) that caused events from * Fixed a regression in rdlogedit(1) that caused events from
previously viewed logs to be prepended to subsequent logs viewed previously viewed logs to be prepended to subsequent logs viewed
during the same session. during the same session.
2022-03-09 Fred Gleason <fredg@paravelsystems.com>
* Refactored the 'RDAddLog' dialog to allow for instance reuse.

View File

@ -2,7 +2,7 @@
// //
// Create a Rivendell Log // Create a Rivendell Log
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -26,16 +26,14 @@
#include "rdidvalidator.h" #include "rdidvalidator.h"
#include "rdadd_log.h" #include "rdadd_log.h"
RDAddLog::RDAddLog(QString *logname,QString *svcname, RDAddLog::RDAddLog(RDLogFilter::FilterMode mode,const QString &caption,
RDLogFilter::FilterMode mode,const QString &caption,
QWidget *parent) QWidget *parent)
: RDDialog(parent) : RDDialog(parent)
{ {
QStringList services_list; QStringList services_list;
QString sql; log_name=NULL;
RDSqlQuery *q; log_svc=NULL;
log_name=logname; log_filter_mode=mode;
log_svc=svcname;
// //
// Fix the Window Size // Fix the Window Size
@ -43,7 +41,7 @@ RDAddLog::RDAddLog(QString *logname,QString *svcname,
setMinimumSize(sizeHint()); setMinimumSize(sizeHint());
setMinimumSize(sizeHint()); setMinimumSize(sizeHint());
setWindowTitle(tr("Create Log")); setWindowTitle(caption);
// //
// Validator // Validator
@ -96,32 +94,6 @@ RDAddLog::RDAddLog(QString *logname,QString *svcname,
add_cancel_button->setFont(buttonFont()); add_cancel_button->setFont(buttonFont());
add_cancel_button->setText(tr("Cancel")); add_cancel_button->setText(tr("Cancel"));
connect(add_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData())); connect(add_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));
//
// Populate Data
//
switch(mode) {
case RDLogFilter::NoFilter:
sql=QString("select `NAME` from `SERVICES` order by `NAME`");
break;
case RDLogFilter::UserFilter:
sql=QString("select `SERVICE_NAME` from `USER_SERVICE_PERMS` where ")+
"`USER_NAME`='"+RDEscapeString(rda->user()->name())+"' "+
"order by `SERVICE_NAME`";
break;
case RDLogFilter::StationFilter:
sql=QString("select `SERVICE_NAME` from `SERVICE_PERMS` where ")+
"`STATION_NAME`='"+RDEscapeString(rda->station()->name())+"' "+
"order by `SERVICE_NAME`";
break;
}
q=new RDSqlQuery(sql);
while(q->next()) {
add_service_box->
insertItem(add_service_box->count(),q->value(0).toString());
}
} }
@ -143,6 +115,44 @@ QSizePolicy RDAddLog::sizePolicy() const
} }
int RDAddLog::exec(QString *logname,QString *svcname)
{
QString sql;
RDSqlQuery *q;
log_name=logname;
log_svc=svcname;
switch(log_filter_mode) {
case RDLogFilter::NoFilter:
sql=QString("select `NAME` from `SERVICES` order by `NAME`");
break;
case RDLogFilter::UserFilter:
sql=QString("select `SERVICE_NAME` from `USER_SERVICE_PERMS` where ")+
"`USER_NAME`='"+RDEscapeString(rda->user()->name())+"' "+
"order by `SERVICE_NAME`";
break;
case RDLogFilter::StationFilter:
sql=QString("select `SERVICE_NAME` from `SERVICE_PERMS` where ")+
"`STATION_NAME`='"+RDEscapeString(rda->station()->name())+"' "+
"order by `SERVICE_NAME`";
break;
}
q=new RDSqlQuery(sql);
add_service_box->clear();
while(q->next()) {
add_service_box->
insertItem(add_service_box->count(),q->value(0).toString());
if(q->value(0).toString()==*log_svc) {
add_service_box->setCurrentIndex(add_service_box->count()-1);
}
}
add_name_edit->setText(*logname);
return QDialog::exec();
}
void RDAddLog::okData() void RDAddLog::okData()
{ {
if(add_service_box->currentText().isEmpty()){ if(add_service_box->currentText().isEmpty()){

View File

@ -5,7 +5,7 @@
// This class creates a basic dialog requesting from the user a name and // This class creates a basic dialog requesting from the user a name and
// corresponding service that is later used to create a new log. // corresponding service that is later used to create a new log.
// //
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -24,9 +24,9 @@
#ifndef ADD_LOG_H #ifndef ADD_LOG_H
#define ADD_LOG_H #define ADD_LOG_H
#include <qcombobox.h> #include <QComboBox>
#include <qlineedit.h> #include <QLineEdit>
#include <qpushbutton.h> #include <QPushButton>
#include <rddialog.h> #include <rddialog.h>
#include <rdlog.h> #include <rdlog.h>
@ -36,12 +36,15 @@ class RDAddLog : public RDDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
RDAddLog(QString *logname,QString *svcname,RDLogFilter::FilterMode mode, RDAddLog(RDLogFilter::FilterMode mode,const QString &caption,
const QString &caption,QWidget *parent=0); QWidget *parent=0);
~RDAddLog(); ~RDAddLog();
QSize sizeHint() const; QSize sizeHint() const;
QSizePolicy sizePolicy() const; QSizePolicy sizePolicy() const;
public slots:
int exec(QString *logname,QString *svcname);
private slots: private slots:
void okData(); void okData();
void cancelData(); void cancelData();
@ -57,6 +60,7 @@ class RDAddLog : public RDDialog
QPushButton *add_cancel_button; QPushButton *add_cancel_button;
QString *log_name; QString *log_name;
QString *log_svc; QString *log_svc;
RDLogFilter::FilterMode log_filter_mode;
}; };

View File

@ -2,7 +2,7 @@
// //
// Abstract a Rivendell RSS Feed // Abstract a Rivendell RSS Feed
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -1452,7 +1452,8 @@ unsigned RDFeed::postLog(const QString &logname,const QTime &start_time,
// //
// Open Log // Open Log
// //
log_model=new RDLogModel(logname,false,this); log_model=new RDLogModel(false,this);
log_model->setLogName(logname);
log_model->load(); log_model->load();
if(!log_model->exists()) { if(!log_model->exists()) {
*err=RDFeed::ErrorNoLog; *err=RDFeed::ErrorNoLog;

View File

@ -2,7 +2,7 @@
// //
// Abstract a Rivendell Log. // Abstract a Rivendell Log.
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -465,7 +465,9 @@ int RDLog::removeTracks(RDStation *station,RDUser *user,RDConfig *config) const
RDLogModel *RDLog::createLogEvent() const RDLogModel *RDLog::createLogEvent() const
{ {
return new RDLogModel(name(),false); RDLogModel *model=new RDLogModel(false);
model->setLogName(name());
return model;
} }
@ -616,6 +618,12 @@ bool RDLog::remove(const QString &name,RDStation *station,RDUser *user,
} }
bool RDLog::remove(const QString &name)
{
return RDLog::remove(name,rda->station(),rda->user(),rda->config());
}
int RDLog::GetIntValue(const QString &field) const int RDLog::GetIntValue(const QString &field) const
{ {
QString sql; QString sql;

View File

@ -2,7 +2,7 @@
// //
// Abstract a Rivendell Log // Abstract a Rivendell Log
// //
// (C) Copyright 2002-2020 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -84,6 +84,7 @@ class RDLog
static bool exists(const QString &name); static bool exists(const QString &name);
static bool remove(const QString &name,RDStation *station,RDUser *user, static bool remove(const QString &name,RDStation *station,RDUser *user,
RDConfig *config); RDConfig *config);
static bool remove(const QString &name);
private: private:
int GetIntValue(const QString &field) const; int GetIntValue(const QString &field) const;

View File

@ -158,6 +158,15 @@ QString RDLogFilter::whereSql() const
} }
QString RDLogFilter::currentServiceName() const
{
if(filter_service_box->currentText()==tr("ALL")) {
return QString();
}
return filter_service_box->currentText();
}
void RDLogFilter::changeUser() void RDLogFilter::changeUser()
{ {
if(filter_filter_mode==RDLogFilter::UserFilter) { if(filter_filter_mode==RDLogFilter::UserFilter) {

View File

@ -2,7 +2,7 @@
// //
// Filter widget for picking Rivendell logs. // Filter widget for picking Rivendell logs.
// //
// (C) Copyright 2017-2018 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2017-2022 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,15 +21,14 @@
#ifndef RDLOGFILTER_H #ifndef RDLOGFILTER_H
#define RDLOGFILTER_H #define RDLOGFILTER_H
#include <qcheckbox.h> #include <QCheckBox>
#include <qcombobox.h> #include <QComboBox>
#include <qlineedit.h> #include <QLabel>
#include <qlabel.h> #include <QLineEdit>
#include <qpushbutton.h> #include <QPushButton>
#include <qstringlist.h>
#include <qwidget.h>
//Added by qt3to4:
#include <QResizeEvent> #include <QResizeEvent>
#include <QStringList>
#include <QWidget>
class RDLogFilter : public QWidget class RDLogFilter : public QWidget
{ {
@ -41,6 +40,7 @@ class RDLogFilter : public QWidget
QSize sizeHint() const; QSize sizeHint() const;
QSizePolicy sizePolicy() const; QSizePolicy sizePolicy() const;
QString whereSql() const; QString whereSql() const;
QString currentServiceName() const;
public slots: public slots:
void changeUser(); void changeUser();

View File

@ -2,7 +2,7 @@
// //
// Data model for Rivendell logs // Data model for Rivendell logs
// //
// (C) Copyright 2020-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2020-2022 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
@ -25,10 +25,9 @@
#include "rdlog_line.h" #include "rdlog_line.h"
#include "rdlogmodel.h" #include "rdlogmodel.h"
RDLogModel::RDLogModel(const QString &logname,bool read_only,QObject *parent) RDLogModel::RDLogModel(bool read_only,QObject *parent)
: QAbstractTableModel(parent) : QAbstractTableModel(parent)
{ {
d_log_name=logname;
d_read_only=read_only; d_read_only=read_only;
MakeModel(); MakeModel();
@ -247,13 +246,11 @@ QString RDLogModel::logName() const
void RDLogModel::setLogName(QString logname) void RDLogModel::setLogName(QString logname)
{ {
if(d_log_name.toLower()!=logname) { clear();
clear(); printf("RDLogModel::setLogName(%s)\n",logname.toUtf8().constData());
printf("RDLogModel::setLogName(%s)\n",logname.toUtf8().constData()); RDLog *log=new RDLog(logname);
RDLog *log=new RDLog(logname); d_log_name=log->name(); // So we normalize the case
d_log_name=log->name(); // So we normalize the case delete log;
delete log;
}
} }
@ -356,6 +353,7 @@ int RDLogModel::append(const QString &logname,bool track_ptrs)
void RDLogModel::clear() void RDLogModel::clear()
{ {
printf("RDLogModel::clear()\n");
if(d_log_lines.size()>0) { if(d_log_lines.size()>0) {
beginResetModel(); beginResetModel();
for(int i=0;i<d_log_lines.size();i++) { for(int i=0;i<d_log_lines.size();i++) {

View File

@ -2,7 +2,7 @@
// //
// Data model for Rivendell logs // Data model for Rivendell logs
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -35,7 +35,7 @@ class RDLogModel : public QAbstractTableModel
Q_OBJECT Q_OBJECT
public: public:
enum StartTimeStyle {Estimated=0,Scheduled=1}; enum StartTimeStyle {Estimated=0,Scheduled=1};
RDLogModel(const QString &logname,bool read_only,QObject *parent=0); RDLogModel(bool read_only,QObject *parent=0);
RDLogModel(QObject *parent=0); RDLogModel(QObject *parent=0);
~RDLogModel(); ~RDLogModel();
QPalette palette(); QPalette palette();

View File

@ -2,7 +2,7 @@
// //
// Abstract a Rivendell Service. // Abstract a Rivendell Service.
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -1008,8 +1008,10 @@ bool RDSvc::linkLog(RDSvc::ImportSource src,const QDate &date,
// //
// Iterate Through the Log // Iterate Through the Log
// //
src_model=new RDLogModel(logname,true,this); src_model=new RDLogModel(true,this);
dst_model=new RDLogModel(logname,true,this); src_model->setLogName(logname);
dst_model=new RDLogModel(true,this);
dst_model->setLogName(logname);
src_model->load(); src_model->load();
for(int i=0;i<src_model->lineCount();i++) { for(int i=0;i<src_model->lineCount();i++) {
logline=src_model->logLine(i); logline=src_model->logLine(i);
@ -1163,8 +1165,10 @@ bool RDSvc::clearLogLinks(RDSvc::ImportSource src,const QString &logname,
break; break;
} }
RDLogModel *src_model=new RDLogModel(logname,false,this); RDLogModel *src_model=new RDLogModel(false,this);
RDLogModel *dst_model=new RDLogModel(logname,false,this); src_model->setLogName(logname);
RDLogModel *dst_model=new RDLogModel(false,this);
dst_model->setLogName(logname);
src_model->load(); src_model->load();
RDLogLine *logline=NULL; RDLogLine *logline=NULL;
for(int i=0;i<src_model->lineCount();i++) { for(int i=0;i<src_model->lineCount();i++) {
@ -1810,7 +1814,8 @@ bool RDSvc::ResolveInlineEvents(const QString &logname,QString *err_msg)
switch(subEventInheritance()) { switch(subEventInheritance()) {
case RDSvc::ParentEvent: case RDSvc::ParentEvent:
model=new RDLogModel(logname,false,this); model=new RDLogModel(false,this);
model->setLogName(logname);
model->load(); model->load();
ok=true; ok=true;
for(int i=0;i<model->lineCount();i++) { for(int i=0;i<model->lineCount();i++) {

View File

@ -2,7 +2,7 @@
// //
// Select a Rivendell Log // Select a Rivendell Log
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -38,6 +38,9 @@ ListLogs::ListLogs(RDLogPlay *log,QWidget *parent)
list_log=log; list_log=log;
setWindowTitle("RDAirPlay - "+tr("Select Log")); setWindowTitle("RDAirPlay - "+tr("Select Log"));
list_addlog_dialog=new RDAddLog(RDLogFilter::StationFilter,
"RDAirPlay - "+tr("Rename Log"),this);
// //
// Filter Widget // Filter Widget
// //
@ -181,14 +184,9 @@ void ListLogs::saveAsButtonData()
{ {
QString logname; QString logname;
QString svcname=*list_svcname; QString svcname=*list_svcname;
RDAddLog *log; if(list_addlog_dialog->exec(&logname,&svcname)<0) {
log=new RDAddLog(&logname,&svcname,RDLogFilter::StationFilter,
tr("Rename Log"),this);
if(log->exec()<0) {
delete log;
return; return;
} }
delete log;
*list_logname=logname; *list_logname=logname;
*list_svcname=svcname; *list_svcname=svcname;
done(ListLogs::SaveAs); done(ListLogs::SaveAs);

View File

@ -2,7 +2,7 @@
// //
// Select a Rivendell Log // Select a Rivendell Log
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -23,6 +23,7 @@
#include <QPushButton> #include <QPushButton>
#include <rdadd_log.h>
#include <rddialog.h> #include <rddialog.h>
#include <rdlogfilter.h> #include <rdlogfilter.h>
#include <rdloglistmodel.h> #include <rdloglistmodel.h>
@ -70,6 +71,7 @@ class ListLogs : public RDDialog
QPushButton *list_cancel_button; QPushButton *list_cancel_button;
RDLogPlay *list_log; RDLogPlay *list_log;
RDLogLock **list_log_lock; RDLogLock **list_log_lock;
RDAddLog *list_addlog_dialog;
}; };

View File

@ -2,7 +2,7 @@
// //
// List Rivendell Casts // List Rivendell Casts
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -247,7 +247,8 @@ void ListCasts::addLogData()
RDListLogs *lld= RDListLogs *lld=
new RDListLogs(&logname,RDLogFilter::UserFilter,"RDCastManager",this); new RDListLogs(&logname,RDLogFilter::UserFilter,"RDCastManager",this);
if(lld->exec()) { if(lld->exec()) {
RDLogModel *model=new RDLogModel(logname,true,this); RDLogModel *model=new RDLogModel(true,this);
model->setLogName(logname);
model->load(); model->load();
QTime start_time; QTime start_time;
bool ignore_stops=true; bool ignore_stops=true;
@ -398,12 +399,6 @@ void ListCasts::userChangedData()
} }
void ListCasts::filterChangedData(const QString &str)
{
// RefreshList();
}
void ListCasts::modelResetData() void ListCasts::modelResetData()
{ {
list_casts_view->resizeColumnsToContents(); list_casts_view->resizeColumnsToContents();

View File

@ -2,7 +2,7 @@
// //
// List Rivendell Casts // List Rivendell Casts
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -50,7 +50,6 @@ class ListCasts : public RDDialog
void deleteData(); void deleteData();
void doubleClickedData(const QModelIndex &index); void doubleClickedData(const QModelIndex &index);
void userChangedData(); void userChangedData();
void filterChangedData(const QString &str);
void modelResetData(); void modelResetData();
void rowsInsertedData(const QModelIndex &parent,int start,int end); void rowsInsertedData(const QModelIndex &parent,int start,int end);
void postProgressChangedData(int step); void postProgressChangedData(int step);

View File

@ -175,7 +175,6 @@ EditLog::EditLog(QString *filter,QString *group,QString *schedcode,
connect(edit_startdate_edit,SIGNAL(dateChanged(const QDate &)), connect(edit_startdate_edit,SIGNAL(dateChanged(const QDate &)),
this,SLOT(dateValueChangedData(const QDate &))); this,SLOT(dateValueChangedData(const QDate &)));
// //
// End Date // End Date
// //
@ -431,7 +430,6 @@ QSize EditLog::sizeHint() const
} }
//int EditLog::exec()
int EditLog::exec(const QString &logname,QStringList *new_logs) int EditLog::exec(const QString &logname,QStringList *new_logs)
{ {
QString sql; QString sql;
@ -980,9 +978,8 @@ void EditLog::saveasData()
QString err_msg; QString err_msg;
if(rda->user()->createLog()) { if(rda->user()->createLog()) {
log=new RDAddLog(&logname,&svcname,RDLogFilter::UserFilter, log=new RDAddLog(RDLogFilter::UserFilter,"RDLogEdit",this);
tr("Add Log"),this); if(log->exec(&logname,&svcname)<0) {
if(log->exec()<0) {
return; return;
} }
if(!RDLog::create(logname,svcname,QDate(),rda->ripc()->user(),&err_msg, if(!RDLog::create(logname,svcname,QDate(),rda->ripc()->user(),&err_msg,
@ -1073,6 +1070,8 @@ void EditLog::okData()
void EditLog::cancelData() void EditLog::cancelData()
{ {
bool ret=false;
if(edit_changed) { if(edit_changed) {
switch(QMessageBox::question(this, switch(QMessageBox::question(this,
tr("RDLogEdit"), tr("RDLogEdit"),
@ -1086,6 +1085,7 @@ void EditLog::cancelData()
return; return;
} }
SaveLog(); SaveLog();
ret=true;
break; break;
case QMessageBox::Cancel: case QMessageBox::Cancel:
@ -1100,7 +1100,7 @@ void EditLog::cancelData()
} }
delete edit_log_lock; delete edit_log_lock;
edit_log_lock=NULL; edit_log_lock=NULL;
done(false); done(ret);
} }

View File

@ -1,8 +1,8 @@
// logmodel.cpp // logmodel.cpp
// //
// Data model for Rivendell logs in RDLogEdit // Data model for Rivendell logs for RDLogEdit(1)
// //
// (C) Copyright 2020 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2020-2022 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
@ -20,13 +20,6 @@
#include "logmodel.h" #include "logmodel.h"
LogModel::LogModel(const QString &logname,QObject *parent)
: RDLogModel(logname,false,parent)
{
d_group_list=new RDGroupList();
}
LogModel::LogModel(QObject *parent) LogModel::LogModel(QObject *parent)
: RDLogModel(parent) : RDLogModel(parent)
{ {

View File

@ -2,7 +2,7 @@
// //
// Data model for Rivendell logs in RDLogEdit // Data model for Rivendell logs in RDLogEdit
// //
// (C) Copyright 2020 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2020-2022 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
@ -28,7 +28,6 @@ class LogModel : public RDLogModel
{ {
Q_OBJECT Q_OBJECT
public: public:
LogModel(const QString &logname,QObject *parent=0);
LogModel(QObject *parent=0); LogModel(QObject *parent=0);
~LogModel(); ~LogModel();
QString serviceName() const; QString serviceName() const;

View File

@ -2,7 +2,7 @@
// //
// The Log Editor Utility for Rivendell. // The Log Editor Utility for Rivendell.
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -22,7 +22,6 @@
#include <QMessageBox> #include <QMessageBox>
#include <QTranslator> #include <QTranslator>
#include <rdadd_log.h>
#include <rdconf.h> #include <rdconf.h>
#include <rdescape_string.h> #include <rdescape_string.h>
#include <rdprofile.h> #include <rdprofile.h>
@ -105,8 +104,6 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
// //
log_filter_widget= log_filter_widget=
new RDLogFilter(RDLogFilter::UserFilter,this); new RDLogFilter(RDLogFilter::UserFilter,this);
connect(log_filter_widget,SIGNAL(filterChanged(const QString &)),
this,SLOT(filterChangedData(const QString &)));
// //
// Dialogs // Dialogs
@ -115,6 +112,8 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
new EditLog(&log_filter,&log_group,&log_schedcode,&log_clipboard,this); new EditLog(&log_filter,&log_group,&log_schedcode,&log_clipboard,this);
log_tracker_dialog=new VoiceTracker(&log_import_path,this); log_tracker_dialog=new VoiceTracker(&log_import_path,this);
log_addlog_dialog=
new RDAddLog(RDLogFilter::UserFilter,"RDLogEdit - "+tr("Add Log"),this);
// //
// Log List // Log List
@ -229,7 +228,6 @@ void MainWidget::userData()
log_filter_widget->changeUser(); log_filter_widget->changeUser();
log_log_model->setFilterSql(log_filter_widget->whereSql()); log_log_model->setFilterSql(log_filter_widget->whereSql());
log_log_view->resizeColumnsToContents(); log_log_view->resizeColumnsToContents();
// RefreshList();
// //
// Set Control Perms // Set Control Perms
@ -240,28 +238,17 @@ void MainWidget::userData()
} }
void MainWidget::recentData(bool state)
{
// RefreshList();
}
void MainWidget::addData() void MainWidget::addData()
{ {
QString logname; QString logname;
QString svcname; QString svcname=log_filter_widget->currentServiceName();
QStringList newlogs; QStringList newlogs;
RDAddLog *log;
QModelIndex row; QModelIndex row;
if(rda->user()->createLog()) { if(rda->user()->createLog()) {
log=new RDAddLog(&logname,&svcname,RDLogFilter::UserFilter, if(log_addlog_dialog->exec(&logname,&svcname)!=0) {
tr("Add Log"),this);
if(log->exec()!=0) {
delete log;
return; return;
} }
delete log;
QString username(rda->ripc()->user()); QString username(rda->ripc()->user());
QString err_msg; QString err_msg;
if(!RDLog::create(logname,svcname,QDate(),username,&err_msg, if(!RDLog::create(logname,svcname,QDate(),username,&err_msg,
@ -270,10 +257,14 @@ void MainWidget::addData()
return; return;
} }
LockList(); LockList();
SendNotification(RDNotification::AddAction,logname); if(log_edit_dialog->exec(logname,&newlogs)) {
log_edit_dialog->exec(logname,&newlogs); SendNotification(RDNotification::AddAction,logname);
row=log_log_model->addLog(logname); row=log_log_model->addLog(logname);
log_log_view->selectRow(row.row()); log_log_view->selectRow(row.row());
}
else {
RDLog::remove(logname);
}
UnlockList(); UnlockList();
} }
} }
@ -424,23 +415,6 @@ void MainWidget::trackData()
UnlockList(); UnlockList();
} }
/*
void MainWidget::trackData()
{
QModelIndex row=SingleSelectedRow();
if(!row.isValid()) {
return;
}
LockList();
VoiceTracker *dialog=
new VoiceTracker(log_log_model->logName(row),&log_import_path);
dialog->exec();
delete dialog;
log_log_model->refresh(row);
UnlockList();
}
*/
void MainWidget::reportData() void MainWidget::reportData()
{ {
@ -564,12 +538,6 @@ void MainWidget::reportData()
} }
void MainWidget::filterChangedData(const QString &str)
{
// RefreshList();
}
void MainWidget::selectionChangedData(const QItemSelection &selected, void MainWidget::selectionChangedData(const QItemSelection &selected,
const QItemSelection &deselected) const QItemSelection &deselected)
{ {

View File

@ -2,7 +2,7 @@
// //
// The Log Editor Utility for Rivendell. // The Log Editor Utility for Rivendell.
// //
// (C) Copyright 2002-2020 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -23,6 +23,7 @@
#include <QList> #include <QList>
#include <rdadd_log.h>
#include <rdlog_line.h> #include <rdlog_line.h>
#include <rdlogfilter.h> #include <rdlogfilter.h>
#include <rdloglistmodel.h> #include <rdloglistmodel.h>
@ -50,13 +51,11 @@ class MainWidget : public RDMainWindow
private slots: private slots:
void caeConnectedData(bool state); void caeConnectedData(bool state);
void userData(); void userData();
void recentData(bool state);
void addData(); void addData();
void editData(); void editData();
void deleteData(); void deleteData();
void trackData(); void trackData();
void reportData(); void reportData();
void filterChangedData(const QString &str);
void selectionChangedData(const QItemSelection &selected, void selectionChangedData(const QItemSelection &selected,
const QItemSelection &deselected); const QItemSelection &deselected);
void doubleClickedData(const QModelIndex &index); void doubleClickedData(const QModelIndex &index);
@ -94,6 +93,7 @@ class MainWidget : public RDMainWindow
QStringList log_deleted_logs; QStringList log_deleted_logs;
EditLog *log_edit_dialog; EditLog *log_edit_dialog;
VoiceTracker *log_tracker_dialog; VoiceTracker *log_tracker_dialog;
RDAddLog *log_addlog_dialog;
}; };

View File

@ -2,7 +2,7 @@
// //
// Generate a Rivendell Log // Generate a Rivendell Log
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 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
@ -329,7 +329,8 @@ void GenerateLog::createData()
// //
// Generate Exception Report // Generate Exception Report
// //
RDLogModel *model=new RDLogModel(logname,false,this); RDLogModel *model=new RDLogModel(false,this);
model->setLogName(logname);
model->load(); model->load();
if((model->validate(&report,gen_date_edit->date())==0)&& if((model->validate(&report,gen_date_edit->date())==0)&&
unused_report.isEmpty()) { unused_report.isEmpty()) {

View File

@ -2,7 +2,7 @@
// //
// Generate/merge logs from the command line. // Generate/merge logs from the command line.
// //
// (C) Copyright 2018-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2018-2022 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
@ -107,7 +107,8 @@ void LogObject::userData()
// //
// Generate Exception Report // Generate Exception Report
// //
RDLogModel *model=new RDLogModel(logname,false,this); RDLogModel *model=new RDLogModel(false,this);
model->setLogName(logname);
model->load(); model->load();
if((model->validate(&report,start_date)!=0)|| if((model->validate(&report,start_date)!=0)||
(!unused_report.isEmpty())) { (!unused_report.isEmpty())) {

View File

@ -2,7 +2,7 @@
// //
// A command-line log editor for Rivendell // A command-line log editor for Rivendell
// //
// (C) Copyright 2016-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2016-2022 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
@ -250,7 +250,8 @@ void MainObject::Load(QString logname)
edit_log=new RDLog(logname); edit_log=new RDLog(logname);
if(edit_log->exists()) { if(edit_log->exists()) {
edit_log_model=new RDLogModel(logname,false,this); edit_log_model=new RDLogModel(false,this);
edit_log_model->setLogName(logname);
edit_log_model->load(); edit_log_model->load();
edit_description=edit_log->description(); edit_description=edit_log->description();
edit_service=edit_log->service(); edit_service=edit_log->service();
@ -362,7 +363,8 @@ void MainObject::New(const QString &logname)
} }
edit_log=new RDLog(logname); edit_log=new RDLog(logname);
if(!edit_log->exists()) { if(!edit_log->exists()) {
edit_log_model=new RDLogModel(logname,false,this); edit_log_model=new RDLogModel(false,this);
edit_log_model->setLogName(logname);
edit_description=logname+" log"; edit_description=logname+" log";
sql=QString("select `NAME` from `SERVICES`"); sql=QString("select `NAME` from `SERVICES`");
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);

View File

@ -2,7 +2,7 @@
// //
// Render a Rivendell log. // Render a Rivendell log.
// //
// (C) Copyright 2017-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2017-2022 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
@ -287,7 +287,8 @@ void MainObject::userData()
fprintf(stderr,"rdrender: no such log\n"); fprintf(stderr,"rdrender: no such log\n");
exit(1); exit(1);
} }
RDLogModel *log_model=new RDLogModel(render_logname,false,this); RDLogModel *log_model=new RDLogModel(false,this);
log_model->setLogName(render_logname);
log_model->load(); log_model->load();
// //

View File

@ -2,7 +2,7 @@
// //
// Rivendell web service portal -- Log services // Rivendell web service portal -- Log services
// //
// (C) Copyright 2013-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2013-2022 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
@ -292,7 +292,9 @@ void Xport::SaveLog()
// //
// Logline Data // Logline Data
// //
RDLogModel *logmodel=new RDLogModel(log_name,false,this); // RDLogModel *logmodel=new RDLogModel(log_name,false,this);
RDLogModel *logmodel=new RDLogModel(false,this);
logmodel->setLogName(log_name);
for(int i=0;i<line_quantity;i++) { for(int i=0;i<line_quantity;i++) {
logmodel->insert(i,1); logmodel->insert(i,1);
RDLogLine *ll=logmodel->logLine(i); RDLogLine *ll=logmodel->logLine(i);