--- qsampler/trunk/src/qsamplerMainForm.ui.h 2005/02/18 10:28:45 391 +++ qsampler/trunk/src/qsamplerMainForm.ui.h 2005/02/20 19:13:33 395 @@ -317,9 +317,8 @@ // Window drag-n-drop event handlers. void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) { - QStringList files; - - pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files)); + QStringList files; + pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files)); } @@ -424,6 +423,9 @@ if (!closeSession(true)) return false; + // Give us what the server has, right now... + updateSession(); + // Ok increment untitled count. m_iUntitled++; @@ -596,20 +598,8 @@ if (iErrors > 0) appendMessagesError(tr("Session could not be loaded\nfrom \"%1\".\n\nSorry.").arg(sFilename)); - // Now we'll try to create the whole GUI session. - int *piChannelIDs = ::lscp_list_channels(m_pClient); - if (piChannelIDs == NULL) { - appendMessagesClient("lscp_list_channels"); - appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); - } else { - // Try to (re)create each channel. - m_pWorkspace->setUpdatesEnabled(false); - for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { - createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel])); - QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); - } - m_pWorkspace->setUpdatesEnabled(true); - } + // Now we'll try to create (update) the whole GUI session. + updateSession(); // Save as default session directory. if (m_pOptions) @@ -774,6 +764,9 @@ // Log this. appendMessages(tr("Sampler reset.")); + + // Make it a new session... + newSession(); } @@ -1230,6 +1223,32 @@ } +// Grab and restore current sampler channels session. +void qsamplerMainForm::updateSession (void) +{ + // Retrieve the current channel list. + int *piChannelIDs = ::lscp_list_channels(m_pClient); + if (piChannelIDs == NULL) { + if (::lscp_client_get_errno(m_pClient)) { + appendMessagesClient("lscp_list_channels"); + appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); + } + return; + } + + // Try to (re)create each channel. + m_pWorkspace->setUpdatesEnabled(false); + for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { + // Check if theres already a channel strip for this one... + if (!channelStrip(piChannelIDs[iChannel])) + createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel])); + // Make it visibly responsive... + QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); + } + m_pWorkspace->setUpdatesEnabled(true); +} + + // Update the recent files list and menu. void qsamplerMainForm::updateRecentFiles ( const QString& sFilename ) { @@ -1469,8 +1488,10 @@ QWidgetList wlist = m_pWorkspace->windowList(); for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); - // y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); - y += pChannelStrip->parentWidget()->frameGeometry().height(); + if (pChannelStrip) { + // y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); + y += pChannelStrip->parentWidget()->frameGeometry().height(); + } } } @@ -1522,12 +1543,33 @@ { QWidgetList wlist = m_pWorkspace->windowList(); if (wlist.isEmpty()) - return 0; + return NULL; return (qsamplerChannelStrip *) wlist.at(iChannel); } +// Retrieve a channel strip by sampler channel id. +qsamplerChannelStrip *qsamplerMainForm::channelStrip ( int iChannelID ) +{ + QWidgetList wlist = m_pWorkspace->windowList(); + if (wlist.isEmpty()) + return NULL; + + for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { + qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); + if (pChannelStrip) { + qsamplerChannel *pChannel = pChannelStrip->channel(); + if (pChannel && pChannel->channelID() == iChannelID) + return pChannelStrip; + } + } + + // Not found. + return NULL; +} + + // Construct the windows menu. void qsamplerMainForm::channelsMenuAboutToShow (void) {