aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kampas <martin.kampas@jolla.com>2016-11-16 09:25:52 +0100
committerJuergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com>2016-11-23 05:24:59 +0000
commit9fc974df47628ad2adf36047648f1a3e4043463c (patch)
tree47626d7640224246d8ef6a2b58c0722259dfb4a6
parent1d506c6cee935a1465814cb5719e366ea585c465 (diff)
Bench: Deduplicate setting host widget title
Change-Id: I058cdf2376faf6a049cba2c1503697814fd0a119 Reviewed-by: Juergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com>
-rw-r--r--src/bench/hostwidget.cpp41
-rw-r--r--src/bench/hostwidget.h4
2 files changed, 12 insertions, 33 deletions
diff --git a/src/bench/hostwidget.cpp b/src/bench/hostwidget.cpp
index bb52cb7..4341eb9 100644
--- a/src/bench/hostwidget.cpp
+++ b/src/bench/hostwidget.cpp
@@ -122,17 +122,18 @@ void HostWidget::setHost(Host *host)
{
m_host = host;
- updateName(m_host->name());
- updateIp(m_host->address());
+ updateTitle();
updateFile(m_host->currentFile());
updateOnlineState(m_host->online());
m_followTreeSelectionAction->setChecked(m_host->followTreeSelection());
- connect(host, SIGNAL(addressChanged(QString)), this, SLOT(updateIp(QString)));
- connect(host, SIGNAL(portChanged(int)), this, SLOT(updatePort(int)));
+ connect(host, SIGNAL(addressChanged(QString)), this, SLOT(updateTitle()));
+ connect(host, SIGNAL(addressChanged(QString)), this, SLOT(scheduleConnectToServer()));
+ connect(host, SIGNAL(portChanged(int)), this, SLOT(updateTitle()));
+ connect(host, SIGNAL(portChanged(int)), this, SLOT(scheduleConnectToServer()));
connect(host, SIGNAL(onlineChanged(bool)), this, SLOT(updateOnlineState(bool)));
connect(host, SIGNAL(currentFileChanged(LiveDocument)), this, SLOT(updateFile(LiveDocument)));
- connect(host, SIGNAL(nameChanged(QString)), this, SLOT(updateName(QString)));
+ connect(host, SIGNAL(nameChanged(QString)), this, SLOT(updateTitle()));
connect(host, SIGNAL(xOffsetChanged(int)), this, SLOT(sendXOffset(int)));
connect(host, SIGNAL(yOffsetChanged(int)), this, SLOT(sendYOffset(int)));
connect(host, SIGNAL(rotationChanged(int)), this, SLOT(sendRotation(int)));
@@ -166,32 +167,12 @@ bool HostWidget::followTreeSelection() const
return m_followTreeSelectionAction->isChecked();
}
-void HostWidget::updateName(const QString &name)
+void HostWidget::updateTitle()
{
- Q_UNUSED(name)
- if(m_host) {
- m_groupBox->setTitle(QString("%1 (%2:%3)").arg(m_host->name(), m_host->address(), QString::number(m_host->port())));
- }
-}
-
-void HostWidget::updateIp(const QString &ip)
-{
- Q_UNUSED(ip)
- if(m_host) {
- m_groupBox->setTitle(QString("%1 (%2:%3)").arg(m_host->name(), m_host->address(), QString::number(m_host->port())));
- }
-
- scheduleConnectToServer();
-}
-
-void HostWidget::updatePort(int port)
-{
- Q_UNUSED(port)
- if(m_host) {
- m_groupBox->setTitle(QString("%1 (%2:%3)").arg(m_host->name(), m_host->address(), QString::number(m_host->port())));
- }
-
- scheduleConnectToServer();
+ m_groupBox->setTitle(QString("%1 (%2:%3)")
+ .arg(m_host->name())
+ .arg(m_host->address())
+ .arg(m_host->port()));
}
void HostWidget::updateFile(const LiveDocument &file)
diff --git a/src/bench/hostwidget.h b/src/bench/hostwidget.h
index 4503e0e..1867932 100644
--- a/src/bench/hostwidget.h
+++ b/src/bench/hostwidget.h
@@ -67,9 +67,7 @@ protected:
void timerEvent(QTimerEvent *event);
private slots:
- void updateName(const QString& name);
- void updateIp(const QString& ip);
- void updatePort(int port);
+ void updateTitle();
void updateFile(const LiveDocument& file);
void setUpdateFile(const LiveDocument& file);
void refreshDocumentLabel();