summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp127
1 files changed, 84 insertions, 43 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 6ac7422..4af9fe1 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -53,9 +53,6 @@ const QString MainWindow::sStrSourceDestSame = tr("Selected projection target is
MainWindow::MainWindow(QString ipListUrl, QWidget* parent) :
QMainWindow(parent), ui(new Ui::MainWindow), _tbIconSize(24), _tbArea(Qt::LeftToolBarArea)
{
-
- _tutorFrame = NULL;
- _selectedFrame = NULL;
_mode = Mode::Multicast;
_streamingSource = 0;
@@ -291,6 +288,12 @@ bool MainWindow::isManagerMachine(Client* client)
return false;
}
+/***************************************************************************//**
+ * Returns connected client which belongs to given id.
+ * Iterating over ConnectionFrames and comparing id to given id.
+ * @param id
+ * @return Client with given id, if not NULL.
+ */
Client* MainWindow::getClientFromId(int id)
{
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
@@ -304,6 +307,38 @@ Client* MainWindow::getClientFromId(int id)
return NULL;
}
+/***************************************************************************//**
+ * Return the Frame, which is currently beeing Tutor.
+ * Iterating over all ConnectionFrames, and looking for flag _isTutor.
+ * @return Frame with flag _isTutor = true,
+ * else NULL if no Tutor is available.
+ */
+ConnectionFrame* MainWindow::getTutorFrame()
+{
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
+ {
+ if (((*it) != NULL) && ((*it)->isTutor()))
+ return (*it);
+ }
+ return NULL;
+}
+
+/***************************************************************************//**
+ * Return the Frame, which is currently selected by user.
+ * Iterating over all ConnectionFrame and looking for flag _isSelected.
+ * @return Frame with flag _isSelected = true,
+ * else NULL if no frame is selected.
+ */
+ConnectionFrame* MainWindow::getSelectedFrame()
+{
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
+ {
+ if (((*it) != NULL) && ((*it)->isSelected()))
+ return (*it);
+ }
+ return NULL;
+}
+
/*
* Overridden methods
*/
@@ -370,9 +405,9 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* e)
const QSize frame(ui->frmRoom->size());
if (frame.width() > pos.x() && frame.height() > pos.y())
{
- if (_selectedFrame != NULL) {
- _selectedFrame->setSelection(false);
- _selectedFrame = NULL;
+ if (getSelectedFrame() != NULL)
+ {
+ getSelectedFrame()->setSelection(false);
}
}
}
@@ -451,15 +486,18 @@ void MainWindow::onPlaceFrame(ConnectionFrame* frame)
void MainWindow::onFrameClicked(ConnectionFrame* frame)
{
// If same frame is clicked again,, do nothing
- if (_selectedFrame == frame)
+ if (getSelectedFrame() == frame)
return;
// If another frame has been selected, unselect it
// Set the ui selected and set a new reference
- if (_selectedFrame != NULL)
- _selectedFrame->setSelection(false);
- _selectedFrame = frame;
- _selectedFrame->setSelection(true);
+ if (getSelectedFrame() != NULL)
+ {
+ getSelectedFrame()->setSelection(false);
+ }
+ frame->setSelection(true);
+ qDebug() << "ID of frame: " << frame->computerId();
+ qDebug() << "ID of selectedFrame: " << getSelectedFrame()->computerId();
}
/***************************************************************************//**
@@ -565,12 +603,12 @@ void MainWindow::onButtonTutorToAll()
{
ui->action_Lock->setChecked(false);
- if (_tutorFrame == NULL)
+ if (getTutorFrame() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorNdef);
- else if (_tutorFrame->client() == NULL)
+ else if (getTutorFrame()->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else
- changeProjection(_tutorFrame->client(), Mode::Broadcast);
+ changeProjection(getTutorFrame()->client(), Mode::Broadcast);
}
/***************************************************************************//**
@@ -582,12 +620,12 @@ void MainWindow::onButtonStudentToAll()
{
ui->action_Lock->setChecked(false);
- if (_selectedFrame == NULL)
+ if (getSelectedFrame() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrSourceNdef);
- if (_selectedFrame->client() == NULL)
+ if (getSelectedFrame()->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrSourceOffline);
else
- changeProjection(_selectedFrame->client(), Mode::Broadcast);
+ changeProjection(getSelectedFrame()->client(), Mode::Broadcast);
}
/***************************************************************************//**
@@ -598,18 +636,18 @@ void MainWindow::onButtonTutorToStudent()
{
ui->action_Lock->setChecked(false);
- if (_selectedFrame == NULL)
+ if (getSelectedFrame() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrDestNdef);
- else if (_tutorFrame == NULL)
+ else if (getTutorFrame() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorNdef);
- else if (_selectedFrame == _tutorFrame)
+ else if (getSelectedFrame() == getTutorFrame())
QMessageBox::critical(this, tr("Projection"), sStrSourceDestSame);
- else if (_selectedFrame->client() == NULL)
+ else if (getSelectedFrame()->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrDestOffline);
- else if (_tutorFrame->client() == NULL)
+ else if (getTutorFrame()->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else
- changeProjection(_tutorFrame->client(), Mode::Multicast, _selectedFrame->client());
+ changeProjection(getTutorFrame()->client(), Mode::Multicast, getSelectedFrame()->client());
}
/***************************************************************************//**
@@ -620,18 +658,18 @@ void MainWindow::onButtonStudentToTutor()
{
ui->action_Lock->setChecked(false);
- if (_selectedFrame == NULL)
+ if (getSelectedFrame() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrSourceNdef);
- else if (_tutorFrame == NULL)
+ else if (getTutorFrame() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorNdef);
- else if (_tutorFrame == _selectedFrame)
+ else if (getTutorFrame() == getSelectedFrame())
QMessageBox::critical(this, tr("Projection"), sStrSourceDestSame);
- else if (_selectedFrame->client() == NULL)
+ else if (getSelectedFrame()->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrSourceOffline);
- else if (_tutorFrame->client() == NULL)
+ else if (getTutorFrame()->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else
- changeProjection(_selectedFrame->client(), Mode::Multicast, _tutorFrame->client());
+ changeProjection(getSelectedFrame()->client(), Mode::Multicast, getTutorFrame()->client());
}
@@ -642,18 +680,18 @@ void MainWindow::onButtonStudentToTutorExclusive()
{
ui->action_Lock->setChecked(false);
- if (_selectedFrame == NULL)
+ if (getSelectedFrame() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrSourceNdef);
- else if (_tutorFrame == NULL)
+ else if (getTutorFrame() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorNdef);
- else if (_tutorFrame == _selectedFrame)
+ else if (getTutorFrame() == getSelectedFrame())
QMessageBox::critical(this, tr("Projection"), sStrSourceDestSame);
- else if (_selectedFrame->client() == NULL)
+ else if (getSelectedFrame()->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrSourceOffline);
- else if (_tutorFrame->client() == NULL)
+ else if (getTutorFrame()->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else
- changeProjection(_selectedFrame->client(), Mode::LockedMulticast, _tutorFrame->client());
+ changeProjection(getSelectedFrame()->client(), Mode::LockedMulticast, getTutorFrame()->client());
}
@@ -706,30 +744,33 @@ void MainWindow::onButtonSetAsTutor()
ui->action_Lock->setChecked(false);
// If no frame is selected, warning.
- if (_selectedFrame == NULL)
+ if (getSelectedFrame() == NULL)
{
QMessageBox::critical(this, tr("Selection"), tr("No client is selected."));
return;
}
// If frame of inactive client has been selected unselect it
- if (_selectedFrame->client() == NULL)
+ if (getSelectedFrame()->client() == NULL)
{
QMessageBox::critical(this, tr("Selection"), tr("The selected client is not connected."));
return;
}
else // If selected client is locked, first unlock
- _selectedFrame->client()->lockScreen(false);
+ {
+ getSelectedFrame()->client()->lockScreen(false);
+ }
// If same frame is already tutor, do nothing
- if (_selectedFrame == _tutorFrame)
+ if (getSelectedFrame() == getTutorFrame())
return;
// Else unset the old and set the new tutor
- if (_tutorFrame != NULL)
- _tutorFrame->setTutor(false);
- _tutorFrame = _selectedFrame;
- _tutorFrame->setTutor(true);
+ if (getTutorFrame() != NULL)
+ {
+ getTutorFrame()->setTutor(false);
+ }
+ getSelectedFrame()->setTutor(true);
}
/***************************************************************************//**