summaryrefslogtreecommitdiff
path: root/FrequencyItemDelegate.cpp
diff options
context:
space:
mode:
authorIain R. Learmonth <irl@debian.org>2015-10-18 18:51:00 +0100
committerIain R. Learmonth <irl@debian.org>2015-10-18 18:51:00 +0100
commitd63dd8d081a6fcd0715cd13f26df59fb831769d2 (patch)
treeb9c1f6245147a310aac3762630bad389bbb57335 /FrequencyItemDelegate.cpp
parentc720a3d55c5ec832c29cb7ce50b6fb4b70c55b11 (diff)
Imported Upstream version 1.5.0upstream/1.5.0
Diffstat (limited to 'FrequencyItemDelegate.cpp')
-rw-r--r--FrequencyItemDelegate.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/FrequencyItemDelegate.cpp b/FrequencyItemDelegate.cpp
new file mode 100644
index 00000000..8e9ebd5d
--- /dev/null
+++ b/FrequencyItemDelegate.cpp
@@ -0,0 +1,36 @@
+#include "FrequencyItemDelegate.hpp"
+
+#include "Radio.hpp"
+#include "FrequencyLineEdit.hpp"
+#include "Bands.hpp"
+
+QString FrequencyItemDelegate::displayText (QVariant const& value, QLocale const& locale) const
+{
+ auto frequency = value.value<Radio::Frequency> ();
+ auto band_name = bands_->data (bands_->find (frequency));
+ return Radio::pretty_frequency_MHz_string (frequency, locale) + " MHz (" + band_name.toString () + ')';
+}
+
+QWidget * FrequencyItemDelegate::createEditor (QWidget * parent
+ , QStyleOptionViewItem const& /* option */
+ , QModelIndex const& /* index */) const
+{
+ auto editor = new FrequencyLineEdit {parent};
+ editor->setFrame (false);
+ return editor;
+}
+
+
+QString FrequencyDeltaItemDelegate::displayText (QVariant const& value, QLocale const& locale) const
+{
+ return Radio::pretty_frequency_MHz_string (value.value<Radio::FrequencyDelta> (), locale) + " MHz";
+}
+
+QWidget * FrequencyDeltaItemDelegate::createEditor (QWidget * parent
+ , QStyleOptionViewItem const& /* option */
+ , QModelIndex const& /* index */) const
+{
+ auto editor = new FrequencyDeltaLineEdit {parent};
+ editor->setFrame (false);
+ return editor;
+}