mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-20 23:03:04 +02:00
2022-12-01 Fred Gleason <fredg@paravelsystems.com>
* Added notification support to the 'RDLibraryModel' class. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
90987c3374
commit
a157602e10
@ -23735,3 +23735,5 @@
|
|||||||
2022-12-01 Fred Gleason <fredg@paravelsystems.com>
|
2022-12-01 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Modifed the 'Edit Audio' dialog in rdlibrary(1) so the waveform
|
* Modifed the 'Edit Audio' dialog in rdlibrary(1) so the waveform
|
||||||
display is initially fully scrolled to the left.
|
display is initially fully scrolled to the left.
|
||||||
|
2022-12-01 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added notification support to the 'RDLibraryModel' class.
|
||||||
|
@ -133,6 +133,9 @@ RDLibraryModel::RDLibraryModel(QObject *parent)
|
|||||||
d_headers.push_back(tr("Owned By")); // 20
|
d_headers.push_back(tr("Owned By")); // 20
|
||||||
d_alignments.push_back(left);
|
d_alignments.push_back(left);
|
||||||
d_order_columns.push_back("`CART`.`OWNER`");
|
d_order_columns.push_back("`CART`.`OWNER`");
|
||||||
|
|
||||||
|
connect(rda->ripc(),SIGNAL(notificationReceived(RDNotification *)),
|
||||||
|
this,SLOT(processNotification(RDNotification *)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -417,45 +420,50 @@ QString RDLibraryModel::cartOwnedBy(const QModelIndex &index)
|
|||||||
|
|
||||||
QModelIndex RDLibraryModel::addCart(unsigned cartnum)
|
QModelIndex RDLibraryModel::addCart(unsigned cartnum)
|
||||||
{
|
{
|
||||||
//
|
if(d_cart_numbers.contains(cartnum)) {
|
||||||
// Find the insertion offset
|
return refreshCart(cartnum);
|
||||||
//
|
}
|
||||||
int offset=d_texts.size();
|
else {
|
||||||
for(int i=0;i<d_texts.size();i++) {
|
//
|
||||||
if(cartnum<d_cart_numbers.at(i)) {
|
// Find the insertion offset
|
||||||
offset=i;
|
//
|
||||||
break;
|
int offset=d_texts.size();
|
||||||
|
for(int i=0;i<d_texts.size();i++) {
|
||||||
|
if(cartnum<d_cart_numbers.at(i)) {
|
||||||
|
offset=i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
beginInsertRows(QModelIndex(),offset,offset);
|
beginInsertRows(QModelIndex(),offset,offset);
|
||||||
QList<QVariant> list;
|
QList<QVariant> list;
|
||||||
for(int i=0;i<columnCount();i++) {
|
for(int i=0;i<columnCount();i++) {
|
||||||
list.push_back(QVariant());
|
list.push_back(QVariant());
|
||||||
}
|
}
|
||||||
QList<QList<QVariant> > list_list;
|
QList<QList<QVariant> > list_list;
|
||||||
list_list.push_back(list);
|
list_list.push_back(list);
|
||||||
d_icons.insert(offset,list);
|
d_icons.insert(offset,list);
|
||||||
d_texts.insert(offset,list);
|
d_texts.insert(offset,list);
|
||||||
d_notes.insert(offset,QVariant());
|
d_notes.insert(offset,QVariant());
|
||||||
d_cart_numbers.insert(offset,0);
|
d_cart_numbers.insert(offset,0);
|
||||||
d_cut_texts.insert(offset,list_list);
|
d_cut_texts.insert(offset,list_list);
|
||||||
d_cut_cutnames.insert(offset,QStringList());
|
d_cut_cutnames.insert(offset,QStringList());
|
||||||
d_background_colors.insert(offset,QVariant());
|
d_background_colors.insert(offset,QVariant());
|
||||||
d_cart_types.insert(offset,RDCart::All);
|
d_cart_types.insert(offset,RDCart::All);
|
||||||
|
|
||||||
QString sql=sqlFields()+
|
QString sql=sqlFields()+
|
||||||
"where "+
|
"where "+
|
||||||
QString::asprintf("`CART`.`NUMBER`=%u",cartnum);
|
QString::asprintf("`CART`.`NUMBER`=%u",cartnum);
|
||||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||||
if(q->first()) {
|
if(q->first()) {
|
||||||
updateRow(offset,q);
|
updateRow(offset,q);
|
||||||
}
|
}
|
||||||
delete q;
|
delete q;
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
emit rowCountChanged(d_texts.size());
|
emit rowCountChanged(d_texts.size());
|
||||||
|
|
||||||
return createIndex(offset,0,(quintptr)0);
|
return createIndex(offset,0,(quintptr)0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -509,7 +517,7 @@ void RDLibraryModel::refreshRow(const QModelIndex &index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RDLibraryModel::refreshCart(unsigned cartnum)
|
QModelIndex RDLibraryModel::refreshCart(unsigned cartnum)
|
||||||
{
|
{
|
||||||
QString cartnum_str=QString::asprintf("%06u",cartnum);
|
QString cartnum_str=QString::asprintf("%06u",cartnum);
|
||||||
for(int i=0;i<d_texts.size();i++) {
|
for(int i=0;i<d_texts.size();i++) {
|
||||||
@ -517,8 +525,10 @@ void RDLibraryModel::refreshCart(unsigned cartnum)
|
|||||||
updateCartLine(i);
|
updateCartLine(i);
|
||||||
emit dataChanged(createIndex(i,0,(quintptr)0),
|
emit dataChanged(createIndex(i,0,(quintptr)0),
|
||||||
createIndex(i,columnCount(),(quintptr)0));
|
createIndex(i,columnCount(),(quintptr)0));
|
||||||
|
return createIndex(i,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -561,6 +571,43 @@ void RDLibraryModel::setFilterSql(const QString &sql,int cart_limit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RDLibraryModel::processNotification(RDNotification *notify)
|
||||||
|
{
|
||||||
|
QString sql;
|
||||||
|
RDSqlQuery *q=NULL;
|
||||||
|
|
||||||
|
if(notify->type()==RDNotification::CartType) {
|
||||||
|
switch(notify->action()) {
|
||||||
|
case RDNotification::AddAction:
|
||||||
|
sql=QString("select ")+
|
||||||
|
"`NUMBER` "+ // 00
|
||||||
|
"from `CART` "+
|
||||||
|
d_filter_sql+
|
||||||
|
QString::asprintf(" && `CART`.`NUMBER`=%u",notify->id().toUInt());
|
||||||
|
q=new RDSqlQuery(sql);
|
||||||
|
if(q->first()) {
|
||||||
|
addCart(notify->id().toUInt());
|
||||||
|
}
|
||||||
|
delete q;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RDNotification::ModifyAction:
|
||||||
|
refreshCart(notify->id().toUInt());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RDNotification::DeleteAction:
|
||||||
|
removeCart(notify->id().toUInt());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RDNotification::NoAction:
|
||||||
|
case RDNotification::LastAction:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RDLibraryModel::updateModel(const QString &filter_sql)
|
void RDLibraryModel::updateModel(const QString &filter_sql)
|
||||||
{
|
{
|
||||||
if(!d_filter_set) {
|
if(!d_filter_set) {
|
||||||
|
@ -64,7 +64,7 @@ class RDLibraryModel : public QAbstractItemModel
|
|||||||
void removeCart(const QModelIndex &index);
|
void removeCart(const QModelIndex &index);
|
||||||
void removeCart(unsigned cartnum);
|
void removeCart(unsigned cartnum);
|
||||||
void refreshRow(const QModelIndex &index);
|
void refreshRow(const QModelIndex &index);
|
||||||
void refreshCart(unsigned cartnum);
|
QModelIndex refreshCart(unsigned cartnum);
|
||||||
bool showNotes() const;
|
bool showNotes() const;
|
||||||
int cartLimit() const;
|
int cartLimit() const;
|
||||||
|
|
||||||
@ -75,6 +75,9 @@ class RDLibraryModel : public QAbstractItemModel
|
|||||||
void setShowNotes(int state);
|
void setShowNotes(int state);
|
||||||
void setFilterSql(const QString &sql,int cart_limit);
|
void setFilterSql(const QString &sql,int cart_limit);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void processNotification(RDNotification *notify);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateModel(const QString &filter_sql);
|
void updateModel(const QString &filter_sql);
|
||||||
void updateCartLine(int cartline);
|
void updateCartLine(int cartline);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user