Skip to content
Snippets Groups Projects
Commit 094105c9 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

New clone action for InstrumentView.

parent 76d470ad
No related branches found
No related tags found
No related merge requests found
......@@ -25,17 +25,22 @@ InstrumentViewActions::InstrumentViewActions(QWidget* parent)
: QObject(parent)
, m_addInstrumentAction(nullptr)
, m_removeInstrumentAction(nullptr)
, m_cloneInstrumentAction(nullptr)
, m_model(nullptr)
, m_selectionModel(nullptr)
{
m_addInstrumentAction
= new QAction(QIcon(":/images/toolbar16dark_newitem.svg"), "Add new instrument", this);
connect(m_addInstrumentAction, SIGNAL(triggered()), this, SLOT(onAddInstrument()));
m_addInstrumentAction = new QAction(QIcon(":/images/toolbar16dark_newitem.svg"),
"Add new instrument", this);
m_removeInstrumentAction = new QAction(QIcon(":/images/toolbar16dark_recycle.svg"),
"Remove currently selected instrument", this);
m_cloneInstrumentAction = new QAction(QIcon(":/images/toolbar16dark_cloneitem.svg"),
"Clone currently selected instrument", this);
m_removeInstrumentAction
= new QAction(QIcon(":/images/toolbar16dark_recycle.svg"),
"Remove currently selected instrument", this);
connect(m_addInstrumentAction, SIGNAL(triggered()), this, SLOT(onAddInstrument()));
connect(m_removeInstrumentAction, SIGNAL(triggered()), this, SLOT(onRemoveInstrument()));
connect(m_cloneInstrumentAction, SIGNAL(triggered()), this, SLOT(onCloneInstrument()));
}
void InstrumentViewActions::setModel(SessionModel* model) { m_model = model; }
......@@ -62,6 +67,18 @@ void InstrumentViewActions::onRemoveInstrument()
updateSelection();
}
void InstrumentViewActions::onCloneInstrument()
{
QModelIndex currentIndex = m_selectionModel->currentIndex();
if (currentIndex.isValid()) {
SessionItem* item = m_model->itemForIndex(currentIndex);
QString nameOfClone = suggestInstrumentName(item->itemName());
SessionItem *clone = m_model->copyParameterizedItem(item);
clone->setItemName(nameOfClone);
}
}
void InstrumentViewActions::onContextMenuRequest(const QPoint& point,
const QModelIndex& indexAtPoint)
{
......@@ -69,6 +86,7 @@ void InstrumentViewActions::onContextMenuRequest(const QPoint& point,
QMenu menu;
menu.addAction(m_addInstrumentAction);
menu.addAction(m_removeInstrumentAction);
menu.addAction(m_cloneInstrumentAction);
menu.exec(point);
}
......
......@@ -41,6 +41,7 @@ public:
public slots:
void onAddInstrument();
void onRemoveInstrument();
void onCloneInstrument();
void onContextMenuRequest(const QPoint &point, const QModelIndex &indexAtPoint);
private:
......@@ -50,6 +51,7 @@ private:
QAction* m_addInstrumentAction;
QAction* m_removeInstrumentAction;
QAction* m_cloneInstrumentAction;
SessionModel* m_model;
QItemSelectionModel* m_selectionModel;
};
......
......@@ -22,6 +22,7 @@ InstrumentViewToolBar::InstrumentViewToolBar(InstrumentViewActions* actions, QWi
: StyledToolBar(parent)
, m_addInstrumentButton(new QToolButton)
, m_removeInstrumentButton(new QToolButton)
, m_cloneInstrumentButton(new QToolButton)
{
m_addInstrumentButton->setText("Add");
m_addInstrumentButton->setIcon(QIcon(":/images/toolbar16light_newitem.svg"));
......@@ -29,16 +30,19 @@ InstrumentViewToolBar::InstrumentViewToolBar(InstrumentViewActions* actions, QWi
m_addInstrumentButton->setToolTip("Add new instrument");
addWidget(m_addInstrumentButton);
addStyledSeparator();
m_removeInstrumentButton->setText("Remove");
m_removeInstrumentButton->setIcon(QIcon(":/images/toolbar16light_recycle.svg"));
m_removeInstrumentButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
m_removeInstrumentButton->setToolTip("Remove currently selected instrument");
addWidget(m_removeInstrumentButton);
addStyledSeparator();
m_cloneInstrumentButton->setText("Clone");
m_cloneInstrumentButton->setIcon(QIcon(":/images/toolbar16light_cloneitem.svg"));
m_cloneInstrumentButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
m_cloneInstrumentButton->setToolTip("Clone currently selected instrument");
addWidget(m_cloneInstrumentButton);
connect(m_addInstrumentButton, SIGNAL(clicked()), actions, SLOT(onAddInstrument()));
connect(m_removeInstrumentButton, SIGNAL(clicked()), actions, SLOT(onRemoveInstrument()));
connect(m_cloneInstrumentButton, SIGNAL(clicked()), actions, SLOT(onCloneInstrument()));
}
......@@ -36,6 +36,7 @@ public:
private:
QToolButton* m_addInstrumentButton;
QToolButton* m_removeInstrumentButton;
QToolButton* m_cloneInstrumentButton;
};
#endif // INSTRUMENTVIEWTOOLBAR_H
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment