91 lines
2.3 KiB
C++
91 lines
2.3 KiB
C++
#ifndef NAVIGATIONCONTROLLER_H
|
|
#define NAVIGATIONCONTROLLER_H
|
|
|
|
#include <QObject>
|
|
#include <QQmlContext>
|
|
|
|
class NavigationItemModel;
|
|
class NavigationListModel;
|
|
class UiStateModel;
|
|
class MusicPlayer;
|
|
|
|
/**
|
|
* @brief Main controller controlling ui state, navigation and music player.
|
|
*/
|
|
class NavigationController : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QString pDebugOutput READ getDebugOutput NOTIFY debugOutputChanged)
|
|
|
|
signals:
|
|
void debugOutputChanged();
|
|
|
|
public:
|
|
explicit NavigationController(QObject *parent = nullptr);
|
|
|
|
/**
|
|
* @brief Setup navigation model parsing all directories under rootPath
|
|
* @param rootPath path to root directory containing music
|
|
*/
|
|
void init(const QString & rootPath);
|
|
/**
|
|
* @brief Set ui profile
|
|
* @param profileString String defining profile
|
|
* @see UiStateModel::setProfile(const QString& profileString)
|
|
*/
|
|
void setUiProfile(const QString& profileString);
|
|
|
|
/**
|
|
* @brief setContext set QML Context and context properties
|
|
* @param context QmlContext
|
|
* @see setContextProperties
|
|
*/
|
|
void setContext(QQmlContext* context);
|
|
|
|
QString getDebugOutput() const { return mDebugOutput; }
|
|
|
|
private:
|
|
/**
|
|
* @brief Register models in context
|
|
*/
|
|
void setContextProperties();
|
|
/**
|
|
* @brief Add a directory and its subdirectories to navigation
|
|
* @param path Path to directory
|
|
* @param parentItem Parent directory
|
|
*/
|
|
void add(const QString & path, NavigationItemModel* parentItem);
|
|
/**
|
|
* @brief Check whether directory contains either a subdirectory or flac or mp3 music files
|
|
* @param path path to directory
|
|
* @return true if directory is valid
|
|
*/
|
|
bool checkContent(const QString& path);
|
|
|
|
/**
|
|
* @brief Set Debug Output. Necessary as Android Debugger does not work yet
|
|
* @param text Output to show in ui
|
|
*/
|
|
void setDebugOutput(const QString& text);
|
|
|
|
NavigationItemModel* mRootItem;
|
|
NavigationListModel* mNavList;
|
|
|
|
UiStateModel* mUiState;
|
|
MusicPlayer* mMediaPlayer;
|
|
|
|
QString mRootPath = ".";
|
|
|
|
QString mDebugOutput;
|
|
|
|
QQmlContext* mContext = nullptr;
|
|
|
|
private slots:
|
|
/**
|
|
* @brief Either show subdirectories or music player depending on current directory type
|
|
*/
|
|
void onNavigationRequest();
|
|
};
|
|
|
|
#endif // NAVIGATIONCONTROLLER_H
|