Implemented drumpad preset detail widget

This commit is contained in:
2022-12-28 00:47:20 +01:00
parent b86de5695e
commit 015d42d977
14 changed files with 378 additions and 75 deletions

View File

@ -20,6 +20,7 @@ SOURCES += \
drumpadjsonconverters.cpp \
drumpadpresets.cpp \
drumpadpresetsmodel.cpp \
drumpadpresettagsmodel.cpp \
graphrenderer.cpp \
jsonconverters.cpp \
loopstationjsonconverters.cpp \
@ -32,13 +33,13 @@ SOURCES += \
synthisizer.cpp \
treetotableproxymodel.cpp \
widgets/djwidget.cpp \
widgets/drumpadpresetdetailwidget.cpp \
widgets/drumpadsampleswidget.cpp \
widgets/drumpadsamplewidget.cpp \
widgets/drumpadwidget.cpp \
widgets/loopstationwidget.cpp \
widgets/mainwindow.cpp \
widgets/midibutton.cpp \
widgets/presetdetailwidget.cpp \
widgets/previewwidget.cpp \
widgets/scratchwidget.cpp \
widgets/sequencerwidget.cpp \
@ -55,6 +56,7 @@ HEADERS += \
drumpadjsonconverters.h \
drumpadpresets.h \
drumpadpresetsmodel.h \
drumpadpresettagsmodel.h \
graphrenderer.h \
jsonconverters.h \
loopstationjsonconverters.h \
@ -66,13 +68,13 @@ HEADERS += \
synthisizer.h \
treetotableproxymodel.h \
widgets/djwidget.h \
widgets/drumpadpresetdetailwidget.h \
widgets/drumpadsampleswidget.h \
widgets/drumpadsamplewidget.h \
widgets/drumpadwidget.h \
widgets/loopstationwidget.h \
widgets/mainwindow.h \
widgets/midibutton.h \
widgets/presetdetailwidget.h \
widgets/previewwidget.h \
widgets/scratchwidget.h \
widgets/sequencerwidget.h \
@ -82,12 +84,12 @@ HEADERS += \
FORMS += \
widgets/djwidget.ui \
widgets/drumpadpresetdetailwidget.ui \
widgets/drumpadsampleswidget.ui \
widgets/drumpadsamplewidget.ui \
widgets/drumpadwidget.ui \
widgets/loopstationwidget.ui \
widgets/mainwindow.ui \
widgets/presetdetailwidget.ui \
widgets/sequencerwidget.ui \
widgets/settingsdialog.ui \
widgets/synthisizerwidget.ui \

View File

@ -6,7 +6,7 @@
#include "drumpadpresets.h"
namespace drumpad_presets { class Preset; class File; }
namespace drumpad_presets { struct Preset; struct File; }
class DrumPadFilesModel : public QAbstractTableModel
{

View File

@ -4,7 +4,7 @@
#include <QAbstractTableModel>
namespace drumpad_presets { class Preset; }
namespace drumpad_presets { struct Preset; }
class DrumPadPresetsModel : public QAbstractTableModel
{

View File

@ -0,0 +1,41 @@
#include "drumpadpresettagsmodel.h"
DrumPadPresetTagsModel::DrumPadPresetTagsModel(QObject *parent) :
QAbstractListModel{parent}
{
}
void DrumPadPresetTagsModel::setPreset(const drumpad_presets::Preset &preset)
{
beginResetModel();
if (preset.tags)
m_tags = *preset.tags;
else
m_tags.clear();
endResetModel();
}
int DrumPadPresetTagsModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return m_tags.size();
}
QVariant DrumPadPresetTagsModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return {};
if (index.row() < 0 || index.row() >= int(m_tags.size()))
return {};
switch (role)
{
case Qt::DisplayRole:
case Qt::EditRole:
return m_tags[index.row()];
}
return {};
}

21
drumpadpresettagsmodel.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include <QAbstractListModel>
#include "drumpadpresets.h"
namespace drumpad_presets { struct Preset; }
class DrumPadPresetTagsModel : public QAbstractListModel
{
public:
DrumPadPresetTagsModel(QObject *parent = nullptr);
void setPreset(const drumpad_presets::Preset &preset);
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
private:
std::vector<QString> m_tags;
};

View File

@ -4,7 +4,7 @@
#include <QAbstractTableModel>
namespace loopstation_presets { class Preset; }
namespace loopstation_presets { struct Preset; }
class LoopStationPresetsModel : public QAbstractTableModel
{

View File

@ -0,0 +1,67 @@
#include "drumpadpresetdetailwidget.h"
#include "ui_drumpadpresetdetailwidget.h"
#include "drumpadpresets.h"
DrumPadPresetDetailWidget::DrumPadPresetDetailWidget(QWidget *parent) :
QScrollArea{parent},
m_ui{std::make_unique<Ui::DrumPadPresetDetailWidget>()}
{
m_ui->setupUi(this);
m_ui->listViewTags->setModel(&m_tagsModel);
}
DrumPadPresetDetailWidget::~DrumPadPresetDetailWidget() = default;
void DrumPadPresetDetailWidget::setPreset(const drumpad_presets::Preset &preset)
{
constexpr const auto applyField = [](QWidget *edit, const auto &field){
edit->setEnabled(field.has_value());
edit->setVisible(field.has_value());
};
constexpr const auto applyLineEdit = [applyField](QLineEdit *edit, const auto &field){
applyField(edit, field);
edit->setText(field ? *field : QString{});
};
constexpr const auto applySpinBox = [applyField](QSpinBox *edit, const auto &field){
applyField(edit, field);
edit->setValue(field ? *field : -1);
};
constexpr const auto applyCheckBox = [applyField](QCheckBox *edit, const auto &field){
applyField(edit, field);
edit->setChecked(field ? *field : false);
};
constexpr const auto applyDateTimeEdit = [applyField](QDateTimeEdit *edit, const auto &field){
applyField(edit, field);
edit->setDateTime(field ? *field : QDateTime{});
};
applyLineEdit(m_ui->lineEditId, preset.id);
applyLineEdit(m_ui->lineEditName, preset.name);
applyLineEdit(m_ui->lineEditAuthor, preset.author);
applyLineEdit(m_ui->lineEditOrderBy, preset.orderBy);
applyLineEdit(m_ui->lineEditVersion, preset.version);
applySpinBox(m_ui->spinBoxTempo, preset.tempo);
applyLineEdit(m_ui->lineEditIcon, preset.icon);
applySpinBox(m_ui->spinBoxPrice, preset.price);
applySpinBox(m_ui->spinBoxPriceForSession, preset.priceForSession);
applyCheckBox(m_ui->checkBoxHasInfo, preset.hasInfo);
applyField(m_ui->listViewTags, preset.tags);
applyCheckBox(m_ui->checkBoxDeleted, preset.DELETED);
applySpinBox(m_ui->spinBoxDifficulty, preset.difficulty);
applySpinBox(m_ui->spinBoxSample, preset.sample);
applyLineEdit(m_ui->lineEditAudioPreview1Name, preset.audioPreview1Name);
applyLineEdit(m_ui->lineEditAudioPreview1URL, preset.audioPreview1URL);
applyLineEdit(m_ui->lineEditAudioPreview2Name, preset.audioPreview2Name);
applyLineEdit(m_ui->lineEditAudioPreview2URL, preset.audioPreview2URL);
applyLineEdit(m_ui->lineEditImagePreview1, preset.imagePreview1);
applyLineEdit(m_ui->lineEditVideoPreview, preset.videoPreview);
applyLineEdit(m_ui->lineEditVideoTutorial, preset.videoTutorial);
// TODO files
// TODO beatschool
// TODO easyPlay
applyDateTimeEdit(m_ui->dateTimeEditTimestamp, preset.timestamp);
m_tagsModel.setPreset(preset);
}

View File

@ -0,0 +1,26 @@
#pragma once
#include <memory>
#include <QScrollArea>
#include "drumpadpresettagsmodel.h"
namespace Ui { class DrumPadPresetDetailWidget; }
namespace drumpad_presets { struct Preset; }
class DrumPadPresetDetailWidget : public QScrollArea
{
Q_OBJECT
public:
explicit DrumPadPresetDetailWidget(QWidget *parent = nullptr);
~DrumPadPresetDetailWidget() override;
void setPreset(const drumpad_presets::Preset &preset);
private:
const std::unique_ptr<Ui::DrumPadPresetDetailWidget> m_ui;
DrumPadPresetTagsModel m_tagsModel;
};

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PresetDetailWidget</class>
<widget class="QScrollArea" name="PresetDetailWidget">
<class>DrumPadPresetDetailWidget</class>
<widget class="QScrollArea" name="DrumPadPresetDetailWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>320</width>
<height>633</height>
<width>389</width>
<height>774</height>
</rect>
</property>
<property name="widgetResizable">
@ -18,8 +18,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>318</width>
<height>631</height>
<width>387</width>
<height>772</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
@ -231,34 +231,109 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditId"/>
<widget class="QLineEdit" name="lineEditId">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEditName"/>
<widget class="QLineEdit" name="lineEditName">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditAuthor"/>
<widget class="QLineEdit" name="lineEditAuthor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEditOrderBy"/>
<widget class="QLineEdit" name="lineEditOrderBy">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditVersion"/>
<widget class="QLineEdit" name="lineEditVersion">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="spinBoxTempo"/>
<widget class="QSpinBox" name="spinBoxTempo">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>-2147483647</number>
</property>
<property name="maximum">
<number>2147483647</number>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lineEditIcon"/>
<widget class="QLineEdit" name="lineEditIcon">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="spinBoxPrice"/>
<widget class="QSpinBox" name="spinBoxPrice">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>-2147483647</number>
</property>
<property name="maximum">
<number>2147483647</number>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QSpinBox" name="spinBoxPriceForSession"/>
<widget class="QSpinBox" name="spinBoxPriceForSession">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>-2147483647</number>
</property>
<property name="maximum">
<number>2147483647</number>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QCheckBox" name="checkBoxHasInfo">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>CheckBox</string>
</property>
@ -266,37 +341,145 @@
</item>
<item row="11" column="1">
<widget class="QCheckBox" name="checkBoxDeleted">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QSpinBox" name="spinBoxDifficulty"/>
<widget class="QSpinBox" name="spinBoxDifficulty">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>-2147483647</number>
</property>
<property name="maximum">
<number>2147483647</number>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QSpinBox" name="spinBoxSample"/>
<widget class="QSpinBox" name="spinBoxSample">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>-2147483647</number>
</property>
<property name="maximum">
<number>2147483647</number>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QLineEdit" name="lineEditAudioPreview1Name"/>
<widget class="QLineEdit" name="lineEditAudioPreview1Name">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QLineEdit" name="lineEditAudioPreview1URL"/>
<widget class="QLineEdit" name="lineEditAudioPreview1URL">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QLineEdit" name="lineEditAudioPreview2Name"/>
<widget class="QLineEdit" name="lineEditAudioPreview2Name">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="QLineEdit" name="lineEditAudioPreview2URL"/>
<widget class="QLineEdit" name="lineEditAudioPreview2URL">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="18" column="1">
<widget class="QLineEdit" name="lineEditImagePreview1"/>
<widget class="QLineEdit" name="lineEditImagePreview1">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="19" column="1">
<widget class="QLineEdit" name="lineEditVideoPreview"/>
<widget class="QLineEdit" name="lineEditVideoPreview">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="20" column="1">
<widget class="QLineEdit" name="lineEditVideoTutorial"/>
<widget class="QLineEdit" name="lineEditVideoTutorial">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="22" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="21" column="0">
<widget class="QLabel" name="labelTimestamp">
<property name="text">
<string>Timestamp:</string>
</property>
<property name="buddy">
<cstring>dateTimeEditTimestamp</cstring>
</property>
</widget>
</item>
<item row="21" column="1">
<widget class="QDateTimeEdit" name="dateTimeEditTimestamp">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QListView" name="listViewTags"/>
</item>
</layout>
</widget>

View File

@ -87,7 +87,7 @@
<property name="currentIndex">
<number>0</number>
</property>
<widget class="PresetDetailWidget" name="presetDetailWidget">
<widget class="DrumPadPresetDetailWidget" name="presetDetailWidget">
<attribute name="title">
<string>Properties</string>
</attribute>
@ -120,9 +120,9 @@
<container>1</container>
</customwidget>
<customwidget>
<class>PresetDetailWidget</class>
<class>DrumPadPresetDetailWidget</class>
<extends>QScrollArea</extends>
<header>widgets/presetdetailwidget.h</header>
<header>widgets/drumpadpresetdetailwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>

View File

@ -38,7 +38,8 @@ LoopStationWidget::~LoopStationWidget() = default;
void LoopStationWidget::writeSamples(frame_t *begin, frame_t *end)
{
Q_UNUSED(begin)
Q_UNUSED(end)
}
void LoopStationWidget::injectNetworkAccessManager(QNetworkAccessManager &networkAccessManager)
@ -49,7 +50,7 @@ void LoopStationWidget::injectNetworkAccessManager(QNetworkAccessManager &networ
void LoopStationWidget::injectDecodingThread(QThread &thread)
{
Q_UNUSED(thread)
}
void LoopStationWidget::loadSettings(DrumMachineSettings &settings)
@ -69,7 +70,7 @@ void LoopStationWidget::sendColors()
void LoopStationWidget::midiReceived(const midi::MidiMessage &message)
{
Q_UNUSED(message);
}
void LoopStationWidget::currentRowChanged(const QModelIndex &current)

View File

@ -1,16 +0,0 @@
#include "presetdetailwidget.h"
#include "ui_presetdetailwidget.h"
PresetDetailWidget::PresetDetailWidget(QWidget *parent) :
QScrollArea{parent},
m_ui{std::make_unique<Ui::PresetDetailWidget>()}
{
m_ui->setupUi(this);
}
PresetDetailWidget::~PresetDetailWidget() = default;
void PresetDetailWidget::setPreset(const drumpad_presets::Preset &preset)
{
// TODO
}

View File

@ -1,22 +0,0 @@
#pragma once
#include <memory>
#include <QScrollArea>
namespace Ui { class PresetDetailWidget; }
namespace drumpad_presets { class Preset; }
class PresetDetailWidget : public QScrollArea
{
Q_OBJECT
public:
explicit PresetDetailWidget(QWidget *parent = nullptr);
~PresetDetailWidget() override;
void setPreset(const drumpad_presets::Preset &preset);
private:
const std::unique_ptr<Ui::PresetDetailWidget> m_ui;
};

View File

@ -9,7 +9,7 @@
class QLabel;
namespace Ui { class SequencerWidget; }
namespace drumpad_presets { class Preset; class Sequence; }
namespace drumpad_presets { struct Preset; struct Sequence; }
class DrumMachineSettings;
namespace midi { struct MidiMessage; }