summaryrefslogtreecommitdiffstats
path: root/src/interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/interface.cpp')
-rw-r--r--src/interface.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/interface.cpp b/src/interface.cpp
new file mode 100644
index 0000000..1ac98a8
--- /dev/null
+++ b/src/interface.cpp
@@ -0,0 +1,57 @@
+//
+// C++ Implementation: interface
+//
+// Description:
+//
+//
+// Author: Hugo Parente Lima <[email protected]>, (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);
+}
+