summaryrefslogtreecommitdiffstats
path: root/src/src/interface.cpp
blob: 1ac98a8eb41500916f5a52f9c0af02216c289345 (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
//
// C++ Implementation: interface
//
// Description:
//
//
// Author: Hugo Parente Lima <hugo.pl@gmail.com>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "interface.h"
#include <tdeapplication.h>
#include <kapp.h>
#include <tdeconfig.h>

Interface::Interface(KNetStats* parent, const TQString& name) : mName(name), mView(0), mParent(parent) {
	update();
}

void Interface::update() {
	bool defaultVisibility = !(mName == "lo" || mName == "sit0");

	TDEConfig* cfg = kapp->config();
	TDEConfigGroupSaver groupSaver(cfg, mName);
	bool visible = cfg->readBoolEntry("Monitoring", defaultVisibility);
	if (!visible)
		setVisible(false);
	else if (visible && !mView)
		setVisible(true);
	else if (visible && mView)
		mView->updateViewOptions();
}

void Interface::setVisible(bool visible) {
	if (!visible) {
		delete mView;
		mView = 0;
	} else if (visible && !mView)
		mView = new KNetStatsView(mParent, mName);
}

KNetStatsView::Options Interface::options() {
	if (mView)
		return mView->options();
	else {
		KNetStatsView::Options opt;
		KNetStatsView::readOptions(mName, &opt, false);
		return opt;
	}
}

void Interface::say(const TQString& message) {
	if (mView)
		mView->say(message);
}