mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-08-02 17:09:28 +02:00
2018-03-21 Fred Gleason <fredg@paravelsystems.com>
* Added support for notifications to rdlibrary(1).
This commit is contained in:
parent
7ce4b2ff10
commit
e3fb53d0cf
@ -16723,3 +16723,5 @@
|
|||||||
ripcd(8).
|
ripcd(8).
|
||||||
* Added an 'RDRipc::sendNotification()' method.
|
* Added an 'RDRipc::sendNotification()' method.
|
||||||
* Added an 'RDRipc::notificationReceived()' signal.
|
* Added an 'RDRipc::notificationReceived()' signal.
|
||||||
|
2018-03-21 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added support for notifications to rdlibrary(1).
|
||||||
|
@ -20,6 +20,15 @@
|
|||||||
|
|
||||||
#include "rdnotification.h"
|
#include "rdnotification.h"
|
||||||
|
|
||||||
|
RDNotification::RDNotification(RDNotification::Type type,
|
||||||
|
RDNotification::Action action,unsigned cartnum)
|
||||||
|
{
|
||||||
|
notify_type=type;
|
||||||
|
notify_action=action;
|
||||||
|
notify_id=QVariant(cartnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RDNotification::RDNotification()
|
RDNotification::RDNotification()
|
||||||
{
|
{
|
||||||
notify_type=RDNotification::NullType;
|
notify_type=RDNotification::NullType;
|
||||||
@ -84,7 +93,7 @@ bool RDNotification::read(const QString &str)
|
|||||||
RDNotification::Type type=(RDNotification::Type)i;
|
RDNotification::Type type=(RDNotification::Type)i;
|
||||||
if(args[1]==RDNotification::typeString(type)) {
|
if(args[1]==RDNotification::typeString(type)) {
|
||||||
notify_type=type;
|
notify_type=type;
|
||||||
notify_id=QVariant(args[2].toUInt());
|
notify_id=QVariant(args[3].toUInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(notify_type==RDNotification::NullType) {
|
if(notify_type==RDNotification::NullType) {
|
||||||
|
@ -30,6 +30,7 @@ class RDNotification
|
|||||||
enum Type {NullType=0,CartType=1,LastType=2};
|
enum Type {NullType=0,CartType=1,LastType=2};
|
||||||
enum Action {NoAction=0,AddAction=1,DeleteAction=2,ModifyAction=3,
|
enum Action {NoAction=0,AddAction=1,DeleteAction=2,ModifyAction=3,
|
||||||
LastAction=4};
|
LastAction=4};
|
||||||
|
RDNotification(Type type,Action action,unsigned cartnum);
|
||||||
RDNotification();
|
RDNotification();
|
||||||
Type type() const;
|
Type type() const;
|
||||||
void setType(Type type);
|
void setType(Type type);
|
||||||
|
@ -178,8 +178,9 @@ MainWidget::MainWidget(QWidget *parent)
|
|||||||
lib_filter_mode=rda->station()->filterMode();
|
lib_filter_mode=rda->station()->filterMode();
|
||||||
rdaudioport_conf=new RDAudioPort(rda->config()->stationName(),
|
rdaudioport_conf=new RDAudioPort(rda->config()->stationName(),
|
||||||
rda->libraryConf()->inputCard());
|
rda->libraryConf()->inputCard());
|
||||||
connect(rda->ripc(),SIGNAL(connected(bool)),this,SLOT(connectedData(bool)));
|
|
||||||
connect(rda,SIGNAL(userChanged()),this,SLOT(userData()));
|
connect(rda,SIGNAL(userChanged()),this,SLOT(userData()));
|
||||||
|
connect(rda->ripc(),SIGNAL(notificationReceived(RDNotification *)),
|
||||||
|
this,SLOT(notificationReceivedData(RDNotification *)));
|
||||||
rda->ripc()->
|
rda->ripc()->
|
||||||
connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
|
connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
|
||||||
cut_clipboard=NULL;
|
cut_clipboard=NULL;
|
||||||
@ -482,11 +483,6 @@ QSizePolicy MainWidget::sizePolicy() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWidget::connectedData(bool state)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWidget::userData()
|
void MainWidget::userData()
|
||||||
{
|
{
|
||||||
QString sql;
|
QString sql;
|
||||||
@ -610,6 +606,7 @@ void MainWidget::addData()
|
|||||||
RDListViewItem *item=new RDListViewItem(lib_cart_list);
|
RDListViewItem *item=new RDListViewItem(lib_cart_list);
|
||||||
item->setText(1,QString().sprintf("%06u",cart_num));
|
item->setText(1,QString().sprintf("%06u",cart_num));
|
||||||
RefreshLine(item);
|
RefreshLine(item);
|
||||||
|
SendNotification(RDNotification::AddAction,cart_num);
|
||||||
QListViewItemIterator it(lib_cart_list);
|
QListViewItemIterator it(lib_cart_list);
|
||||||
while(it.current()) {
|
while(it.current()) {
|
||||||
lib_cart_list->setSelected(it.current(),false);
|
lib_cart_list->setSelected(it.current(),false);
|
||||||
@ -657,6 +654,7 @@ void MainWidget::editData()
|
|||||||
edit_cart->exec();
|
edit_cart->exec();
|
||||||
RefreshLine(item);
|
RefreshLine(item);
|
||||||
cartOnItemData(item);
|
cartOnItemData(item);
|
||||||
|
SendNotification(RDNotification::ModifyAction,item->text(1).toUInt());
|
||||||
delete edit_cart;
|
delete edit_cart;
|
||||||
delete it;
|
delete it;
|
||||||
}
|
}
|
||||||
@ -673,6 +671,8 @@ void MainWidget::editData()
|
|||||||
while(it->current()) {
|
while(it->current()) {
|
||||||
if (it->current()->isSelected()) {
|
if (it->current()->isSelected()) {
|
||||||
RefreshLine((RDListViewItem *)it->current());
|
RefreshLine((RDListViewItem *)it->current());
|
||||||
|
SendNotification(RDNotification::ModifyAction,
|
||||||
|
it->current()->text(1).toUInt());
|
||||||
}
|
}
|
||||||
++(*it);
|
++(*it);
|
||||||
}
|
}
|
||||||
@ -757,6 +757,7 @@ Do you still want to delete it?"),item->text(1).toUInt());
|
|||||||
QMessageBox::warning(this,tr("RDLibrary"),tr("Unable to delete audio!"));
|
QMessageBox::warning(this,tr("RDLibrary"),tr("Unable to delete audio!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
SendNotification(RDNotification::DeleteAction,rdcart->number());
|
||||||
delete rdcart;
|
delete rdcart;
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
@ -894,6 +895,54 @@ void MainWidget::dragsChangedData(int state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWidget::notificationReceivedData(RDNotification *notify)
|
||||||
|
{
|
||||||
|
RDListViewItem *item=NULL;
|
||||||
|
QString sql;
|
||||||
|
RDSqlQuery *q;
|
||||||
|
|
||||||
|
if(notify->type()==RDNotification::CartType) {
|
||||||
|
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());
|
||||||
|
q=new RDSqlQuery(sql);
|
||||||
|
if(q->first()) {
|
||||||
|
item=new RDListViewItem(lib_cart_list);
|
||||||
|
item->setText(1,QString().sprintf("%06u",notify->id().toUInt()));
|
||||||
|
RefreshLine(item);
|
||||||
|
}
|
||||||
|
delete q;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RDNotification::ModifyAction:
|
||||||
|
if((item=(RDListViewItem *)lib_cart_list->
|
||||||
|
findItem(QString().sprintf("%06u",notify->id().toUInt()),1))!=NULL) {
|
||||||
|
RefreshLine(item);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RDNotification::DeleteAction:
|
||||||
|
if(lib_edit_pending) {
|
||||||
|
lib_deleted_carts.push_back(notify->id().toUInt());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if((item=(RDListViewItem *)lib_cart_list->findItem(QString().sprintf("%06u",notify->id().toUInt()),1))!=NULL) {
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RDNotification::NoAction:
|
||||||
|
case RDNotification::LastAction:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWidget::quitMainWidget()
|
void MainWidget::quitMainWidget()
|
||||||
{
|
{
|
||||||
SaveGeometry();
|
SaveGeometry();
|
||||||
@ -1011,21 +1060,7 @@ void MainWidget::RefreshList()
|
|||||||
"CUTS.SUN "+ // 36
|
"CUTS.SUN "+ // 36
|
||||||
"from CART left join GROUPS on CART.GROUP_NAME=GROUPS.NAME "+
|
"from CART left join GROUPS on CART.GROUP_NAME=GROUPS.NAME "+
|
||||||
"left join CUTS on CART.NUMBER=CUTS.CART_NUMBER";
|
"left join CUTS on CART.NUMBER=CUTS.CART_NUMBER";
|
||||||
QString schedcode="";
|
sql+=WhereClause();
|
||||||
if(lib_codes_box->currentText()!=tr("ALL")) {
|
|
||||||
schedcode=lib_codes_box->currentText();
|
|
||||||
}
|
|
||||||
if(lib_group_box->currentText()==QString(tr("ALL"))) {
|
|
||||||
sql+=QString(" where ")+
|
|
||||||
RDAllCartSearchText(lib_filter_edit->text(),schedcode,
|
|
||||||
rda->user()->name(),true)+" && "+type_filter;
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql+=QString(" where ")+
|
|
||||||
RDCartSearchText(lib_filter_edit->text(),lib_group_box->currentText(),
|
|
||||||
schedcode,true)+" && "+type_filter;
|
|
||||||
}
|
|
||||||
sql+=" order by CART.NUMBER";
|
sql+=" order by CART.NUMBER";
|
||||||
if(lib_showmatches_box->isChecked()) {
|
if(lib_showmatches_box->isChecked()) {
|
||||||
sql+=QString().sprintf(" limit %d",RD_LIMITED_CART_SEARCH_QUANTITY);
|
sql+=QString().sprintf(" limit %d",RD_LIMITED_CART_SEARCH_QUANTITY);
|
||||||
@ -1141,6 +1176,31 @@ void MainWidget::RefreshList()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString MainWidget::WhereClause() const
|
||||||
|
{
|
||||||
|
QString sql="";
|
||||||
|
QString type_filter=GetTypeFilter();
|
||||||
|
|
||||||
|
QString schedcode="";
|
||||||
|
if(lib_codes_box->currentText()!=tr("ALL")) {
|
||||||
|
schedcode=lib_codes_box->currentText();
|
||||||
|
}
|
||||||
|
if(lib_group_box->currentText()==QString(tr("ALL"))) {
|
||||||
|
sql+=QString(" where ")+
|
||||||
|
RDAllCartSearchText(lib_filter_edit->text(),schedcode,
|
||||||
|
rda->user()->name(),true)+" && "+type_filter;
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sql+=QString(" where ")+
|
||||||
|
RDCartSearchText(lib_filter_edit->text(),lib_group_box->currentText(),
|
||||||
|
schedcode,true)+" && "+type_filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SigHandler(int signo)
|
void SigHandler(int signo)
|
||||||
{
|
{
|
||||||
pid_t pLocalPid;
|
pid_t pLocalPid;
|
||||||
@ -1321,7 +1381,7 @@ void MainWidget::SetCaption(QString user)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString MainWidget::GetTypeFilter()
|
QString MainWidget::GetTypeFilter() const
|
||||||
{
|
{
|
||||||
QString type_filter;
|
QString type_filter;
|
||||||
|
|
||||||
@ -1410,16 +1470,42 @@ void MainWidget::LockUser()
|
|||||||
|
|
||||||
bool MainWidget::UnlockUser()
|
bool MainWidget::UnlockUser()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
RDListViewItem *item=NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Process Deleted Carts
|
||||||
|
//
|
||||||
|
for(unsigned i=0;i<lib_deleted_carts.size();i++) {
|
||||||
|
if((item=(RDListViewItem *)lib_cart_list->findItem(QString().sprintf("%06u",lib_deleted_carts.at(i)),1))!=NULL) {
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Process User Change
|
||||||
|
//
|
||||||
bool ret=lib_user_changed;
|
bool ret=lib_user_changed;
|
||||||
lib_edit_pending=false;
|
lib_edit_pending=false;
|
||||||
if(lib_user_changed) {
|
if(lib_user_changed) {
|
||||||
lib_user_timer->start(0,true);
|
lib_user_timer->start(0,true);
|
||||||
lib_user_changed=false;
|
lib_user_changed=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWidget::SendNotification(RDNotification::Action action,
|
||||||
|
unsigned cartnum)
|
||||||
|
{
|
||||||
|
RDNotification *notify=
|
||||||
|
new RDNotification(RDNotification::CartType,action,cartnum);
|
||||||
|
rda->ripc()->sendNotification(*notify);
|
||||||
|
delete notify;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc,argv);
|
QApplication a(argc,argv);
|
||||||
|
@ -70,7 +70,6 @@ class MainWidget : public QWidget
|
|||||||
QSizePolicy sizePolicy() const;
|
QSizePolicy sizePolicy() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void connectedData(bool state);
|
|
||||||
void userData();
|
void userData();
|
||||||
void filterChangedData(const QString &str);
|
void filterChangedData(const QString &str);
|
||||||
void searchClickedData();
|
void searchClickedData();
|
||||||
@ -88,6 +87,7 @@ class MainWidget : public QWidget
|
|||||||
void macroChangedData(int state);
|
void macroChangedData(int state);
|
||||||
void searchLimitChangedData(int state);
|
void searchLimitChangedData(int state);
|
||||||
void dragsChangedData(int state);
|
void dragsChangedData(int state);
|
||||||
|
void notificationReceivedData(RDNotification *notify);
|
||||||
void quitMainWidget();
|
void quitMainWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -96,17 +96,19 @@ class MainWidget : public QWidget
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void RefreshList();
|
void RefreshList();
|
||||||
|
QString WhereClause() const;
|
||||||
void RefreshLine(RDListViewItem *item);
|
void RefreshLine(RDListViewItem *item);
|
||||||
void UpdateItemColor(RDListViewItem *item,RDCart::Validity validity,
|
void UpdateItemColor(RDListViewItem *item,RDCart::Validity validity,
|
||||||
const QDateTime &end_datetime,
|
const QDateTime &end_datetime,
|
||||||
const QDateTime ¤t_datetime);
|
const QDateTime ¤t_datetime);
|
||||||
void SetCaption(QString user);
|
void SetCaption(QString user);
|
||||||
QString GetTypeFilter();
|
QString GetTypeFilter() const;
|
||||||
QString GeometryFile();
|
QString GeometryFile();
|
||||||
void LoadGeometry();
|
void LoadGeometry();
|
||||||
void SaveGeometry();
|
void SaveGeometry();
|
||||||
void LockUser();
|
void LockUser();
|
||||||
bool UnlockUser();
|
bool UnlockUser();
|
||||||
|
void SendNotification(RDNotification::Action action,unsigned cartnum);
|
||||||
LibListView *lib_cart_list;
|
LibListView *lib_cart_list;
|
||||||
CartTip *lib_cart_tip;
|
CartTip *lib_cart_tip;
|
||||||
QString lib_filter_text;
|
QString lib_filter_text;
|
||||||
@ -148,6 +150,7 @@ class MainWidget : public QWidget
|
|||||||
bool lib_user_changed;
|
bool lib_user_changed;
|
||||||
QTimer *lib_user_timer;
|
QTimer *lib_user_timer;
|
||||||
bool lib_resize;
|
bool lib_resize;
|
||||||
|
std::vector<unsigned> lib_deleted_carts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user