33 |
|
|
34 |
#include <QHeaderView> |
#include <QHeaderView> |
35 |
#include <QMessageBox> |
#include <QMessageBox> |
36 |
|
#include <QContextMenuEvent> |
37 |
|
|
38 |
|
|
39 |
namespace QSampler { |
namespace QSampler { |
48 |
{ |
{ |
49 |
m_ui.setupUi(this); |
m_ui.setupUi(this); |
50 |
|
|
51 |
|
m_pInstrumentListView = new InstrumentListView(this); |
52 |
|
QMainWindow::setCentralWidget(m_pInstrumentListView); |
53 |
|
|
54 |
// Setup toolbar widgets. |
// Setup toolbar widgets. |
55 |
m_pMapComboBox = new QComboBox(m_ui.instrumentToolbar); |
m_pMapComboBox = new QComboBox(m_ui.instrumentToolbar); |
56 |
m_pMapComboBox->setMinimumWidth(120); |
m_pMapComboBox->setMinimumWidth(120); |
57 |
m_pMapComboBox->setEnabled(false); |
m_pMapComboBox->setEnabled(false); |
58 |
m_pMapComboBox->setToolTip(tr("Instrument Map")); |
m_pMapComboBox->setToolTip(tr("Instrument Map")); |
59 |
|
|
60 |
m_ui.instrumentToolbar->addWidget(m_pMapComboBox); |
m_ui.instrumentToolbar->addWidget(m_pMapComboBox); |
|
|
|
61 |
m_ui.instrumentToolbar->addSeparator(); |
m_ui.instrumentToolbar->addSeparator(); |
62 |
m_ui.instrumentToolbar->addAction(m_ui.newInstrumentAction); |
m_ui.instrumentToolbar->addAction(m_ui.newInstrumentAction); |
63 |
m_ui.instrumentToolbar->addAction(m_ui.editInstrumentAction); |
m_ui.instrumentToolbar->addAction(m_ui.editInstrumentAction); |
65 |
m_ui.instrumentToolbar->addSeparator(); |
m_ui.instrumentToolbar->addSeparator(); |
66 |
m_ui.instrumentToolbar->addAction(m_ui.refreshInstrumentsAction); |
m_ui.instrumentToolbar->addAction(m_ui.refreshInstrumentsAction); |
67 |
|
|
|
m_pInstrumentListView = new InstrumentListView(this); |
|
|
m_pInstrumentListView->setContextMenuPolicy(Qt::CustomContextMenu); |
|
|
QMainWindow::setCentralWidget(m_pInstrumentListView); |
|
|
|
|
68 |
QObject::connect(m_pMapComboBox, |
QObject::connect(m_pMapComboBox, |
69 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
70 |
SLOT(activateMap(int))); |
SLOT(activateMap(int))); |
71 |
QObject::connect( |
QObject::connect(m_pInstrumentListView->selectionModel(), |
72 |
m_pInstrumentListView, |
SIGNAL(currentRowChanged(const QModelIndex&,const QModelIndex&)), |
|
SIGNAL(customContextMenuRequested(const QPoint&)), |
|
|
SLOT(contextMenu(const QPoint&))); |
|
|
QObject::connect( |
|
|
m_pInstrumentListView, |
|
|
SIGNAL(activated(const QModelIndex&)), |
|
73 |
SLOT(stabilizeForm())); |
SLOT(stabilizeForm())); |
74 |
QObject::connect( |
QObject::connect( |
75 |
m_pInstrumentListView, |
m_pInstrumentListView, |
99 |
|
|
100 |
InstrumentListForm::~InstrumentListForm (void) |
InstrumentListForm::~InstrumentListForm (void) |
101 |
{ |
{ |
|
delete m_pInstrumentListView; |
|
102 |
delete m_pMapComboBox; |
delete m_pMapComboBox; |
103 |
|
delete m_pInstrumentListView; |
104 |
} |
} |
105 |
|
|
106 |
|
|
311 |
} |
} |
312 |
|
|
313 |
|
|
314 |
// Handle custom context menu here... |
// Context menu request. |
315 |
void InstrumentListForm::contextMenu ( const QPoint& pos ) |
void InstrumentListForm::contextMenuEvent ( |
316 |
|
QContextMenuEvent *pContextMenuEvent ) |
317 |
{ |
{ |
318 |
if (!m_ui.newInstrumentAction->isEnabled()) |
if (m_ui.newInstrumentAction->isEnabled()) |
319 |
return; |
m_ui.contextMenu->exec(pContextMenuEvent->globalPos()); |
|
|
|
|
m_ui.contextMenu->exec( |
|
|
(m_pInstrumentListView->viewport())->mapToGlobal(pos)); |
|
320 |
} |
} |
321 |
|
|
322 |
|
|