summaryrefslogtreecommitdiffstats
path: root/clients/tde/src/app/views/instrumentview.cpp
blob: ab6c141ba972d4cde44eabad6502aa3c7803a01f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//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 )
{
	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 )
{
	init();
}

InstrumentView::~InstrumentView() {
	//
}

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::ReadOnlyPart");
	}
}

bool InstrumentView::queryExit() {
	if( !m_instrumentPart )	//apparently std::exit() still calls this function, and abort() causes a crash..
		return true;

	m_instrumentPart->closeURL();

	return true;
}

void InstrumentView::closeConnections() {
	queryExit();
}

void InstrumentView::connectServer(TQString server) {
	if (m_instrumentPart) {
		m_instrumentPart->openURL(KURL(server));
	}
}

/**********************************************
  SESSION MANAGEMENT
 **********************************************/

void InstrumentView::saveProperties( KConfig *config ) {
}

void InstrumentView::readProperties( KConfig *config ) {
}

} //namespace RemoteLab