mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-11-30 17:20:32 +01:00
2021-02-03 Fred Gleason <fredg@paravelsystems.com>
* Added 'RDReplCartListModel'. * Refactored the 'XDS Replicator Carts' dialog in rdadmin(1) to use the model-based API. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// List Rivendell Replicator Carts
|
||||
//
|
||||
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@@ -18,41 +18,20 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <rdcart.h>
|
||||
#include <rddb.h>
|
||||
#include <rdescape_string.h>
|
||||
#include <rdreplicator.h>
|
||||
#include <rdtextfile.h>
|
||||
|
||||
#include "add_replicator.h"
|
||||
#include "edit_replicator.h"
|
||||
#include "list_replicator_carts.h"
|
||||
|
||||
#include "../icons/play.xpm"
|
||||
#include "../icons/rml5.xpm"
|
||||
|
||||
ListReplicatorCarts::ListReplicatorCarts(QWidget *parent)
|
||||
: RDDialog(parent)
|
||||
{
|
||||
setModal(true);
|
||||
|
||||
//
|
||||
// Fix the Window Size
|
||||
//
|
||||
setMinimumSize(sizeHint());
|
||||
|
||||
//
|
||||
// Create Icons
|
||||
//
|
||||
list_playout_map=new QPixmap(play_xpm);
|
||||
list_macro_map=new QPixmap(rml5_xpm);
|
||||
|
||||
//
|
||||
// Refresh Timer
|
||||
//
|
||||
list_refresh_timer=new QTimer(this);
|
||||
connect(list_refresh_timer,SIGNAL(timeout()),this,SLOT(refreshTimeoutData()));
|
||||
|
||||
//
|
||||
// Repost Button
|
||||
//
|
||||
@@ -81,14 +60,14 @@ ListReplicatorCarts::ListReplicatorCarts(QWidget *parent)
|
||||
//
|
||||
// Replicator List
|
||||
//
|
||||
list_view=new RDListView(this);
|
||||
list_view->setAllColumnsShowFocus(true);
|
||||
list_view->setItemMargin(5);
|
||||
list_view->addColumn(" ");
|
||||
list_view->addColumn(tr("CART"));
|
||||
list_view->addColumn(tr("TITLE"));
|
||||
list_view->addColumn(tr("LAST POSTED"));
|
||||
list_view->addColumn(tr("POSTED FILENAME"));
|
||||
list_view=new RDTableView(this);
|
||||
list_model=new RDReplCartListModel(this);
|
||||
list_model->setFont(defaultFont());
|
||||
list_model->setPalette(palette());
|
||||
list_view->setModel(list_model);
|
||||
connect(list_model,SIGNAL(modelReset()),
|
||||
list_view,SLOT(resizeColumnsToContents()));
|
||||
|
||||
QLabel *list_box_label=new QLabel(list_view,tr("&Active Carts:"),this);
|
||||
list_box_label->setFont(labelFont());
|
||||
list_box_label->setGeometry(14,11,85,19);
|
||||
@@ -97,6 +76,7 @@ ListReplicatorCarts::ListReplicatorCarts(QWidget *parent)
|
||||
|
||||
ListReplicatorCarts::~ListReplicatorCarts()
|
||||
{
|
||||
delete list_model;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,75 +94,42 @@ QSizePolicy ListReplicatorCarts::sizePolicy() const
|
||||
|
||||
int ListReplicatorCarts::exec(const QString &replname)
|
||||
{
|
||||
list_replicator_name=replname;
|
||||
setWindowTitle("RDAdmin - "+replname+tr(" Replicator Carts"));
|
||||
RefreshList();
|
||||
list_refresh_timer->start(5000,true);
|
||||
list_model->setReplicatorName(replname);
|
||||
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
|
||||
void ListReplicatorCarts::repostData()
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
QModelIndexList rows=list_view->selectionModel()->selectedRows();
|
||||
|
||||
RDListViewItem *item=(RDListViewItem *)list_view->selectedItem();
|
||||
if(item==NULL) {
|
||||
if(rows.size()==0) {
|
||||
return;
|
||||
}
|
||||
sql=QString().sprintf("update REPL_CART_STATE set REPOST=\"Y\" \
|
||||
where ID=%d",item->id());
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
QString sql=QString("update REPL_CART_STATE set ")+
|
||||
"REPOST=\"Y\" where ";
|
||||
for(int i=0;i<rows.size();i++) {
|
||||
sql+=QString().sprintf("(ID=%u)||",list_model->cartId(rows.at(i)));
|
||||
}
|
||||
sql=sql.left(sql.length()-2);
|
||||
RDSqlQuery::apply(sql);
|
||||
}
|
||||
|
||||
|
||||
void ListReplicatorCarts::repostAllData()
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
|
||||
sql=QString("update REPL_CART_STATE set ")+
|
||||
QString sql=QString("update REPL_CART_STATE set ")+
|
||||
"REPOST=\"Y\" where "+
|
||||
"REPLICATOR_NAME=\""+RDEscapeString(list_replicator_name)+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
"REPLICATOR_NAME=\""+RDEscapeString(list_model->replicatorName())+"\"";
|
||||
RDSqlQuery::apply(sql);
|
||||
}
|
||||
|
||||
|
||||
void ListReplicatorCarts::closeData()
|
||||
{
|
||||
list_refresh_timer->stop();
|
||||
done(0);
|
||||
}
|
||||
|
||||
|
||||
void ListReplicatorCarts::refreshTimeoutData()
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
RDListViewItem *item;
|
||||
|
||||
sql=QString("select ")+
|
||||
"ID,"+
|
||||
"ITEM_DATETIME "+
|
||||
"from REPL_CART_STATE where "+
|
||||
"REPLICATOR_NAME=\""+RDEscapeString(list_replicator_name)+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
item=(RDListViewItem *)list_view->firstChild();
|
||||
while(item!=NULL) {
|
||||
if(item->id()==q->value(0).toInt()) {
|
||||
item->setText(3,q->value(1).
|
||||
toDateTime().toString("hh:mm:ss dd/MM/yyyy"));
|
||||
break;
|
||||
}
|
||||
item=(RDListViewItem *)item->nextSibling();
|
||||
}
|
||||
}
|
||||
delete q;
|
||||
list_refresh_timer->start(5000,true);
|
||||
done(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,45 +140,3 @@ void ListReplicatorCarts::resizeEvent(QResizeEvent *e)
|
||||
list_close_button->setGeometry(size().width()-90,size().height()-60,80,50);
|
||||
list_view->setGeometry(10,30,size().width()-120,size().height()-40);
|
||||
}
|
||||
|
||||
|
||||
void ListReplicatorCarts::RefreshList()
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
RDListViewItem *item;
|
||||
|
||||
list_view->clear();
|
||||
sql=QString("select ")+
|
||||
"REPL_CART_STATE.ID,"+ // 00
|
||||
"CART.TYPE,"+ // 01
|
||||
"REPL_CART_STATE.CART_NUMBER,"+ // 02
|
||||
"CART.TITLE,"+ // 03
|
||||
"REPL_CART_STATE.ITEM_DATETIME,"+ // 04
|
||||
"REPL_CART_STATE.POSTED_FILENAME "+ // 05
|
||||
"from REPL_CART_STATE left join CART "+
|
||||
"on REPL_CART_STATE.CART_NUMBER=CART.NUMBER where "+
|
||||
"REPLICATOR_NAME=\""+RDEscapeString(list_replicator_name)+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
while (q->next()) {
|
||||
item=new RDListViewItem(list_view);
|
||||
item->setId(q->value(0).toInt());
|
||||
item->setText(1,QString().sprintf("%06u",q->value(2).toUInt()));
|
||||
switch((RDCart::Type)q->value(1).toInt()) {
|
||||
case RDCart::Audio:
|
||||
item->setPixmap(0,*list_playout_map);
|
||||
break;
|
||||
|
||||
case RDCart::Macro:
|
||||
item->setPixmap(0,*list_macro_map);
|
||||
break;
|
||||
|
||||
case RDCart::All:
|
||||
break;
|
||||
}
|
||||
item->setText(2,q->value(3).toString());
|
||||
item->setText(3,q->value(4).toDateTime().toString("hh:mm:ss dd/MM/yyyy"));
|
||||
item->setText(4,q->value(5).toString());
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user