summaryrefslogtreecommitdiffstats
path: root/kradio3/src/frequencyseekhelper.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-22 18:23:26 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-22 18:23:26 +0000
commitae364d9bed0589bf1a22cd5f530c563462379e3e (patch)
treee32727e2664e7ce68d0d30270afa040320ae35a1 /kradio3/src/frequencyseekhelper.cpp
downloadtderadio-ae364d9bed0589bf1a22cd5f530c563462379e3e.tar.gz
tderadio-ae364d9bed0589bf1a22cd5f530c563462379e3e.zip
Added old KDE3 version of kradio
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kradio@1094417 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kradio3/src/frequencyseekhelper.cpp')
-rw-r--r--kradio3/src/frequencyseekhelper.cpp142
1 files changed, 142 insertions, 0 deletions
diff --git a/kradio3/src/frequencyseekhelper.cpp b/kradio3/src/frequencyseekhelper.cpp
new file mode 100644
index 0000000..670c300
--- /dev/null
+++ b/kradio3/src/frequencyseekhelper.cpp
@@ -0,0 +1,142 @@
+/***************************************************************************
+ frequencyseekhelper.cpp - description
+ -------------------
+ begin : Fre Mai 9 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "include/frequencyseekhelper.h"
+#include <qtimer.h>
+
+FrequencySeekHelper::FrequencySeekHelper(ISeekRadio &parent)
+ : SeekHelper(parent)
+{
+ m_timer = new QTimer(this);
+ QObject::connect (m_timer, SIGNAL(timeout()), this, SLOT(step()));
+}
+
+
+FrequencySeekHelper::~FrequencySeekHelper()
+{
+ delete m_timer;
+}
+
+
+bool FrequencySeekHelper::connectI (Interface *i)
+{
+ bool a = SeekHelper::connectI(i);
+ bool b = IFrequencyRadioClient::connectI(i);
+ return a || b;
+}
+
+
+bool FrequencySeekHelper::disconnectI(Interface *i)
+{
+ bool a = SeekHelper::disconnectI(i);
+ bool b = IFrequencyRadioClient::disconnectI(i);
+ return a || b;
+}
+
+
+void FrequencySeekHelper::start(const SoundStreamID &id, direction_t dir)
+{
+ SeekHelper::start(id, dir);
+ m_bestFrequency = 0;
+}
+
+
+void FrequencySeekHelper::abort()
+{
+ m_timer->stop();
+ m_bestFrequency = 0;
+}
+
+
+bool FrequencySeekHelper::nextSeekStep()
+{
+ float f = queryFrequency();
+ f += (m_direction == up ? 1 : -1) * queryScanStep();
+
+ bool bounds = false;
+ if (f > queryMaxFrequency()) {
+ f = queryMaxFrequency();
+ bounds = true;
+ }
+ if (f < queryMinFrequency()) {
+ f = queryMinFrequency();
+ bounds = true;
+ }
+
+ if (sendFrequency(f) > 0) {
+ if (!bounds) {
+ m_timer->start (50, true);
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+}
+
+
+bool FrequencySeekHelper::bestFound() const
+{
+ return m_bestFrequency > 0;
+}
+
+
+void FrequencySeekHelper::rememberBest()
+{
+ m_bestFrequency = m_currentFrequency;
+}
+
+
+void FrequencySeekHelper::getData()
+{
+ m_oldSignal = m_currentSignal;
+ m_oldFrequency = m_currentFrequency;
+
+ querySignalQuality(m_SoundStreamID, m_currentSignal);
+ queryHasGoodQuality(m_SoundStreamID, m_goodSignal);
+ m_currentFrequency = queryFrequency();
+}
+
+
+bool FrequencySeekHelper::isBetter() const
+{
+ return m_currentSignal > m_oldSignal;
+}
+
+
+bool FrequencySeekHelper::isWorse() const
+{
+ return m_currentSignal < m_oldSignal;
+}
+
+
+bool FrequencySeekHelper::isGood() const
+{
+ return m_goodSignal;
+}
+
+
+void FrequencySeekHelper::applyBest()
+{
+ sendFrequency( (m_bestFrequency + m_currentFrequency) / 2);
+}
+
+
+
+
+#include "frequencyseekhelper.moc"