diff --git a/DrumMachine.pro b/DrumMachine.pro index 3546324..98bedcb 100755 --- a/DrumMachine.pro +++ b/DrumMachine.pro @@ -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 \ diff --git a/drumpadfilesmodel.h b/drumpadfilesmodel.h index 2f17fe1..7186825 100755 --- a/drumpadfilesmodel.h +++ b/drumpadfilesmodel.h @@ -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 { diff --git a/drumpadpresetsmodel.h b/drumpadpresetsmodel.h index be02e4c..8bd3a4e 100755 --- a/drumpadpresetsmodel.h +++ b/drumpadpresetsmodel.h @@ -4,7 +4,7 @@ #include -namespace drumpad_presets { class Preset; } +namespace drumpad_presets { struct Preset; } class DrumPadPresetsModel : public QAbstractTableModel { diff --git a/drumpadpresettagsmodel.cpp b/drumpadpresettagsmodel.cpp new file mode 100644 index 0000000..1d71f8a --- /dev/null +++ b/drumpadpresettagsmodel.cpp @@ -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 {}; +} diff --git a/drumpadpresettagsmodel.h b/drumpadpresettagsmodel.h new file mode 100644 index 0000000..b9be164 --- /dev/null +++ b/drumpadpresettagsmodel.h @@ -0,0 +1,21 @@ +#pragma once + +#include + +#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 m_tags; +}; diff --git a/loopstationpresetsmodel.h b/loopstationpresetsmodel.h index 4ddf60d..292b04f 100644 --- a/loopstationpresetsmodel.h +++ b/loopstationpresetsmodel.h @@ -4,7 +4,7 @@ #include -namespace loopstation_presets { class Preset; } +namespace loopstation_presets { struct Preset; } class LoopStationPresetsModel : public QAbstractTableModel { diff --git a/widgets/drumpadpresetdetailwidget.cpp b/widgets/drumpadpresetdetailwidget.cpp new file mode 100755 index 0000000..ed2f01d --- /dev/null +++ b/widgets/drumpadpresetdetailwidget.cpp @@ -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()} +{ + 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); +} diff --git a/widgets/drumpadpresetdetailwidget.h b/widgets/drumpadpresetdetailwidget.h new file mode 100755 index 0000000..594f624 --- /dev/null +++ b/widgets/drumpadpresetdetailwidget.h @@ -0,0 +1,26 @@ +#pragma once + +#include + +#include + +#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 m_ui; + + DrumPadPresetTagsModel m_tagsModel; +}; diff --git a/widgets/presetdetailwidget.ui b/widgets/drumpadpresetdetailwidget.ui similarity index 56% rename from widgets/presetdetailwidget.ui rename to widgets/drumpadpresetdetailwidget.ui index 8648f75..a8d48f8 100755 --- a/widgets/presetdetailwidget.ui +++ b/widgets/drumpadpresetdetailwidget.ui @@ -1,13 +1,13 @@ - PresetDetailWidget - + DrumPadPresetDetailWidget + 0 0 - 320 - 633 + 389 + 774 @@ -18,8 +18,8 @@ 0 0 - 318 - 631 + 387 + 772 @@ -231,34 +231,109 @@ - + + + false + + + true + + - + + + false + + + true + + - + + + false + + + true + + - + + + false + + + true + + - + + + false + + + true + + - + + + false + + + -2147483647 + + + 2147483647 + + - + + + false + + + true + + - + + + false + + + -2147483647 + + + 2147483647 + + - + + + false + + + -2147483647 + + + 2147483647 + + + + false + CheckBox @@ -266,37 +341,145 @@ + + false + CheckBox - + + + false + + + -2147483647 + + + 2147483647 + + - + + + false + + + -2147483647 + + + 2147483647 + + - + + + false + + + true + + - + + + false + + + true + + - + + + false + + + true + + - + + + false + + + true + + - + + + false + + + true + + - + + + false + + + true + + - + + + false + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Timestamp: + + + dateTimeEditTimestamp + + + + + + + false + + + true + + + + + diff --git a/widgets/drumpadwidget.ui b/widgets/drumpadwidget.ui index 05a7104..e2dd06a 100644 --- a/widgets/drumpadwidget.ui +++ b/widgets/drumpadwidget.ui @@ -87,7 +87,7 @@ 0 - + Properties @@ -120,9 +120,9 @@ 1 - PresetDetailWidget + DrumPadPresetDetailWidget QScrollArea -
widgets/presetdetailwidget.h
+
widgets/drumpadpresetdetailwidget.h
1
diff --git a/widgets/loopstationwidget.cpp b/widgets/loopstationwidget.cpp index 67423ad..547070e 100644 --- a/widgets/loopstationwidget.cpp +++ b/widgets/loopstationwidget.cpp @@ -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 ¤t) diff --git a/widgets/presetdetailwidget.cpp b/widgets/presetdetailwidget.cpp deleted file mode 100755 index b064880..0000000 --- a/widgets/presetdetailwidget.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "presetdetailwidget.h" -#include "ui_presetdetailwidget.h" - -PresetDetailWidget::PresetDetailWidget(QWidget *parent) : - QScrollArea{parent}, - m_ui{std::make_unique()} -{ - m_ui->setupUi(this); -} - -PresetDetailWidget::~PresetDetailWidget() = default; - -void PresetDetailWidget::setPreset(const drumpad_presets::Preset &preset) -{ - // TODO -} diff --git a/widgets/presetdetailwidget.h b/widgets/presetdetailwidget.h deleted file mode 100755 index 747f36e..0000000 --- a/widgets/presetdetailwidget.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include - -#include - -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 m_ui; -}; diff --git a/widgets/sequencerwidget.h b/widgets/sequencerwidget.h index e71d677..d191285 100755 --- a/widgets/sequencerwidget.h +++ b/widgets/sequencerwidget.h @@ -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; }