- Rust backend (qobuz-backend static lib): Qobuz API client (reqwest/tokio), Symphonia audio decoder, CPAL audio output, extern "C" FFI bridge - Qt 6 frontend mirroring spotify-qt layout: toolbar with playback controls, left library dock, central track list, right search panel - Auth: email/password login with MD5-signed requests; session token persisted via QSettings - Playback: double-click a track → Rust fetches stream URL → Symphonia decodes → CPAL outputs to default audio device - Dark Fusion palette matching spotify-qt feel Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <QAbstractTableModel>
|
|
#include <QJsonArray>
|
|
#include <QJsonObject>
|
|
#include <QVector>
|
|
|
|
/// Flat data stored for each row in the track list.
|
|
struct TrackItem {
|
|
qint64 id = 0;
|
|
int number = 0;
|
|
QString title;
|
|
QString artist;
|
|
QString album;
|
|
QString albumId;
|
|
qint64 duration = 0; // seconds
|
|
bool hiRes = false;
|
|
bool streamable = false;
|
|
QJsonObject raw; // full JSON for context menus / playback
|
|
};
|
|
|
|
class TrackListModel : public QAbstractTableModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
enum Column {
|
|
ColNumber = 0,
|
|
ColTitle = 1,
|
|
ColArtist = 2,
|
|
ColAlbum = 3,
|
|
ColDuration = 4,
|
|
ColCount
|
|
};
|
|
|
|
enum Role {
|
|
TrackIdRole = Qt::UserRole + 1,
|
|
TrackJsonRole = Qt::UserRole + 2,
|
|
HiResRole = Qt::UserRole + 3,
|
|
};
|
|
|
|
explicit TrackListModel(QObject *parent = nullptr);
|
|
|
|
void setTracks(const QJsonArray &tracks);
|
|
void clear();
|
|
|
|
const TrackItem &trackAt(int row) const { return m_tracks.at(row); }
|
|
int rowCount(const QModelIndex &parent = {}) const override;
|
|
int columnCount(const QModelIndex &parent = {}) const override;
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
|
|
static QString formatDuration(qint64 secs);
|
|
|
|
private:
|
|
QVector<TrackItem> m_tracks;
|
|
};
|