You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
2.9 KiB
113 lines
2.9 KiB
//Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>, (C) 2012
|
|
//Copyright: See COPYING file that comes with this distribution
|
|
|
|
#include "instrumentview.h"
|
|
|
|
#include <tqtimer.h>
|
|
|
|
#include <klibloader.h>
|
|
#include <klocale.h>
|
|
#include <kmessagebox.h>
|
|
|
|
namespace RemoteLab {
|
|
|
|
InstrumentView::InstrumentView(const TQString &library, TQWidget *parentWidget, const char *name, WFlags f)
|
|
: KMdiChildView(parentWidget, name, f)
|
|
, m_libraryName(library)
|
|
, m_instrumentPart( 0 )
|
|
, m_canary( NULL )
|
|
{
|
|
init();
|
|
}
|
|
|
|
InstrumentView::InstrumentView(const TQString &library, const TQString &caption, TQWidget *parentWidget, const char *name, WFlags f)
|
|
: KMdiChildView(caption, parentWidget, name, f)
|
|
, m_libraryName(library)
|
|
, m_instrumentPart( 0 )
|
|
, m_canary( NULL )
|
|
{
|
|
init();
|
|
}
|
|
|
|
InstrumentView::~InstrumentView() {
|
|
if (m_canary) {
|
|
*m_canary = true;
|
|
}
|
|
}
|
|
|
|
void InstrumentView::init() {
|
|
KLibFactory *factory = KLibLoader::self()->factory(m_libraryName.ascii());
|
|
|
|
if (!factory) {
|
|
KMessageBox::error( this, i18n("TDE could not find the %1 Part, or the Remote Laboratory Communications Analyzer Part could not be started. Did you make install?").arg(m_libraryName) );
|
|
TQTimer::singleShot(0, this, SLOT(close()));
|
|
}
|
|
else {
|
|
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::resizeEvent(TQResizeEvent *) {
|
|
TQWidget *childPartWidget = m_instrumentPart->widget();
|
|
if (childPartWidget) {
|
|
setFixedSize(childPartWidget->sizeHint());
|
|
}
|
|
}
|
|
|
|
TQPtrList<KAction> InstrumentView::menuActionList() {
|
|
return m_instrumentPart->menuActionList();
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
printf("[RAJA DEBUG 700.0] In InstrumentView::queryExit\n\r"); fflush(stdout);
|
|
m_instrumentPart->closeURL();
|
|
printf("[RAJA DEBUG 700.1] In InstrumentView::queryExit\n\r"); fflush(stdout);
|
|
|
|
return true;
|
|
}
|
|
|
|
void InstrumentView::closeConnections() {
|
|
queryExit();
|
|
}
|
|
|
|
void InstrumentView::connectServer(TQString server) {
|
|
if (!m_canary) {
|
|
m_canary = new bool;
|
|
*m_canary = false;
|
|
}
|
|
bool* canary = m_canary;
|
|
|
|
if (m_instrumentPart) {
|
|
if (m_instrumentPart->openURL(KURL(server))) { // This can call processEvents, therefore this object may not exist when it returns!
|
|
if (*canary == true) {
|
|
delete canary;
|
|
return;
|
|
}
|
|
TQTimer::singleShot(0, this, SLOT(close()));
|
|
}
|
|
}
|
|
|
|
delete m_canary;
|
|
m_canary = NULL;
|
|
}
|
|
|
|
/**********************************************
|
|
SESSION MANAGEMENT
|
|
**********************************************/
|
|
|
|
void InstrumentView::saveProperties( KConfig *config ) {
|
|
}
|
|
|
|
void InstrumentView::readProperties( KConfig *config ) {
|
|
}
|
|
|
|
} //namespace RemoteLab
|