2021-01-13 Fred Gleason <fredg@paravelsystems.com>

* Modified the 'Edit Log' dialog in rdlibrary(1) to use the
	model-based API.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2021-01-14 13:05:59 -05:00
parent f558125a7a
commit 7bbe5a759e
14 changed files with 369 additions and 661 deletions

View File

@ -20778,3 +20778,6 @@
RD_LISTWIDGET_ITEM_HEIGHT defines in 'lib/rd.h' to define consistent
item sizes in list-style widgets.
* Modified rdlibrary(1) to use a tree-based model.
2021-01-13 Fred Gleason <fredg@paravelsystems.com>
* Modified the 'Edit Log' dialog in rdlibrary(1) to use the
model-based API.

View File

@ -270,21 +270,61 @@ QVariant RDLibraryModel::data(const QModelIndex &index,int role) const
}
unsigned RDLibraryModel::cartNumber(int row) const
bool RDLibraryModel::isCart(const QModelIndex &index) const
{
return d_texts.at(row).at(0).toUInt();
return index.internalId()==0;
}
RDCart::Type RDLibraryModel::cartType(int row) const
unsigned RDLibraryModel::cartNumber(const QModelIndex &index) const
{
return d_cart_types.at(row);
if(index.isValid()) {
if(isCart(index)) {
return d_cart_numbers.at(index.row());
}
return d_cart_numbers.at(index.internalId()-1);
}
return 0;
}
QString RDLibraryModel::cartOwnedBy(int row)
QModelIndex RDLibraryModel::cartRow(unsigned cartnum) const
{
return d_texts.at(row).at(20).toString();
int pos=d_cart_numbers.indexOf(cartnum);
if(pos<0) {
return QModelIndex();
}
return createIndex(pos,0,0);
}
RDCart::Type RDLibraryModel::cartType(const QModelIndex &index) const
{
if(isCart(index)) {
return d_cart_types.at(index.row());
}
return d_cart_types.at(index.internalId()-1);
}
QString RDLibraryModel::cutName(const QModelIndex &index) const
{
if(isCart(index)) {
return QString();
}
return RDCut::cutName(d_cart_numbers.at(index.internalId()-1),
d_cut_texts.at(index.internalId()-1).at(index.row()).
at(0).toString().right(3).toInt());
}
QString RDLibraryModel::cartOwnedBy(const QModelIndex &index)
{
if(isCart(index)) {
return d_texts.at(index.row()).at(20).toString();
}
return d_texts.at(index.internalId()-1).at(20).toString();
}
@ -295,7 +335,7 @@ int RDLibraryModel::addCart(unsigned cartnum)
//
int offset=d_texts.size();
for(int i=0;i<d_texts.size();i++) {
if(cartnum<d_texts.at(i).at(0).toUInt()) {
if(cartnum<d_cart_numbers.at(i)) {
offset=i;
break;
}
@ -310,6 +350,7 @@ int RDLibraryModel::addCart(unsigned cartnum)
list_list.push_back(list);
d_icons.insert(offset,list);
d_texts.insert(offset,list);
d_cart_numbers.insert(offset,0);
d_cut_texts.insert(offset,list_list);
d_background_colors.insert(offset,QVariant());
d_cart_types.insert(offset,RDCart::All);
@ -332,10 +373,11 @@ int RDLibraryModel::addCart(unsigned cartnum)
void RDLibraryModel::removeCart(unsigned cartnum)
{
for(int i=0;i<d_texts.size();i++) {
if(d_texts.at(i).at(0).toUInt()==cartnum) {
if(d_cart_numbers.at(i)==cartnum) {
beginRemoveRows(QModelIndex(),i,i);
d_texts.removeAt(i);
d_cart_numbers.removeAt(i);
d_cut_texts.removeAt(i);
d_background_colors.removeAt(i);
d_cart_types.removeAt(i);
@ -349,17 +391,11 @@ void RDLibraryModel::removeCart(unsigned cartnum)
}
void RDLibraryModel::refreshRow(int row)
void RDLibraryModel::refreshRow(const QModelIndex &index)
{
QString sql=sqlFields()+
"where "+
QString().sprintf("CART.NUMBER=%u",cartNumber(row));
RDSqlQuery *q=new RDSqlQuery(sql);
if(q->first()) {
updateRow(row,q);
emit dataChanged(createIndex(row,0,0),createIndex(row,columnCount(),(quint32)0));
if(isCart(index)) {
refreshCartLine(index.row());
}
delete q;
}
@ -368,12 +404,27 @@ void RDLibraryModel::refreshCart(unsigned cartnum)
QString cartnum_str=QString().sprintf("%06u",cartnum);
for(int i=0;i<d_texts.size();i++) {
if(d_texts.at(i).at(0).toString()==cartnum_str) {
refreshRow(i);
refreshCartLine(i);
}
}
}
void RDLibraryModel::refreshCartLine(int cartline)
{
QString sql=sqlFields()+
"where "+
"CART.NUMBER="+d_texts.at(cartline).at(0).toString();
RDSqlQuery *q=new RDSqlQuery(sql);
if(q->first()) {
updateRow(cartline,q);
emit dataChanged(createIndex(cartline,0,0),
createIndex(cartline,columnCount(),(quint32)0));
}
delete q;
}
void RDLibraryModel::setFilterSql(const QString &sql)
{
updateModel(sql);
@ -420,6 +471,7 @@ void RDLibraryModel::updateModel(const QString &filter_sql)
filter_sql;
beginResetModel();
d_texts.clear();
d_cart_numbers.clear();
d_cut_texts.clear();
d_background_colors.clear();
d_cart_types.clear();
@ -429,6 +481,7 @@ void RDLibraryModel::updateModel(const QString &filter_sql)
while(q->next()) {
if(q->value(0).toUInt()!=prev_cartnum) {
d_texts.push_back(list);
d_cart_numbers.push_back(0);
d_cut_texts.push_back(list_list);
d_background_colors.push_back(QVariant());
d_cart_types.push_back(RDCart::All);
@ -436,8 +489,6 @@ void RDLibraryModel::updateModel(const QString &filter_sql)
updateRow(d_texts.size()-1,q);
prev_cartnum=q->value(0).toUInt();
}
// if(q->value(15).toUInt()==RDCart::Audio) {
}
delete q;
endResetModel();
@ -473,6 +524,7 @@ void RDLibraryModel::updateRow(int row,RDSqlQuery *q)
d_cart_types[row]=(RDCart::Type)q->value(15).toUInt();
d_texts[row][0]= // Cart Number
QString().sprintf("%06d",q->value(0).toUInt());
d_cart_numbers[row]=q->value(0).toUInt();
d_texts[row][1]=q->value(12); // Group
if(q->value(16).toUInt()==1) {
d_texts[row][2]=RDGetTimeLength(q->value(1).toUInt()); // Total Length

View File

@ -51,13 +51,17 @@ class RDLibraryModel : public QAbstractItemModel
QVariant headerData(int section,Qt::Orientation orient,
int role=Qt::DisplayRole) const;
QVariant data(const QModelIndex &index,int role=Qt::DisplayRole) const;
unsigned cartNumber(int row) const;
RDCart::Type cartType(int row) const;
QString cartOwnedBy(int row);
bool isCart(const QModelIndex &index) const;
unsigned cartNumber(const QModelIndex &index) const;
QModelIndex cartRow(unsigned cartnum) const;
RDCart::Type cartType(const QModelIndex &index) const;
QString cutName(const QModelIndex &index) const;
QString cartOwnedBy(const QModelIndex &index);
int addCart(unsigned cartnum);
void removeCart(unsigned cartnum);
void refreshRow(int row);
void refreshRow(const QModelIndex &index);
void refreshCart(unsigned cartnum);
void refreshCartLine(int cartline);
signals:
void rowCountChanged(int rows);
@ -84,6 +88,7 @@ class RDLibraryModel : public QAbstractItemModel
QList<QList<QList<QVariant> > > d_cut_texts;
QList<QVariant> d_alignments;
QList<QVariant> d_background_colors;
QList<unsigned> d_cart_numbers;
QList<RDCart::Type> d_cart_types;
QMap<QString,QVariant> d_group_colors;
RDLogIcons *d_log_icons;

View File

@ -30,26 +30,26 @@
#include "rdlibrary.h"
#include "record_cut.h"
EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
QWidget *parent,const char *name,Q3ListView *lib_cart_list)
EditCart::EditCart(const QList<unsigned> &cartnums,QString *path,bool new_cart,
bool profile_rip,QWidget *parent)
: RDDialog(parent)
{
bool modification_allowed;
rdcart_cart=NULL;
rdcart_profile_rip=profile_rip;
rdcart_cart_numbers=cartnums;
rdcart_new_cart=new_cart;
sched_codes="";
add_codes="";
remove_codes="";
lib_cart_list_edit=lib_cart_list;
//
// Fix the Window Size
//
setMinimumWidth(sizeHint().width());
setMaximumWidth(sizeHint().width());
if(lib_cart_list_edit==NULL) {
if(cartnums.size()==1) {
setMinimumHeight(sizeHint().height());
setMaximumHeight(sizeHint().height());
}
@ -58,8 +58,8 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
setMaximumHeight(sizeHint().height()-270);
}
if(lib_cart_list_edit==NULL) {
rdcart_cart=new RDCart(number);
if(cartnums.size()==1) {
rdcart_cart=new RDCart(cartnums.at(0));
rdcart_import_path=path;
setWindowTitle("RDLibrary - "+tr("Edit Cart")+
QString().sprintf(" %06u",rdcart_cart->number())+" ["+
@ -84,7 +84,7 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
}
}
if(lib_cart_list_edit==NULL) {
if(cartnums.size()==1) {
//
// Cart Number
//
@ -104,7 +104,7 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
// Cart Group
//
rdcart_group_box=new QComboBox(this);
if(lib_cart_list_edit==NULL) {
if(cartnums.size()==1) {
rdcart_group_box->setGeometry(280,11,140,21);
}
else {
@ -114,7 +114,7 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
rdcart_group_edit->setGeometry(280,11,140,21);
rdcart_group_edit->setReadOnly(true);
QLabel *rdcart_group_label=new QLabel(rdcart_group_box,tr("Group:"),this);
if(lib_cart_list_edit==NULL) {
if(cartnums.size()==1) {
rdcart_group_label->setGeometry(215,13,60,21);
}
else {
@ -136,7 +136,7 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
rdcart_type_label->setFont(labelFont());
rdcart_type_label->
setAlignment(Qt::AlignRight|Qt::AlignVCenter|Qt::TextShowMnemonic);
if(lib_cart_list_edit!=NULL) {
if(cartnums.size()>1) {
rdcart_type_label->hide();
rdcart_type_edit->hide();
}
@ -155,7 +155,7 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
rdcart_average_length_label->setFont(labelFont());
rdcart_average_length_label->
setAlignment(Qt::AlignRight|Qt::AlignVCenter|Qt::TextShowMnemonic);
if(lib_cart_list_edit!=NULL) {
if(cartnums.size()>1) {
rdcart_average_length_label->hide();
rdcart_average_length_edit->hide();
}
@ -173,7 +173,7 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
setAlignment(Qt::AlignLeft|Qt::AlignVCenter|Qt::TextShowMnemonic);
connect(rdcart_controls.enforce_length_box,SIGNAL(toggled(bool)),
this,SLOT(forcedLengthData(bool)));
if(lib_cart_list_edit!=NULL) {
if(cartnums.size()>1) {
rdcart_enforce_length_label->hide();
rdcart_controls.enforce_length_box->hide();
}
@ -196,7 +196,7 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
rdcart_forced_length_label->setFont(labelFont());
rdcart_forced_length_label->
setAlignment(Qt::AlignRight|Qt::AlignVCenter|Qt::TextShowMnemonic);
if(lib_cart_list_edit!=NULL) {
if(cartnums.size()>1) {
rdcart_forced_length_label->hide();
rdcart_controls.forced_length_edit->hide();
}
@ -278,7 +278,7 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
//
rdcart_usage_box=new QComboBox(this);
rdcart_usage_box->setGeometry(270,110,150,21);
if(lib_cart_list_edit!=0) {
if(cartnums.size()>1) {
rdcart_usage_box->insertItem("");
}
for(int i=0;i<(int)RDCart::UsageLast;i++) {
@ -503,7 +503,7 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
connect(script_button,SIGNAL(clicked()),this,SLOT(scriptData()));
script_button->hide();
if(lib_cart_list_edit==NULL) {
if(cartnums.size()==1) {
//
// Cut Widget
//
@ -547,10 +547,11 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
// Ok Button
//
QPushButton *ok_button=new QPushButton(this);
if(lib_cart_list_edit==NULL)
if(cartnums.size()==1)
ok_button->setGeometry(sizeHint().width()-180,sizeHint().height()-60,80,50);
else
ok_button->setGeometry(sizeHint().width()-180,sizeHint().height()-60-270,80,50);
ok_button->
setGeometry(sizeHint().width()-180,sizeHint().height()-60-270,80,50);
ok_button->setDefault(true);
ok_button->setFont(buttonFont());
ok_button->setText(tr("&OK"));
@ -560,12 +561,12 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
// Cancel Button
//
QPushButton *cancel_button=new QPushButton(this);
if(lib_cart_list_edit==NULL)
if(cartnums.size()==1)
cancel_button->setGeometry(sizeHint().width()-90,sizeHint().height()-60,
80,50);
else
cancel_button->setGeometry(sizeHint().width()-90,sizeHint().height()-60-270,
80,50);
cancel_button->
setGeometry(sizeHint().width()-90,sizeHint().height()-60-270,80,50);
cancel_button->setFont(buttonFont());
cancel_button->setText(tr("&Cancel"));
connect(cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));
@ -573,7 +574,7 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
//
// Populate Fields
//
if(lib_cart_list_edit==NULL) { //single edit
if(cartnums.size()==1) { //single edit
rdcart_number_edit->
setText(QString().sprintf("%06d",rdcart_cart->number()));
if(rdcart_group_box->count() == 0)
@ -602,9 +603,10 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
rdcart_type_edit->setText(tr("UNKNOWN"));
break;
}
rdcart_controls.enforce_length_box->setChecked(rdcart_cart->enforceLength());
rdcart_controls.enforce_length_box->
setChecked(rdcart_cart->enforceLength());
forcedLengthData(rdcart_controls.enforce_length_box->isChecked());
if(lib_cart_list_edit==NULL) {
if(cartnums.size()==1) {
rdcart_average_length_edit->
setText(RDGetTimeLength(rdcart_cart->averageLength()));
}
@ -688,7 +690,7 @@ EditCart::EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
rdcart_start_date_edit->setReadOnly(!modification_allowed);
rdcart_end_date_edit->setReadOnly(!modification_allowed);
rdcart_notes_button->setEnabled(modification_allowed);
if(lib_cart_list_edit==NULL) {
if(cartnums.size()==1) {
rdcart_average_length_edit->
setReadOnly((!modification_allowed)||
(!rdcart_controls.enforce_length_box->isChecked()));
@ -763,20 +765,17 @@ void EditCart::lengthChangedData(unsigned len)
void EditCart::okData()
{
Q3ListViewItemIterator *it;
RDCart *rdcart_cart_medit;
RDSystem *system;
// RDSystem *system;
QString sql;
RDSqlQuery *q;
if(lib_cart_list_edit==NULL) { // Single Edit
if(rdcart_cart_numbers.size()==1) { // Single Edit
if(rdcart_controls.title_edit->text().isEmpty()) {
QMessageBox::warning(this,tr("Missing Title"),
tr("You must provide at least a Cart Title!"));
return;
}
system=new RDSystem();
if(!system->allowDuplicateCartTitles()) {
if(!rda->system()->allowDuplicateCartTitles()) {
sql=QString("select NUMBER from CART where ")+
"(TITLE=\""+RDEscapeString(rdcart_controls.title_edit->text())+"\") &&"+
QString().sprintf("(NUMBER!=%u)",rdcart_cart->number());
@ -785,12 +784,10 @@ void EditCart::okData()
QMessageBox::warning(this,tr("Duplicate Title"),
tr("The cart title must be unique!"));
delete q;
delete system;
return;
}
delete q;
}
delete system;
if(rdcart_controls.enforce_length_box->isChecked()) {
if(!ValidateLengths()) {
switch(QMessageBox::warning(this,tr("Length Mismatch"),
@ -867,74 +864,60 @@ void EditCart::okData()
}
}
else { // Multi Edit
it=new Q3ListViewItemIterator(lib_cart_list_edit);
while(it->current()) {
if(it->current()->isSelected()) {
RDListViewItem *item=(RDListViewItem *)it->current();
if(item->text(MainWidget::OwnedBy).isEmpty()) {
rdcart_cart_medit=new RDCart(item->text(MainWidget::Cart).toUInt());
if(!rdcart_group_box->currentText().stripWhiteSpace().isEmpty()) {
rdcart_cart_medit->setGroupName(rdcart_group_box->currentText());
}
if(!rdcart_controls.title_edit->text().stripWhiteSpace().isEmpty()) {
rdcart_cart_medit->setTitle(rdcart_controls.title_edit->text());
}
if(rdcart_controls.year_edit->text().toInt()) {
rdcart_cart_medit->setYear(rdcart_controls.year_edit->text().toInt());
}
if(!rdcart_controls.artist_edit->text().stripWhiteSpace().isEmpty()) {
rdcart_cart_medit->setArtist(rdcart_controls.artist_edit->text());
}
if(!rdcart_controls.album_edit->text().stripWhiteSpace().isEmpty()) {
rdcart_cart_medit->setAlbum(rdcart_controls.album_edit->text());
}
if(!rdcart_controls.label_edit->text().stripWhiteSpace().isEmpty()) {
rdcart_cart_medit->setLabel(rdcart_controls.label_edit->text());
}
if(!rdcart_controls.client_edit->text().stripWhiteSpace().isEmpty()) {
rdcart_cart_medit->setClient(rdcart_controls.client_edit->text());
}
if(!rdcart_controls.agency_edit->text().stripWhiteSpace().isEmpty()) {
rdcart_cart_medit->setAgency(rdcart_controls.agency_edit->text());
}
if(!rdcart_controls.song_id_edit->
text().stripWhiteSpace().isEmpty()) {
rdcart_cart_medit->
setSongId(rdcart_controls.song_id_edit->text());
}
if(!rdcart_controls.publisher_edit->text().stripWhiteSpace().
isEmpty()) {
rdcart_cart_medit->
setPublisher(rdcart_controls.publisher_edit->text());
}
if(!rdcart_controls.composer_edit->
text().stripWhiteSpace().isEmpty()) {
rdcart_cart_medit->
setComposer(rdcart_controls.composer_edit->text());
}
if(!rdcart_controls.conductor_edit->text().
stripWhiteSpace().isEmpty()) {
rdcart_cart_medit->
setConductor(rdcart_controls.conductor_edit->text());
}
if(!rdcart_controls.user_defined_edit->text().
stripWhiteSpace().isEmpty()) {
rdcart_cart_medit->
setUserDefined(rdcart_controls.user_defined_edit->text());
}
if(!rdcart_usage_box->currentText().stripWhiteSpace().isEmpty()) {
rdcart_cart_medit->setUsageCode((RDCart::UsageCode)
(rdcart_usage_box->currentItem()-1));
}
rdcart_cart_medit->updateSchedCodes(add_codes,remove_codes);
delete rdcart_cart_medit;
}
for(int i=0;i<rdcart_cart_numbers.size();i++) {
RDCart *cart=new RDCart(rdcart_cart_numbers.at(i));
if(cart->owner().isEmpty()) {
if(!rdcart_group_box->currentText().stripWhiteSpace().isEmpty()) {
cart->setGroupName(rdcart_group_box->currentText());
}
if(!rdcart_controls.title_edit->text().stripWhiteSpace().isEmpty()) {
cart->setTitle(rdcart_controls.title_edit->text());
}
if(rdcart_controls.year_edit->text().toInt()) {
cart->setYear(rdcart_controls.year_edit->text().toInt());
}
if(!rdcart_controls.artist_edit->text().stripWhiteSpace().isEmpty()) {
cart->setArtist(rdcart_controls.artist_edit->text());
}
if(!rdcart_controls.album_edit->text().stripWhiteSpace().isEmpty()) {
cart->setAlbum(rdcart_controls.album_edit->text());
}
if(!rdcart_controls.label_edit->text().stripWhiteSpace().isEmpty()) {
cart->setLabel(rdcart_controls.label_edit->text());
}
if(!rdcart_controls.client_edit->text().stripWhiteSpace().isEmpty()) {
cart->setClient(rdcart_controls.client_edit->text());
}
if(!rdcart_controls.agency_edit->text().stripWhiteSpace().isEmpty()) {
cart->setAgency(rdcart_controls.agency_edit->text());
}
if(!rdcart_controls.song_id_edit->text().stripWhiteSpace().isEmpty()) {
cart->setSongId(rdcart_controls.song_id_edit->text());
}
if(!rdcart_controls.publisher_edit->text().
stripWhiteSpace().isEmpty()) {
cart->setPublisher(rdcart_controls.publisher_edit->text());
}
if(!rdcart_controls.composer_edit->
text().stripWhiteSpace().isEmpty()) {
cart->setComposer(rdcart_controls.composer_edit->text());
}
if(!rdcart_controls.conductor_edit->text().
stripWhiteSpace().isEmpty()) {
cart->setConductor(rdcart_controls.conductor_edit->text());
}
if(!rdcart_controls.user_defined_edit->text().
stripWhiteSpace().isEmpty()) {
cart->setUserDefined(rdcart_controls.user_defined_edit->text());
}
if(!rdcart_usage_box->currentText().stripWhiteSpace().isEmpty()) {
cart->setUsageCode((RDCart::UsageCode)
(rdcart_usage_box->currentItem()-1));
}
cart->updateSchedCodes(add_codes,remove_codes);
}
++(*it);
delete cart;
}
delete it;
}
done(true);
@ -944,7 +927,7 @@ void EditCart::okData()
void EditCart::cancelData()
{
unsigned len;
if((lib_cart_list_edit==NULL)&&(rdcart_cart->type()==RDCart::Audio)) {
if((rdcart_cart_numbers.size()==1)&&(rdcart_cart->type()==RDCart::Audio)) {
len=rdcart_cart->calculateAverageLength(&rdcart_length_deviation);
rdcart_cart->setLengthDeviation(rdcart_length_deviation);
if(!rdcart_controls.enforce_length_box->isChecked()) {
@ -1026,7 +1009,7 @@ bool EditCart::ValidateLengths()
void EditCart::schedCodesData()
{
if(lib_cart_list_edit==NULL) {
if(rdcart_cart_numbers.size()==1) {
EditSchedulerCodes *dialog=new EditSchedulerCodes(&sched_codes,NULL,this);
dialog->exec();
delete dialog;

View File

@ -2,7 +2,7 @@
//
// Edit a Rivendell Cart
//
// (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
@ -21,6 +21,8 @@
#ifndef EDIT_CART_H
#define EDIT_CART_H
#include <QList>
#include <rddialog.h>
#include "audio_cart.h"
@ -32,8 +34,8 @@ class EditCart : public RDDialog
{
Q_OBJECT
public:
EditCart(unsigned number,QString *path,bool new_cart,bool profile_rip,
QWidget *parent=0,const char *name=0,Q3ListView *lib_cart_list=NULL);
EditCart(const QList<unsigned> &cartnums,QString *path,bool new_cart,
bool profile_rip,QWidget *parent=0);
~EditCart();
QSize sizeHint() const;
QSizePolicy sizePolicy() const;
@ -54,7 +56,7 @@ class EditCart : public RDDialog
private:
void PopulateGroupList();
Q3ListView *lib_cart_list_edit;
QList<unsigned> rdcart_cart_numbers;
bool ValidateLengths();
RDCart *rdcart_cart;
QLineEdit *rdcart_type_edit;

View File

@ -278,7 +278,8 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
lib_player->stopButton()->setFocusPolicy(Qt::NoFocus);
QShortcut *lib_player_shortcut=new QShortcut(Qt::Key_Space,this);
connect(lib_player_shortcut,SIGNAL(activated()),this,SLOT(playerShortcutData()));
connect(lib_player_shortcut,SIGNAL(activated()),
this,SLOT(playerShortcutData()));
//
// Setup Signal Handling
@ -294,7 +295,6 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
dragsChangedData(lib_cart_filter->dragEnabled());
lib_cart_model->setFilterSql(lib_cart_filter->filterSql());
// lib_cart_view->resizeColumnsToContents();
LoadGeometry();
}
@ -360,6 +360,7 @@ void MainWidget::addData()
int cart_num;
RDCart::Type cart_type=RDCart::All;
QString cart_title;
QList<unsigned> cartnums;
lib_player->stop();
LockUser();
@ -380,12 +381,12 @@ void MainWidget::addData()
"TITLE=\""+RDEscapeString(cart_title)+"\"";
q=new RDSqlQuery(sql);
delete q;
cartnums.push_back(cart_num);
EditCart *cart=
new EditCart(cart_num,&lib_import_path,true,profile_ripping,this);
new EditCart(cartnums,&lib_import_path,true,profile_ripping,this);
if(cart->exec()) {
int row=lib_cart_model->addCart(cart_num);
// lib_cart_view->selectRow(row);
lib_cart_view->scrollTo(lib_cart_model->index(row,0));
SendNotification(RDNotification::AddAction,cart_num);
}
@ -403,25 +404,29 @@ void MainWidget::addData()
void MainWidget::editData()
{
QModelIndexList rows=lib_cart_view->selectionModel()->selectedRows();
QModelIndexList carts;
if(!CurrentSelection(&carts)) {
return;
}
lib_player->stop();
LockUser();
if(rows.size()==1) {
EditCart *edit_cart=
new EditCart(lib_cart_model->cartNumber(rows.first().row()),
&lib_import_path,false,profile_ripping,this);
if(edit_cart->exec()) {
lib_cart_model->refreshRow(rows.first().row());
//cartOnItemData(item);
QList<unsigned> cartnums;
for(int i=0;i<carts.size();i++) {
cartnums.push_back(lib_cart_model->cartNumber(carts.at(i)));
}
EditCart *d=
new EditCart(cartnums,&lib_import_path,false,profile_ripping,this);
if(d->exec()) {
for(int i=0;i<carts.size();i++) {
lib_cart_model->refreshRow(carts.at(i));
SendNotification(RDNotification::ModifyAction,
lib_cart_model->cartNumber(rows.first().row()));
lib_cart_model->cartNumber(carts.at(i)));
}
delete edit_cart;
}
if(rows.size()>1) {
}
delete d;
UnlockUser();
}
@ -429,19 +434,19 @@ void MainWidget::editData()
void MainWidget::macroData()
{
int row=-1;
QModelIndexList carts;
if(((row=SingleSelectedCartLine())<0)||
(lib_cart_model->cartType(row)!=RDCart::Macro)) {
if((!CurrentSelection(&carts))||(carts.size()!=1)) {
return;
}
RDCart *rdcart=new RDCart(lib_cart_model->cartNumber(row));
RDCart *rdcart=new RDCart(lib_cart_model->cartNumber(carts.first()));
lib_macro_events->clear();
lib_macro_events->load(rdcart->macros());
lib_macro_events->exec();
delete rdcart;
}
void MainWidget::deleteData()
{
QString sql;
@ -450,9 +455,9 @@ void MainWidget::deleteData()
lib_player->stop();
LockUser();
QModelIndexList rows=lib_cart_view->selectionModel()->selectedRows();
QModelIndexList carts;
if(rows.size()==0) {
if(!CurrentSelection(&carts)) {
UnlockUser();
return;
}
@ -470,8 +475,8 @@ void MainWidget::deleteData()
//
// Check for RDCatch events
//
for(int i=0;i<rows.size();i++) {
unsigned cartnum=lib_cart_model->cartNumber(rows.at(i).row());
for(int i=0;i<carts.size();i++) {
unsigned cartnum=lib_cart_model->cartNumber(carts.at(i));
sql=QString("select ")+
"CUT_NAME "+ // 00
"from RECORDINGS where "+
@ -498,8 +503,8 @@ void MainWidget::deleteData()
// Check clipboard
//
if(cut_clipboard!=NULL) {
for(int i=0;i<rows.size();i++) {
unsigned cartnum=lib_cart_model->cartNumber(rows.at(i).row());
for(int i=0;i<carts.size();i++) {
unsigned cartnum=lib_cart_model->cartNumber(carts.at(i));
if(cartnum==cut_clipboard->cartNumber()) {
QString str=tr("Deleting cart")+QString().sprintf(" %06u ",cartnum)+
tr("will also empty the clipboard.")+"\n"+
@ -520,23 +525,37 @@ void MainWidget::deleteData()
//
// Check for voicetracks
//
for(int i=0;i<rows.size();i++) {
unsigned cartnum=lib_cart_model->cartNumber(rows.at(i).row());
if(!lib_cart_model->cartOwnedBy(i).isEmpty()) {
for(int i=0;i<carts.size();i++) {
unsigned cartnum=lib_cart_model->cartNumber(carts.at(i));
if(!lib_cart_model->cartOwnedBy(carts.at(i)).isEmpty()) {
QString str=tr("Cart")+QString().sprintf(" %06u ",cartnum)+
tr("is a voicetrack belonging to log")+" \""+
lib_cart_model->cartOwnedBy(i)+"\".\n"+tr("It cannot be deleted here!");
lib_cart_model->cartOwnedBy(carts.at(i))+"\".\n"+tr("It cannot be deleted here!");
QMessageBox::information(this,"RDLibrary - "+tr("Voicetrack Found"),str);
UnlockUser();
return;
}
}
//
// Find row to be selected after deletion
//
unsigned newcartnum=0;
QModelIndex row=lib_cart_model->index(carts.last().row(),0).
sibling(carts.last().row()+1,0);
if((!row.isValid())||(row.row()>=lib_cart_model->rowCount())) {
row=lib_cart_model->index(carts.last().row(),0).
sibling(carts.first().row()-1,0);
}
if(row.isValid()) {
newcartnum=lib_cart_model->cartNumber(row);
}
//
// Delete Carts
//
for(int i=rows.size()-1;i>=0;i--) {
RDCart *rdcart=new RDCart(lib_cart_model->cartNumber(rows.at(i).row()));
for(int i=carts.size()-1;i>=0;i--) {
RDCart *rdcart=new RDCart(lib_cart_model->cartNumber(carts.at(i)));
if(!rdcart->remove(rda->station(),rda->user(),rda->config())) {
QMessageBox::warning(this,tr("RDLibrary"),tr("Unable to delete audio!"));
return;
@ -546,9 +565,12 @@ void MainWidget::deleteData()
delete rdcart;
}
// lib_cart_view->selectRow(rows.first().row());
lib_cart_view->scrollTo(lib_cart_model->index(rows.first().row(),0));
if(newcartnum>0) {
QModelIndex index=lib_cart_model->cartRow(newcartnum);
if(index.isValid()) {
SelectRow(index);
}
}
UnlockUser();
}
@ -596,41 +618,48 @@ void MainWidget::cartDoubleClickedData(const QModelIndex &)
void MainWidget::selectionChangedData(const QItemSelection &,
const QItemSelection &)
{
QList<int> cartlines;
QStringList cutnames;
QModelIndexList rows=lib_cart_view->selectionModel()->selectedRows();
for(int i=0;i<rows.size();i++) {
QModelIndexList carts;
QModelIndexList cuts;
if(!CurrentSelection(&carts,&cuts)) {
lib_edit_button->setEnabled(false);
lib_delete_button->setEnabled(false);
lib_player->playButton()->setEnabled(false);
lib_player->stopButton()->setEnabled(false);
return;
}
lib_player->playButton()->setEnabled(rows.size()==1);
lib_player->stopButton()->setEnabled(rows.size()==1);
lib_macro_button->setEnabled(rows.size()==1);
if(rows.size()==1) {
switch(lib_cart_model->cartType(rows.first().row())) {
case RDCart::Audio:
lib_player->setCart(lib_cart_model->cartNumber(rows.first().row()));
lib_player->playButton()->show();
lib_player->stopButton()->show();
lib_macro_button->hide();
break;
case RDCart::Macro:
lib_player->playButton()->hide();
lib_player->stopButton()->hide();
lib_macro_button->show();
break;
case RDCart::All:
lib_player->playButton()->hide();
lib_player->stopButton()->hide();
lib_macro_button->hide();
break;
/*
printf("CARTS\n");
for(int i=0;i<carts.size();i++) {
printf(" %d: %06u\n",i,lib_cart_model->cartNumber(carts.at(i)));
}
printf("CUTS\n");
for(int i=0;i<cuts.size();i++) {
printf(" %d: %s\n",i,lib_cart_model->cutName(cuts.at(i)).toUtf8().constData());
}
printf("\n");
return;
*/
if(carts.size()>0) {
lib_edit_button->setEnabled(true);
lib_delete_button->setEnabled(rda->user()->deleteCarts());
lib_player->playButton()->setEnabled(carts.size()==1);
lib_player->stopButton()->setEnabled(carts.size()==1);
lib_player->setCart(lib_cart_model->cartNumber(carts.first()));
SetPlayer(lib_cart_model->cartType(carts.first()));
}
else {
lib_edit_button->setEnabled(false);
lib_delete_button->setEnabled(false);
lib_player->playButton()->setEnabled(cuts.size()==1);
lib_player->stopButton()->setEnabled(cuts.size()==1);
if(cuts.size()>=1) {
lib_player->setCart(lib_cart_model->cartNumber(cuts.first()));
lib_player->setCut(lib_cart_model->cutName(cuts.first()));
}
SetPlayer(lib_cart_model->cartType(cuts.first()));
}
lib_edit_button->setEnabled(rows.size()>0);
lib_delete_button->setEnabled((rows.size()>0)&&rda->user()->deleteCarts());
lib_macro_button->setEnabled(carts.size()==1);
}
@ -753,245 +782,6 @@ void MainWidget::resizeEvent(QResizeEvent *e)
}
void MainWidget::RefreshCuts(RDListViewItem *p,unsigned cartnum)
{
/*
RDListViewItem *l=NULL;
Q3ListViewItem *i=NULL;
RDSqlQuery *q;
QString sql;
QDateTime current_datetime(QDate::currentDate(),QTime::currentTime());
QDateTime end_datetime;
RDCart::Validity cart_validity=RDCart::NeverValid;
RDCart::Validity cut_validity=RDCart::NeverValid;
while ((i=p->firstChild())) {
delete i;
}
sql=QString("select ")+
"CUTS.CART_NUMBER,"+ // 00
"CUTS.CUT_NAME,"+ // 01
"CUTS.DESCRIPTION,"+ // 02
"CUTS.TALK_START_POINT,"+ // 03
"CUTS.TALK_END_POINT,"+ // 04
"CUTS.LENGTH,"+ // 05 offsets begin here
"CUTS.EVERGREEN,"+ // 06
"CUTS.START_DATETIME,"+ // 07
"CUTS.END_DATETIME,"+ // 08
"CUTS.START_DAYPART,"+ // 09
"CUTS.END_DAYPART,"+ // 10
"CUTS.MON,"+ // 11
"CUTS.TUE,"+ // 12
"CUTS.WED,"+ // 13
"CUTS.THU,"+ // 14
"CUTS.FRI,"+ // 15
"CUTS.SAT,"+ // 16
"CUTS.SUN "+ // 17
"from CUTS ";
sql+=QString().sprintf("where CUTS.CART_NUMBER=%u ",cartnum);
sql+="order by CUTS.CUT_NAME";
q=new RDSqlQuery(sql);
if (q->size()>1) {
while(q->next()) {
l=new RDListViewItem(p);
l->setDragEnabled(false);
l->setText(Cart,q->value(1).toString());
l->setText(Length,RDGetTimeLength(q->value(5).toUInt()));
l->setText(Talk,RDGetTimeLength(q->value(4).toUInt()-q->value(3).toUInt()));
l->setText(Title,q->value(2).toString());
if(!q->value(7).toDateTime().isNull()) {
l->setText(Start,q->value(7).toDateTime().
toString("MM/dd/yyyy hh:mm:ss"));
}
if(!q->value(8).toDateTime().isNull()) {
l->setText(End,q->value(8).toDateTime().
toString("MM/dd/yyyy - hh:mm:ss"));
}
else {
l->setText(End,"TFN");
}
end_datetime=q->value(8).toDateTime();
cut_validity=ValidateCut(q,5,RDCart::NeverValid,current_datetime);
UpdateItemColor(l,cut_validity,end_datetime,current_datetime);
cart_validity=ValidateCut(q,5,cart_validity,current_datetime);
UpdateItemColor(p,cart_validity,end_datetime,current_datetime);
}
}
else if(q->size()==1){
if(q->next()) {
cart_validity=ValidateCut(q,5,cart_validity,current_datetime);
end_datetime=q->value(8).toDateTime();
UpdateItemColor(p,cart_validity,end_datetime,current_datetime);
}
}
else {
p->setBackgroundColor(RD_CART_ERROR_COLOR);
}
delete q;
*/
}
void MainWidget::RefreshList()
{
/*
RDSqlQuery *q;
QString sql;
RDListViewItem *l=NULL;
QString type_filter;
QDateTime current_datetime(QDate::currentDate(),QTime::currentTime());
QDateTime end_datetime;
lib_cart_list->clear();
lib_edit_button->setEnabled(false);
lib_delete_button->setEnabled(false);
type_filter=GetTypeFilter();
if(type_filter.isEmpty()) {
return;
}
sql=QString("select ")+
"CART.NUMBER,"+ // 00
"CART.FORCED_LENGTH,"+ // 01
"CART.TITLE,"+ // 02
"CART.ARTIST,"+ // 03
"CART.ALBUM,"+ // 04
"CART.LABEL,"+ // 05
"CART.CLIENT,"+ // 06
"CART.AGENCY,"+ // 07
"CART.USER_DEFINED,"+ // 08
"CART.COMPOSER,"+ // 09
"CART.PUBLISHER,"+ // 10
"CART.CONDUCTOR,"+ // 11
"CART.GROUP_NAME,"+ // 12
"CART.START_DATETIME,"+ // 13
"CART.END_DATETIME,"+ // 14
"CART.TYPE,"+ // 15
"CART.CUT_QUANTITY,"+ // 16
"CART.LAST_CUT_PLAYED,"+ // 17
"CART.ENFORCE_LENGTH,"+ // 18
"CART.PRESERVE_PITCH,"+ // 19
"CART.LENGTH_DEVIATION,"+ // 20
"CART.OWNER,"+ // 21
"CART.VALIDITY,"+ // 22
"GROUPS.COLOR,"+ // 23
"CUTS.TALK_START_POINT,"+ // 24
"CUTS.TALK_END_POINT "+ // 25
"from CART left join GROUPS on CART.GROUP_NAME=GROUPS.NAME "+
"left join CUTS on CART.NUMBER=CUTS.CART_NUMBER";
sql+=WhereClause();
sql+=" group by CART.NUMBER order by CART.NUMBER";
if(lib_showmatches_box->isChecked()) {
sql+=QString().sprintf(" limit %d",RD_LIMITED_CART_SEARCH_QUANTITY);
}
q=new RDSqlQuery(sql);
int step=0;
int count=0;
int matches=0;
lib_progress_dialog->setMaximum(q->size()/RDLIBRARY_STEP_SIZE);
lib_progress_dialog->setValue(0);
while(q->next()) {
end_datetime=q->value(14).toDateTime();
//
// Start a new entry
//
l=new RDListViewItem(lib_cart_list);
l->setExpandable(false);
switch((RDCart::Type)q->value(15).toUInt()) {
case RDCart::Audio:
if(q->value(21).isNull()) {
l->setPixmap(Icon,*lib_playout_map);
}
else {
l->setPixmap(Icon,*lib_track_cart_map);
}
break;
case RDCart::Macro:
l->setPixmap(Icon,*lib_macro_map);
l->setBackgroundColor(backgroundColor());
break;
case RDCart::All:
break;
}
l->setText(Cart,QString().sprintf("%06d",q->value(0).toUInt()));
l->setText(Group,q->value(12).toString());
l->setTextColor(Group,q->value(23).toString(),QFont::Bold);
if(q->value(16).toUInt()==1) {
l->setText(Length,RDGetTimeLength(q->value(1).toUInt()));
l->setText(Talk,RDGetTimeLength(q->value(25).toUInt()-q->value(24).toUInt()));
}
l->setText(Title,q->value(2).toString());
l->setText(Artist,q->value(3).toString());
if(!q->value(13).toDateTime().isNull()) {
l->setText(Start,q->value(13).toDateTime().
toString("MM/dd/yyyy - hh:mm:ss"));
}
if(!q->value(14).toDateTime().isNull()) {
l->setText(End,q->value(14).toDateTime().
toString("MM/dd/yyyy - hh:mm:ss"));
}
else {
l->setText(End,"TFN");
}
l->setText(Album,q->value(4).toString());
l->setText(Label,q->value(5).toString());
l->setText(Composer,q->value(9).toString());
l->setText(Conductor,q->value(11).toString());
l->setText(Publisher,q->value(10).toString());
l->setText(Client,q->value(6).toString());
l->setText(Agency,q->value(7).toString());
l->setText(UserDefined,q->value(8).toString());
l->setText(Cuts,q->value(16).toString());
l->setText(LastCutPlayed,q->value(17).toString());
l->setText(EnforceLength,q->value(18).toString());
l->setText(PreservePitch,q->value(19).toString());
l->setText(LengthDeviation,q->value(20).toString());
l->setText(OwnedBy,q->value(21).toString());
if(q->value(18).toString()=="Y") {
l->setTextColor(Length,QColor(RDLIBRARY_ENFORCE_LENGTH_COLOR),QFont::Bold);
}
else {
if((q->value(20).toUInt()>RDLIBRARY_MID_LENGTH_LIMIT)&&
(q->value(18).toString()=="N")) {
if(q->value(20).toUInt()>RDLIBRARY_MAX_LENGTH_LIMIT) {
l->setTextColor(Length,QColor(RDLIBRARY_MAX_LENGTH_COLOR),QFont::Bold);
}
else {
l->setTextColor(Length,QColor(RDLIBRARY_MID_LENGTH_COLOR),QFont::Bold);
}
}
else {
l->setTextColor(Length,QColor(Qt::black),QFont::Normal);
}
}
if((RDCart::Type)q->value(15).toUInt()==RDCart::Audio) {
RefreshCuts(l,q->value(0).toUInt());
}
else {
l->setBackgroundColor(palette().color(QPalette::Active,QColorGroup::Base));
}
matches++;
count++;
if(count>RDLIBRARY_STEP_SIZE) {
lib_progress_dialog->setValue(++step);
count=0;
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
}
}
lib_progress_dialog->reset();
lib_matches_edit->setText(QString().sprintf("%d",matches));
delete q;
*/
}
void SigHandler(int signo)
{
pid_t pLocalPid;
@ -1010,167 +800,6 @@ void SigHandler(int signo)
}
void MainWidget::RefreshLine(RDListViewItem *item)
{
RDCart::Validity validity=RDCart::NeverValid;
QDateTime current_datetime(QDate::currentDate(),QTime::currentTime());
QString sql=QString("select ")+
"CART.FORCED_LENGTH,"+ // 00
"CART.TITLE,"+ // 01
"CART.ARTIST,"+ // 02
"CART.ALBUM,"+ // 03
"CART.LABEL,"+ // 04
"CART.CLIENT,"+ // 05
"CART.AGENCY,"+ // 06
"CART.USER_DEFINED,"+ // 07
"CART.COMPOSER,"+ // 08
"CART.CONDUCTOR,"+ // 09
"CART.PUBLISHER,"+ // 10
"CART.GROUP_NAME,"+ // 11
"CART.START_DATETIME,"+ // 12
"CART.END_DATETIME,"+ // 13
"CART.TYPE,"+ // 14
"CART.CUT_QUANTITY,"+ // 15
"CART.LAST_CUT_PLAYED,"+ // 16
"CART.ENFORCE_LENGTH,"+ // 17
"CART.PRESERVE_PITCH,"+ // 18
"CART.LENGTH_DEVIATION,"+ // 19
"CART.OWNER,"+ // 20
"CART.VALIDITY,"+ // 21
"GROUPS.COLOR,"+ // 22
"CUTS.TALK_START_POINT,"+ // 23
"CUTS.TALK_END_POINT "+ // 24
"from CART left join GROUPS "+
"on CART.GROUP_NAME=GROUPS.NAME left join CUTS on "+
"CART.NUMBER=CUTS.CART_NUMBER where "+
QString().sprintf("CART.NUMBER=%u ",item->text(Cart).toUInt())+
"group by CART.NUMBER";
RDSqlQuery *q=new RDSqlQuery(sql);
while(q->next()) {
switch((RDCart::Type)q->value(14).toUInt()) {
case RDCart::Audio:
if(q->value(20).isNull()) {
item->setPixmap(Icon,*lib_playout_map);
}
else {
item->setPixmap(Icon,*lib_track_cart_map);
}
if(q->value(0).toUInt()==0) {
item->setBackgroundColor(RD_CART_ERROR_COLOR);
}
else {
UpdateItemColor(item,validity,
q->value(13).toDateTime(),current_datetime);
}
break;
case RDCart::Macro:
item->setPixmap(Icon,*lib_macro_map);
break;
case RDCart::All:
break;
}
item->setText(Group,q->value(11).toString());
item->setTextColor(Group,q->value(22).toString(),QFont::Bold);
if(q->value(15).toUInt()==1) {
item->setText(Length,RDGetTimeLength(q->value(0).toUInt()));
item->setText(Talk,RDGetTimeLength(q->value(24).toUInt()-q->value(23).toUInt()));
}
item->setText(Title,q->value(1).toString());
item->setText(Artist,q->value(2).toString());
item->setText(Album,q->value(3).toString());
item->setText(Label,q->value(4).toString());
item->setText(Composer,q->value(8).toString());
item->setText(Conductor,q->value(9).toString());
item->setText(Publisher,q->value(10).toString());
item->setText(Client,q->value(5).toString());
item->setText(Agency,q->value(6).toString());
if(!q->value(12).toDateTime().isNull()) {
item->setText(Start,q->value(12).toDateTime().
toString("MM/dd/yyyy - hh:mm:ss"));
}
else {
item->setText(Start,"");
}
if(!q->value(13).toDateTime().isNull()) {
item->setText(End,q->value(13).toDateTime().
toString("MM/dd/yyyy - hh:mm:ss"));
}
else {
item->setText(End,tr("TFN"));
}
item->setText(Cuts,q->value(15).toString());
item->setText(LastCutPlayed,q->value(16).toString());
item->setText(EnforceLength,q->value(17).toString());
item->setText(PreservePitch,q->value(18).toString());
item->setText(LengthDeviation,q->value(19).toString());
item->setText(OwnedBy,q->value(20).toString());
if(q->value(17).toString()=="Y") {
item->setTextColor(Length,QColor(RDLIBRARY_ENFORCE_LENGTH_COLOR),QFont::Bold);
}
else {
if((q->value(19).toUInt()>RDLIBRARY_MID_LENGTH_LIMIT)&&
(q->value(17).toString()=="N")) {
if(q->value(19).toUInt()>RDLIBRARY_MAX_LENGTH_LIMIT) {
item->setTextColor(Length,QColor(RDLIBRARY_MAX_LENGTH_COLOR),QFont::Bold);
}
else {
item->setTextColor(Length,QColor(RDLIBRARY_MID_LENGTH_COLOR),QFont::Bold);
}
}
else {
item->setTextColor(Length,QColor(Qt::black),QFont::Normal);
}
}
if((RDCart::Type)q->value(14).toUInt()==RDCart::Audio) {
RefreshCuts(item,item->text(Cart).toUInt());
}
}
delete q;
}
void MainWidget::UpdateItemColor(RDListViewItem *item,
RDCart::Validity validity,
const QDateTime &end_datetime,
const QDateTime &current_datetime)
{
if(item!=NULL) {
switch(validity) {
case RDCart::NeverValid:
item->setBackgroundColor(RD_CART_ERROR_COLOR);
break;
case RDCart::ConditionallyValid:
if(end_datetime.isValid()&&
(end_datetime<current_datetime)) {
item->setBackgroundColor(RD_CART_ERROR_COLOR);
}
else {
item->setBackgroundColor(RD_CART_CONDITIONAL_COLOR);
}
break;
case RDCart::FutureValid:
item->setBackgroundColor(RD_CART_FUTURE_COLOR);
break;
case RDCart::AlwaysValid:
item->setBackgroundColor(palette().color(QPalette::Active,
QColorGroup::Base));
break;
case RDCart::EvergreenValid:
item->setBackgroundColor(RD_CART_EVERGREEN_COLOR);
break;
}
}
}
void MainWidget::SetCaption(QString user)
{
QString str1;
@ -1182,17 +811,45 @@ void MainWidget::SetCaption(QString user)
}
int MainWidget::SingleSelectedCartLine() const
int MainWidget::CurrentSelection(QModelIndexList *carts,
QModelIndexList *cuts) const
{
int row=-1;
QModelIndexList rows=lib_cart_view->selectionModel()->selectedRows();
if((lib_cart_view->selectionModel()->selectedRows().size()==1)&&
(lib_cart_view->selectionModel()->selectedRows().first().internalId()==
0)) {
return lib_cart_view->selectionModel()->selectedRows().first().row();
carts->clear();
if(cuts!=NULL) {
cuts->clear();
}
for(int i=0;i<rows.size();i++) {
if(lib_cart_model->isCart(rows.at(i))) {
carts->push_back(rows.at(i));
}
else {
if(cuts!=NULL) {
cuts->push_back(rows.at(i));
}
}
}
if(cuts!=NULL) {
return (carts->size()>0)||(cuts->size()>0);
}
return carts->size()>0;
}
return row;
void MainWidget::SelectRow(const QModelIndex &index)
{
if(index.isValid()) {
lib_cart_view->selectionModel()->
select(index,QItemSelectionModel::ClearAndSelect|QItemSelectionModel::Rows);
lib_cart_view->scrollTo(index);
}
}
void MainWidget::SelectRow(unsigned cartnum)
{
SelectRow(lib_cart_model->cartRow(cartnum));
}
@ -1247,18 +904,11 @@ void MainWidget::LockUser()
bool MainWidget::UnlockUser()
{
// RDListViewItem *item=NULL;
//
// Process Deleted Carts
//
for(unsigned i=0;i<lib_deleted_carts.size();i++) {
lib_cart_model->removeCart(lib_deleted_carts.at(i));
/*
if((item=(RDListViewItem *)lib_cart_list->findItem(QString().sprintf("%06u",lib_deleted_carts.at(i)),Cart))!=NULL) {
delete item;
}
*/
}
lib_deleted_carts.clear();
@ -1286,6 +936,30 @@ void MainWidget::SendNotification(RDNotification::Action action,
}
void MainWidget::SetPlayer(RDCart::Type type)
{
switch(type) {
case RDCart::Audio:
lib_player->playButton()->show();
lib_player->stopButton()->show();
lib_macro_button->hide();
break;
case RDCart::Macro:
lib_player->playButton()->hide();
lib_player->stopButton()->hide();
lib_macro_button->show();
break;
case RDCart::All:
lib_player->playButton()->hide();
lib_player->stopButton()->hide();
lib_macro_button->hide();
break;
}
}
int main(int argc,char *argv[])
{
QApplication::setStyle(RD_GUI_STYLE);

View File

@ -86,20 +86,17 @@ class MainWidget : public RDWidget
void closeEvent(QCloseEvent *e);
private:
void RefreshList();
void RefreshCuts(RDListViewItem *p,unsigned cartnum);
void RefreshLine(RDListViewItem *item);
void UpdateItemColor(RDListViewItem *item,RDCart::Validity validity,
const QDateTime &end_datetime,
const QDateTime &current_datetime);
void SetCaption(QString user);
int SingleSelectedCartLine() const;
int CurrentSelection(QModelIndexList *carts,QModelIndexList *cuts=NULL) const;
void SelectRow(const QModelIndex &index);
void SelectRow(unsigned cartnum);
QString GeometryFile();
void LoadGeometry();
void SaveGeometry();
void LockUser();
bool UnlockUser();
void SendNotification(RDNotification::Action action,unsigned cartnum);
void SetPlayer(RDCart::Type type);
RDCartFilter *lib_cart_filter;
// LibListView *lib_cart_list;
QTreeView *lib_cart_view;

View File

@ -1292,7 +1292,7 @@ Přesto smazat?</translation>
</message>
<message>
<source>TFN</source>
<translation>TFN</translation>
<translation type="obsolete">TFN</translation>
</message>
<message>
<source>RDLibrary - Host:</source>

View File

@ -1269,7 +1269,7 @@ verwendet. Trotzdem löschen?</translation>
</message>
<message>
<source>TFN</source>
<translation>TFN</translation>
<translation type="obsolete">TFN</translation>
</message>
<message>
<source>RDLibrary - Host:</source>

View File

@ -1218,10 +1218,6 @@ Cartucho</translation>
<source>Random</source>
<translation type="obsolete">Aleatorio</translation>
</message>
<message>
<source>TFN</source>
<translation></translation>
</message>
<message>
<source>RDLibrary - Host:</source>
<translation type="obsolete">RDLibrary - Servidor: </translation>

View File

@ -875,10 +875,6 @@ CD</source>
<source></source>
<translation></translation>
</message>
<message>
<source>TFN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Host</source>
<translation type="unfinished"></translation>
@ -944,14 +940,6 @@ CD</source>
<source>Empty Clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDLibrary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete audio!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>is a voicetrack belonging to log</source>
<translation type="unfinished"></translation>
@ -964,6 +952,14 @@ CD</source>
<source>Voicetrack Found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDLibrary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete audio!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RecordCut</name>

View File

@ -1261,7 +1261,7 @@ Vil du sletta ho likevel?</translation>
</message>
<message>
<source>TFN</source>
<translation>TFN</translation>
<translation type="obsolete">TFN</translation>
</message>
<message>
<source>RDLibrary - Host:</source>
@ -1336,14 +1336,6 @@ Vil du sletta ho likevel?</translation>
<source>Do you still want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDLibrary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete audio!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>is a voicetrack belonging to log</source>
<translation type="unfinished"></translation>
@ -1356,6 +1348,14 @@ Vil du sletta ho likevel?</translation>
<source>Voicetrack Found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDLibrary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete audio!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RecordCut</name>

View File

@ -1261,7 +1261,7 @@ Vil du sletta ho likevel?</translation>
</message>
<message>
<source>TFN</source>
<translation>TFN</translation>
<translation type="obsolete">TFN</translation>
</message>
<message>
<source>RDLibrary - Host:</source>
@ -1336,14 +1336,6 @@ Vil du sletta ho likevel?</translation>
<source>Do you still want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDLibrary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete audio!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>is a voicetrack belonging to log</source>
<translation type="unfinished"></translation>
@ -1356,6 +1348,14 @@ Vil du sletta ho likevel?</translation>
<source>Voicetrack Found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDLibrary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete audio!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RecordCut</name>

View File

@ -1263,7 +1263,7 @@ Você ainda quer deletá-lo?</translation>
</message>
<message>
<source>TFN</source>
<translation>TFN</translation>
<translation type="obsolete">TFN</translation>
</message>
<message>
<source>RDLibrary - Host:</source>
@ -1338,14 +1338,6 @@ Você ainda quer deletá-lo?</translation>
<source>Do you still want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDLibrary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete audio!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>is a voicetrack belonging to log</source>
<translation type="unfinished"></translation>
@ -1358,6 +1350,14 @@ Você ainda quer deletá-lo?</translation>
<source>Voicetrack Found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RDLibrary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete audio!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RecordCut</name>