From 922dd0203f484cd83038582cfaa8c0a280ca343d Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Fri, 28 Jul 2023 17:36:50 -0400 Subject: [PATCH] 2023-07-28 Fred Gleason * Fixed a bug in rdcastmanager(1) where changes to podcast metadata would fail to be reflected in the feed list. Signed-off-by: Fred Gleason --- ChangeLog | 3 ++ lib/rdfeedlistmodel.cpp | 107 ++++++++++++++++++++++++++-------------- lib/rdfeedlistmodel.h | 5 +- 3 files changed, 78 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c3ae1c7..6e612d87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24297,3 +24297,6 @@ 2023-07-12 Fred Gleason * Fixed a bug in rdlibrary(1) that could cause the 'Add Cart' dialog to display the incorrect type for the selected group. +2023-07-28 Fred Gleason + * Fixed a bug in rdcastmanager(1) where changes to podcast metadata + would fail to be reflected in the feed list. diff --git a/lib/rdfeedlistmodel.cpp b/lib/rdfeedlistmodel.cpp index a38566e5..d0cff38d 100644 --- a/lib/rdfeedlistmodel.cpp +++ b/lib/rdfeedlistmodel.cpp @@ -2,7 +2,7 @@ // // Data model for Rivendell RSS feeds // -// (C) Copyright 2021-2022 Fred Gleason +// (C) Copyright 2021-2023 Fred Gleason // // 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 @@ -405,9 +405,12 @@ void RDFeedListModel::removeFeed(const QString &keyname) void RDFeedListModel::refreshRow(const QModelIndex &index) { if(isFeed(index)) { - updateRowLine(index.row()); + updateFeedLine(index.row()); emit dataChanged(index,createIndex(index.row(),columnCount(),(quintptr)0)); } + else { + updateCastLine(index.parent().row(),index.row()); + } } @@ -415,7 +418,7 @@ void RDFeedListModel::refreshFeed(const QString &keyname) { for(int i=0;ifirst()) { + updateCastRow(feed_line,cast_line,q,0); + emit dataChanged(createIndex(cast_line,0,(quintptr)feed_line), + createIndex(cast_line,3,(quintptr)feed_line)); + } + delete q; +} + + +void RDFeedListModel::updateCastRow(int feed_line,int cast_line, + RDSqlQuery *q,int q_offset) +{ + switch((RDPodcast::Status)q->value(2+q_offset).toUInt()) { + case RDPodcast::StatusPending: + d_cast_icons[feed_line][cast_line]= + rda->iconEngine()->listIcon(RDIconEngine::RedBall); + break; + + case RDPodcast::StatusActive: + if(q->value(4+q_offset).toDateTime()<=QDateTime::currentDateTime()) { + d_cast_icons[feed_line][cast_line]= + rda->iconEngine()->listIcon(RDIconEngine::GreenBall); + } + else { + d_cast_icons[feed_line][cast_line]= + rda->iconEngine()->listIcon(RDIconEngine::BlueBall); + } + break; + + case RDPodcast::StatusExpired: + d_cast_icons[feed_line][cast_line]= + rda->iconEngine()->listIcon(RDIconEngine::WhiteBall); + break; + } + d_cast_texts[feed_line][cast_line][1]=q->value(1+q_offset); // Item Title + d_cast_texts[feed_line][cast_line][3]= + rda->shortDateString(q->value(3+q_offset).toDateTime().date()); +} + + void RDFeedListModel::updateRow(int row,RDSqlQuery *q) { int active_casts=0; @@ -564,17 +614,12 @@ void RDFeedListModel::updateRow(int row,RDSqlQuery *q) d_feed_ids[row]=q->value(0).toUInt(); d_key_names[row]=q->value(1).toString(); d_texts[row][0]=keyname; // Key Name - if(q->value(12).isNull()) { + if(q->value(13).isNull()) { d_icons[row][0]=rda->iconEngine()-> applicationIcon(RDIconEngine::RdCastManager,32); } else { - d_icons[row][0]=QImage::fromData(q->value(12).toByteArray()); - /* - d_icons[row][0]= - QImage::fromData(q->value(12).toByteArray()). - scaled(32,32,Qt::IgnoreAspectRatio,Qt::SmoothTransformation); - */ + d_icons[row][0]=QImage::fromData(q->value(13).toByteArray()); } d_texts[row][1]=q->value(2); // Title if(q->value(4).toString()=="Y") { @@ -606,27 +651,9 @@ void RDFeedListModel::updateRow(int row,RDSqlQuery *q) // Process total_casts++; d_cast_ids[row].push_back(q->value(8).toUInt()); - switch((RDPodcast::Status)q->value(10).toUInt()) { - case RDPodcast::StatusPending: - d_cast_icons[row].push_back(rda->iconEngine()-> - listIcon(RDIconEngine::BlueBall)); - break; - - case RDPodcast::StatusActive: - d_cast_icons[row].push_back(rda->iconEngine()-> - listIcon(RDIconEngine::GreenBall)); - active_casts++; - break; - - case RDPodcast::StatusExpired: - d_cast_icons[row].push_back(rda->iconEngine()-> - listIcon(RDIconEngine::WhiteBall)); - break; - } + d_cast_icons[row].push_back(QVariant()); d_cast_texts[row].push_back(list); - d_cast_texts[row].back()[1]=q->value(9); // Item Title - d_cast_texts[row].back()[3]= - rda->shortDateString(q->value(11).toDateTime().date()); + updateCastRow(row,d_cast_icons[row].size()-1,q,8); } while(q->next()&&(q->value(1).toString()==keyname)); q->previous(); @@ -651,11 +678,8 @@ QString RDFeedListModel::sqlFields() const "`FEEDS`.`ID`,"+ // 05 "`FEEDS`.`BASE_URL`,"+ // 06 "`FEEDS`.`ORIGIN_DATETIME`,"+ // 07 - "`PODCASTS`.`ID`,"+ // 08 - "`PODCASTS`.`ITEM_TITLE`,"+ // 09 - "`PODCASTS`.`STATUS`,"+ // 10 - "`PODCASTS`.`ORIGIN_DATETIME`,"+ // 11 - "`FEED_IMAGES`.`DATA_MID_THUMB` "+ // 12 + castSqlFields()+","+ // 08 - 12 + "`FEED_IMAGES`.`DATA_MID_THUMB` "+ // 13 "from `FEEDS` left join `FEED_IMAGES` "+ "on `FEEDS`.`CHANNEL_IMAGE_ID`=`FEED_IMAGES`.`ID` left join `PODCASTS` "+ "on `FEEDS`.`ID`=`PODCASTS`.`FEED_ID` "; @@ -664,6 +688,17 @@ QString RDFeedListModel::sqlFields() const } +QString RDFeedListModel::castSqlFields() const +{ + QString sql=QString("`PODCASTS`.`ID`,")+ // 00 + "`PODCASTS`.`ITEM_TITLE`,"+ // 01 + "`PODCASTS`.`STATUS`,"+ // 02 + "`PODCASTS`.`ORIGIN_DATETIME`,"+ // 03 + "`PODCASTS`.`EFFECTIVE_DATETIME` "; // 04 + return sql; +} + + QByteArray RDFeedListModel::DumpIndex(const QModelIndex &index,const QString &caption) const { QByteArray ret; diff --git a/lib/rdfeedlistmodel.h b/lib/rdfeedlistmodel.h index b053cc55..21eb7970 100644 --- a/lib/rdfeedlistmodel.h +++ b/lib/rdfeedlistmodel.h @@ -75,9 +75,12 @@ class RDFeedListModel : public QAbstractItemModel protected: void updateModel(const QString &filter_sql); - void updateRowLine(int line); + void updateFeedLine(int line); + void updateCastLine(int feed_line,int cast_line); + void updateCastRow(int feed_line,int cast_line,RDSqlQuery *q,int q_offset); void updateRow(int row,RDSqlQuery *q); QString sqlFields() const; + QString castSqlFields() const; private: QByteArray DumpIndex(const QModelIndex &index,const QString &caption="") const;