예제 #1
0
void RDLog::updateLinkQuantity(RDLog::Source src) const
{
  QString sql;
  RDSqlQuery *q;
  switch(src) {
      case RDLog::SourceMusic:
	sql=QString("select ID from `")+RDLog::tableName(log_name)+
	  "` where "+QString().sprintf("TYPE=%d",RDLogLine::MusicLink);
	q=new RDSqlQuery(sql);
	sql=QString("update LOGS set ")+
	  QString().sprintf("MUSIC_LINKS=%d ",q->size())+
	  "where NAME=\""+RDEscapeString(log_name)+"\"";
	break;

      case RDLog::SourceTraffic:
	sql=QString("select ID from `")+RDLog::tableName(log_name)+
	  "` where "+QString().sprintf("TYPE=%d",RDLogLine::TrafficLink);
	q=new RDSqlQuery(sql);

	sql=QString("update LOGS set ")+
	  QString().sprintf("TRAFFIC_LINKS=%d ",q->size())+
	  "where NAME=\""+RDEscapeString(log_name)+"\"";
	break;

      default:
	return;
  }
  delete q;
  q=new RDSqlQuery(sql);
  delete q;
}
예제 #2
0
void RDLog::updateTracks()
{
  QString sql;
  RDSqlQuery *q;
  unsigned scheduled=0;
  unsigned completed=0;

  sql=QString().sprintf("select NUMBER from CART where OWNER=\"%s\"",
			(const char *)RDEscapeString(log_name));
  q=new RDSqlQuery(sql);
  completed=q->size();
  delete q;

  sql=QString("select ID from `")+RDLog::tableName(log_name)+
    "` where "+QString().sprintf("TYPE=%d",RDLogLine::Track);
  q=new RDSqlQuery(sql);
  scheduled=q->size()+completed;
  delete q;

  sql=QString().sprintf("update LOGS set SCHEDULED_TRACKS=%d,\
                         COMPLETED_TRACKS=%u where NAME=\"%s\"",
			scheduled,completed,
			(const char *)RDEscapeString(log_name));
  q=new RDSqlQuery(sql);
  delete q;
}
예제 #3
0
파일: rdgpimon.cpp 프로젝트: WMFO/rivendell
void MainWidget::UpdateLabelsUp(int last_line)
{
  QString sql;
  RDSqlQuery *q;
  int count=0;
  int count_limit=GPIMON_ROWS*GPIMON_COLS;
  bool last_updated=false;
  QString tablename="GPIS";

  for(int i=0;i<(GPIMON_ROWS*GPIMON_COLS);i++) {
    gpi_labels[i]->hide();
  }
  switch((RDMatrix::GpioType)gpi_type_box->currentItem()) {
    case RDMatrix::GpioInput:
      tablename="GPIS";
      break;

    case RDMatrix::GpioOutput:
      tablename="GPOS";
      break;
  }
  sql=QString("select ")+
    "NUMBER,"+
    "OFF_MACRO_CART,"+
    "MACRO_CART "+
    "from "+tablename+" where "+
    "(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
    QString().sprintf("(MATRIX=%d)&&",gpi_matrix->matrix())+
    QString().sprintf("(NUMBER<=%d) ",last_line)+
    "order by NUMBER desc";
  q=new RDSqlQuery(sql);
  if(q->size()<count_limit) {
    count_limit=q->size();
  }
  while(q->next()&&(count<count_limit)) {
    gpi_labels[count_limit-count-1]->setLine(q->value(0).toInt()-1);
    gpi_labels[count_limit-count-1]->
      setCart(q->value(1).toUInt(),q->value(2).toUInt());
    gpi_labels[count_limit-count-1]->show();
    if(!last_updated) {
      gpi_last_line=q->value(0).toInt();
      last_updated=true;
    }
    gpi_first_line=q->value(0).toInt();
    count++;
  }
  gpi_up_button->setEnabled(q->next());
  delete q;
}
예제 #4
0
void EditUserPerms::okData()
{
  RDSqlQuery *q;
  QString sql;

  //
  // Add New Groups
  //
  for(unsigned i=0;i<user_host_sel->destCount();i++) {
    sql=QString().sprintf("select GROUP_NAME from USER_PERMS \
                           where USER_NAME=\"%s\" && GROUP_NAME=\"%s\"",
			  (const char *)user_user->name(),
			  (const char *)user_host_sel->destText(i));
    q=new RDSqlQuery(sql);
    if(q->size()==0) {
      delete q;
      sql=QString().
	sprintf("insert into USER_PERMS (USER_NAME,GROUP_NAME) \
                 values (\"%s\",\"%s\")",
		(const char *)user_user->name(),
		(const char *)user_host_sel->destText(i));
      q=new RDSqlQuery(sql);
    }
    delete q;
  }
예제 #5
0
//
// Global Classes
//
RDDeck::RDDeck(QString station,unsigned channel,bool create)
{
  RDSqlQuery *q;
  QString sql;

  deck_station=station;
  deck_channel=channel;

  if(create) {
    sql=QString("select ID from DECKS where ")+
      "(STATION_NAME=\""+RDEscapeString(deck_station)+"\")&&"+
      QString().sprintf("(CHANNEL=%d)",deck_channel);
    q=new RDSqlQuery(sql);
    if(q->size()!=1) {
      delete q;
      sql=QString().
        sprintf("insert into DECKS set ")+
	"STATION_NAME=\""+RDEscapeString(deck_station)+"\","+
	QString().sprintf("CHANNEL=%d",deck_channel);
      q=new RDSqlQuery(sql);
      delete q;
    }
    else {
      delete q;
    }
  }
}
예제 #6
0
//
// Global Classes
//
RDLog::RDLog(const QString &name,bool create)
{
  RDSqlQuery *q;
  QString sql;

  log_name=name;

  if(create) {
    sql=QString().sprintf("select NAME from LOGS where \
(NAME=\"%s\")",(const char *)RDEscapeString(log_name));
    q=new RDSqlQuery(sql);
    if(q->size()!=1) {
      delete q;
      sql=QString().
        sprintf("INSERT INTO LOGS SET NAME=\"%s\",ORIGIN_DATETIME=NOW(),\
                 LINK_DATETIME=NOW(),MODIFIED_DATETIME=now()",
		(const char *)RDEscapeString(log_name));
      q=new RDSqlQuery(sql);
      delete q;
    }
    else {
      delete q;
    }
  }
}
예제 #7
0
void EditPerms::okData()
{
  RDSqlQuery *q;
  QString sql;

  //
  // Add New Objects
  //
  for(unsigned i=0;i<svc_object_sel->destCount();i++) {
    sql=QString().sprintf("select %s_NAME from %s_PERMS \
                           where SERVICE_NAME=\"%s\" && %s_NAME=\"%s\"",
			  (const char *)object_type,
			  (const char *)object_type,
			  (const char *)svc_object_sel->destText(i),
			  (const char *)object_type,
			  (const char *)sel_name);
    q=new RDSqlQuery(sql);
    if(q->size()==0) {
      delete q;
      sql=QString().
	sprintf("insert into %s_PERMS (SERVICE_NAME,%s_NAME) \
                 values (\"%s\",\"%s\")",
		(const char *)object_type,
		(const char *)object_type,
		(const char *)svc_object_sel->destText(i),
		(const char *)sel_name);
      q=new RDSqlQuery(sql);
    }
    delete q;
  }
예제 #8
0
void EditSvcPerms::okData()
{
  RDSqlQuery *q;
  QString sql;

  //
  // Add New Hosts
  //
  for(unsigned i=0;i<svc_host_sel->destCount();i++) {
    sql=QString().sprintf("select STATION_NAME from SERVICE_PERMS \
                           where SERVICE_NAME=\"%s\" && STATION_NAME=\"%s\"",
			  (const char *)svc_svc->name(),
			  (const char *)svc_host_sel->destText(i));
    q=new RDSqlQuery(sql);
    if(q->size()==0) {
      delete q;
      sql=QString().
	sprintf("insert into SERVICE_PERMS (SERVICE_NAME,STATION_NAME) \
                 values (\"%s\",\"%s\")",
		(const char *)svc_svc->name(),
		(const char *)svc_host_sel->destText(i));
      q=new RDSqlQuery(sql);
    }
    delete q;
  }
예제 #9
0
파일: rdtty.cpp 프로젝트: WMFO/rivendell
//
// Global Classes
//
RDTty::RDTty(const QString &station,unsigned port_id,bool create)
{
  RDSqlQuery *q;
  QString sql;

  tty_station=station;
  tty_id=port_id;

  if(create) {
    sql=QString("select ID from TTYS where ")+
      "(STATION_NAME=\""+RDEscapeString(tty_station)+"\")&&"+
      QString().sprintf("(PORT_ID=%d)",tty_id);
    q=new RDSqlQuery(sql);
    if(q->size()!=1) {
      delete q;
      sql=QString().sprintf("insert into TTYS set ")+
	"STATION_NAME=\""+RDEscapeString(tty_station)+"\","+
	QString().sprintf("PORT_ID=%d",tty_id);
      q=new RDSqlQuery(sql);
      delete q;
    }
    else {
      delete q;
    }
  }
}
예제 #10
0
void EditGroup::okData()
{
  RDSqlQuery *q;
  QString sql;

  if(!CheckRange()) {
    return;
  }

  group_group->setDescription(group_description_edit->text());
  group_group->setDefaultTitle(group_title_edit->text());
  group_group->
    setDefaultCartType((RDCart::Type)(group_carttype_box->currentItem()+1));
  group_group->setDefaultLowCart(group_lowcart_box->value());
  group_group->setDefaultHighCart(group_highcart_box->value());
  if(group_lowcart_box->value()==0) {
    group_group->setEnforceCartRange(false);
  }
  else {
    group_group->setEnforceCartRange(group_enforcerange_box->isChecked());
  }
  group_group->
    setExportReport(RDGroup::Traffic,group_traffic_box->isChecked());
  group_group->setExportReport(RDGroup::Music,group_music_box->isChecked());
  if(group_shelflife_box->isChecked()) {
    group_group->setCutShelflife(group_shelflife_spin->value());
  }
  else {
    group_group->setCutShelflife(-1);
  }
  group_group->setEnableNowNext(group_nownext_box->isChecked());
  group_group->setColor(group_color_button->
			palette().color(QPalette::Active,
					QColorGroup::ButtonText));

  //
  // Add New Services
  //
  for(unsigned i=0;i<group_svcs_sel->destCount();i++) {
    sql=QString().sprintf("select SERVICE_NAME from AUDIO_PERMS \
where GROUP_NAME=\"%s\" && SERVICE_NAME=\"%s\"",
			  (const char *)group_group->name(),
			  (const char *)group_svcs_sel->destText(i));
    q=new RDSqlQuery(sql);
    if(q->size()==0) {
      delete q;
      sql=QString().sprintf("insert into AUDIO_PERMS (GROUP_NAME,SERVICE_NAME) \
values (\"%s\",\"%s\")",
			    (const char *)group_group->name(),
			    (const char *)group_svcs_sel->destText(i));
      q=new RDSqlQuery(sql);
    }
    delete q;
  }
예제 #11
0
void EditReport::okData()
{
  QString sql;
  RDSqlQuery *q;

  edit_report->setDescription(edit_description_edit->text());
  edit_report->
    setFilter((RDReport::ExportFilter)edit_filter_box->currentItem());
  edit_report->setStationId(edit_stationid_edit->text());
  edit_report->setCartDigits(edit_cartdigits_spin->value());
  edit_report->setUseLeadingZeros(edit_cartzeros_box->isChecked());
  edit_report->setLinesPerPage(edit_linesperpage_spin->value());
  edit_report->
    setStationType((RDReport::StationType)edit_stationtype_box->currentItem());
  edit_report->setServiceName(edit_servicename_edit->text());
  edit_report->setStationFormat(edit_stationformat_edit->text());
  edit_report->setExportPath(RDReport::Linux,edit_path_edit->text());
  edit_report->setExportPath(RDReport::Windows,edit_winpath_edit->text());
  edit_report->
    setExportTypeEnabled(RDReport::Traffic,edit_traffic_box->isChecked());
  edit_report->
    setExportTypeEnabled(RDReport::Music,edit_music_box->isChecked());
  edit_report->
    setExportTypeForced(RDReport::Traffic,edit_forcetraffic_box->isChecked());
  edit_report->
    setExportTypeForced(RDReport::Music,edit_forcemusic_box->isChecked());
  edit_report->
    setExportTypeEnabled(RDReport::Generic,edit_generic_box->isChecked());
  edit_report->setFilterOnairFlag(edit_onairflag_box->currentItem()==1);

  //
  // Add New Services
  //
  for(unsigned i=0;i<edit_service_sel->destCount();i++) {
    sql=QString().sprintf("select SERVICE_NAME from REPORT_SERVICES \
where REPORT_NAME=\"%s\" && SERVICE_NAME=\"%s\"",
			  (const char *)edit_report->name(),
			  (const char *)edit_service_sel->destText(i));
    q=new RDSqlQuery(sql);
    if(q->size()==0) {
      delete q;
      sql=QString().
	sprintf("insert into REPORT_SERVICES (REPORT_NAME,SERVICE_NAME) \
                 values (\"%s\",\"%s\")",
			    (const char *)edit_report->name(),
			    (const char *)edit_service_sel->destText(i));
      q=new RDSqlQuery(sql);
    }
    delete q;
  }
예제 #12
0
파일: rdconf.cpp 프로젝트: WMTH/rivendell
bool RDDoesRowExist(const QString &table,const QString &name,unsigned test,
		    QSqlDatabase *db)
{
  RDSqlQuery *q;
  QString sql;

  sql="select `"+name+"` from `"+table+"` where `"+name+"`="+
    QString().sprintf("%d",test);
  q=new RDSqlQuery(sql,db);
  if(q->size()>0) {
    delete q;
    return true;
  }
  delete q;
  return false;
}
예제 #13
0
void ListSvcs::deleteData()
{
  QString str1;
  QString str2;
  QString sql;
  RDSqlQuery *q;

  str1=QString(tr("Are you sure you want to delete service"));
  if(QMessageBox::warning(this,tr("Delete Service"),
			  QString().sprintf(
			    "%s %s?",(const char *)str1,
			    (const char *)list_box->currentText()),
			  QMessageBox::Yes,QMessageBox::No)!=
     QMessageBox::Yes) {
    return;
  }
  sql=QString().sprintf("select NAME from LOGS where SERVICE=\"%s\"",
			(const char *)list_box->currentText());
  q=new RDSqlQuery(sql);
  if(q->first()) {
    str1=tr("There are");
    str2=tr("logs owned by this service that will also be deleted.\nDo you still want to proceed?");
    if(QMessageBox::warning(this,tr("Logs Exist"),
			 QString().sprintf("%s %d %s",
					   (const char *)str1,
					   q->size(),
					   (const char *)str2),
			    QMessageBox::Yes,QMessageBox::No)!=
       QMessageBox::Yes) {
      delete q;
      return;
    }
  }
  delete q;
  RDSvc *svc=new RDSvc(list_box->currentText());
  svc->remove();
  delete svc;
  list_box->removeItem(list_box->currentItem());
  if(list_box->currentItem()>=0) {
    list_box->setSelected(list_box->currentItem(),true);
  }
}
void MainWidget::RefreshList()
{
  RDSqlQuery *q;
  QString sql;
  int id=-1;
  RDListViewItem *selected_item=NULL;
  RDListViewItem *item=(RDListViewItem *)cast_feed_list->selectedItem();
  if(item!=NULL) {
    id=item->id();
  }
  cast_feed_list->clear();
  sql=QString().sprintf("select KEY_NAME from FEED_PERMS \
                         where USER_NAME=\"%s\"",
			(const char *)rda->user()->name());
  q=new RDSqlQuery(sql);
  if(q->size()<=0) {  // No valid feeds!
    delete q;
    return;
  }
  sql="select ID,KEY_NAME from FEEDS where ";
  while(q->next()) {
    sql+=QString().sprintf("(KEY_NAME=\"%s\")||",
			   (const char *)q->value(0).toString());
  }
  delete q;
  sql=sql.left(sql.length()-2);
  q=new RDSqlQuery(sql);
  while(q->next()) {
    item=new RDListViewItem(cast_feed_list);
    item->setId(q->value(0).toInt());
    item->setText(1,q->value(1).toString());
    RefreshItem(item);
    if(item->id()==id) {
      selected_item=item;
    }
  }
  delete q;
  if(selected_item!=NULL) {
    cast_feed_list->setSelected(selected_item,true);
    cast_feed_list->ensureItemVisible(item);
  }
}
예제 #15
0
//
// Global Classes
//
RDAudioPort::RDAudioPort(QString station,int card,bool create)
{
  RDSqlQuery *q;
  QString sql;

  port_station=station;
  port_card=card;

  if(create) {
    sql=QString().sprintf("select ID from AUDIO_PORTS where \
(STATION_NAME=\"%s\")&&(CARD_NUMBER=%d)",(const char *)port_station,port_card);
    q=new RDSqlQuery(sql);
    if(q->size()!=1) {
      delete q;
      sql=QString().sprintf("INSERT INTO AUDIO_PORTS SET STATION_NAME=\"%s\",\
CARD_NUMBER=%d",
			    (const char *)port_station,port_card);
      q=new RDSqlQuery(sql);
      delete q;
    }
    else {
      delete q;
예제 #16
0
void EditPerms::okData()
{
  RDSqlQuery *q;
  QString sql;

  //
  // Add New Objects
  //
  for(unsigned i=0;i<svc_object_sel->destCount();i++) {
    sql=QString("select ")+object_type+"_NAME from "+
      object_type+"_PERMS where "+
      "(SERVICE_NAME=\""+RDEscapeString(svc_object_sel->destText(i))+"\")&&"+
      object_type+"_NAME=\""+RDEscapeString(sel_name)+"\"";
    q=new RDSqlQuery(sql);
    if(q->size()==0) {
      delete q;
      sql=QString("insert into ")+object_type+"_PERMS set "+
	"SERVICE_NAME=\""+RDEscapeString(svc_object_sel->destText(i))+"\","+
	object_type+"_NAME=\""+RDEscapeString(sel_name)+"\"";
      q=new RDSqlQuery(sql);
    }
    delete q;
  }

  //
  // Delete Old Hosts
  //
  sql=QString("delete from ")+object_type+"_PERMS where "+
    "("+object_type+"_NAME=\""+RDEscapeString(sel_name)+"\")&&";
  for(unsigned i=0;i<svc_object_sel->destCount();i++) {
    sql+=QString("(SERVICE_NAME<>\"")+
      RDEscapeString(svc_object_sel->destText(i))+"\")";
  }
  q=new RDSqlQuery(sql);
  delete q;

  done(0);
}
예제 #17
0
//
// Global Classes
//
RDRecording::RDRecording(int id,bool create)
{
  RDSqlQuery *q;
  QString sql;

  if(id<0) {
    rec_id=AddRecord();
    create=false;
  }
  else {
    rec_id=id;
  }

  if(create) {
    sql=QString().sprintf("select ID from RECORDINGS where ID=%d",rec_id);
    q=new RDSqlQuery(sql);
    if(q->size()!=1) {
      delete q;
      sql=QString().sprintf("insert into RECORDINGS set ID=%d",rec_id);
      q=new RDSqlQuery(sql);
    }
    delete q;
  }
}
예제 #18
0
void EditUserPerms::okData()
{
  RDSqlQuery *q;
  QString sql;

  //
  // Add New Groups
  //
  for(unsigned i=0;i<user_host_sel->destCount();i++) {
    sql=QString("select GROUP_NAME from USER_PERMS where ")+
      "(USER_NAME=\""+RDEscapeString(user_user->name())+"\")&&"+
      "(GROUP_NAME=\""+RDEscapeString(user_host_sel->destText(i))+"\")";
    q=new RDSqlQuery(sql);
    if(q->size()==0) {
      delete q;
      sql=QString("insert into USER_PERMS set ")+
	"USER_NAME=\""+RDEscapeString(user_user->name())+"\","+
	"GROUP_NAME=\""+RDEscapeString(user_host_sel->destText(i))+"\"";
      q=new RDSqlQuery(sql);
    }
    delete q;
  }

  //
  // Delete Old Groups
  //
  sql=QString("delete from USER_PERMS where ")+
    "(USER_NAME=\""+RDEscapeString(user_user->name())+"\")";
  for(unsigned i=0;i<user_host_sel->destCount();i++) {
    sql+=QString("&&(GROUP_NAME<>")+"\""+
      RDEscapeString(user_host_sel->destText(i))+"\")";
  }
  q=new RDSqlQuery(sql);
  delete q;
  done(0);
}
예제 #19
0
파일: rdevent.cpp 프로젝트: WMFO/rivendell
//
// Global Classes
//
RDEvent::RDEvent(const QString &name,bool create)
{
  RDSqlQuery *q;
  QString sql;

  event_name=name;

  if(create) {
    sql=QString("select NAME from EVENTS where ")+
      "(NAME=\""+RDEscapeString(event_name)+"\")";
    q=new RDSqlQuery(sql);
    if(q->size()!=1) {
      delete q;
      sql=QString("insert into EVENTS set ")+
	"NAME=\""+RDEscapeString(event_name)+"\","+
	"TITLE_SEP=100";
      q=new RDSqlQuery(sql);
      delete q;
    }
    else {
      delete q;
    }
  }
}
예제 #20
0
void RDCutDialog::RefreshCarts()
{
  QString sql;
  RDSqlQuery *q;
  RDListViewItem *l;
  QString group=cut_group_box->currentText();

  if(!cut_cutname->isEmpty()) {
  }
  cut_cart_list->clear();
  if(group==QString(tr("ALL"))) {
    group="";
  }
  QString schedcode="";
  if(cut_schedcode_box->currentText()!=tr("ALL")) {
    schedcode=cut_schedcode_box->currentText();
  }
  sql=QString().sprintf("select CART.NUMBER,CART.TITLE,CART.GROUP_NAME,\
                         GROUPS.COLOR,CART.TYPE from CART left join GROUPS \
                         on CART.GROUP_NAME=GROUPS.NAME \
                         %s&&(CART.TYPE=%u)",
			(const char *)RDCartSearchText(cut_filter_edit->text(),
						       group,schedcode.utf8(),
						       false),
			RDCart::Audio);
  if(cut_exclude_tracks) {
    sql+="&&(CART.OWNER is null)";
  }
  if(cart_limit_box->isChecked()) {
    sql+=QString().sprintf(" limit %d",RD_LIMITED_CART_SEARCH_QUANTITY);
  }
  q=new RDSqlQuery(sql);
  int step=0;
  int count=0;
  cut_progress_dialog->setTotalSteps(q->size()/RDCUT_DIALOG_STEP_SIZE);
  cut_progress_dialog->setProgress(0);
  while(q->next()) {
    l=new RDListViewItem(cut_cart_list);
    switch((RDCart::Type)q->value(4).toUInt()) {
    case RDCart::Audio:
      l->setPixmap(0,*cut_playout_map);
      break;

    case RDCart::All:
    case RDCart::Macro:
      break;
    }
    l->setText(1,QString().sprintf("%06u",q->value(0).toUInt()));   // Number

    l->setText(2,q->value(1).toString());     // Title
    l->setText(3,q->value(2).toString());     // Group
    l->setTextColor(3,q->value(3).toString(),QFont::Bold);
    if(count++>RDCUT_DIALOG_STEP_SIZE) {
      cut_progress_dialog->setProgress(++step);
      count=0;
      qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
    }
  }
  cut_progress_dialog->reset();
  delete q;
  cut_search_button->setDisabled(true);
}
void EditSettings::okData()
{
  QString sql;
  RDSqlQuery *q;
  RDSqlQuery *q1;
  std::map<unsigned,QString> dups;

  if(edit_duplicate_carts_box->isChecked()!=
     edit_system->allowDuplicateCartTitles()) {
    QLabel *msg=new QLabel(this);
    QProgressDialog *pd=new QProgressDialog(this);
    pd->setLabel(msg);
    pd->setCancelButton(NULL);
    pd->setMinimumDuration(2);
    if(!edit_duplicate_carts_box->isChecked()) {
      //
      // Check for dups
      //
      msg->setText(tr("Checking the Library for duplicates."));
      sql="select NUMBER,TITLE from CART order by NUMBER";
      q=new RDSqlQuery(sql);
      int count=0;
      int step=0;
      int step_size=q->size()/10;
      pd->setProgress(0,10);
      while(q->next()) {
	sql=QString().sprintf("select NUMBER from CART \
                           where (TITLE=\"%s\")&&(NUMBER!=%u)",
			      (const char *)RDEscapeString(q->value(1).toString()),
			      q->value(0).toUInt());
	q1=new RDSqlQuery(sql);
	while(q1->next()) {
	  dups[q1->value(0).toUInt()]=q->value(1).toString();
	}
	delete q1;
	count++;
	if(count>=step_size) {
	  pd->setProgress(++step);
	  count=0;
	  qApp->processEvents();
	}
      }
      delete q;
      pd->reset();
      if(dups.size()>0) {
	QListViewItem *item;
	y_pos=305;
	setMinimumWidth(sizeHint().width());
	setMaximumWidth(sizeHint().width());
	setMinimumHeight(sizeHint().height());
	setMaximumHeight(sizeHint().height());
	edit_duplicate_carts_box->setChecked(true);
	edit_duplicate_label->show();
	edit_duplicate_list->show();
	edit_save_button->show();
	edit_duplicate_list->clear();
	edit_ok_button->setGeometry(sizeHint().width()-180,
				    sizeHint().height()-60,
				    80,50);
	edit_cancel_button->
	  setGeometry(sizeHint().width()-90,sizeHint().height()-60,80,50);
	for(std::map<unsigned,QString>::const_iterator ci=dups.begin();
	    ci!=dups.end();ci++) {
	  item=new QListViewItem(edit_duplicate_list);
	  item->setText(0,QString().sprintf("%06u",ci->first));
	  item->setText(1,ci->second);
	}
	return;
      }

      //
      // All ok -- make the change
      //
      sql="alter table CART drop index TITLE_IDX";
      q=new RDSqlQuery(sql);
      delete q;
      sql="alter table CART modify column TITLE char(255) unique";
      q=new RDSqlQuery(sql);
      delete q;
      edit_system->setAllowDuplicateCartTitles(false);
    }
예제 #22
0
void EditSettings::okData()
{
  QString sql;
  RDSqlQuery *q;
  RDSqlQuery *q1;
  std::map<unsigned,QString> dups;

  if(edit_duplicate_carts_box->isChecked()!=
     edit_system->allowDuplicateCartTitles()) {
    QLabel *msg=new QLabel(this);
    Q3ProgressDialog *pd=new Q3ProgressDialog(this);
    pd->setLabel(msg);
    pd->setCancelButton(NULL);
    pd->setMinimumDuration(2);
    if(!edit_duplicate_carts_box->isChecked()) {
      //
      // Check for dups
      //
      msg->setText(tr("Checking the Library for duplicates."));
      sql="select NUMBER,TITLE from CART order by NUMBER";
      q=new RDSqlQuery(sql);
      int count=0;
      int step=0;
      int step_size=q->size()/10;
      pd->setProgress(0,10);
      while(q->next()) {
	sql=QString("select NUMBER from CART where ")+
	  "(TITLE=\""+RDEscapeString(q->value(1).toString())+"\")&&"+
	  QString().sprintf("(NUMBER!=%u)",q->value(0).toUInt());
	q1=new RDSqlQuery(sql);
	while(q1->next()) {
	  dups[q1->value(0).toUInt()]=q->value(1).toString();
	}
	delete q1;
	count++;
	if(count>=step_size) {
	  pd->setProgress(++step);
	  count=0;
	  qApp->processEvents();
	}
      }
      delete q;
      pd->reset();
      if(dups.size()>0) {
	Q3ListViewItem *item;
	y_pos=305;
	setMinimumWidth(sizeHint().width());
	setMaximumWidth(sizeHint().width());
	setMinimumHeight(sizeHint().height());
	setMaximumHeight(sizeHint().height());
	edit_duplicate_carts_box->setChecked(true);
	edit_duplicate_label->show();
	edit_duplicate_list->show();
	edit_save_button->show();
	edit_duplicate_list->clear();
	edit_ok_button->setGeometry(sizeHint().width()-180,
				    sizeHint().height()-60,
				    80,50);
	edit_cancel_button->
	  setGeometry(sizeHint().width()-90,sizeHint().height()-60,80,50);
	for(std::map<unsigned,QString>::const_iterator ci=dups.begin();
	    ci!=dups.end();ci++) {
	  item=new Q3ListViewItem(edit_duplicate_list);
	  item->setText(0,QString().sprintf("%06u",ci->first));
	  item->setText(1,ci->second);
	}
	return;
      }

      //
      // All ok -- make the change
      //
      sql="alter table CART drop index TITLE_IDX";
      q=new RDSqlQuery(sql);
      delete q;
      sql="alter table CART modify column TITLE char(255) unique";
      q=new RDSqlQuery(sql);
      delete q;
      edit_system->setAllowDuplicateCartTitles(false);
    }
    else {
      sql="alter table CART drop index TITLE";
      q=new RDSqlQuery(sql);
      delete q;
      sql="alter table CART modify column TITLE char(255)";
      q=new RDSqlQuery(sql);
      delete q;
      sql="alter table CART add index TITLE_IDX(TITLE)";
      q=new RDSqlQuery(sql);
      delete q;
      edit_system->setAllowDuplicateCartTitles(true);
    }
    delete pd;
  }
  edit_system->
    setFixDuplicateCartTitles(edit_fix_duplicate_carts_box->isChecked());
  edit_system->setSampleRate(edit_sample_rate_box->currentText().toUInt());
  edit_system->setMaxPostLength(edit_maxpost_spin->value()*1000000);
  edit_system->setIsciXreferencePath(edit_isci_path_edit->text());
  edit_system->
    setNotificationAddress(QHostAddress(edit_notification_address_edit->text()));
  edit_system->setTempCartGroup(edit_temp_cart_group_box->currentText());
  edit_system->setShowUserList(edit_show_user_list_box->isChecked());

  done(0);
}
예제 #23
0
void ListGroups::deleteData()
{
  RDListViewItem *item=(RDListViewItem *)list_groups_view->selectedItem();
  if(item==NULL) {
    return;
  }

  QString sql;
  RDSqlQuery *q;
  QString warning;
  int carts=0;
  QString str;

  QString groupname=item->text(0);
  if(groupname.isEmpty()) {
    return;
  }
  sql=QString().sprintf("select NUMBER from CART where GROUP_NAME=\"%s\"",
			(const char *)groupname);
  q=new RDSqlQuery(sql);
  if((carts=q->size())>0) {
    str=QString(tr("member carts will be deleted along with group"));
    warning=QString().
      sprintf("%d %s %s!\n",
	      carts,(const char *)str,(const char *)groupname);
  }
  str=QString(tr("Are you sure you want to delete group"));
  warning+=QString().sprintf("%s %s?",(const char *)str,
			     (const char *)groupname);
  switch(QMessageBox::warning(this,tr("Delete Group"),warning,
			      QMessageBox::Yes,QMessageBox::No)) {
      case QMessageBox::No:
      case QMessageBox::NoButton:
	delete q;
	return;

      default:
	break;
  }

  //
  // Delete Member Carts
  //
  RDCart *cart;
  while(q->next()) {
    cart=new RDCart(q->value(0).toUInt());
    cart->remove(admin_station,admin_user,admin_config);
    delete cart;
  }
  delete q;
  
  //
  // Delete Member Audio Perms
  //
  sql=QString().sprintf("delete from AUDIO_PERMS where GROUP_NAME=\"%s\"",
			(const char *)RDEscapeString(groupname));
  q=new RDSqlQuery(sql);
  delete q;
  
  //
  // Delete Member User Perms
  //
  sql=QString().sprintf("delete from USER_PERMS where GROUP_NAME=\"%s\"",
			(const char *)RDEscapeString(groupname));
  q=new RDSqlQuery(sql);
  delete q;
  
  //
  // Delete Replicator Map Records
  //
  sql=QString().sprintf("delete from REPLICATOR_MAP where GROUP_NAME=\"%s\"",
			(const char *)RDEscapeString(groupname));
  q=new RDSqlQuery(sql);
  delete q;
  
  //
  // Delete from Group List
  //
  sql=QString().sprintf("delete from GROUPS where NAME=\"%s\"",
			(const char *)RDEscapeString(groupname));
  q=new RDSqlQuery(sql);
  delete q;
  item->setSelected(false);
  delete item;
}
예제 #24
0
SchedRulesList::SchedRulesList(QString clockname)
{
  QString sql;
  RDSqlQuery *q;
  RDSqlQuery *q1;

  sql=QString().sprintf("create table if not exists `%s_RULES` (\
      CODE varchar(10) not null primary key,\
      MAX_ROW int unsigned,\
      MIN_WAIT int unsigned,\
      NOT_AFTER varchar(10),\
      OR_AFTER varchar(10),\
      OR_AFTER_II varchar(10))",(const char*)clockname.replace(" ","_")); 

  q=new RDSqlQuery(sql);
  if(!q->isActive()) {
    printf("SQL: %s\n",(const char *)sql);
    printf("SQL Error: %s\n",(const char *)q->lastError().databaseText());
  }
  delete q;

  sql=QString().sprintf("select CODE,DESCRIPTION from SCHED_CODES order by `CODE` asc"); 

  q=new RDSqlQuery(sql);

  itemcounter=q->size();  
  sched_code = new QString[itemcounter];
  max_row = new int[itemcounter];
  min_wait = new int[itemcounter];
  not_after = new QString[itemcounter];
  or_after = new QString[itemcounter];
  or_after_II = new QString[itemcounter];
  description = new QString[itemcounter];
    
  for (int i=0; i<itemcounter; i++){
    q->next();
    sched_code[i] = q->value(0).toString();
    description[i] = q->value(1).toString();
    sql=QString().sprintf("select MAX_ROW,MIN_WAIT,NOT_AFTER,OR_AFTER,OR_AFTER_II from %s_RULES where CODE=\"%s\"",
	(const char *)clockname.replace(" ","_"),(const char *)sched_code[i]);
    q1=new RDSqlQuery(sql);
    if(q1->first())
      {
      max_row[i] = q1->value(0).toInt();
      min_wait[i] = q1->value(1).toInt();
      not_after[i] = q1->value(2).toString();
      or_after[i] = q1->value(3).toString();
      or_after_II[i] = q1->value(3).toString();
      }
    else
      {
      max_row[i] = 1;
      min_wait[i] = 0;
      not_after[i] = "";
      or_after[i] = "";
      or_after_II[i] = "";
      }
    delete q1;
    }
  delete q;
}
예제 #25
0
void ListUsers::deleteData()
{
  RDListViewItem *item=(RDListViewItem *)list_users_view->selectedItem();
  if(item==NULL) {
    return;
  }

  if(list_admin_name==item->text(1)) {
    QMessageBox::warning(this,tr("Delete User"),
			 tr("You cannot delete yourself!"));
    return;
  }

  QString sql;
  RDSqlQuery *q;
  QString warning;
  QString str;

  QString username=RDEscapeString(item->text(1));

  //
  // Check for default user assignments
  //
  sql=QString().sprintf("select NAME from STATIONS where DEFAULT_NAME=\"%s\"",
			(const char *)username);
  q=new RDSqlQuery(sql);
  if(q->size()>0) {
    str=tr("This user is set as the default user for the following hosts:\n\n");
    while(q->next()) {
      str+=("     "+q->value(0).toString()+"\n");
    }
    str+="\n";
    str+=tr("You must change this before deleting the user.");
    delete q;
    QMessageBox::warning(this,tr("Delete User"),str);
    return;
  }
  delete q;

  str=QString(tr("Are you sure you want to delete user"));
  warning+=QString().sprintf("%s \"%s\"?",(const char *)str,
			     (const char *)item->text(1));
  switch(QMessageBox::warning(this,tr("Delete User"),warning,
			      QMessageBox::Yes,QMessageBox::No)) {
      case QMessageBox::No:
      case QMessageBox::NoButton:
	return;

      default:
	break;
  }

  //
  // Delete RSS Feed Perms
  //
  sql=QString().sprintf("delete from FEED_PERMS where USER_NAME=\"%s\"",
			(const char *)username);
  q=new RDSqlQuery(sql);
  delete q;
  
  //
  // Delete Member User Perms
  //
  sql=QString().sprintf("delete from USER_PERMS where USER_NAME=\"%s\"",
			(const char *)username);
  q=new RDSqlQuery(sql);
  delete q;
  
  //
  // Delete from User List
  //
  sql=QString().sprintf("delete from USERS where LOGIN_NAME=\"%s\"",
			(const char *)username);
  q=new RDSqlQuery(sql);
  delete q;

  //
  // Delete from Cached Web Connections
  //
  sql=QString().sprintf("delete from WEB_CONNECTIONS where LOGIN_NAME=\"%s\"",
			(const char *)username);
  q=new RDSqlQuery(sql);
  delete q;

  item->setSelected(false);
  delete item;
}
예제 #26
0
void RDCartDialog::RefreshCarts()
{
  QString sql;
  RDSqlQuery *q;
  RDListViewItem *l;

  cart_cart_list->clear();
  QString group=cart_group_box->currentText();
  if(group==QString(tr("ALL"))) {
    group="";
  }
  QString schedcode=cart_schedcode_box->currentText();
  if(group==QString(tr("ALL"))) {
    schedcode="";
  }
  if(cart_type==RDCart::All) {
    sql=QString("select ")+
      "CART.NUMBER,"+          // 00
      "CART.TITLE,"+           // 01
      "CART.ARTIST,"+          // 02
      "CART.CLIENT,"+          // 03
      "CART.AGENCY,"+          // 04
      "CART.USER_DEFINED,"+    // 05
      "CART.COMPOSER,"+        // 06
      "CART.CONDUCTOR,"+       // 07
      "CART.START_DATETIME,"+  // 08
      "CART.END_DATETIME,"+    // 09
      "CART.TYPE,"+            // 10
      "CART.FORCED_LENGTH,"+   // 11
      "CART.GROUP_NAME,"+      // 12
      "GROUPS.COLOR "+         // 13
      "from CART left join GROUPS "+
      "on CART.GROUP_NAME=GROUPS.NAME where "+
      GetSearchFilter(cart_filter_edit->text(),group,schedcode);
  }
  else {
    sql=QString("select ")+
      "CART.NUMBER,"+          // 00
      "CART.TITLE,"+           // 01
      "CART.ARTIST,"+          // 02
      "CART.CLIENT,"+          // 03
      "CART.AGENCY,"+          // 04
      "CART.USER_DEFINED,"+    // 05
      "CART.COMPOSER,"+        // 06
      "CART.CONDUCTOR,"+       // 07
      "CART.START_DATETIME,"+  // 08
      "CART.END_DATETIME,"+    // 09
      "CART.TYPE,"+            // 10
      "CART.FORCED_LENGTH,"+   // 11
      "CART.GROUP_NAME,"+      // 12
      "GROUPS.COLOR "+         // 13
      "from CART left join GROUPS "+
      "on CART.GROUP_NAME=GROUPS.NAME where "+
      "("+GetSearchFilter(cart_filter_edit->text(),group,schedcode)+")&&"+
      QString().sprintf("(TYPE=%d)",cart_type);
  }
  if(cart_limit_box->isChecked()) {
    sql+=QString().sprintf(" limit %d",RD_LIMITED_CART_SEARCH_QUANTITY);
  }
  q=new RDSqlQuery(sql);
  int step=0;
  int count=0;
  cart_progress_dialog->setTotalSteps(q->size()/RDCART_DIALOG_STEP_SIZE);
  cart_progress_dialog->setProgress(0);
  while(q->next()) {
    l=new RDListViewItem(cart_cart_list);
    l->setId(q->value(10).toUInt());
    switch((RDCart::Type)q->value(10).toUInt()) {
	case RDCart::Audio:
	  l->setPixmap(0,*cart_playout_map);
	  break;

	case RDCart::Macro:
	  l->setPixmap(0,*cart_macro_map);
	  break;

	default:
	  break;
    }
    l->setText(1,QString().sprintf("%06d",q->value(0).toUInt())); // Number
    l->setText(2,RDGetTimeLength(q->value(11).toInt(),false,true)); // Length
    l->setText(3,q->value(1).toString());                       // Title
    l->setText(4,q->value(2).toString());                       // Artist
    l->setText(5,q->value(12).toString());                      // Group
    l->setText(6,q->value(6).toString());                      // Composer
    l->setText(7,q->value(7).toString());                      // Conductor
    l->setTextColor(5,q->value(13).toString(),QFont::Bold);
    l->setText(8,q->value(3).toString());                       // Client
    l->setText(9,q->value(4).toString());                       // Agency
    l->setText(10,q->value(5).toString());                       // User Defined
    if(!q->value(8).toDate().isNull()) {
      l->setText(11,q->value(8).toDate().toString("MM/dd/yyyy"));  // Start Date
    }
    if(!q->value(10).toDate().isNull()) {
      l->setText(12,q->value(9).toDate().toString("MM/dd/yyyy"));  // End Date
    }
    else {
      l->setText(12,"TFN");
    }
    if(count++>RDCART_DIALOG_STEP_SIZE) {
      cart_progress_dialog->setProgress(++step);
      count=0;
      qApp->processEvents(QEventLoop::ExcludeUserInput);
    }
  }
  cart_progress_dialog->reset();
  delete q;
  cart_search_button->setDisabled(true);
}