From 2a04cb4147eb9c583fae8d0b3120a74eaf1af68a Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 1 Aug 2011 12:31:12 +0200 Subject: seperation of logic and gui completed. --- workspace/LogReceiver/ndgui.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'workspace/LogReceiver/ndgui.cpp') diff --git a/workspace/LogReceiver/ndgui.cpp b/workspace/LogReceiver/ndgui.cpp index 0d4c505..e838a8c 100644 --- a/workspace/LogReceiver/ndgui.cpp +++ b/workspace/LogReceiver/ndgui.cpp @@ -5,8 +5,12 @@ ndgui::ndgui(QWidget *parent) { ui.setupUi(this); - buildGui(); - addInterfacesToGroupBox(list); + connect(&logReceiver, SIGNAL(addNewInterface(QString, int)), this, SLOT(addNewInterface(QString, int))); + connect(&logReceiver, SIGNAL(changeProgressBarValue(int , int )), this, SLOT(handleProgress(int, int))); + + buildGui(); + + logReceiver.initAndRun(); setWindowTitle(tr("NetD")); @@ -19,6 +23,8 @@ ndgui::~ndgui() void ndgui::buildGui() { + + ndStatusLabel = new QLabel(tr("test")); ndStatusLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -28,6 +34,8 @@ void ndgui::buildGui() { // create interface group box createInterfaceGroupBox(); + + mainLayout = new QVBoxLayout; mainLayout->addWidget(ndStatusLabel); mainLayout->addWidget(interfaceGroupBox); @@ -44,6 +52,21 @@ void ndgui::createInterfaceGroupBox(){ interfaceGroupBox->setLayout(interfaceGroupBoxLayout); } +void ndgui::addNewInterface(QString ifName, int index) { + QHBoxLayout *hBoxLayout = new QHBoxLayout; + QLabel *label = new QLabel(ifName); + 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::addInterfacesToGroupBox(QList &interfaces) { foreach(QNetworkInterface nI, interfaces){ int index = indexToIfaceNameMap.value(nI.humanReadableName()); @@ -61,7 +84,7 @@ void ndgui::addInterfacesToGroupBox(QList &interfaces) { interfaceGroupBoxLayout->addLayout(hBoxLayout,2); } } - +*/ void ndgui::handleProgress(int iFaceIndex, int newValue) { QProgressBar * pBar = progressBars.value(iFaceIndex); if(newValue >= pBar->value()) { -- cgit v1.2.3-55-g7522