QString RDCartDialog::GetSearchFilter(const QString &filter, const QString &group, const QString &schedcode) { QString sql; RDSqlQuery *q; QString sched=""; if(schedcode!=tr("ALL")) { sched=schedcode; } QString search=RDCartSearchText(filter,group,sched,false).utf8(); // // Excluded Groups // sql=QString().sprintf("select NAME from GROUPS where "); for(int i=1;i<cart_group_box->count();i++) { sql+=QString("(NAME!=\"")+RDEscapeString(cart_group_box->text(i))+"\")&&"; } sql=sql.left(sql.length()-2); q=new RDSqlQuery(sql); while(q->next()) { search+=QString("&&(GROUP_NAME!=\"")+ RDEscapeString(q->value(0).toString())+"\")"; } delete q; return search; }
void ListReports::GenerateCartDumpCsv(QString *report,bool prepend_names) { QString sql; RDSqlQuery *q; QString schedcode=""; if(list_schedcode!=tr("ALL")) { schedcode=list_schedcode; } // // Prepend Field Names // if(prepend_names) { *report="CART,CUT,GROUP_NAME,TITLE,ARTIST,ALBUM,YEAR,ISRC,ISCI,LABEL,"; *report+="CLIENT,AGENCY,PUBLISHER,COMPOSER,USER_DEFINED,LENGTH\n"; } // // Generate Rows // if(list_type_filter.isEmpty()) { return; } sql="select CUTS.CUT_NAME,CART.GROUP_NAME,CART.TITLE,CART.ARTIST,CART.ALBUM,\ CART.YEAR,CUTS.ISRC,CUTS.ISCI,CART.LABEL,CART.CLIENT,CART.AGENCY,\ CART.PUBLISHER,CART.COMPOSER,CART.USER_DEFINED,CUTS.LENGTH from CART \ join CUTS on CART.NUMBER=CUTS.CART_NUMBER"; if(list_group==QString("ALL")) { sql+=QString(" where ")+ RDAllCartSearchText(list_filter,schedcode,lib_user->name(),true)+" && "+ list_type_filter+" order by CUTS.CUT_NAME"; } else { sql=QString(" where ")+ RDCartSearchText(list_filter,list_group,schedcode,true)+" && "+ list_type_filter+" order by CUTS.CUT_NAME"; } q=new RDSqlQuery(sql); while(q->next()) { *report+=QString().sprintf("%u,",RDCut::cartNumber(q->value(0).toString())); *report+=QString().sprintf("%u,",RDCut::cutNumber(q->value(0).toString())); *report+="\""+q->value(1).toString()+"\","; *report+="\""+q->value(2).toString()+"\","; *report+="\""+q->value(3).toString()+"\","; *report+="\""+q->value(4).toString()+"\","; *report+="\""+q->value(5).toString()+"\","; *report+="\""+q->value(6).toString()+"\","; *report+="\""+q->value(7).toString()+"\","; *report+="\""+q->value(8).toString()+"\","; *report+="\""+q->value(9).toString()+"\","; *report+="\""+q->value(10).toString()+"\","; *report+="\""+q->value(11).toString()+"\","; *report+="\""+q->value(12).toString()+"\","; *report+="\""+q->value(13).toString()+"\","; *report+="\""+RDGetTimeLength(q->value(14).toInt(),false,false)+"\","; *report+="\n"; } }
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 Xport::ListCarts() { QString sql; RDSqlQuery *q; QString where=""; RDCart *cart; QString group_name; QString filter; int include_cuts; RDCart::Type cart_type=RDCart::All; QString type; // // Verify Post // xport_post->getValue("GROUP_NAME",&group_name); xport_post->getValue("FILTER",&filter); xport_post->getValue("INCLUDE_CUTS",&include_cuts); xport_post->getValue("TYPE",&type); if(type.lower()=="audio") { cart_type=RDCart::Audio; } if(type.lower()=="macro") { cart_type=RDCart::Macro; } // // Generate Cart List // if(group_name.isEmpty()||(group_name==tr("ALL"))) { where=RDAllCartSearchText(filter,"",rda->user()->name(),false); } else { sql=QString("select GROUP_NAME from USER_PERMS where ")+ "(GROUP_NAME=\""+RDEscapeString(group_name)+"\")&&"+ "(USER_NAME=\""+RDEscapeString(rda->user()->name())+"\")"; q=new RDSqlQuery(sql); if(!q->first()) { delete q; XmlExit("No such group",404); } where=RDCartSearchText(filter,group_name,"",false); } if(cart_type!=RDCart::All) { where+=QString().sprintf("&&(TYPE=%u)",cart_type); } sql="select NUMBER from CART where "+where+"order by NUMBER"; q=new RDSqlQuery(sql); // // Process Request // printf("Content-type: application/xml\n"); printf("Status: 200\n\n"); printf("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); printf("<cartList>\n"); while(q->next()) { cart=new RDCart(q->value(0).toUInt()); printf("%s",(const char *)cart->xml(include_cuts,true)); delete cart; } printf("</cartList>\n"); delete q; Exit(0); }
void ListReports::GenerateCartDumpCsv(QString *report,bool prepend_names) { QString sql; RDSqlQuery *q; QString schedcode=""; QStringList f0; int code_quan=0; if(list_schedcode!=tr("ALL")) { schedcode=list_schedcode; } // // Generate Rows // if(list_type_filter.isEmpty()) { return; } sql=QString("select CART.NUMBER,CART.TYPE,CUTS.CUT_NAME,CART.GROUP_NAME,CART.TITLE,CART.ARTIST,")+ "CART.ALBUM,CART.YEAR,CUTS.ISRC,CUTS.ISCI,CART.LABEL,CART.CLIENT,"+ "CART.AGENCY,CART.PUBLISHER,CART.COMPOSER,CART.CONDUCTOR,CART.SONG_ID,"+ "CART.USER_DEFINED,CUTS.DESCRIPTION,CUTS.OUTCUE,"+ "CUTS.LENGTH,"+ "CUTS.START_POINT,CUTS.END_POINT,"+ "CUTS.SEGUE_START_POINT,CUTS.SEGUE_END_POINT,"+ "CUTS.HOOK_START_POINT,CUTS.HOOK_END_POINT,"+ "CUTS.TALK_START_POINT,CUTS.TALK_END_POINT,"+ "CUTS.FADEUP_POINT,CUTS.FADEDOWN_POINT,"+ "SCHED_CODES from CART "+ "left join CUTS on CART.NUMBER=CUTS.CART_NUMBER"; if(list_group==QString("ALL")) { sql+=QString(" where ")+ RDAllCartSearchText(list_filter,schedcode,lib_user->name(),true)+" && "+ list_type_filter+" order by CART.NUMBER,CUTS.CUT_NAME"; } else { sql+=QString(" where ")+ RDCartSearchText(list_filter,list_group,schedcode,true)+" && "+ list_type_filter+" order by CART.NUMBER,CUTS.CUT_NAME"; } q=new RDSqlQuery(sql); // // Get max number of scheduler codes // while(q->next()) { f0=f0.split(" ",q->value(17).toString()); if((int)f0.size()>code_quan) { code_quan=f0.size(); } } code_quan--; // // Prepend Field Names // if(prepend_names) { *report="CART,CUT,TYPE,GROUP_NAME,TITLE,ARTIST,ALBUM,YEAR,ISRC,ISCI,LABEL,"; *report+="CLIENT,AGENCY,PUBLISHER,COMPOSER,CONDUCTOR,SONG_ID,USER_DEFINED,"; *report+="DESCRIPTION,OUTCUE,"; *report+="FILENAME,LENGTH,"; *report+="START_POINT,END_POINT,"; *report+="SEGUE_START_POINT,SEGUE_END_POINT,"; *report+="HOOK_START_POINT,HOOK_END_POINT,"; *report+="TALK_START_POINT,TALK_END_POINT,"; *report+="FADEUP_POINT,FADEDOWN_POINT,"; for(int i=0;i<code_quan;i++) { *report+=QString().sprintf("SCHED_CODE%u,",i+1); } *report=report->left(report->length()-1); *report+="\n"; } // // Generate Rows // q->seek(-1); while(q->next()) { RDCart::Type type=(RDCart::Type)q->value(1).toInt(); *report+=QString().sprintf("%u,",q->value(0).toUInt()); if(type==RDCart::Macro) { *report+="0,\"macro\","; } else { *report+=QString().sprintf("%u,",RDCut::cutNumber(q->value(2).toString())); *report+="\"audio\","; } *report+="\""+q->value(3).toString()+"\","; *report+="\""+q->value(4).toString()+"\","; *report+="\""+q->value(5).toString()+"\","; *report+="\""+q->value(6).toString()+"\","; *report+="\""+q->value(7).toDate().toString("yyyy")+"\","; *report+="\""+q->value(8).toString()+"\","; *report+="\""+q->value(9).toString()+"\","; *report+="\""+q->value(10).toString()+"\","; *report+="\""+q->value(11).toString()+"\","; *report+="\""+q->value(12).toString()+"\","; *report+="\""+q->value(13).toString()+"\","; *report+="\""+q->value(14).toString()+"\","; *report+="\""+q->value(15).toString()+"\","; *report+="\""+q->value(16).toString()+"\","; *report+="\""+q->value(17).toString()+"\","; *report+="\""+q->value(18).toString()+"\","; *report+="\""+q->value(19).toString()+"\","; if(type==RDCart::Macro) { *report+="\"\","; } else { *report+="\""+q->value(2).toString()+".wav\","; } *report+="\""+ RDGetTimeLength(q->value(20).toInt(),false,false).stripWhiteSpace()+"\","; if(type==RDCart::Macro) { *report+="-1,"; *report+="-1,"; *report+="-1,"; *report+="-1,"; *report+="-1,"; *report+="-1,"; *report+="-1,"; *report+="-1,"; *report+="-1,"; *report+="-1,"; } else { *report+=QString().sprintf("%d,",q->value(21).toInt()); *report+=QString().sprintf("%d,",q->value(22).toInt()); *report+=QString().sprintf("%d,",q->value(23).toInt()); *report+=QString().sprintf("%d,",q->value(24).toInt()); *report+=QString().sprintf("%d,",q->value(25).toInt()); *report+=QString().sprintf("%d,",q->value(26).toInt()); *report+=QString().sprintf("%d,",q->value(27).toInt()); *report+=QString().sprintf("%d,",q->value(28).toInt()); *report+=QString().sprintf("%d,",q->value(29).toInt()); *report+=QString().sprintf("%d,",q->value(30).toInt()); } f0=f0.split(" ",q->value(31).toString()); for(int i=0;i<code_quan;i++) { if(((int)f0.size()>i)&&(f0[i]!=".")) { *report+="\""+f0[i].stripWhiteSpace()+"\","; } else { *report+="\"\","; } } *report=report->left(report->length()-1); *report+="\n"; } }
void ListReports::GenerateCartDumpFixed(QString *report,bool prepend_names) { QString sql; RDSqlQuery *q; QString schedcode=""; if(list_schedcode!=tr("ALL")) { schedcode=list_schedcode; } // // Prepend Field Names // if(prepend_names) { *report="CART |"; *report+="CUT|"; *report+="GROUP_NAME|"; *report+="TITLE |"; *report+="ARTIST |"; *report+="ALBUM |"; *report+="YEAR|"; *report+="ISRC |"; *report+="LABEL |"; *report+="CLIENT |"; *report+="AGENCY |"; *report+="PUBLISHER |"; *report+="COMPOSER |"; *report+="USER_DEFINED |"; *report+="LENGTH |\n"; } // // Generate Rows // if(list_type_filter.isEmpty()) { return; } sql="select CUTS.CUT_NAME,CART.GROUP_NAME,CART.TITLE,CART.ARTIST,CART.ALBUM,\ CART.YEAR,CUTS.ISRC,CART.LABEL,CART.CLIENT,CART.AGENCY,CART.PUBLISHER,\ CART.COMPOSER,CART.USER_DEFINED,CUTS.LENGTH from CART \ join CUTS on CART.NUMBER=CUTS.CART_NUMBER"; if(list_group==QString("ALL")) { sql+=QString(" where ")+ RDAllCartSearchText(list_filter,schedcode,lib_user->name(),true)+" && "+ list_type_filter+" order by CUTS.CUT_NAME"; } else { sql+=QString(" where ")+ RDCartSearchText(list_filter,list_group,schedcode,true)+" && "+ list_type_filter+" order by CUTS.CUT_NAME"; } q=new RDSqlQuery(sql); while(q->next()) { // // Cart Number // *report+=QString().sprintf("%-6s|",(const char *)q->value(0).toString(). utf8().left(6)); // // Cut Number // *report+= QString().sprintf("%-3s|",(const char *)q->value(0).toString().right(3)); // // Group Name // *report+=QString().sprintf("%-10s|",(const char *)q->value(1).toString(). utf8()); // // Title // *report+=QString().sprintf("%-255s|",(const char *)q->value(2).toString(). utf8()); // // Artist // *report+=QString().sprintf("%-255s|",(const char *)q->value(3).toString(). utf8()); // // Album // *report+=QString().sprintf("%-255s|",(const char *)q->value(4).toString(). utf8()); // // Year // if(q->value(5).toDate().isNull()) { *report+=" |"; } else { *report+=QString().sprintf("%4d|",q->value(5).toDate().year()); } // // ISRC // *report+=QString().sprintf("%-12s|",(const char *)q->value(6).toString(). utf8()); // // Label // *report+=QString().sprintf("%-64s|",(const char *)q->value(7).toString(). utf8()); // // Client // *report+=QString().sprintf("%-64s|",(const char *)q->value(8).toString(). utf8()); // // Agency // *report+=QString().sprintf("%-64s|",(const char *)q->value(9).toString(). utf8()); // // Publisher // *report+=QString().sprintf("%-64s|",(const char *)q->value(10).toString(). utf8()); // // Composer // *report+=QString().sprintf("%-64s|",(const char *)q->value(11).toString(). utf8()); // // User Defined // *report+=QString().sprintf("%-255s|",(const char *)q->value(12).toString(). utf8()); // // Length // *report+=QString().sprintf("%9s|", (const char *)RDGetTimeLength(q->value(13).toInt(),true,true)); // // End of Line // *report+="\n"; } delete q; }
void ListReports::GenerateCutReport(QString *report) { QString sql; RDSqlQuery *q; unsigned current_cart=0; QString schedcode=""; if(list_schedcode!=tr("ALL")) { schedcode=list_schedcode; } // // Generate Header // QString filter=list_filter; if(list_filter.isEmpty()) { filter="[none]"; } *report=" Rivendell Cut Report\n"; *report+=QString(). sprintf("Generated: %s Group: %-10s Filter: %s\n", (const char *)QDateTime(QDate::currentDate(),QTime::currentTime()). toString("MM/dd/yyyy - hh:mm:ss"), (const char *)list_group.utf8(),(const char *)filter.utf8()); *report+="\n"; *report+="-Cart- Cut Wht -Cart Title-------------- -Description--- -Len- Last Play Plays Start Date End Date -Days of Week- -Daypart-----------\n"; // // Generate Rows // if(list_type_filter.isEmpty()) { return; } sql="select CART.NUMBER,CUTS.CUT_NAME,CUTS.WEIGHT,CART.TITLE,\ CUTS.DESCRIPTION,CUTS.LENGTH,CUTS.LAST_PLAY_DATETIME,CUTS.PLAY_COUNTER,\ CUTS.START_DATETIME,CUTS.END_DATETIME,SUN,MON,TUE,WED,THU,FRI,SAT,\ CUTS.START_DAYPART,CUTS.END_DAYPART from CART join CUTS \ on CART.NUMBER=CUTS.CART_NUMBER"; if(list_group==QString("ALL")) { sql+=QString(" where ")+ RDAllCartSearchText(list_filter,schedcode,lib_user->name(),true)+" && "+ list_type_filter+" order by CART.NUMBER"; } else { sql+=QString(" where ")+ RDCartSearchText(list_filter,list_group,schedcode,true)+" && "+ list_type_filter+" order by CART.NUMBER"; } q=new RDSqlQuery(sql); while(q->next()) { // // Cart Number // if(q->value(0).toUInt()!=current_cart) { *report+=QString().sprintf("%06u ",q->value(0).toUInt()); } else { *report+=" "; } // // Cut Number // *report+= QString().sprintf("%03d ",q->value(1).toString().right(3).toInt()); // // Weight // *report+=QString().sprintf("%3d ",q->value(2).toInt()); // // Title // if(q->value(0).toUInt()!=current_cart) { *report+=QString().sprintf("%-25s ",(const char *)q->value(3).toString(). utf8().left(25)); } else { *report+=" "; } // // Description // *report+=QString().sprintf("%-15s ",(const char *)q->value(4).toString(). utf8().left(15)); // // Length // *report+= QString().sprintf("%5s ", (const char *)RDGetTimeLength(q->value(5).toInt(),false,false)); // // Last Play // if(q->value(6).toDateTime().isNull()) { *report+=" [none] "; } else { *report+=QString().sprintf(" %8s ", (const char *)q->value(6).toDate().toString("MM/dd/yy")); } // // Plays // *report+=QString().sprintf("%4d ",q->value(7).toInt()); // // Start Date // if(q->value(8).toDateTime().isNull()) { *report+=" [none] "; } else { *report+=QString().sprintf(" %8s ", (const char *)q->value(8).toDateTime().toString("MM/dd/yy")); } // // End Date // if(q->value(9).toDateTime().isNull()) { *report+=" TFN "; } else { *report+=QString().sprintf(" %8s ", (const char *)q->value(9).toDateTime().toString("MM/dd/yy")); } // // Days of the Week // if(q->value(10).toString()=="Y") { *report+="Su"; } else { *report+=" "; } if(q->value(11).toString()=="Y") { *report+="Mo"; } else { *report+=" "; } if(q->value(12).toString()=="Y") { *report+="Tu"; } else { *report+=" "; } if(q->value(13).toString()=="Y") { *report+="We"; } else { *report+=" "; } if(q->value(14).toString()=="Y") { *report+="Th"; } else { *report+=" "; } if(q->value(15).toString()=="Y") { *report+="Fr"; } else { *report+=" "; } if(q->value(16).toString()=="Y") { *report+="Sa "; } else { *report+=" "; } // // Dayparts // if(q->value(18).toTime().isNull()) { *report+="[none]"; } else { *report+=QString().sprintf("%8s - %8s", (const char *)q->value(17).toTime().toString("hh:mm:ss"), (const char *)q->value(18).toTime().toString("hh:mm:ss")); } // // End of Line // *report+="\n"; current_cart=q->value(0).toUInt(); } delete q; }
void ListReports::GenerateCartReport(QString *report) { QString sql; RDSqlQuery *q; QString schedcode=""; if(list_schedcode!=tr("ALL")) { schedcode=list_schedcode; } // // Generate Header // QString filter=list_filter; if(list_filter.isEmpty()) { filter="[none]"; } *report=" Rivendell Cart Report\n"; *report+=QString(). sprintf("Generated: %s Group: %-10s Filter: %s\n", (const char *)QDateTime(QDate::currentDate(),QTime::currentTime()). toString("MM/dd/yyyy - hh:mm:ss"), (const char *)list_group.utf8(),(const char *)filter.utf8()); *report+="\n"; *report+="Type -Cart- -Group---- -Len- -Title------------------------- -Artist----------------------- Cuts Rot Enf -LenDev -Owner--------------\n"; // // Generate Rows // if(list_type_filter.isEmpty()) { return; } sql=QString("select CART.TYPE,CART.NUMBER,CART.GROUP_NAME,")+ "CART.FORCED_LENGTH,CART.TITLE,CART.ARTIST,CART.CUT_QUANTITY,"+ "CART.PLAY_ORDER,CART.ENFORCE_LENGTH,CART.LENGTH_DEVIATION,CART.OWNER "+ "from CART left join CUTS on CART.NUMBER=CUTS.CART_NUMBER"; if(list_group==QString("ALL")) { sql+=QString(" where ")+ RDAllCartSearchText(list_filter,schedcode,lib_user->name(),true)+" && "+ list_type_filter+" order by NUMBER"; } else { sql+=QString(" where ")+ RDCartSearchText(list_filter,list_group,schedcode,true)+" && "+ list_type_filter+" order by NUMBER"; } q=new RDSqlQuery(sql); while(q->next()) { // // Cart Type // switch((RDCart::Type)q->value(0).toInt()) { case RDCart::Audio: *report+=" A "; break; case RDCart::Macro: *report+=" M "; break; default: *report+=" ? "; break; } // // Cart Number // *report+=QString().sprintf("%06u ",q->value(1).toUInt()); // // Group // *report+= QString().sprintf("%-10s ",(const char *)q->value(2).toString().utf8()); // // Length // *report+= QString().sprintf("%5s ", (const char *)RDGetTimeLength(q->value(3).toInt(),false,false)); // // Title // *report+=QString().sprintf("%-31s ",(const char *)q->value(4).toString(). utf8().left(31)); // // Artist // *report+=QString().sprintf("%-30s ",(const char *)q->value(5).toString(). utf8().left(30)); // // Cut Quantity // *report+=QString().sprintf("%4d ",q->value(6).toInt()); // // Play Order // switch((RDCart::PlayOrder)q->value(7).toInt()) { case RDCart::Sequence: *report+="SEQ "; break; case RDCart::Random: *report+="RND "; break; default: *report+="???"; break; } // // Enforce Length // if(q->value(8).toString()=="Y") { *report+="Yes "; } else { *report+="No "; } // // Length Deviation // *report+= QString().sprintf("%7s ", (const char *)RDGetTimeLength(q->value(9).toInt(),false,true)); // // Owner // if(q->value(10).toString().isEmpty()) { *report+="[none]"; } else { *report+=QString().sprintf("%s",(const char *)q->value(10).toString(). utf8().left(20)); } // // End of Line // *report+="\n"; } delete q; }