~mrp/aerodramus

91f830165a9f0118b70480060c88b2861c5fbe24 — Mark Penner 6 months ago a5a5950
put fileListModel in App
4 files changed, 29 insertions(+), 6 deletions(-)

M src/CMakeLists.txt
A src/app.cpp
M src/app.h
M src/qml/main.qml
M src/CMakeLists.txt => src/CMakeLists.txt +1 -1
@@ 9,7 9,7 @@ qt_add_qml_module(aerodramus-gui URI mrp.aerodramus NO_RESOURCE_TARGET_PATH
        qml/main.qml
        qml/AudioFile.qml
    SOURCES
        app.h
        app.cpp
        audiofile.cpp
        filelistmodel.cpp
)

A src/app.cpp => src/app.cpp +15 -0
@@ 0,0 1,15 @@
// SPDX-FileCopyrightText: 2023 Mark Penner <mrpenner@mailbox.org>
// SPDX-License-Identifier: GPL-3.0-or-later

#include "app.h"

App::App()
    : QObject::QObject()
{
    m_fileListModel = new FileListModel;
}
void App::appendFile(QString string)
{
    m_fileListModel->append(string);
    Q_EMIT fileListModelChanged();
}

M src/app.h => src/app.h +11 -0
@@ 4,6 4,7 @@
#ifndef AERODRAMUS_APP_H
#define AERODRAMUS_APP_H

#include "filelistmodel.h"
#include <QObject>
#include <QtQmlIntegration>



@@ 12,6 13,16 @@ class App : public QObject
    Q_OBJECT
    QML_ELEMENT
    QML_SINGLETON
    Q_PROPERTY(FileListModel *fileListModel MEMBER m_fileListModel NOTIFY fileListModelChanged)

public:
    App();

    Q_INVOKABLE void appendFile(QString string);

    Q_SIGNAL void fileListModelChanged();

private:
    FileListModel *m_fileListModel;
};
#endif

M src/qml/main.qml => src/qml/main.qml +2 -5
@@ 49,9 49,6 @@ Kirigami.ApplicationWindow {
        ]
    }

    FileListModel {
        id: fileListModel
    }
    pageStack.initialPage: navPage
    Kirigami.ScrollablePage {
        id: navPage


@@ 64,7 61,7 @@ Kirigami.ApplicationWindow {
                text: i18n("No views yet")
                helpfulAction: openAction
            }
            model: fileListModel
            model: App.fileListModel
            delegate: QQC.Label{
                required property string name
                text: name


@@ 77,6 74,6 @@ Kirigami.ApplicationWindow {
            pageStack.pop();
        }
        root.mainPage = pageStack.push("qrc:/qml/AudioFile.qml", {fileUrl: fileUrl});
        fileListModel.append(root.mainPage.name);
        App.appendFile(root.mainPage.name);
    }
}