Extend instrument parts

master
Timothy Pearson 12 years ago
parent 4dbe57682c
commit b6eb803097

@ -51,17 +51,19 @@ RemoteMDI::RemoteMDI()
menuBar()->insertItem(i18n("&Window"), windowMenu());
}
setMenuForSDIModeSysButtons(menuBar());
createGUI( 0 );
// When we change view, change the status bar text
connect(this, SIGNAL(viewActivated(KMdiChildView*)), this, SLOT(currentChanged(KMdiChildView*)));
ac->setHighlightingEnabled(true);
connect(ac, TQT_SIGNAL(actionStatusText(const TQString&)), statusBar(), TQT_SLOT(message(const TQString&) ));
connect(ac, TQT_SIGNAL(actionStatusText(const TQString&)), this, TQT_SLOT(updateStatusBarMainMessage(const TQString&) ));
connect(ac, TQT_SIGNAL(clearStatusText()), statusBar(), TQT_SLOT(clear()));
// Create the status bar
statusBar()->message(i18n("No view!"));
updateStatusBarMainMessage(i18n("No active instruments"));
processActions();
@ -82,6 +84,28 @@ RemoteMDI::~RemoteMDI()
}
}
void RemoteMDI::updateStatusBarMessage() {
KStatusBar* sb = statusBar();
if (sb) {
sb->message(m_mainStatusBarMessage + ((m_windowStatusBarMessage != "")?" [" + i18n("Instrument") + ": " + m_windowStatusBarMessage + "]":""));
}
}
void RemoteMDI::updateStatusBarMainMessage(const TQString& message) {
m_mainStatusBarMessage = message;
updateStatusBarMessage();
}
void RemoteMDI::updateStatusBarWindowMessage(const TQString& message) {
m_windowStatusBarMessage = message;
updateStatusBarMessage();
}
void RemoteMDI::resizeEvent(TQResizeEvent *e) {
KMdiMainFrm::resizeEvent(e);
setSysButtonsAtMenuPosition();
}
void RemoteMDI::processActions() {
// Add dynamic actions
// RAJA FIXME
@ -130,6 +154,7 @@ void RemoteMDI::startModule() {
}
RemoteLab::InstrumentView* view = new RemoteLab::InstrumentView(sendingAction->name(), st.name, (mdiMode() == KMdi::ToplevelMode) ? 0 : this);
connect(view, SIGNAL(statusMessageSet(const TQString&)), this, SLOT(updateStatusBarWindowMessage(const TQString&)));
openNewWindow(view);
if (m_serverHost != "") {
view->connectServer(m_serverHost);
@ -227,7 +252,7 @@ void RemoteMDI::connectToServer() {
if (!m_rsvSvrSocket) {
m_rsvSvrSocket = new TDEKerberosClientSocket(this);
connect(m_rsvSvrSocket, SIGNAL(connectionClosed()), this, SLOT(connectionClosedHandler()));
connect(m_rsvSvrSocket, TQT_SIGNAL(statusMessageUpdated(const TQString&)), statusBar(), TQT_SLOT(message(const TQString&) ));
connect(m_rsvSvrSocket, TQT_SIGNAL(statusMessageUpdated(const TQString&)), this, TQT_SLOT(updateStatusBarMainMessage(const TQString&) ));
}
m_rsvSvrSocket->setServiceName("remotefpga");
if (m_serverHost != "") {
@ -386,7 +411,7 @@ void RemoteMDI::childWindowCloseRequest(KMdiChildView *pWnd) {
void RemoteMDI::currentChanged(KMdiChildView *current) {
// Update status bar and list box
statusBar()->message(i18n( "%1 activated").arg(current->tabCaption()));
updateStatusBarMainMessage(i18n("Instrument %1 activated").arg(current->tabCaption()));
}
void RemoteMDI::closeCurrent() {
@ -399,7 +424,8 @@ void RemoteMDI::closeCurrent() {
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()));
updateStatusBarWindowMessage(TQString::null);
updateStatusBarMainMessage(i18n("Instrument %1 removed").arg(window->tabCaption()));
// We could also call removeWindowFromMdi, but it doesn't delete the
// pointer. This way, we're sure that the view will get deleted.
@ -420,7 +446,8 @@ void RemoteMDI::childClosed(KMdiChildView * w) {
assert(w == m_pCurrentWindow);
// Notify the status bar of the removal of the window
statusBar()->message(i18n("%1 removed").arg(w->tabCaption()));
updateStatusBarWindowMessage(TQString::null);
updateStatusBarMainMessage(i18n("Instrument %1 removed").arg(w->tabCaption()));
// Remove the view from MDI, BUT DO NOT DELETE IT! It is automatically deleted by TQt since it was closed.
removeWindowFromMdi(w);

@ -58,6 +58,9 @@ class RemoteMDI : public KMdiMainFrm
private slots:
void configToolbars();
void configKeys();
void updateStatusBarMessage();
void updateStatusBarMainMessage(const TQString& message);
void updateStatusBarWindowMessage(const TQString& message);
void connectToServer();
void finishConnectingToServer();
void disconnectFromServer();
@ -69,8 +72,12 @@ class RemoteMDI : public KMdiMainFrm
protected:
virtual bool queryClose();
virtual void resizeEvent(TQResizeEvent *);
private:
TQString m_mainStatusBarMessage;
TQString m_windowStatusBarMessage;
private:
unsigned m_children;
TQString m_serverHost;

@ -43,10 +43,15 @@ void InstrumentView::init() {
TQTimer::singleShot(0, this, SLOT(close()));
}
else {
m_instrumentPart = (InstrumentPart *)factory->create(TQT_TQOBJECT(this), "part", "KParts::ReadOnlyPart");
m_instrumentPart = (InstrumentPart *)factory->create(TQT_TQOBJECT(this), "part", "KParts::RemoteInstrumentPart");
connect(m_instrumentPart, SIGNAL(statusMessageSet(const TQString&)), this, SLOT(setStatusMessage(const TQString&)));
}
}
void InstrumentView::setStatusMessage(const TQString& message) {
emit(statusMessageSet(message));
}
bool InstrumentView::queryExit() {
if (!m_instrumentPart) { // apparently std::exit() still calls this function, and abort() causes a crash..
return true;

@ -29,6 +29,12 @@ class InstrumentView : public KMdiChildView
virtual void saveProperties(KConfig *);
virtual void readProperties(KConfig *);
virtual bool queryExit();
private slots:
void setStatusMessage(const TQString& message);
signals:
void statusMessageSet(const TQString&);
private:
void init();

@ -4,6 +4,6 @@ METASOURCES = AUTO
# Part
kde_module_LTLIBRARIES = libremotelab_fpgaviewer.la
libremotelab_fpgaviewer_la_LIBADD = ../../widgets/libtracewidget.la ../../widgets/libfloatspinbox.la $(LIB_KFILE) $(LIB_KPARTS) $(LIB_TDEUI) $(LIB_QT) -ltdekrbsocket
libremotelab_fpgaviewer_la_LIBADD = ../../widgets/libtracewidget.la ../../widgets/libfloatspinbox.la $(LIB_KFILE) $(LIB_KPARTS) $(LIB_TDEUI) $(LIB_QT) -ltdekrbsocket -ltqtrla
libremotelab_fpgaviewer_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) $(LIB_TDECORE) $(LIB_TDEUI) -lkio -ltdefx
libremotelab_fpgaviewer_la_SOURCES = part.cpp layout.ui

@ -54,7 +54,7 @@ K_EXPORT_COMPONENT_FACTORY(libremotelab_fpgaviewer, RemoteLab::Factory)
FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList&)
: ReadOnlyPart( parent, name ), m_socket(0), m_base(0), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL)
: RemoteInstrumentPart( parent, name ), m_socket(0), m_base(0), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL)
{
// Initialize mutex
m_connectionMutex = new TQMutex(false);
@ -200,6 +200,7 @@ printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r", response.ascii()); ffl
connToServerConnecting = false;
disconnectFromServer();
KMessageBox::error(0, i18n("<qt>Unable to establish connection with backend server<p>Please verify that you are currently connected to a workspace</qt>"), i18n("Connection Failed"));
close();
return;
}
else if (response == "ERRNOTAVL") {
@ -207,6 +208,7 @@ printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r", response.ascii()); ffl
connToServerConnecting = false;
disconnectFromServer();
KMessageBox::error(0, i18n("<qt>The backend server is not available at this time<p>Please try a different workspace, or try again later</qt>"), i18n("Connection Failed"));
close();
return;
}
else if (response == "ERRNOSERV") {
@ -214,6 +216,7 @@ printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r", response.ascii()); ffl
connToServerConnecting = false;
disconnectFromServer();
KMessageBox::error(0, i18n("<qt>The active laboratory workspace does not support the requested service</qt>"), i18n("Service Unavailable"));
close();
return;
}
else {
@ -221,6 +224,7 @@ printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r", response.ascii()); ffl
connToServerConnecting = false;
disconnectFromServer();
KMessageBox::error(0, i18n("<qt>Unable to establish connection with remote server</qt>"), i18n("Connection Failed"));
close();
return;
}
break;
@ -236,6 +240,7 @@ int FPGAViewPart::connectToServer(TQString server) {
}
if (!m_socket) {
m_socket = new TDEKerberosClientSocket(this);
connect(m_socket, TQT_SIGNAL(statusMessageUpdated(const TQString&)), this, TQT_SLOT(setStatusMessage(const TQString&) ));
}
m_socket->setServiceName("remotefpga");
m_socket->setServerFQDN(server);

@ -30,6 +30,8 @@
#include <kparts/part.h>
#include <kurl.h>
#include <tqtrla.h>
class KAboutData;
using KParts::StatusBarExtension;
class TraceWidget;
@ -40,7 +42,7 @@ class FPGAViewBase;
namespace RemoteLab
{
class FPGAViewPart : public KParts::ReadOnlyPart
class FPGAViewPart : public KParts::RemoteInstrumentPart
{
Q_OBJECT

@ -8,4 +8,4 @@ include_HEADERS = tqtrla.h
libtqtrla_la_SOURCES = tqtrla.cpp
libtqtrla_la_LIBADD = -lkio $(LIB_TDEUI)
libtqtrla_la_LDFLAGS = -avoid-version -module -no-undefined $(all_libraries)
libtqtrla_la_LDFLAGS = -avoid-version -module -no-undefined $(all_libraries) $(LIB_KPARTS)

@ -20,6 +20,54 @@
#include "tqtrla.h"
#include <tqwidget.h>
namespace KParts
{
class RemoteInstrumentPartPrivate
{
public:
RemoteInstrumentPartPrivate() {
//
}
~RemoteInstrumentPartPrivate() {
//
}
};
RemoteInstrumentPart::RemoteInstrumentPart(TQObject *parent, const char *name)
: Part( parent, name )
{
d = new RemoteInstrumentPartPrivate;
}
RemoteInstrumentPart::~RemoteInstrumentPart() {
RemoteInstrumentPart::closeURL();
delete d;
}
bool RemoteInstrumentPart::openURL(const KURL &url) {
m_url = url;
return false;
}
bool RemoteInstrumentPart::closeURL() {
return false;
}
void RemoteInstrumentPart::close() {
TQWidget* parentWidget = dynamic_cast<TQWidget*>(parent());
if (parentWidget) {
parentWidget->close();
}
}
void RemoteInstrumentPart::setStatusMessage(const TQString& message) {
emit(statusMessageSet(message));
}
}
bool operator==( const ServiceType &s1, const ServiceType &s2 ) {
bool identical = true;

@ -23,6 +23,46 @@
#include <tqobject.h>
#include <kparts/part.h>
// =============================================================================
namespace KParts
{
class RemoteInstrumentPartPrivate;
class KPARTS_EXPORT RemoteInstrumentPart : public Part
{
Q_OBJECT
public:
RemoteInstrumentPart(TQObject *parent = 0, const char *name = 0);
virtual ~RemoteInstrumentPart();
public slots:
virtual bool openURL( const KURL &url );
public:
KURL url() const { return m_url; }
virtual bool closeURL();
protected slots:
void close();
void setStatusMessage(const TQString& message);
signals:
void statusMessageSet(const TQString&);
protected:
KURL m_url;
private:
RemoteInstrumentPartPrivate *d;
};
}
// =============================================================================
class ServiceType
{
public:
@ -42,6 +82,8 @@ typedef TQValueList<ServiceType> ServiceList;
Q_EXPORT bool operator==(const ServiceType &s1, const ServiceType &s2);
// =============================================================================
class StationType
{
public:
@ -59,4 +101,6 @@ Q_EXPORT TQDataStream &operator>>(TQDataStream &, StationType &);
typedef TQValueList<StationType> StationList;
// =============================================================================
#endif // TQTRLA_H
Loading…
Cancel
Save