2018-03-24 Fred Gleason <fredg@paravelsystems.com>

* Added a 'LogType' value to the 'RDNotification::Type
	enumeration.
	* Added support for notifications to rdlogedit(1).
This commit is contained in:
Fred Gleason 2018-03-24 15:47:20 -04:00
parent 04cc669175
commit af0ac339a6
11 changed files with 246 additions and 33 deletions

View File

@ -16733,3 +16733,7 @@
rdlibrary(1).
2018-03-21 Fred Gleason <fredg@paravelsystems.com>
* Added support for cart notifications to rdairplay(1).
2018-03-24 Fred Gleason <fredg@paravelsystems.com>
* Added a 'LogType' value to the 'RDNotification::Type
enumeration.
* Added support for notifications to rdlogedit(1).

View File

@ -25,7 +25,6 @@
NOTIFY <replaceable choice='req'>obj-type</replaceable>
<replaceable choice='req'>action</replaceable>
<replaceable choice='req'>id</replaceable>
[<replaceable choice='opt'>args</replaceable>]
</para>
<variablelist>
<varlistentry>
@ -90,17 +89,6 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<replaceable>args</replaceable>
</term>
<listitem>
<para>
Zero or more additional arguments. Varies by
<replaceable>obj-type</replaceable>.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect1>
@ -123,6 +111,27 @@
<row><entry>Field</entry><entry>Value</entry></row>
<row><entry>obj-type</entry><entry>CART</entry></row>
<row><entry>id</entry><entry>Cart number</entry></row>
<row><entry>type</entry><entry>Unsigned Integer</entry></row>
</tbody>
</tgroup>
</table>
</sect2>
<sect2 xml:id="sect.object_types.log">
<title>Logs</title>
<para>
<userinput>LOG</userinput>
</para>
<table xml:id="table.object_types.logs" frame="all" pgwide="0">
<title>Log Fields</title>
<tgroup cols="2" align="left" colsep="1" rowsep="1">
<colspec colname="Field" colwidth="2.0*"/>
<colspec colname="Value" colwidth="10.0*"/>
<tbody>
<row><entry>Field</entry><entry>Value</entry></row>
<row><entry>obj-type</entry><entry>LOG</entry></row>
<row><entry>id</entry><entry>Log name</entry></row>
<row><entry>type</entry><entry>String</entry></row>
</tbody>
</tgroup>
</table>

View File

@ -92,7 +92,19 @@ bool RDNotification::read(const QString &str)
RDNotification::Type type=(RDNotification::Type)i;
if(args[1]==RDNotification::typeString(type)) {
notify_type=type;
notify_id=QVariant(args[3].toUInt());
switch(type) {
case RDNotification::CartType:
notify_id=QVariant(args[3].toUInt());
break;
case RDNotification::LogType:
notify_id=QVariant(args[3]);
break;
case RDNotification::NullType:
case RDNotification::LastType:
break;
}
}
}
if(notify_type==RDNotification::NullType) {
@ -124,6 +136,10 @@ QString RDNotification::write() const
ret+=QString().sprintf("%u",notify_id.toUInt());
break;
case RDNotification::LogType:
ret+=notify_id.toString();
break;
case RDNotification::NullType:
case RDNotification::LastType:
break;
@ -141,6 +157,10 @@ QString RDNotification::typeString(RDNotification::Type type)
ret="CART";
break;
case RDNotification::LogType:
ret="LOG";
break;
case RDNotification::NullType:
case RDNotification::LastType:
break;

View File

@ -27,7 +27,7 @@
class RDNotification
{
public:
enum Type {NullType=0,CartType=1,LastType=2};
enum Type {NullType=0,CartType=1,LogType=2,LastType=3};
enum Action {NoAction=0,AddAction=1,DeleteAction=2,ModifyAction=3,
LastAction=4};
RDNotification(Type type,Action action,const QVariant &id);

View File

@ -902,16 +902,17 @@ void MainWidget::notificationReceivedData(RDNotification *notify)
RDSqlQuery *q;
if(notify->type()==RDNotification::CartType) {
unsigned cartnum=notify->id().toUInt();
switch(notify->action()) {
case RDNotification::AddAction:
sql=QString("select CART.NUMBER from CART ")+
"left join CUTS on CART.NUMBER=CUTS.CART_NUMBER "+
WhereClause()+
QString().sprintf(" && CART.NUMBER=%u ",notify->id().toUInt());
QString().sprintf(" && CART.NUMBER=%u ",cartnum);
q=new RDSqlQuery(sql);
if(q->first()) {
item=new RDListViewItem(lib_cart_list);
item->setText(1,QString().sprintf("%06u",notify->id().toUInt()));
item->setText(1,QString().sprintf("%06u",cartnum));
RefreshLine(item);
}
delete q;
@ -919,17 +920,17 @@ void MainWidget::notificationReceivedData(RDNotification *notify)
case RDNotification::ModifyAction:
if((item=(RDListViewItem *)lib_cart_list->
findItem(QString().sprintf("%06u",notify->id().toUInt()),1))!=NULL) {
findItem(QString().sprintf("%06u",cartnum),1))!=NULL) {
RefreshLine(item);
}
break;
case RDNotification::DeleteAction:
if(lib_edit_pending) {
lib_deleted_carts.push_back(notify->id().toUInt());
lib_deleted_carts.push_back(cartnum);
}
else {
if((item=(RDListViewItem *)lib_cart_list->findItem(QString().sprintf("%06u",notify->id().toUInt()),1))!=NULL) {
if((item=(RDListViewItem *)lib_cart_list->findItem(QString().sprintf("%06u",cartnum),1))!=NULL) {
delete item;
}
}

View File

@ -154,6 +154,12 @@ EditLog::EditLog(QString logname,QString *filter,QString *group,
edit_log_event=new RDLogEvent(RDLog::tableName(edit_logname));
edit_log_event->load(true);
//
// Notifications
//
connect(rda->ripc(),SIGNAL(notificationReceived(RDNotification *)),
this,SLOT(notificationReceivedData(RDNotification *)));
//
// Log Name
//
@ -1082,6 +1088,27 @@ void EditLog::cartDroppedData(int line,RDLogLine *ll)
}
void EditLog::notificationReceivedData(RDNotification *notify)
{
RDListViewItem *item=NULL;
if(notify->type()==RDNotification::CartType) {
unsigned cartnum=notify->id().toUInt();
item=(RDListViewItem *)edit_log_list->firstChild();
while(item!=NULL) {
if(item->text(3).toUInt()==cartnum) {
int line=item->text(14).toInt();
if(line>=0) {
edit_log_event->refresh(line);
RefreshLine(item);
}
}
item=(RDListViewItem *)item->nextSibling();
}
}
}
void EditLog::saveData()
{
if(!ValidateSvc()) {
@ -1127,6 +1154,7 @@ void EditLog::saveasData()
QMessageBox::warning(this,"RDLogEdit - "+tr("Error"),err_msg);
return;
}
SendNotification(RDNotification::AddAction,logname);
delete edit_log;
edit_newlogs->push_back(logname);
edit_log=new RDLog(logname);
@ -1400,6 +1428,7 @@ void EditLog::SaveLog()
edit_log_event->save(rda->config());
edit_log->
setModifiedDatetime(QDateTime(QDate::currentDate(),QTime::currentTime()));
SendNotification(RDNotification::ModifyAction,edit_log->name());
}
@ -1409,6 +1438,7 @@ void EditLog::RefreshLine(RDListViewItem *item)
if(line<0) {
return;
}
edit_log_event->refresh(line);
RDLogLine *logline=edit_log_event->logLine(line);
switch(logline->timeType()) {
case RDLogLine::Hard:
@ -1862,3 +1892,13 @@ void EditLog::SetLogModified(bool state)
edit_changed=state;
}
}
void EditLog::SendNotification(RDNotification::Action action,
const QString &log_name)
{
RDNotification *notify=new RDNotification(RDNotification::LogType,
action,QVariant(log_name));
rda->ripc()->sendNotification(*notify);
delete notify;
}

View File

@ -2,7 +2,7 @@
//
// Create a Rivendell Log
//
// (C) Copyright 2002-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2018 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
@ -37,6 +37,7 @@
#include <rdlog.h>
#include <rdlog_event.h>
#include <rdloglock.h>
#include <rdnotification.h>
#include <rdsimpleplayer.h>
#include <rdtransportbutton.h>
#include <rduser.h>
@ -89,6 +90,7 @@ class EditLog : public QDialog
void copyButtonData();
void pasteButtonData();
void cartDroppedData(int line,RDLogLine *ll);
void notificationReceivedData(RDNotification *notify);
void saveData();
void saveasData();
void renderasData();
@ -116,6 +118,7 @@ class EditLog : public QDialog
void LoadClipboard(bool clear_ext);
RDListViewItem *SingleSelection();
void SetLogModified(bool state);
void SendNotification(RDNotification::Action action,const QString &log_name);
RDLog *edit_log;
RDLogEvent *edit_log_event;
std::vector<RDLogLine> *edit_clipboard;

View File

@ -105,6 +105,7 @@ MainWidget::MainWidget(QWidget *parent)
log_resize=false;
log_log_list=NULL;
log_list_locked=false;
//
// Fix the Window Size
@ -153,6 +154,8 @@ MainWidget::MainWidget(QWidget *parent)
//
#ifndef WIN32
connect(rda->ripc(),SIGNAL(connected(bool)),this,SLOT(connectedData(bool)));
connect(rda->ripc(),SIGNAL(notificationReceived(RDNotification *)),
this,SLOT(notificationReceivedData(RDNotification *)));
connect(rda,SIGNAL(userChanged()),this,SLOT(userData()));
rda->ripc()->connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
#else
@ -376,11 +379,13 @@ void MainWidget::addData()
QString username(rda->ripc()->user());
#endif // WIN32
QString err_msg;
if(!RDLog::create(logname,svcname,QDate(),username,&err_msg,
rda->config())) {
if(!RDLog::create(logname,svcname,QDate(),username,&err_msg,
rda->config())) {
QMessageBox::warning(this,"RDLogEdit - "+tr("Error"),err_msg);
return;
}
LockList();
SendNotification(RDNotification::AddAction,logname);
EditLog *editlog=new EditLog(logname,&log_filter,&log_group,&log_schedcode,
&log_clipboard,&newlogs,this);
editlog->exec();
@ -395,6 +400,7 @@ void MainWidget::addData()
item->setText(1,newlogs[i]);
RefreshItem(item);
}
UnlockList();
}
}
@ -405,19 +411,22 @@ void MainWidget::editData()
if(SelectedLogs(&items)!=1) {
return;
}
QString logname=items.at(0)->text(1);
std::vector<QString> newlogs;
LockList();
EditLog *log=
new EditLog(items.at(0)->text(1),&log_filter,&log_group,&log_schedcode,
new EditLog(logname,&log_filter,&log_group,&log_schedcode,
&log_clipboard,&newlogs,this);
log->exec();
delete log;
RefreshItem(items.at(0));
for(unsigned i=0;i<newlogs.size();i++) {
ListListViewItem *item=new ListListViewItem(log_log_list);
item->setText(1,newlogs[i]);
RefreshItem(item);
if(log->exec()) {
RefreshItem(items.at(0));
for(unsigned i=0;i<newlogs.size();i++) {
ListListViewItem *item=new ListListViewItem(log_log_list);
item->setText(1,newlogs[i]);
RefreshItem(item);
}
}
UnlockList();
delete log;
}
@ -482,6 +491,7 @@ void MainWidget::deleteData()
}
}
LockList();
for(unsigned i=0;i<items.size();i++) {
QString username;
QString stationname;
@ -491,6 +501,7 @@ void MainWidget::deleteData()
if(log_lock->tryLock(&username,&stationname,&addr)) {
RDLog *log=new RDLog(items.at(i)->text(1));
if(log->remove(rda->station(),rda->user(),rda->config())) {
SendNotification(RDNotification::DeleteAction,log->name());
delete items.at(i);
}
else {
@ -511,6 +522,7 @@ void MainWidget::deleteData()
}
delete log_lock;
}
UnlockList();
}
}
@ -522,10 +534,12 @@ void MainWidget::trackData()
if(SelectedLogs(&items)!=1) {
return;
}
LockList();
VoiceTracker *dialog=new VoiceTracker(items.at(0)->text(1),&log_import_path);
dialog->exec();
delete dialog;
RefreshItem(items.at(0));
UnlockList();
#endif // WIN32
}
@ -679,6 +693,53 @@ void MainWidget::logDoubleclickedData(QListViewItem *,const QPoint &,int)
}
void MainWidget::notificationReceivedData(RDNotification *notify)
{
QString sql;
RDSqlQuery *q;
ListListViewItem *item=NULL;
if(notify->type()==RDNotification::LogType) {
QString logname=notify->id().toString();
switch(notify->action()) {
case RDNotification::AddAction:
sql=QString("select NAME from LOGS where (TYPE=0)&&(LOG_EXISTS=\"Y\")&&")+
"(NAME=\""+RDEscapeString(logname)+"\") "+
log_filter_widget->whereSql();
q=new RDSqlQuery(sql);
if(q->first()) {
item=new ListListViewItem(log_log_list);
item->setText(1,logname);
RefreshItem(item);
}
delete q;
break;
case RDNotification::ModifyAction:
if((item=(ListListViewItem *)log_log_list->findItem(logname,1))!=NULL) {
RefreshItem(item);
}
break;
case RDNotification::DeleteAction:
if(log_list_locked) {
log_deleted_logs.push_back(logname);
}
else {
if((item=(ListListViewItem *)log_log_list->findItem(logname,1))!=NULL) {
delete item;
}
}
break;
case RDNotification::NoAction:
case RDNotification::LastAction:
break;
}
}
}
void MainWidget::quitMainWidget()
{
exit(0);
@ -820,6 +881,37 @@ unsigned MainWidget::SelectedLogs(std::vector<ListListViewItem *> *items,
}
void MainWidget::SendNotification(RDNotification::Action action,
const QString &logname)
{
RDNotification *notify=new RDNotification(RDNotification::LogType,action,
QVariant(logname));
rda->ripc()->sendNotification(*notify);
delete notify;
}
void MainWidget::LockList()
{
log_list_locked=true;
}
void MainWidget::UnlockList()
{
ListListViewItem *item=NULL;
for(unsigned i=0;i<log_deleted_logs.size();i++) {
if((item=(ListListViewItem *)log_log_list->
findItem(log_deleted_logs[i],1))!=NULL) {
delete item;
}
}
log_deleted_logs.clear();
log_list_locked=false;
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv);

View File

@ -36,6 +36,7 @@
#include <rdlog_line.h>
#include <rdlogfilter.h>
#include <rdnotification.h>
#include "list_listviewitem.h"
@ -61,6 +62,7 @@ class MainWidget : public QMainWindow
void filterChangedData(const QString &str);
void logSelectionChangedData();
void logDoubleclickedData(QListViewItem *item,const QPoint &pt,int col);
void notificationReceivedData(RDNotification *notify);
void quitMainWidget();
protected:
@ -71,7 +73,9 @@ class MainWidget : public QMainWindow
void RefreshList();
unsigned SelectedLogs(std::vector<ListListViewItem *> *items,
int *tracks=NULL) const;
// QSqlDatabase *log_db;
void SendNotification(RDNotification::Action action,const QString &logname);
void LockList();
void UnlockList();
QString log_filename;
QString log_import_path;
QLabel *log_user_label;
@ -96,6 +100,8 @@ class MainWidget : public QMainWindow
QString log_group;
QString log_schedcode;
bool log_resize;
bool log_list_locked;
QStringList log_deleted_logs;
};

View File

@ -164,6 +164,12 @@ VoiceTracker::VoiceTracker(const QString &logname,QString *import_path,
//
track_event_player=new RDEventPlayer(rda->ripc(),this);
//
// Notifications
//
connect(rda->ripc(),SIGNAL(notificationReceived(RDNotification *)),
this,SLOT(notificationReceivedData(RDNotification *)));
//
// Waveform Pixmaps
//
@ -1964,6 +1970,24 @@ void VoiceTracker::recordUnloadedData(int card,int stream,unsigned msecs)
}
void VoiceTracker::notificationReceivedData(RDNotification *notify)
{
RDListViewItem *item=NULL;
if(notify->type()==RDNotification::CartType) {
unsigned cartnum=notify->id().toUInt();
item=(RDListViewItem *)track_log_list->firstChild();
while(item!=NULL) {
if(item->text(3).toUInt()==cartnum) {
track_log_event->refresh(item->line());
RefreshLine(item);
}
item=(RDListViewItem *)item->nextSibling();
}
}
}
void VoiceTracker::closeData()
{
stopData();
@ -2346,6 +2370,7 @@ void VoiceTracker::SaveTrack(int line)
setModifiedDatetime(QDateTime(QDate::currentDate(),QTime::currentTime()));
track_changed=false;
track_size_altered=false;
SendNotification(RDNotification::ModifyAction,track_log->name());
}
@ -4135,3 +4160,13 @@ void VoiceTracker::PopSegues()
}
}
}
void VoiceTracker::SendNotification(RDNotification::Action action,
const QString &log_name)
{
RDNotification *notify=new RDNotification(RDNotification::LogType,
action,QVariant(log_name));
rda->ripc()->sendNotification(*notify);
delete notify;
}

View File

@ -2,7 +2,7 @@
//
// A Rivendell Voice Tracker
//
// (C) Copyright 2002-2006,2016-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2006,2016-2018 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
@ -41,6 +41,7 @@
#include <rdlog.h>
#include <rdlog_event.h>
#include <rdloglock.h>
#include <rdnotification.h>
#include <rdplay_deck.h>
#include <rdsettings.h>
#include <rdstereometer.h>
@ -121,6 +122,7 @@ class VoiceTracker : public QDialog
void recordingData(int card,int stream);
void recordStoppedData(int card,int stream);
void recordUnloadedData(int cart,int stream,unsigned msecs);
void notificationReceivedData(RDNotification *notify);
void closeData();
protected:
@ -170,6 +172,7 @@ class VoiceTracker : public QDialog
void CheckChanges();
void PushSegues();
void PopSegues();
void SendNotification(RDNotification::Action action,const QString &log_name);
RDStereoMeter *track_meter;
QTimer *track_meter_timer;
RDTransportButton *track_play_button;