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_.setReadOnly(true);
00056 time_.setFont(QFont ("Fixed"));
00057 time_.setFixedHeight(time_.fontMetrics().height());
00058 time_.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
00059 time_.setFrame(false);
00060 {
00061 QBoxLayout* const l = this->layout();
00062
00063 l->addWidget(&proto_);
00064 l->addSpacing(default_spacing);
00065
00066 l->addWidget(&time_);
00067 l->addSpacing(default_spacing);
00068
00069 l->addWidget(&rate_);
00070 l->addSpacing(default_spacing);
00071
00072 l->addWidget(&channel_);
00073 l->addStretch();
00074
00075 l->addWidget(&signal_);
00076 }
00077 this->setUpdatesEnabled(true);
00078 }
00079
00080 template <class E, int P>
00081 void
00082 PHYHeader<E, P>::setTruncated(bool trunc)
00083 {
00084 static const QColor trunc_fore (Qt::white),
00085 trunc_back (Qt::red),
00086 full_fore ("darkslategrey"),
00087 full_back (Qt::white);
00088 QPalette p;
00089
00090 if (trunc)
00091 {
00092 p.setColor(QPalette::WindowText, trunc_fore);
00093 p.setColor(QPalette::Window, trunc_back);
00094 p.setColor(QPalette::Text, trunc_fore);
00095 p.setColor(QPalette::Base, trunc_back);
00096 proto_.setText(proto_str_ + " (truncated)");
00097 }
00098 else
00099 {
00100 p.setColor(QPalette::WindowText, full_fore);
00101 p.setColor(QPalette::Window, full_back);
00102 p.setColor(QPalette::Text, full_fore);
00103 p.setColor(QPalette::Base, full_back);
00104 proto_.setText(proto_str_);
00105 }
00106
00107 this->setPalette(p);
00108 }
00109
00110 template <class E, int P>
00111 void
00112 PHYHeader<E, P>::setTime(uint64_t hosttime, uint64_t mactime)
00113 {
00114 const std::string s =
00115 boost::lexical_cast<std::string> (boost::format ("%010u:%010u")
00116 % hosttime
00117 % mactime);
00118
00119 time_.setText(s.c_str());
00120 }
00121
00122 template <class E, int P>
00123 void
00124 PHYHeader<E, P>::setRate(float rate)
00125 {
00126 rate_.setText(this->tr("%1 Mb/s").arg(rate));
00127 }
00128
00129 template <class E, int P>
00130 void
00131 PHYHeader<E, P>::setChannel(unsigned channel)
00132 {
00133 channel_.setText(this->tr("channel %1").arg(channel));
00134 }
00135 template <class E, int P>
00136 void
00137 PHYHeader<E, P>::setSignal(int rssi, int signal, int noise)
00138 {
00139 signal_.setText(this->tr("rssi/signal/noise: %1 / %2 / %3")
00140 .arg(rssi >= 0 ? QString::number(rssi) : "NA")
00141 .arg(signal >= 0 ? QString::number(signal) : "NA")
00142 .arg(noise >= 0 ? QString::number(noise) : "NA"));
00143 }
00144
00145 }
00146
00147 }
00148
00149 #endif // ! WSCOUT_GUI_PRISM_HEADER_HXX_