diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-26 23:52:01 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-26 23:52:01 -0500 |
commit | 65886d792d198528a7f35d8d59f8cfeaa5d34e1c (patch) | |
tree | b83ca439b0b7e6a4d6ff8d6ed1de1f22c6a91f97 /clients/tde/src/app/remotemdi.cpp | |
parent | 9c9085621bf01f9b39e15eb856ff521ecb01fccf (diff) | |
download | ulab-65886d792d198528a7f35d8d59f8cfeaa5d34e1c.tar.gz ulab-65886d792d198528a7f35d8d59f8cfeaa5d34e1c.zip |
Add skeleton for FPGA viewer
Fix authserver crash
Diffstat (limited to 'clients/tde/src/app/remotemdi.cpp')
-rw-r--r-- | clients/tde/src/app/remotemdi.cpp | 80 |
1 files changed, 49 insertions, 31 deletions
diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp index 4d355e3..10d4fc8 100644 --- a/clients/tde/src/app/remotemdi.cpp +++ b/clients/tde/src/app/remotemdi.cpp @@ -1,7 +1,7 @@ //Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>, (C) 2012 //Copyright: See COPYING file that comes with this distribution -// TDE MDI interface based on excellent tutorial by Andrea Bergia et al. +// TDE MDI interface based on a (passable) tutorial by Andrea Bergia et al. #include "remotemdi.h" @@ -45,7 +45,8 @@ RemoteMDI::RemoteMDI() KStdAction::keyBindings(TQT_TQOBJECT(this), TQT_SLOT(configKeys()), ac); connect_action = new KAction(i18n("Connect to Server"), "connect_creating", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(connectToServer()), ac, "connect_server"); disconnect_action = new KAction(i18n("Disconnect from Server"), "connect_no", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(disconnectFromServer()), ac, "disconnect_server"); - inst_sa_menu = new KAction(i18n("Launch Spectrum Analyzer"), "remote", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(startSpectrumAnalyzer()), ac, "spectrum_analyzer"); + inst_fpgaviewer_menu = new KAction(i18n("Launch Spectrum Analyzer"), "remote", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(startSpectrumAnalyzer()), ac, "spectrum_analyzer"); + inst_sa_menu = new KAction(i18n("Launch FPGA Viewer"), "remote", KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(startFPGAViewer()), ac, "fpga_viewer"); // Add Window menu if ( !isFakingSDIApplication() ) { @@ -92,12 +93,13 @@ RemoteMDI::~RemoteMDI() void RemoteMDI::connectToServer() { if (m_rsvSvrSocket) { if (m_rsvSvrSocket->state() != TQSocket::Idle) { + printf("[DEBUG] Not connecting because the socket is still in state %d\n\r", m_rsvSvrSocket->state()); fflush(stdout); return; } } connect_action->setEnabled(false); - disconnect_action->setEnabled(false); + disconnect_action->setEnabled(true); // Connect to the central reservation/control server if (!m_rsvSvrSocket) { @@ -196,7 +198,15 @@ void RemoteMDI::disconnectFromServer() { connect_action->setEnabled(false); disconnect_action->setEnabled(false); + for (TQValueList< KMdiChildView *>::iterator it = m_window.begin(); it != m_window.end(); ++it ) { + // Get the view + KMdiChildView *view = *it; + // Close it + closeSpecifiedWindow(view); + } + if (m_rsvSvrSocket) { + m_rsvSvrSocket->clearPendingData(); m_rsvSvrSocket->close(); while (m_rsvSvrSocket->state() == TQSocket::Closing) { tqApp->processEvents(); @@ -222,6 +232,7 @@ printf("[RAJA DEBUG 600.0] connected: %d\n\r", connected); fflush(stdout); connect_action->setEnabled(!connected); disconnect_action->setEnabled(connected); + inst_fpgaviewer_menu->setEnabled(connected); inst_sa_menu->setEnabled(connected); } @@ -250,8 +261,15 @@ void RemoteMDI::startSpectrumAnalyzer() { } } -void RemoteMDI::openNewWindow(KMdiChildView *view) -{ +void RemoteMDI::startFPGAViewer() { + RemoteLab::InstrumentView* fpgaview = new RemoteLab::InstrumentView("libremotelab_fpgaviewer", i18n("FPGA Viewer"), (mdiMode() == KMdi::ToplevelMode) ? 0 : this); + openNewWindow(fpgaview); + if (m_serverHost != "") { + fpgaview->connectServer(m_serverHost); + } +} + +void RemoteMDI::openNewWindow(KMdiChildView *view) { // Add a child view m_children++; @@ -288,8 +306,7 @@ void RemoteMDI::childWindowCloseRequest(KMdiChildView *pWnd) { } } -void RemoteMDI::currentChanged(KMdiChildView *current) -{ +void RemoteMDI::currentChanged(KMdiChildView *current) { // Update status bar and list box statusBar()->message(i18n( "%1 activated").arg(current->tabCaption())); @@ -298,34 +315,38 @@ void RemoteMDI::currentChanged(KMdiChildView *current) m_listBox->setCurrentItem(item); } -void RemoteMDI::closeCurrent() -{ +void RemoteMDI::closeCurrent() { // If there's a current view, close it - if ( m_pCurrentWindow != 0 ) { - // Notify the status bar of the removal of the window - statusBar()->message(i18n("%1 removed").arg(m_pCurrentWindow->tabCaption())); + if (m_pCurrentWindow) { + closeSpecifiedWindow(m_pCurrentWindow); + } +} +void RemoteMDI::closeSpecifiedWindow(KMdiChildView *window) { + if (window) { + // Notify the status bar of the removal of the window + statusBar()->message(i18n("%1 removed").arg(window->tabCaption())); + // Remove from the window list - m_window.remove(m_window.find(m_pCurrentWindow)); - + m_window.remove(m_window.find(window)); + // Remove from the list box - TQListBoxItem *item = m_listBox->findItem(m_pCurrentWindow->tabCaption()); - assert( item ); + TQListBoxItem *item = m_listBox->findItem(window->tabCaption()); + assert(item); delete item; - + // We could also call removeWindowFromMdi, but it doesn't delete the // pointer. This way, we're sure that the view will get deleted. - closeWindow(m_pCurrentWindow); - } - - // Synchronize combo box - if (m_pCurrentWindow) { - currentChanged(m_pCurrentWindow); + closeWindow(window); + + // Synchronize combo box + if (m_pCurrentWindow) { + currentChanged(m_pCurrentWindow); + } } } -void RemoteMDI::listBoxExecuted(TQListBoxItem *item) -{ +void RemoteMDI::listBoxExecuted(TQListBoxItem *item) { // Get the current item's text TQString text = item->text(); @@ -343,8 +364,7 @@ void RemoteMDI::listBoxExecuted(TQListBoxItem *item) } } -void RemoteMDI::listBoxRightClicked(TQListBoxItem *item) -{ +void RemoteMDI::listBoxRightClicked(TQListBoxItem *item) { // Get the current item's text TQString text = item->text(); @@ -363,8 +383,7 @@ void RemoteMDI::listBoxRightClicked(TQListBoxItem *item) } } -void RemoteMDI::childClosed(KMdiChildView * w) -{ +void RemoteMDI::childClosed(KMdiChildView * w) { assert(w); // Set as active @@ -386,8 +405,7 @@ void RemoteMDI::childClosed(KMdiChildView * w) removeWindowFromMdi(w); } -bool RemoteMDI::queryClose() -{ +bool RemoteMDI::queryClose() { // Close all open connections for (TQValueList< KMdiChildView *>::iterator it = m_window.begin(); it != m_window.end(); ++it ) { RemoteLab::InstrumentView* iview = dynamic_cast<RemoteLab::InstrumentView*>(*it); |