summaryrefslogtreecommitdiff
path: root/src/mainwindow.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-09-29 18:48:05 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-09-29 18:48:05 +0200
commitcc8d62af149323752ed6a6ea0fb3b6b7407ea77b (patch)
tree39bdc50c1a44ab30addafad288d98b7f529b8bf8 /src/mainwindow.cc
parent46efa2def1212dcb2610c545a78c8ab81bb22bbf (diff)
Remove all channel map ids if in use when deleting a channel.
Diffstat (limited to 'src/mainwindow.cc')
-rw-r--r--src/mainwindow.cc38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 4084df1..ad13975 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -148,13 +148,6 @@ MainWindow::MainWindow(Settings& settings)
channel_list = new QListWidget();
connect(channel_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(channelDoubleClicked(QListWidgetItem*)));
-// channel_list->addItems({"AmbL", "AmbR", "Kdrum_back", "Kdrum_front",
-// "Hihat", "OHL", "OHR", "Ride","Snare_bottom",
-// "Snare_top", "Tom1", "Tom2", "Tom3"});
-// for(int i = 0; i < channel_list->count(); ++i)
-// {
-// channel_list->item(i)->setIcon(QPixmap(":icons/channel.png"));
-// }
l->addWidget(tools);
l->addWidget(channel_list);
@@ -222,9 +215,8 @@ void MainWindow::removeInstrument()
int ret =
QMessageBox::question(this, tr("Delete Instrument"),
tr("Are you sure you want to delete the selected "
- "instrument?"),
- QMessageBox::Yes | QMessageBox::No |
- QMessageBox::Cancel);
+ "instrument(s)?"),
+ QMessageBox::Yes | QMessageBox::Cancel);
if(ret != QMessageBox::Yes)
{
return;
@@ -289,10 +281,36 @@ void MainWindow::addChannel()
void MainWindow::removeChannel()
{
+ int ret =
+ QMessageBox::question(this, tr("Delete Channel"),
+ tr("Are you sure you want to delete the selected "
+ "channel(s)?"),
+ QMessageBox::Yes | QMessageBox::Cancel);
+ if(ret != QMessageBox::Yes)
+ {
+ return;
+ }
+
auto items = channel_list->selectedItems();
for(auto item : items)
{
auto id = item->data(Qt::UserRole).toInt();
+
+ auto instrument_ids = project.getInstrumentList();
+ for(auto instrument_id : instrument_ids)
+ {
+ auto& instrument = project.getInstrument(instrument_id);
+ auto audiofile_ids = instrument.getAudioFileList();
+ for(auto audiofile_id : audiofile_ids)
+ {
+ auto& audiofile = instrument.getAudioFile(audiofile_id);
+ if(audiofile.getChannelMapId() == id)
+ {
+ audiofile.setChannelMapId(-1); // Unset channel map
+ }
+ }
+ }
+
project.deleteChannel(id);
delete item;
}