00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef WSCOUT_GUI_PHY_HEADER_HXX_
00024 # define WSCOUT_GUI_PHY_HEADER_HXX_
00025
00026 # include <boost/lexical_cast.hpp>
00027 # include <boost/format.hpp>
00028
00029 # include "wscout_gui_prism_header.hh"
00030
00031 namespace wscout
00032 {
00033
00034 namespace gui
00035 {
00036
00037 template <class E, int P>
00038 PHYHeader<E, P>::PHYHeader(const QString& proto,
00039 QWidget* parent):
00040 HeaderBase<E, P> (parent),
00041 proto_str_ (proto)
00042 {
00043 this->setUpdatesEnabled(false);
00044
00045 this->setForegroundRole(QPalette::WindowText);
00046 this->setBackgroundRole(QPalette::Window);
00047 this->setAutoFillBackground(true);
00048
00049 {
00050 QFont bold;
00051 bold.setBold(true);
00052
00053 proto_.setFont(bold);
00054 }
00055 time_.setFont(QFont ("Fixed"));
00056 {
00057 QBoxLayout* const l = this->layout();
00058
00059 l->addWidget(&proto_);
00060 l->addSpacing(default_spacing);
00061
00062 l->addWidget(&time_);
00063 l->addSpacing(default_spacing);
00064
00065 l->addWidget(&rate_);
00066 l->addSpacing(default_spacing);
00067
00068 l->addWidget(&channel_);
00069 l->addStretch();
00070
00071 l->addWidget(&signal_);
00072 }
00073 this->setUpdatesEnabled(true);
00074 }
00075
00076 template <class E, int P>
00077 void
00078 PHYHeader<E, P>::setTruncated(bool trunc)
00079 {
00080 static const QColor trunc_fore (Qt::white),
00081 trunc_back (Qt::red),
00082 full_fore ("darkslategrey"),
00083 full_back (Qt::white);
00084 QPalette p;
00085
00086 if (trunc)
00087 {
00088 p.setColor(QPalette::WindowText, trunc_fore);
00089 p.setColor(QPalette::Window, trunc_back);
00090 proto_.setText(proto_str_ + " (truncated)");
00091 }
00092 else
00093 {
00094 p.setColor(QPalette::WindowText, full_fore);
00095 p.setColor(QPalette::Window, full_back);
00096 proto_.setText(proto_str_);
00097 }
00098
00099 this->setPalette(p);
00100 }
00101
00102 template <class E, int P>
00103 void
00104 PHYHeader<E, P>::setTime(uint64_t hosttime, uint64_t mactime)
00105 {
00106 const std::string s =
00107 boost::lexical_cast<std::string> (boost::format ("%010u:%010u")
00108 % hosttime
00109 % mactime);
00110
00111 time_.setText(s.c_str());
00112 }
00113
00114 template <class E, int P>
00115 void
00116 PHYHeader<E, P>::setRate(float rate)
00117 {
00118 rate_.setText(this->tr("%1 Mb/s").arg(rate));
00119 }
00120
00121 template <class E, int P>
00122 void
00123 PHYHeader<E, P>::setChannel(unsigned channel)
00124 {
00125 channel_.setText(this->tr("channel %1").arg(channel));
00126 }
00127 template <class E, int P>
00128 void
00129 PHYHeader<E, P>::setSignal(int rssi, int signal, int noise)
00130 {
00131 signal_.setText(this->tr("rssi/signal/noise: %1 / %2 / %3")
00132 .arg(rssi >= 0 ? QString::number(rssi) : "NA")
00133 .arg(signal >= 0 ? QString::number(signal) : "NA")
00134 .arg(noise >= 0 ? QString::number(noise) : "NA"));
00135 }
00136
00137 }
00138
00139 }
00140
00141 #endif // ! WSCOUT_GUI_PRISM_HEADER_HXX_