From 87dc3eae8eeb774aecf005465ddd9eecdd829b8a Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 28 Jul 2011 16:00:49 +0200 Subject: better version of the logwriter.c and started to devide gui and logic --- workspace/LogReceiver/ndgui.cpp | 73 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 workspace/LogReceiver/ndgui.cpp (limited to 'workspace/LogReceiver/ndgui.cpp') diff --git a/workspace/LogReceiver/ndgui.cpp b/workspace/LogReceiver/ndgui.cpp new file mode 100644 index 0000000..0d4c505 --- /dev/null +++ b/workspace/LogReceiver/ndgui.cpp @@ -0,0 +1,73 @@ +#include "ndgui.h" + +ndgui::ndgui(QWidget *parent) + : QWidget(parent) +{ + ui.setupUi(this); + + buildGui(); + addInterfacesToGroupBox(list); + + + setWindowTitle(tr("NetD")); +} + +ndgui::~ndgui() +{ + +} + +void ndgui::buildGui() { + + ndStatusLabel = new QLabel(tr("test")); + ndStatusLabel->setSizePolicy(QSizePolicy::Expanding, + QSizePolicy::Expanding); + ndStatusLabel->setAlignment(Qt::AlignCenter); + ndStatusLabel->setMinimumSize(100, 20); + + // create interface group box + createInterfaceGroupBox(); + + mainLayout = new QVBoxLayout; + mainLayout->addWidget(ndStatusLabel); + mainLayout->addWidget(interfaceGroupBox); + + setLayout(mainLayout); +} + +void ndgui::createInterfaceGroupBox(){ + interfaceGroupBox = new QGroupBox(tr("Interfaces")); + + interfaceGroupBoxLayout = new QVBoxLayout; + /* add interfaces via addInterfacesToGroupBox()*/ + + interfaceGroupBox->setLayout(interfaceGroupBoxLayout); +} + +void ndgui::addInterfacesToGroupBox(QList &interfaces) { + foreach(QNetworkInterface nI, interfaces){ + int index = indexToIfaceNameMap.value(nI.humanReadableName()); + QHBoxLayout *hBoxLayout = new QHBoxLayout; + QLabel *label = new QLabel(nI.humanReadableName()); + QProgressBar *pBar = new QProgressBar(this); + pBar->setRange(1,100); + pBar->setMaximumSize(200,20); + + progressBars.insert(index,pBar); + + hBoxLayout->addWidget(label, Qt::AlignLeft); + hBoxLayout->addWidget(pBar, Qt::AlignRight); + + interfaceGroupBoxLayout->addLayout(hBoxLayout,2); + } +} + +void ndgui::handleProgress(int iFaceIndex, int newValue) { + QProgressBar * pBar = progressBars.value(iFaceIndex); + if(newValue >= pBar->value()) { + pBar->setValue(newValue); + } + else { + qDebug() << "Error: new value is smaller than the old value!"; + } +} -- cgit v1.2.3-55-g7522