From f7da785b78a2412d1d5bdd43836ed8c9656cae81 Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Mon, 21 Jul 2014 18:14:09 +0200 Subject: Tried to implement the fixed room settings, but is not working correctly right now. Problem is, the frames do not appear at setted position because of placeFrameInFreeCell() - call. Also, after updateSessionName(), all frames and clients are currently deleted if SessionName want to be setted manually. --- src/server/mainwindow/mainwindow.cpp | 57 ++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index a52690f..8762dbf 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -103,6 +103,39 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : connect(ui->action_Lock, SIGNAL(toggled(bool)), this, SLOT(onButtonLock(bool))); connect(ui->action_Help, SIGNAL(triggered()), this, SLOT(onButtonHelp())); + USER_SETTINGS(test); + int i = 1; + QMap ipPosList; + while (true) + { + test.beginGroup(QString("room%1").arg(i)); + if (!test.contains("mgrIP")) + break; + QString mgrIP = test.value("mgrIP").toString(); + foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) + { + qDebug() << "in Adress loop" << address.toString(); + if (address != QHostAddress(QHostAddress::LocalHost) + && mgrIP == address.toString()) + { + qDebug("matched"); + int size = test.beginReadArray("client"); + for (int i = 0; i < size; ++i) { + test.setArrayIndex(i); + ipPosList[test.value("ip").toString()] = test.value("pos").toPoint(); + ConnectionFrame *cf = createFrame(test.value("ip").toString(), test.value("pos").toPoint()); + cf->move(cf->getCurrentPosition()); + onPlaceFrame(cf); + qDebug() << "IP: " << test.value("ip").toString(); + qDebug() << "pos: " << test.value("pos").toPoint(); + } + test.endArray(); + } + } + qDebug() << "ManagerIP: " << mgrIP; + test.endGroup(); + i++; + } /* Stuff for the button lock */ //Setup a timeout @@ -135,7 +168,7 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : _discoveryListener = new DiscoveryListener(); // Finally - this->onSessionNameUpdate(); +// this->onSessionNameUpdate(); } MainWindow::~MainWindow() @@ -214,6 +247,26 @@ ConnectionFrame* MainWindow::createFrame() return cf; } +/***************************************************************************//** + * Create new Frame. + * Create new frame and add to current available frame list. + * Also connect signals frameMoved() and clicked() with slots. + * @return ConnectionFrame* + */ +ConnectionFrame* MainWindow::createFrame(QString computerId, QPoint position) +{ + // Allocate and resize + ConnectionFrame *cf = new ConnectionFrame(ui->frmRoom, _tileWidth, _tileHeight); + cf->setComputerId(computerId); + cf->setCurrentPosition(position); + _clientFrames.append(cf); + cf->show(); + connect(cf, SIGNAL(frameMoved(ConnectionFrame *)), this, SLOT(onPlaceFrame(ConnectionFrame *))); + connect(cf, SIGNAL(clicked(ConnectionFrame *)), this, SLOT(onFrameClicked(ConnectionFrame *))); + return cf; +} + + /***************************************************************************//** * Load position. * @param settings @@ -225,7 +278,7 @@ ConnectionFrame* MainWindow::createFrame() bool MainWindow::loadPosition(QSettings& settings, const QString& id, int& x, int& y) { settings.beginGroup("client_position"); - const QVariant retval(settings.value(id)); + const QVariant retval = (settings.value(id)); settings.endGroup(); if (retval.type() != QVariant::Point) return false; -- cgit v1.2.3-55-g7522