Delete reloads preset if required.
This commit is contained in:
@@ -497,7 +497,7 @@ int64_t PiPedalModel::SaveCurrentPresetAs(int64_t clientId, const std::string &n
|
|||||||
|
|
||||||
auto pedalboard = this->pedalBoard;
|
auto pedalboard = this->pedalBoard;
|
||||||
pedalboard.name(name);
|
pedalboard.name(name);
|
||||||
int64_t result = storage.saveCurrentPresetAs(pedalboard, name, saveAfterInstanceId);
|
int64_t result = storage.SaveCurrentPresetAs(pedalboard, name, saveAfterInstanceId);
|
||||||
FirePresetsChanged(clientId);
|
FirePresetsChanged(clientId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -594,10 +594,16 @@ int64_t PiPedalModel::DeleteBank(int64_t clientId, int64_t instanceId)
|
|||||||
int64_t PiPedalModel::DeletePreset(int64_t clientId, int64_t instanceId)
|
int64_t PiPedalModel::DeletePreset(int64_t clientId, int64_t instanceId)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard{mutex};
|
std::lock_guard<std::recursive_mutex> guard{mutex};
|
||||||
|
int64_t oldSelection = storage.GetCurrentPresetId();
|
||||||
int64_t newSelection = storage.DeletePreset(instanceId);
|
int64_t newSelection = storage.DeletePreset(instanceId);
|
||||||
this->FirePresetsChanged(clientId); // fire now.
|
this->FirePresetsChanged(clientId); // fire now.
|
||||||
return newSelection;
|
if (oldSelection != newSelection)
|
||||||
|
{
|
||||||
|
this->LoadPreset(
|
||||||
|
-1, // can't use cached version.
|
||||||
|
newSelection);
|
||||||
|
}
|
||||||
|
return newSelection;
|
||||||
}
|
}
|
||||||
bool PiPedalModel::RenamePreset(int64_t clientId, int64_t instanceId, const std::string &name)
|
bool PiPedalModel::RenamePreset(int64_t clientId, int64_t instanceId, const std::string &name)
|
||||||
{
|
{
|
||||||
|
|||||||
+6
-1
@@ -425,7 +425,7 @@ void Storage::SaveCurrentPreset(const PedalBoard &pedalBoard)
|
|||||||
item.preset(pedalBoard);
|
item.preset(pedalBoard);
|
||||||
SaveCurrentBank();
|
SaveCurrentBank();
|
||||||
}
|
}
|
||||||
int64_t Storage::saveCurrentPresetAs(const PedalBoard &pedalBoard, const std::string &name, int64_t saveAfterInstanceId)
|
int64_t Storage::SaveCurrentPresetAs(const PedalBoard &pedalBoard, const std::string &name, int64_t saveAfterInstanceId)
|
||||||
{
|
{
|
||||||
PedalBoard newPedalBoard = pedalBoard;
|
PedalBoard newPedalBoard = pedalBoard;
|
||||||
newPedalBoard.name(name);
|
newPedalBoard.name(name);
|
||||||
@@ -741,6 +741,11 @@ int64_t Storage::DeleteBank(int64_t bankId)
|
|||||||
throw PiPedalStateException("Bank not found.");
|
throw PiPedalStateException("Bank not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t Storage::GetCurrentPresetId() const
|
||||||
|
{
|
||||||
|
return this->currentBank.selectedPreset();
|
||||||
|
}
|
||||||
|
|
||||||
int64_t Storage::UploadPreset(const BankFile&bankFile,int64_t uploadAfter)
|
int64_t Storage::UploadPreset(const BankFile&bankFile,int64_t uploadAfter)
|
||||||
{
|
{
|
||||||
int64_t lastPreset = this->currentBank.selectedPreset();
|
int64_t lastPreset = this->currentBank.selectedPreset();
|
||||||
|
|||||||
+2
-2
@@ -90,8 +90,8 @@ public:
|
|||||||
void LoadBank(int64_t instanceId);
|
void LoadBank(int64_t instanceId);
|
||||||
const PedalBoard& GetCurrentPreset();
|
const PedalBoard& GetCurrentPreset();
|
||||||
void SaveCurrentPreset(const PedalBoard&pedalBoard);
|
void SaveCurrentPreset(const PedalBoard&pedalBoard);
|
||||||
int64_t saveCurrentPresetAs(const PedalBoard&pedalBoard, const std::string&namne,int64_t saveAfterInstanceId = -1);
|
int64_t SaveCurrentPresetAs(const PedalBoard&pedalBoard, const std::string&namne,int64_t saveAfterInstanceId = -1);
|
||||||
|
int64_t GetCurrentPresetId() const;
|
||||||
void GetPresetIndex(PresetIndex*pResult);
|
void GetPresetIndex(PresetIndex*pResult);
|
||||||
void SetPresetIndex(const PresetIndex &presetIndex);
|
void SetPresetIndex(const PresetIndex &presetIndex);
|
||||||
PedalBoard GetPreset(int64_t instanceId) const;
|
PedalBoard GetPreset(int64_t instanceId) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user