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::Text, trunc_fore);
00094 p.setColor(QPalette::Window, trunc_back);
00095 proto_.setText(proto_str_ + " (truncated)");
00096 }
00097 else
00098 {
00099 p.setColor(QPalette::WindowText, full_fore);
00100 p.setColor(QPalette::Text, full_fore);
00101 p.setColor(QPalette::Window, full_back);
00102 proto_.setText(proto_str_);
00103 }
00104
00105 this->setPalette(p);
00106 }
00107
00108 template <class E, int P>
00109 void
00110 PHYHeader<E, P>::setTime(uint64_t hosttime, uint64_t mactime)
00111 {
00112 const std::string s =
00113 boost::lexical_cast<std::string> (boost::format ("%010u:%010u")
00114 % hosttime
00115 % mactime);
00116
00117 time_.setText(s.c_str());
00118 }
00119
00120 template <class E, int P>
00121 void
00122 PHYHeader<E, P>::setRate(float rate)
00123 {
00124 rate_.setText(this->tr("%1 Mb/s").arg(rate));
00125 }
00126
00127 template <class E, int P>
00128 void
00129 PHYHeader<E, P>::setChannel(unsigned channel)
00130 {
00131 channel_.setText(this->tr("channel %1").arg(channel));
00132 }
00133 template <class E, int P>
00134 void
00135 PHYHeader<E, P>::setSignal(int rssi, int signal, int noise)
00136 {
00137 signal_.setText(this->tr("rssi/signal/noise: %1 / %2 / %3")
00138 .arg(rssi >= 0 ? QString::number(rssi) : "NA")
00139 .arg(signal >= 0 ? QString::number(signal) : "NA")
00140 .arg(noise >= 0 ? QString::number(noise) : "NA"));
00141 }
00142
00143 }
00144
00145 }
00146
00147 #endif // ! WSCOUT_GUI_PRISM_HEADER_HXX_