comparison framework/MainWindowBase.cpp @ 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
comparison
equal deleted inserted replaced
127:7ee6da3f2b3c 128:09e6016c5436
1349 1349
1350 if (!m_playTarget) { 1350 if (!m_playTarget) {
1351 emit hideSplash(); 1351 emit hideSplash();
1352 1352
1353 if (factory->isAutoCallbackTarget(targetName)) { 1353 if (factory->isAutoCallbackTarget(targetName)) {
1354 QMessageBox::warning
1354 (this, tr("Couldn't open audio device"), 1355 (this, tr("Couldn't open audio device"),
1355 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>"), 1356 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>"),
1356 QMessageBox::Ok); 1357 QMessageBox::Ok);
1357 } else { 1358 } else {
1358 QMessageBox::warning 1359 QMessageBox::warning
1970 } 1971 }
1971 1972
1972 QString title = layer->getLayerPresentationName(); 1973 QString title = layer->getLayerPresentationName();
1973 1974
1974 ModelDataTableDialog *dialog = new ModelDataTableDialog(tabular, title, this); 1975 ModelDataTableDialog *dialog = new ModelDataTableDialog(tabular, title, this);
1975 dialog->setAttribute(Qt::WA_DeleteOnClose); // see below 1976 dialog->setAttribute(Qt::WA_DeleteOnClose);
1976 1977
1978 connectLayerEditDialog(dialog);
1979
1980 m_layerDataDialogMap[layer] = dialog;
1981 m_viewDataDialogMap[pane].insert(dialog);
1982
1983 dialog->show();
1984 }
1985
1986 void
1987 MainWindowBase::connectLayerEditDialog(ModelDataTableDialog *dialog)
1988 {
1977 connect(m_viewManager, 1989 connect(m_viewManager,
1978 SIGNAL(globalCentreFrameChanged(unsigned long)), 1990 SIGNAL(globalCentreFrameChanged(unsigned long)),
1979 dialog, 1991 dialog,
1980 SLOT(userScrolledToFrame(unsigned long))); 1992 SLOT(userScrolledToFrame(unsigned long)));
1981 1993
1986 1998
1987 connect(dialog, 1999 connect(dialog,
1988 SIGNAL(scrollToFrame(unsigned long)), 2000 SIGNAL(scrollToFrame(unsigned long)),
1989 m_viewManager, 2001 m_viewManager,
1990 SLOT(setGlobalCentreFrame(unsigned long))); 2002 SLOT(setGlobalCentreFrame(unsigned long)));
1991 2003 }
1992 m_layerDataDialogMap[layer] = dialog;
1993 m_viewDataDialogMap[pane].insert(dialog);
1994
1995 dialog->show();
1996 }
1997 2004
1998 void 2005 void
1999 MainWindowBase::previousPane() 2006 MainWindowBase::previousPane()
2000 { 2007 {
2001 if (!m_paneStack) return; 2008 if (!m_paneStack) return;
2164 } 2171 }
2165 2172
2166 void 2173 void
2167 MainWindowBase::layerAboutToBeDeleted(Layer *layer) 2174 MainWindowBase::layerAboutToBeDeleted(Layer *layer)
2168 { 2175 {
2169 if (m_layerDataDialogMap.find(layer) != m_layerDataDialogMap.end()) { 2176 std::cerr << "MainWindowBase::layerAboutToBeDeleted(" << layer << ")" << std::endl;
2170 2177
2171 ModelDataTableDialog *dialog = m_layerDataDialogMap[layer]; 2178 removeLayerEditDialog(layer);
2172 2179
2173 for (ViewDataDialogMap::iterator vi = m_viewDataDialogMap.begin();
2174 vi != m_viewDataDialogMap.end(); ++vi) {
2175 vi->second.erase(dialog);
2176 }
2177
2178 m_layerDataDialogMap.erase(layer);
2179 delete dialog;
2180 }
2181
2182 // std::cerr << "MainWindowBase::layerAboutToBeDeleted(" << layer << ")" << std::endl;
2183 if (m_timeRulerLayer && (layer == m_timeRulerLayer)) { 2180 if (m_timeRulerLayer && (layer == m_timeRulerLayer)) {
2184 // std::cerr << "(this is the time ruler layer)" << std::endl; 2181 // std::cerr << "(this is the time ruler layer)" << std::endl;
2185 m_timeRulerLayer = 0; 2182 m_timeRulerLayer = 0;
2186 } 2183 }
2187 } 2184 }
2188 2185
2189 void 2186 void
2190 MainWindowBase::layerInAView(Layer *layer, bool inAView) 2187 MainWindowBase::layerInAView(Layer *layer, bool inAView)
2191 { 2188 {
2192 // std::cerr << "MainWindowBase::layerInAView(" << layer << "," << inAView << ")" << std::endl; 2189 std::cerr << "MainWindowBase::layerInAView(" << layer << "," << inAView << ")" << std::endl;
2190
2191 if (!inAView) removeLayerEditDialog(layer);
2193 2192
2194 // Check whether we need to add or remove model from play source 2193 // Check whether we need to add or remove model from play source
2195 Model *model = layer->getModel(); 2194 Model *model = layer->getModel();
2196 if (model) { 2195 if (model) {
2197 if (inAView) { 2196 if (inAView) {
2216 2215
2217 updateMenuStates(); 2216 updateMenuStates();
2218 } 2217 }
2219 2218
2220 void 2219 void
2220 MainWindowBase::removeLayerEditDialog(Layer *layer)
2221 {
2222 if (m_layerDataDialogMap.find(layer) != m_layerDataDialogMap.end()) {
2223
2224 ModelDataTableDialog *dialog = m_layerDataDialogMap[layer];
2225
2226 for (ViewDataDialogMap::iterator vi = m_viewDataDialogMap.begin();
2227 vi != m_viewDataDialogMap.end(); ++vi) {
2228 vi->second.erase(dialog);
2229 }
2230
2231 m_layerDataDialogMap.erase(layer);
2232 delete dialog;
2233 }
2234 }
2235
2236 void
2221 MainWindowBase::modelAdded(Model *model) 2237 MainWindowBase::modelAdded(Model *model)
2222 { 2238 {
2223 // std::cerr << "MainWindowBase::modelAdded(" << model << ")" << std::endl; 2239 // std::cerr << "MainWindowBase::modelAdded(" << model << ")" << std::endl;
2224 m_playSource->addModel(model); 2240 m_playSource->addModel(model);
2225 } 2241 }