From 90fd7d0430cc3b34681eb7500c101c4cc843553b Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Wed, 14 Sep 2022 11:21:40 -0400 Subject: [PATCH] 2022-09-14 Fred Gleason * Rearranged data layout in the 'RDFeedListModel' class to aid code readability. Signed-off-by: Fred Gleason --- ChangeLog | 3 +++ lib/rdfeedlistmodel.cpp | 32 ++++++++++++++++---------------- lib/rdfeedlistmodel.h | 15 ++++++++++----- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index a70ed3b1..eff8fd38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23300,3 +23300,6 @@ * Fixed a regression in rdlogedit(1) that caused the default setting of the 'Show Start Times As' dropdown in the 'Edit Log' dialog to fail to be preserved across instances. +2022-09-14 Fred Gleason + * Rearranged data layout in the 'RDFeedListModel' class to aid + code readability. diff --git a/lib/rdfeedlistmodel.cpp b/lib/rdfeedlistmodel.cpp index 9d6912f4..f1e5f876 100644 --- a/lib/rdfeedlistmodel.cpp +++ b/lib/rdfeedlistmodel.cpp @@ -350,13 +350,13 @@ QModelIndex RDFeedListModel::addFeed(const QString &keyname) } QList > list_list; QList ids_list; - list_list.push_back(list); - d_icons.insert(offset,list); - d_texts.insert(offset,list); - d_key_names.insert(offset,keyname); d_feed_ids.insert(offset,0); + d_texts.insert(offset,list); + d_icons.insert(offset,list); + list_list.push_back(list); d_cast_ids.insert(offset,ids_list); d_cast_icons.insert(offset,list); + d_key_names.insert(offset,keyname); QString sql=sqlFields()+ "where "+ @@ -379,12 +379,12 @@ void RDFeedListModel::removeFeed(const QString &keyname) if(d_key_names.at(i)==keyname) { beginRemoveRows(QModelIndex(),i,i); - d_key_names.removeAt(i); d_feed_ids.removeAt(i); d_texts.removeAt(i); + d_icons.removeAt(i); d_cast_ids.removeAt(i); d_cast_icons.removeAt(i); - d_icons.removeAt(i); + d_key_names.removeAt(i); endRemoveRows(); emit rowCountChanged(d_texts.size()); @@ -489,35 +489,35 @@ void RDFeedListModel::updateModel(const QString &filter_sql) "order by `FEEDS`.`KEY_NAME` asc, `PODCASTS`.`ORIGIN_DATETIME` desc"; // printf("SQL: %s\n",sql.toUtf8().constData()); beginResetModel(); - d_texts.clear(); - d_key_names.clear(); d_feed_ids.clear(); + d_texts.clear(); + d_icons.clear(); d_cast_ids.clear(); d_cast_icons.clear(); - d_icons.clear(); + d_key_names.clear(); if(d_include_none) { + d_feed_ids.push_back(0); d_texts.push_back(list); d_texts[0][0]=tr("[none]"); + d_icons.push_back(icons); d_key_names.push_back(QString()); - d_feed_ids.push_back(0); - d_cast_texts.push_back(list_list); d_cast_ids.push_back(ids); d_cast_icons.push_back(list); - d_icons.push_back(icons); + d_cast_texts.push_back(list_list); } QString prev_keyname; q=new RDSqlQuery(sql); while(q->next()) { if(q->value(0).toString()!=prev_keyname) { - d_texts.push_back(list); - d_key_names.push_back(QString()); d_feed_ids.push_back(0); - d_cast_texts.push_back(list_list); + d_texts.push_back(list); + d_icons.push_back(icons); d_cast_ids.push_back(ids); d_cast_icons.push_back(list); - d_icons.push_back(icons); + d_key_names.push_back(QString()); + d_cast_texts.push_back(list_list); updateRow(d_texts.size()-1,q); prev_keyname=q->value(0).toString(); } diff --git a/lib/rdfeedlistmodel.h b/lib/rdfeedlistmodel.h index 8b74b8d1..0b6c7ca5 100644 --- a/lib/rdfeedlistmodel.h +++ b/lib/rdfeedlistmodel.h @@ -2,7 +2,7 @@ // // Data model for Rivendell RSS feeds // -// (C) Copyright 2021 Fred Gleason +// (C) Copyright 2021-2022 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 @@ -85,16 +85,21 @@ class RDFeedListModel : public QAbstractItemModel QFontMetrics *d_font_metrics; QFont d_bold_font; QFontMetrics *d_bold_font_metrics; + // Column Data QList d_headers; + QList d_alignments; + + // Row Data + QList d_feed_ids; QList > d_texts; QList > d_icons; - QList > > d_cast_texts; QList > d_cast_ids; QList > d_cast_icons; - QList d_alignments; - QList d_background_colors; QStringList d_key_names; - QList d_feed_ids; + + // Z Data (episodes) + QList > > d_cast_texts; + bool d_is_admin; bool d_include_none; };