changeset 128:09e6016c5436

* Add playback controls to data edit dialog * Make data edit dialog close properly when layer is removed from view * More fixes to playback tracking & selection model in data edit dialog * Remove edit button from data edit dialog for now
author Chris Cannam
date Wed, 18 Jun 2008 15:53:23 +0000
parents 7ee6da3f2b3c
children df5f16b3c925
files framework/MainWindowBase.cpp framework/MainWindowBase.h
diffstat 2 files changed, 40 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Tue Jun 17 16:07:56 2008 +0000
+++ b/framework/MainWindowBase.cpp	Wed Jun 18 15:53:23 2008 +0000
@@ -1351,6 +1351,7 @@
         emit hideSplash();
 
         if (factory->isAutoCallbackTarget(targetName)) {
+            QMessageBox::warning
 	    (this, tr("Couldn't open audio device"),
 	     tr("<b>No audio available</b><p>Could not open an audio device for playback.<p>Automatic audio device detection failed. Audio playback will not be available during this session.</p>"),
 	     QMessageBox::Ok);
@@ -1972,8 +1973,19 @@
     QString title = layer->getLayerPresentationName();
 
     ModelDataTableDialog *dialog = new ModelDataTableDialog(tabular, title, this);
-    dialog->setAttribute(Qt::WA_DeleteOnClose); // see below
+    dialog->setAttribute(Qt::WA_DeleteOnClose);
+    
+    connectLayerEditDialog(dialog);
 
+    m_layerDataDialogMap[layer] = dialog;
+    m_viewDataDialogMap[pane].insert(dialog);
+
+    dialog->show();
+}
+
+void
+MainWindowBase::connectLayerEditDialog(ModelDataTableDialog *dialog)
+{
     connect(m_viewManager,
             SIGNAL(globalCentreFrameChanged(unsigned long)),
             dialog,
@@ -1988,12 +2000,7 @@
             SIGNAL(scrollToFrame(unsigned long)),
             m_viewManager,
             SLOT(setGlobalCentreFrame(unsigned long)));
-    
-    m_layerDataDialogMap[layer] = dialog;
-    m_viewDataDialogMap[pane].insert(dialog);
-
-    dialog->show();
-}
+}    
 
 void
 MainWindowBase::previousPane()
@@ -2166,20 +2173,10 @@
 void
 MainWindowBase::layerAboutToBeDeleted(Layer *layer)
 {
-    if (m_layerDataDialogMap.find(layer) != m_layerDataDialogMap.end()) {
+    std::cerr << "MainWindowBase::layerAboutToBeDeleted(" << layer << ")" << std::endl;
 
-        ModelDataTableDialog *dialog = m_layerDataDialogMap[layer];
+    removeLayerEditDialog(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;
 	m_timeRulerLayer = 0;
@@ -2189,7 +2186,9 @@
 void
 MainWindowBase::layerInAView(Layer *layer, bool inAView)
 {
-//    std::cerr << "MainWindowBase::layerInAView(" << layer << "," << inAView << ")" << std::endl;
+    std::cerr << "MainWindowBase::layerInAView(" << layer << "," << inAView << ")" << std::endl;
+
+    if (!inAView) removeLayerEditDialog(layer);
 
     // Check whether we need to add or remove model from play source
     Model *model = layer->getModel();
@@ -2218,6 +2217,23 @@
 }
 
 void
+MainWindowBase::removeLayerEditDialog(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;
+    }
+}
+
+void
 MainWindowBase::modelAdded(Model *model)
 {
 //    std::cerr << "MainWindowBase::modelAdded(" << model << ")" << std::endl;
--- a/framework/MainWindowBase.h	Tue Jun 17 16:07:56 2008 +0000
+++ b/framework/MainWindowBase.h	Wed Jun 18 15:53:23 2008 +0000
@@ -307,6 +307,8 @@
     LayerDataDialogMap m_layerDataDialogMap;
     ViewDataDialogMap m_viewDataDialogMap;
 
+    void removeLayerEditDialog(Layer *);
+
     class PaneCallback : public SVFileReaderPaneCallback
     {
     public:
@@ -370,6 +372,8 @@
     virtual void setupMenus() = 0;
     virtual void updateVisibleRangeDisplay(Pane *p) const = 0;
 
+    virtual void connectLayerEditDialog(ModelDataTableDialog *dialog);
+
     virtual void toXml(QTextStream &stream);
 };