# HG changeset patch # User Chris Cannam # Date 1213188858 0 # Node ID 74dd55646f521d2432247e87f9263437d8ea71ad # Parent ab861544f9981128a4910ee45b1e314852a89eae * A bit more work on the data editor diff -r ab861544f998 -r 74dd55646f52 framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Fri Jun 06 10:32:50 2008 +0000 +++ b/framework/MainWindowBase.cpp Wed Jun 11 12:54:18 2008 +0000 @@ -39,6 +39,7 @@ #include "widgets/ProgressDialog.h" #include "widgets/MIDIFileImportDialog.h" #include "widgets/CSVFormatDialog.h" +#include "widgets/ModelDataTableDialog.h" #include "audioio/AudioCallbackPlaySource.h" #include "audioio/AudioCallbackPlayTarget.h" @@ -1923,6 +1924,47 @@ } void +MainWindowBase::editCurrentLayer() +{ + Layer *layer = 0; + Pane *pane = m_paneStack->getCurrentPane(); + if (pane) layer = pane->getSelectedLayer(); + if (!layer) return; + + Model *model = layer->getModel(); + if (!model) return; + + if (m_layerDataDialogMap.find(layer) != m_layerDataDialogMap.end()) { + m_layerDataDialogMap[layer]->show(); + m_layerDataDialogMap[layer]->raise(); + return; + } + + ModelDataTableDialog *dialog = new ModelDataTableDialog(model); +// dialog->setAttribute(Qt::WA_DeleteOnClose); //!!! how to manage this? + + connect(m_viewManager, + SIGNAL(globalCentreFrameChanged(unsigned long)), + dialog, + SLOT(scrollToFrameRequested(unsigned long))); +/* + connect(m_viewManager, + SIGNAL(playbackFrameChanged(unsigned long)), + dialog, + SLOT(scrollToFrameRequested(unsigned long))); +*/ + connect(dialog, + SIGNAL(scrollToFrame(unsigned long)), + m_viewManager, + SLOT(setGlobalCentreFrame(unsigned long))); + + m_layerDataDialogMap[layer] = dialog; + m_viewDataDialogMap[pane].insert(dialog); + + dialog->show(); +} + +void MainWindowBase::previousPane() { if (!m_paneStack) return; @@ -2051,8 +2093,17 @@ } void -MainWindowBase::viewCentreFrameChanged(View *v, unsigned long ) +MainWindowBase::viewCentreFrameChanged(View *v, unsigned long frame) { + std::cerr << "MainWindowBase::viewCentreFrameChanged(" << v << "," << frame << ")" << std::endl; + + if (m_viewDataDialogMap.find(v) != m_viewDataDialogMap.end()) { + for (DataDialogSet::iterator i = m_viewDataDialogMap[v].begin(); + i != m_viewDataDialogMap[v].end(); ++i) { + std::cerr << "found dialog" << std::endl; + (*i)->scrollToFrameRequested(frame); + } + } if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return; Pane *p = 0; if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return; @@ -2085,6 +2136,19 @@ void MainWindowBase::layerAboutToBeDeleted(Layer *layer) { + if (m_layerDataDialogMap.find(layer) != m_layerDataDialogMap.end()) { + + ModelDataTableDialog *dialog = m_layerDataDialogMap[layer]; + + for (ViewDataDialogMap::iterator vi = m_viewDataDialogMap.begin(); + vi != m_viewDataDialogMap.end(); ++vi) { + vi->second.erase(dialog); + } + + m_layerDataDialogMap.erase(layer); + delete dialog; + } + // std::cerr << "MainWindowBase::layerAboutToBeDeleted(" << layer << ")" << std::endl; if (m_timeRulerLayer && (layer == m_timeRulerLayer)) { // std::cerr << "(this is the time ruler layer)" << std::endl; diff -r ab861544f998 -r 74dd55646f52 framework/MainWindowBase.h --- a/framework/MainWindowBase.h Fri Jun 06 10:32:50 2008 +0000 +++ b/framework/MainWindowBase.h Wed Jun 11 12:54:18 2008 +0000 @@ -57,6 +57,7 @@ class OSCMessage; class KeyReference; class Labeller; +class ModelDataTableDialog; /** * The base class for the SV main window. This includes everything to @@ -171,6 +172,7 @@ virtual void deleteCurrentPane(); virtual void deleteCurrentLayer(); + virtual void editCurrentLayer(); virtual void previousPane(); virtual void nextPane(); @@ -298,6 +300,13 @@ Pane *addPaneToStack(); Layer *getSnapLayer() const; + typedef std::map LayerDataDialogMap; + typedef std::set DataDialogSet; + typedef std::map ViewDataDialogMap; + + LayerDataDialogMap m_layerDataDialogMap; + ViewDataDialogMap m_viewDataDialogMap; + class PaneCallback : public SVFileReaderPaneCallback { public: