summaryrefslogtreecommitdiff
path: root/src/mainwindow.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-05-20 14:26:43 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-05-20 14:26:43 +0200
commit8d551ed344a9bfa7f0b96a8677aca570d8c7c407 (patch)
treee189123b8f753b67318b7bd0771a85a98b403d4f /src/mainwindow.cc
parentaada18db0ae8611e8e0ae67e0096d1f9e1d44d48 (diff)
Implement remove functionality for instruments and channels.
Diffstat (limited to 'src/mainwindow.cc')
-rw-r--r--src/mainwindow.cc32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 6238a18..61ea9bb 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -98,7 +98,7 @@ MainWindow::MainWindow(Settings& settings)
tools->addWidget(rem);
instrument_list = new QListWidget();
connect(instrument_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
- this, SLOT(itemDoubleClicked(QListWidgetItem*)));
+ this, SLOT(instrumentDoubleClicked(QListWidgetItem*)));
l->addWidget(tools);
l->addWidget(instrument_list);
@@ -125,6 +125,8 @@ MainWindow::MainWindow(Settings& settings)
tools->addWidget(add);
tools->addWidget(rem);
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"});
@@ -167,9 +169,25 @@ void MainWindow::addInstrument()
void MainWindow::removeInstrument()
{
+ auto items = instrument_list->selectedItems();
+ for(auto item : items)
+ {
+ auto id = item->data(Qt::UserRole).toInt();
+
+ for(int i = 0; i < tab_widget->count(); ++i)
+ {
+ if(tab_widget->widget(i)->property("id").toInt() == id)
+ {
+ tab_widget->removeTab(i);
+ }
+ }
+
+ project.deleteInstrument(id);
+ delete item;
+ }
}
-void MainWindow::itemDoubleClicked(QListWidgetItem *item)
+void MainWindow::instrumentDoubleClicked(QListWidgetItem *item)
{
int id = item->data(Qt::UserRole).toInt();
auto& instr = project.getInstrument(id);
@@ -196,11 +214,21 @@ void MainWindow::addChannel()
auto item = new QListWidgetItem();
item->setIcon(QPixmap(":icons/channel.png"));
item->setText("New Channel");
+ //item->setData(Qt::UserRole, id);
channel_list->addItem(item);
}
void MainWindow::removeChannel()
{
+ auto items = channel_list->selectedItems();
+ for(auto item : items)
+ {
+ delete item;
+ }
+}
+
+void MainWindow::channelDoubleClicked(QListWidgetItem *item)
+{
}
void MainWindow::updateWindowTitle()