updates
authorThomas L. Balzer <tbalzer2012@gmail.com>
Sun, 26 Nov 2023 21:38:10 +0000 (15:38 -0600)
committerThomas L. Balzer <tbalzer2012@gmail.com>
Sun, 26 Nov 2023 21:38:10 +0000 (15:38 -0600)
.gitignore
AppManager.h
CardsList.qml
Shows.cpp
Shows.h
components/Episodes.qml [new file with mode: 0644]
templates/TextWrapper.qml
views/Show.qml
views/Summary.qml

index 27cb642..da83bce 100644 (file)
@@ -1,3 +1,5 @@
 b/
 data/
 docs/podcast-index/
+/cmake-build-debug/
+/.idea/
index 30759c8..d07ed8a 100644 (file)
@@ -20,14 +20,14 @@ class AppManager: public QObject
   Q_PROPERTY(QObject* shows READ shows CONSTANT)
 
 public:
-  AppManager(QObject* parent);
-  virtual ~AppManager();
+  explicit AppManager(QObject* parent);
+  ~AppManager() override;
 
   static AppManager *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine);
 
   void initializeView(QUrl url);
   QObject *shows();
-  QString dataDirectory(void) const;
+  [[nodiscard]] QString dataDirectory() const;
 
 public slots:
   void requestNewSource(QUrl sourceFile);
index a51ecec..de56caa 100644 (file)
@@ -31,37 +31,11 @@ Column {
                 {"display": "refresh all",
                  "link"   : "error.qml",
                  "action" : "refreshAll"} ]
-       /* Rectangle { */
-       /*     id: cardDelegate */
-       /*     width: cards.width */
-       /*     height: 100 */
-           
-       /*     border { */
-       /*      color: "red" */
-       /*      width: 1 */
-       /*     } */
-
-       /*     Text { */
-       /*      anchors.centerIn: parent */
 
-       /*      text: modelData.display */
-       /*     } */
-
-       /*     MouseArea { */
-       /*      anchors.fill: parent */
-       /*      onClicked: { */
-       /*          if("error.qml" !== modelData.link){ */
-       /*              AppManager.requestNewSource(modelData.link) */
-       /*          }else if(modelData.action) { */
-       /*              if("refreshAll" == modelData.action){ */
-       /*                  AppManager.shows.refreshAllFeeds() */
-       /*              }                        */
-       /*          } */
-       /*      } */
-       /*     } */
-       /* } */
        TextWrapper {
            id: cardDelegate
+           name: modelData.display
+           
            width: cards.width
            height: 100
            isTotallyCentered: true
index af28a64..ad8ad76 100644 (file)
--- a/Shows.cpp
+++ b/Shows.cpp
@@ -6,10 +6,11 @@
 #include <QNetworkRequest>
 
 #include <QDomDocument>
+#include <utility>
 
 Shows::Shows(QString dataDirectory, QObject *parent)
   : QObject(parent),
-    m_dataDirectory(dataDirectory),
+    m_dataDirectory(std::move(dataDirectory)),
     m_netMgr(new QNetworkAccessManager(this)),
     m_current(nullptr)
 {
@@ -22,11 +23,9 @@ Shows::Shows(QString dataDirectory, QObject *parent)
 }
 
 Shows::~Shows()
-{
-
-}
+= default;
 
-void Shows::checkSetCurrent(QString normalSelected)
+void Shows::checkSetCurrent(const QString& normalSelected)
 {
   QFile cacheFile(m_dataDirectory + "/" + normalSelected + "/feed.xml");
   if(cacheFile.exists()){
@@ -43,12 +42,12 @@ void Shows::checkSetCurrent(QString normalSelected)
   }
 }
 
-QString Shows::selectedName(void)
+QString Shows::selectedName()
 {
   return m_selectedName;
 }
 
-void Shows::setSelectedName(QString name)
+void Shows::setSelectedName(const QString &name)
 {
   if(name != m_selectedName){ 
     m_selectedName = name;
@@ -58,12 +57,12 @@ void Shows::setSelectedName(QString name)
   }
 }
 
-QString Shows::selected(void)
+QString Shows::selected()
 {
   return m_selectedFeed;
 }
 
-void Shows::setSelected(QString rssFeedUrl)
+void Shows::setSelected(const QString& rssFeedUrl)
 {
   if(rssFeedUrl != m_selectedFeed){ 
     m_selectedFeed = rssFeedUrl;
@@ -71,13 +70,13 @@ void Shows::setSelected(QString rssFeedUrl)
   }
 }
 
-void Shows::processByteArray(QByteArray ba)
+void Shows::processByteArray(const QByteArray& ba)
 {
   QDomDocument feedDoc;
   QDomDocument::ParseResult res = feedDoc.setContent(ba);
   if(!res){
     // error
-    fprintf(stderr, "[SH] RSS feed invalid. ba.size(): %d. Error: %s\n",
+    fprintf(stderr, "[SH] RSS feed invalid. ba.size(): %lld. Error: %s\n",
            ba.size(), res.errorMessage.toStdString().c_str());
   }else{
     // fine. get the title so we can write it out.
@@ -164,7 +163,7 @@ void Shows::processByteArray(QByteArray ba)
   }
 }
 
-void Shows::refreshAllFeeds(void)
+void Shows::refreshAllFeeds()
 {
   // open the xml file that holds this
 #define COLLECTION_XML "/home/tlb/dev/git/android-qt-sandbox/example-data/collection_opml.xml"
@@ -208,9 +207,9 @@ void Shows::refreshAllFeeds(void)
   }
 }
 
-void Shows::refreshSelected(void)
+void Shows::refreshSelected()
 {
-  // need to setup the download thing
+  // need to set up the download thing
   m_netMgr->get(QNetworkRequest(QUrl(selected())));
 
   // QFile cache(m_dataDirectory + "/last-downloaded.txt");
@@ -224,7 +223,7 @@ void Shows::refreshSelected(void)
   // }
 }
 
-QObject *Shows::current(void)
+QObject *Shows::current()
 {
   return m_current;
 }
diff --git a/Shows.h b/Shows.h
index 46d1a20..afcfed2 100644 (file)
--- a/Shows.h
+++ b/Shows.h
@@ -22,8 +22,8 @@ public:
   Q_INVOKABLE void refreshAllFeeds(void);
 
 public slots:
-  void setSelectedName(QString name);
-  void setSelected(QString rssFeedUrl);
+  void setSelectedName(const QString &name);
+  void setSelected(const QString& rssFeedUrl);
   void refreshSelected(void);
 
 signals:
@@ -32,8 +32,8 @@ signals:
   void currentChanged(QObject *current);
 
 private:
-  void processByteArray(QByteArray ba);
-  void checkSetCurrent(QString normalSelected);
+  void processByteArray(const QByteArray& ba);
+  void checkSetCurrent(const QString& normalSelected);
 
   QString m_dataDirectory;
   QString m_selectedName;
diff --git a/components/Episodes.qml b/components/Episodes.qml
new file mode 100644 (file)
index 0000000..3268139
--- /dev/null
@@ -0,0 +1,2 @@
+import QtQuick
+
dissimilarity index 72%
index 96580c6..ffff86b 100644 (file)
@@ -1,97 +1,90 @@
-import QtQuick
-import QtQuick.Layouts
-
-Rectangle {
-    id: root
-    
-    property alias  text: t.text
-    property alias  wrapMode: t.wrapMode
-    property alias  isClickable: ma.enabled
-    property var    clickHandler: undefined
-    property string name: "unnamed"
-    property int    buffer: 6
-    property int    textMaxWidth
-    property var    isTotallyCentered: undefined
-
-    height: t.height + buffer
-    width: t.width + buffer
-
-    /* not sure any of this matters */
-    
-    /* none = 0, grid = 1, col = 2, row = 3 */
-    /* property int fillMode: 0 */
-    /* Layout.fillHeight: { */
-    /*         return (fillMode == 1) || (fillMode == 2) */
-    /* } */
-    /* Layout.minimumHeight: t.height + buffer */
-    /* Layout.preferredHeight:  t.height + buffer */
-
-    /* Layout.fillWidth: { */
-    /*         return (fillMode == 1) || (fillMode == 3) */
-    /* } */
-    /* Layout.minimumWidth: t.width + buffer */
-    
-    border {
-       width: 1
-       color: "red"
-    }
-    Text {
-       id: t
-
-       anchors {
-           left: {
-               if(typeof isTotallyCentered !== "undefined"){
-                   if(isTotallyCentered){
-                       return undefined
-                   }
-               }
-               return parent.left
-           }
-           leftMargin: {
-               if(typeof isTotallyCentered !== "undefined"){
-                   if(isTotallyCentered){
-                       return undefined
-                   }
-               }
-               return 5
-           }
-           verticalCenter: {
-               if(typeof isTotallyCentered !== "undefined"){
-                   if(isTotallyCentered){
-                       return parent.verticalCenter
-                   }
-               }
-               /* always? */
-               return undefined
-           }
-           /* don't always want this */
-           horizontalCenter: {
-               if(typeof isTotallyCentered !== "undefined"){
-                   if(isTotallyCentered){
-                       return parent.horizontalCenter
-                   }
-               }
-               return undefined
-           }
-       }
-       
-       text: "unset"
-       wrapMode: Text.WordWrap
-       width: parent.width
-    }
-    function _l_on_clicked()
-    {
-       console.error("button '" + root.name + "' clicked")
-       if(typeof clickHandler !== "undefined"){
-           clickHandler()
-       }
-    }
-    MouseArea {
-       id: ma
-
-       anchors.fill: parent
-       
-       enabled: false
-       onClicked: _l_on_clicked()
-    }
-}
+import QtQuick
+import QtQuick.Layouts
+
+Rectangle {
+    id: root
+
+    property alias  text: t.text
+    property alias  wrapMode: t.wrapMode
+    property alias  isClickable: ma.enabled
+    property var    clickHandler: undefined
+    property string name: "unnamed"
+    property int    buffer: 6
+    property int    textMaxWidth
+    property var    isTotallyCentered: undefined
+
+    height: t.height + buffer
+    width: t.width + buffer
+
+    border {
+        width: 1
+        color: "red"
+    }
+    Text {
+        id: t
+
+        anchors {
+            left: {
+                if (typeof isTotallyCentered !== "undefined") {
+                    if (isTotallyCentered) {
+                        return undefined
+                    }
+                }
+                return parent.left
+            }
+            leftMargin: {
+                if (typeof isTotallyCentered !== "undefined") {
+                    if (isTotallyCentered) {
+                        return undefined
+                    }
+                }
+                return 5
+            }
+           fill: {
+               if (typeof isTotallyCentered !== "undefined") {
+                    if (isTotallyCentered) {
+                       return parent
+                   }
+               }
+               return undefined
+           }
+        }
+
+       horizontalAlignment: {
+           if (typeof isTotallyCentered !== "undefined") {
+                if (isTotallyCentered) {
+                    return Text.AlignHCenter
+                }
+            }
+           return Text.AlignLeft
+       }
+       verticalAlignment: {
+           if (typeof isTotallyCentered !== "undefined") {
+                if (isTotallyCentered) {
+                    return Text.AlignVCenter
+                }
+            }
+           return Text.AlignTop
+       }
+
+        text: "unset"
+        wrapMode: Text.WordWrap
+        width: parent.width
+    }
+
+    function _l_on_clicked() {
+        console.error("button '" + root.name + "' clicked")
+        if (typeof clickHandler !== "undefined") {
+            clickHandler()
+        }
+    }
+
+    MouseArea {
+        id: ma
+
+        anchors.fill: parent
+
+        enabled: false
+        onClicked: _l_on_clicked()
+    }
+}
dissimilarity index 66%
index dbb6636..5ea1676 100644 (file)
-import QtQuick
-import QtQuick.Layouts
-
-import tlb
-import "qrc:/tlb/templates"
-
-Page {
-    pageTitle: "Show Details"
-    
-    /* this should show actual details for a show. sqlite? */
-    content: Item {
-       id: root
-
-       anchors {
-           top: parent.top
-           left: parent.left
-           right: parent.right
-           margins: 20
-       }
-
-       /* MVP: show basic stats of the show. */
-       Loader {
-           id: l1
-
-           anchors {
-               left: parent.left
-               right: parent.right
-           }
-
-           active: AppManager.shows.current !== null
-           sourceComponent: /* ColumnLayout { */ Column {
-               spacing: 5
-
-               TextWrapper {
-                   text: "Name: " + AppManager.shows.current.title
-
-                   Layout.preferredWidth: parent.width
-                   width: parent.width
-               }
-               TextWrapper {
-                   wrapMode: Text.WordWrap
-                   /* the description already has paragraphs, add more for separation */
-                   text: "Description: <p>" + AppManager.shows.current.description + "</p>"
-
-                   width: parent.width
-                   /* these don't work by proxy if we want the word wrap to work */
-                   textMaxWidth: parent.width
-                   /* Layout.fillWidth: true */
-                   Layout.maximumWidth: parent.width
-                   Layout.preferredWidth: parent.width
-                   Layout.maximumHeight: 1000
-               }
-               TextWrapper {
-                   text: "Language: " + AppManager.shows.current.language
-
-                   width: parent.width
-                   Layout.preferredWidth: parent.width
-               }
-               TextWrapper {
-                   text: "Author: " + AppManager.shows.current.author
-
-                   width: parent.width
-                   Layout.preferredWidth: parent.width
-               }
-               TextWrapper {
-                   text: "Episodes: " + AppManager.shows.current.episodeCount
-
-                   width: parent.width
-                   Layout.preferredWidth: parent.width
-               }
-           }
-       }
-
-       Text {
-           text: AppManager.shows.selectedName + " FETCH BY HAND"
-           visible: !l1.active
-       }
-
-       /* near the bottom, put a refresh button that downloads the feed. */
-       Rectangle {
-           width: 40
-           height: 40
-           color: "purple"
-           anchors {
-               bottom: root.bottom
-               left: root.left
-               margins: 30
-           }
-           MouseArea {
-               anchors.fill: parent
-               onClicked: {
-                   AppManager.shows.refreshSelected()
-               }
-           }
-       }
-    }
-}
+import QtQuick
+import QtQuick.Layouts
+
+import tlb
+import "qrc:/tlb/templates"
+
+Page {
+    pageTitle: "Show Details"
+    
+    /* this should show actual details for a show. sqlite? */
+    content: Item {
+       id: root
+
+       anchors.fill: parent
+
+       Column {
+           anchors {
+               fill: parent
+               margins: 20
+               bottomMargin: 80
+           }
+           clip: true
+
+           /* MVP: show basic stats of the show. */
+           Loader {
+               id: l1
+
+               anchors {
+                   left: parent.left
+                   right: parent.right
+               }
+
+               active: AppManager.shows.current !== null
+               sourceComponent: /* ColumnLayout { */ Column {
+                   spacing: 5
+
+                   TextWrapper {
+                       text: "Name: " + AppManager.shows.current.title
+
+                       Layout.preferredWidth: parent.width
+                       width: parent.width
+                   }
+                   TextWrapper {
+                       wrapMode: Text.WordWrap
+                       /* the description already has paragraphs, add more for separation */
+                       text: "Description: <p>" + AppManager.shows.current.description + "</p>"
+
+                       width: parent.width
+                       /* these don't work by proxy if we want the word wrap to work */
+                       textMaxWidth: parent.width
+                       /* Layout.fillWidth: true */
+                       Layout.maximumWidth: parent.width
+                       Layout.preferredWidth: parent.width
+                       Layout.maximumHeight: 1000
+                   }
+                   TextWrapper {
+                       text: "Language: " + AppManager.shows.current.language
+
+                       width: parent.width
+                       Layout.preferredWidth: parent.width
+                   }
+                   TextWrapper {
+                       text: "Author: " + AppManager.shows.current.author
+
+                       width: parent.width
+                       Layout.preferredWidth: parent.width
+                   }
+                   TextWrapper {
+                       text: "Episodes: " + AppManager.shows.current.episodeCount
+
+                       width: parent.width
+                       Layout.preferredWidth: parent.width
+                   }
+               }
+           }
+
+           /* Summary of recent episodes */
+           
+       }
+
+       Text {
+           text: AppManager.shows.selectedName + " FETCH BY HAND"
+           visible: !l1.active
+       }
+
+       /* near the bottom, put a refresh button that downloads the feed. */
+       Rectangle {
+           width: 40
+           height: 40
+           color: "purple"
+           anchors {
+               bottom: root.bottom
+               left: root.left
+               margins: 30
+           }
+           MouseArea {
+               anchors.fill: parent
+               onClicked: {
+                   AppManager.shows.refreshSelected()
+               }
+           }
+       }
+    }
+}
index da886fb..b409c4d 100644 (file)
@@ -53,7 +53,7 @@ Page {
        property real curMouseX: 0.0
        property real curMouseY: 0.0
        property real jumpPos: 0.0
-       property alias showBox: selector.visible
+       /* property alias showBox: selector.visible */
        property string selectedTitle: ""
        property string selectedUrl: ""
 
@@ -100,12 +100,12 @@ Page {
                            var myMiddle = rec.height / 2
                            var newPoint = mapToItem(col, 0, myMiddle)
                            jumpPos = newPoint.y
-                           showBox = true
+                           /* showBox = true */
                            selectedTitle = title
                            selectedUrl = url
                        }else if(selectedTitle === title){
                            console.error(title + " no longer hovered")
-                           showBox = false
+                           /* showBox = false */
                            selectedTitle = ""
                            selectedUrl = ""
                        }