Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > media > contrib-backports > by-pkgid > 9601c7beb4ff23e834bfa171795ed560 > files > 31

vidalia-0.2.9-1mdv2010.1.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Vidalia: BandwidthGraph.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="dir_b47abd1aad201a152869566145babb61.html">src</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_695ba8f8357372e02d38c40b3c6dbe81.html">vidalia</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_b8299d6fcca538b98c7d31c1201c7907.html">bwgraph</a>
  </div>
</div>
<div class="contents">
<h1>BandwidthGraph.cpp</h1><a href="_bandwidth_graph_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">**  This file is part of Vidalia, and is subject to the license terms in the</span>
<a name="l00003"></a>00003 <span class="comment">**  LICENSE file, found in the top level directory of this distribution. If you</span>
<a name="l00004"></a>00004 <span class="comment">**  did not receive the LICENSE file with this file, you may obtain it from the</span>
<a name="l00005"></a>00005 <span class="comment">**  Vidalia source package distributed by the Vidalia Project at</span>
<a name="l00006"></a>00006 <span class="comment">**  http://www.vidalia-project.net/. No part of Vidalia, including this file,</span>
<a name="l00007"></a>00007 <span class="comment">**  may be copied, modified, propagated, or distributed except according to the</span>
<a name="l00008"></a>00008 <span class="comment">**  terms described in the LICENSE file.</span>
<a name="l00009"></a>00009 <span class="comment">*/</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="comment">/*</span>
<a name="l00012"></a>00012 <span class="comment">** \file BandwidthGraph.cpp</span>
<a name="l00013"></a>00013 <span class="comment">** \version $Id: BandwidthGraph.cpp 4054 2009-08-17 02:25:08Z edmanm $</span>
<a name="l00014"></a>00014 <span class="comment">** \brief Displays a graph of Tor&#39;s bandwidth usage</span>
<a name="l00015"></a>00015 <span class="comment">*/</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#include &quot;<a class="code" href="_bandwidth_graph_8h.html">BandwidthGraph.h</a>&quot;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;<a class="code" href="_vidalia_8h.html">Vidalia.h</a>&quot;</span>
<a name="l00019"></a>00019 
<a name="l00020"></a><a class="code" href="_bandwidth_graph_8cpp.html#ac36c3925f93963bf3788b12bf4773d57">00020</a> <span class="preprocessor">#define BWGRAPH_LINE_SEND       (1u&lt;&lt;0)</span>
<a name="l00021"></a><a class="code" href="_bandwidth_graph_8cpp.html#a7fe3f4ed004d92946d12b624fcb86071">00021</a> <span class="preprocessor"></span><span class="preprocessor">#define BWGRAPH_LINE_RECV       (1u&lt;&lt;1)</span>
<a name="l00022"></a><a class="code" href="_bandwidth_graph_8cpp.html#a12d38dd208054131a53c05b670d8a372">00022</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_FILTER          &quot;LineFilter&quot;</span>
<a name="l00023"></a><a class="code" href="_bandwidth_graph_8cpp.html#a725ac32907a9950c1e76dcc1e2181a29">00023</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_OPACITY         &quot;Opacity&quot;</span>
<a name="l00024"></a><a class="code" href="_bandwidth_graph_8cpp.html#aabe6e4d0ad4e484032ee321a641ba780">00024</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_ALWAYS_ON_TOP   &quot;AlwaysOnTop&quot;</span>
<a name="l00025"></a><a class="code" href="_bandwidth_graph_8cpp.html#a66fe833f0d8d6ed45e1e61f4acb19381">00025</a> <span class="preprocessor"></span><span class="preprocessor">#define SETTING_STYLE           &quot;GraphStyle&quot;</span>
<a name="l00026"></a><a class="code" href="_bandwidth_graph_8cpp.html#aa95e3139cc87a5ce4415baef85d3bcbc">00026</a> <span class="preprocessor"></span><span class="preprocessor">#define DEFAULT_FILTER          (BWGRAPH_LINE_SEND|BWGRAPH_LINE_RECV)</span>
<a name="l00027"></a><a class="code" href="_bandwidth_graph_8cpp.html#aa91f520b9e2ce857cf1d1ab262335e0a">00027</a> <span class="preprocessor"></span><span class="preprocessor">#define DEFAULT_ALWAYS_ON_TOP   false</span>
<a name="l00028"></a><a class="code" href="_bandwidth_graph_8cpp.html#a815f9da4099f0010dcc31f73557e3450">00028</a> <span class="preprocessor"></span><span class="preprocessor">#define DEFAULT_OPACITY         100</span>
<a name="l00029"></a><a class="code" href="_bandwidth_graph_8cpp.html#ad0f737d6f892e9d7a566ab5602690c82">00029</a> <span class="preprocessor"></span><span class="preprocessor">#define DEFAULT_STYLE           GraphFrame::AreaGraph</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>
<a name="l00031"></a><a class="code" href="_bandwidth_graph_8cpp.html#af08449cd26a1000cfdaf0e26f8f0d9b4">00031</a> <span class="preprocessor">#define ADD_TO_FILTER(f,v,b)  (f = ((b) ? ((f) | (v)) : ((f) &amp; ~(v))))</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span>
<a name="l00033"></a>00033 <span class="comment">/* Define the format used for displaying the date and time */</span>
<a name="l00034"></a><a class="code" href="_bandwidth_graph_8cpp.html#a88d14c36233b470fce94ac3f4fe3d707">00034</a> <span class="preprocessor">#define DATETIME_FMT  &quot;MMM dd hh:mm:ss&quot;</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span>
<a name="l00036"></a>00036 <span class="comment">/* Images used in the graph style drop-down */</span>
<a name="l00037"></a><a class="code" href="_bandwidth_graph_8cpp.html#a36a23ee1c93914dcf2ffdfc8b745493d">00037</a> <span class="preprocessor">#define IMG_AREA_GRAPH    &quot;:/images/16x16/graph-area.png&quot;</span>
<a name="l00038"></a><a class="code" href="_bandwidth_graph_8cpp.html#a56f88dfad36d8ca32507fd3618a18095">00038</a> <span class="preprocessor"></span><span class="preprocessor">#define IMG_LINE_GRAPH    &quot;:/images/16x16/graph-line.png&quot;</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00040"></a>00040 <span class="comment"></span>
<a name="l00041"></a>00041 <span class="comment">/** Default constructor */</span>
<a name="l00042"></a><a class="code" href="class_bandwidth_graph.html#a41af3923220c457c4fe9aabd3c9342de">00042</a> <a class="code" href="class_bandwidth_graph.html#a41af3923220c457c4fe9aabd3c9342de">BandwidthGraph::BandwidthGraph</a>(QWidget *parent, Qt::WFlags flags)
<a name="l00043"></a>00043   : <a class="code" href="class_vidalia_window.html">VidaliaWindow</a>(<span class="stringliteral">&quot;BandwidthGraph&quot;</span>, parent, flags)
<a name="l00044"></a>00044 {
<a name="l00045"></a>00045   <span class="comment">/* Invoke Qt Designer generated QObject setup routine */</span>
<a name="l00046"></a>00046   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.setupUi(<span class="keyword">this</span>);
<a name="l00047"></a>00047 
<a name="l00048"></a>00048   <span class="comment">/* Ask Tor to notify us about bandwidth updates */</span>
<a name="l00049"></a>00049   <a class="code" href="class_vidalia.html#a24c23bc8e35fcf66370d31ef176412d5">Vidalia::torControl</a>()-&gt;<a class="code" href="class_tor_control.html#ab3dd744e5f82c562ef380a8ca447c3a3">setEvent</a>(<a class="code" href="class_tor_events.html#a08aed30fd27832e89f96114617da72bfa37aa333e6b9acdb8cf240fbafeba4e38">TorEvents::Bandwidth</a>);
<a name="l00050"></a>00050   connect(<a class="code" href="class_vidalia.html#a24c23bc8e35fcf66370d31ef176412d5">Vidalia::torControl</a>(), SIGNAL(bandwidthUpdate(quint64,quint64)),
<a name="l00051"></a>00051           <span class="keyword">this</span>, SLOT(<a class="code" href="class_bandwidth_graph.html#a54fdb1471ea17962d87041658613bcae">updateGraph</a>(quint64,quint64)));
<a name="l00052"></a>00052 
<a name="l00053"></a>00053   <span class="comment">/* Pressing &#39;Esc&#39; or &#39;Ctrl+W&#39; will close the window */</span>
<a name="l00054"></a>00054   <a class="code" href="class_vidalia_window.html#ad3d1892561bb67129fc1b1dccea92f5f">setShortcut</a>(<span class="stringliteral">&quot;Esc&quot;</span>, SLOT(close()));
<a name="l00055"></a>00055   <a class="code" href="class_vidalia_window.html#ad3d1892561bb67129fc1b1dccea92f5f">setShortcut</a>(<span class="stringliteral">&quot;Ctrl+W&quot;</span>, SLOT(close()));
<a name="l00056"></a>00056 
<a name="l00057"></a>00057   <span class="comment">/* Bind events to actions */</span>
<a name="l00058"></a>00058   <a class="code" href="class_bandwidth_graph.html#acf976f391890bc83305135aa1dda80fd">createActions</a>();
<a name="l00059"></a>00059 
<a name="l00060"></a>00060   <span class="comment">/* Initialize Sent/Receive data counters */</span>
<a name="l00061"></a>00061   <a class="code" href="class_bandwidth_graph.html#a6a60a338da254a84c451737995ca76b8">reset</a>();
<a name="l00062"></a>00062   <span class="comment">/* Hide Bandwidth Graph Settings frame */</span>
<a name="l00063"></a>00063   <a class="code" href="class_bandwidth_graph.html#a4f1de4fb621eee0931b4d744401ac22c">showSettingsFrame</a>(<span class="keyword">false</span>);
<a name="l00064"></a>00064   <span class="comment">/* Load the previously saved settings */</span>
<a name="l00065"></a>00065   <a class="code" href="class_bandwidth_graph.html#addbee4c94373f62cc1e954f469adc39d">loadSettings</a>();
<a name="l00066"></a>00066 
<a name="l00067"></a>00067   <span class="comment">/* Turn off opacity group on unsupported platforms */</span>
<a name="l00068"></a>00068 <span class="preprocessor">#if defined(Q_WS_WIN)</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span>  <span class="keywordflow">if</span>(!(QSysInfo::WindowsVersion &amp; QSysInfo::WV_NT_based)
<a name="l00070"></a>00070        || QSysInfo::WindowsVersion &lt; QSysInfo::WV_2000) {
<a name="l00071"></a>00071     <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.frmOpacity-&gt;setVisible(<span class="keyword">false</span>);
<a name="l00072"></a>00072   }
<a name="l00073"></a>00073 <span class="preprocessor">#endif</span>
<a name="l00074"></a>00074 <span class="preprocessor"></span>  
<a name="l00075"></a>00075 <span class="preprocessor">#if defined(Q_WS_X11)</span>
<a name="l00076"></a>00076 <span class="preprocessor"></span>  <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.frmOpacity-&gt;setVisible(<span class="keyword">false</span>);
<a name="l00077"></a>00077 <span class="preprocessor">#endif</span>
<a name="l00078"></a>00078 <span class="preprocessor"></span>}
<a name="l00079"></a>00079 <span class="comment"></span>
<a name="l00080"></a>00080 <span class="comment">/** Called when the user changes the UI translation. */</span>
<a name="l00081"></a>00081 <span class="keywordtype">void</span>
<a name="l00082"></a><a class="code" href="class_bandwidth_graph.html#a19b17f1f47022e34a67215c18270745c">00082</a> <a class="code" href="class_bandwidth_graph.html#a19b17f1f47022e34a67215c18270745c">BandwidthGraph::retranslateUi</a>()
<a name="l00083"></a>00083 {
<a name="l00084"></a>00084   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.retranslateUi(<span class="keyword">this</span>);
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 <span class="comment"></span>
<a name="l00087"></a>00087 <span class="comment">/** Binds events to actions. */</span>
<a name="l00088"></a>00088 <span class="keywordtype">void</span>
<a name="l00089"></a><a class="code" href="class_bandwidth_graph.html#acf976f391890bc83305135aa1dda80fd">00089</a> <a class="code" href="class_bandwidth_graph.html#acf976f391890bc83305135aa1dda80fd">BandwidthGraph::createActions</a>()
<a name="l00090"></a>00090 {
<a name="l00091"></a>00091   connect(<a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.btnToggleSettings, SIGNAL(toggled(<span class="keywordtype">bool</span>)),
<a name="l00092"></a>00092           <span class="keyword">this</span>, SLOT(<a class="code" href="class_bandwidth_graph.html#a4f1de4fb621eee0931b4d744401ac22c">showSettingsFrame</a>(<span class="keywordtype">bool</span>)));
<a name="l00093"></a>00093 
<a name="l00094"></a>00094   connect(<a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.btnReset, SIGNAL(clicked()),
<a name="l00095"></a>00095           <span class="keyword">this</span>, SLOT(<a class="code" href="class_bandwidth_graph.html#a6a60a338da254a84c451737995ca76b8">reset</a>()));
<a name="l00096"></a>00096 
<a name="l00097"></a>00097   connect(<a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.btnSaveSettings, SIGNAL(clicked()),
<a name="l00098"></a>00098           <span class="keyword">this</span>, SLOT(<a class="code" href="class_bandwidth_graph.html#a8f8883f1c0dc8d0b8c9c81cdc05109f3">saveChanges</a>()));
<a name="l00099"></a>00099 
<a name="l00100"></a>00100   connect(<a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.btnCancelSettings, SIGNAL(clicked()),
<a name="l00101"></a>00101           <span class="keyword">this</span>, SLOT(<a class="code" href="class_bandwidth_graph.html#a3f55822a92f81e06b3135c04cc71e87e">cancelChanges</a>()));
<a name="l00102"></a>00102 
<a name="l00103"></a>00103   connect(<a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.sldrOpacity, SIGNAL(valueChanged(<span class="keywordtype">int</span>)),
<a name="l00104"></a>00104           <span class="keyword">this</span>, SLOT(<a class="code" href="class_bandwidth_graph.html#ae49e83eaab32c01486c33a1bece650ac">setOpacity</a>(<span class="keywordtype">int</span>)));
<a name="l00105"></a>00105 }
<a name="l00106"></a>00106 <span class="comment"></span>
<a name="l00107"></a>00107 <span class="comment">/** Adds new data to the graph. */</span>
<a name="l00108"></a>00108 <span class="keywordtype">void</span>
<a name="l00109"></a><a class="code" href="class_bandwidth_graph.html#a54fdb1471ea17962d87041658613bcae">00109</a> <a class="code" href="class_bandwidth_graph.html#a54fdb1471ea17962d87041658613bcae">BandwidthGraph::updateGraph</a>(quint64 bytesRead, quint64 bytesWritten)
<a name="l00110"></a>00110 {
<a name="l00111"></a>00111   <span class="comment">/* Graph only cares about kilobytes */</span>
<a name="l00112"></a>00112   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.frmGraph-&gt;addPoints(bytesRead/1024.0, bytesWritten/1024.0);
<a name="l00113"></a>00113 }
<a name="l00114"></a>00114 <span class="comment"></span>
<a name="l00115"></a>00115 <span class="comment">/** Loads the saved Bandwidth Graph settings. */</span>
<a name="l00116"></a>00116 <span class="keywordtype">void</span>
<a name="l00117"></a><a class="code" href="class_bandwidth_graph.html#addbee4c94373f62cc1e954f469adc39d">00117</a> <a class="code" href="class_bandwidth_graph.html#addbee4c94373f62cc1e954f469adc39d">BandwidthGraph::loadSettings</a>()
<a name="l00118"></a>00118 {
<a name="l00119"></a>00119   <span class="comment">/* Set window opacity slider widget */</span>
<a name="l00120"></a>00120   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.sldrOpacity-&gt;setValue(<a class="code" href="class_vidalia_window.html#a52dc2a258fe687778e49a1abf117fade">getSetting</a>(<a class="code" href="_bandwidth_graph_8cpp.html#a725ac32907a9950c1e76dcc1e2181a29">SETTING_OPACITY</a>, <a class="code" href="_bandwidth_graph_8cpp.html#a815f9da4099f0010dcc31f73557e3450">DEFAULT_OPACITY</a>).toInt());
<a name="l00121"></a>00121   <a class="code" href="class_bandwidth_graph.html#ae49e83eaab32c01486c33a1bece650ac">setOpacity</a>(<a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.sldrOpacity-&gt;value());
<a name="l00122"></a>00122 
<a name="l00123"></a>00123   <span class="comment">/* Set whether the window appears on top. */</span>
<a name="l00124"></a>00124   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.chkAlwaysOnTop-&gt;setChecked(<a class="code" href="class_vidalia_window.html#a52dc2a258fe687778e49a1abf117fade">getSetting</a>(<a class="code" href="_bandwidth_graph_8cpp.html#aabe6e4d0ad4e484032ee321a641ba780">SETTING_ALWAYS_ON_TOP</a>,
<a name="l00125"></a>00125                                            <a class="code" href="_bandwidth_graph_8cpp.html#aa91f520b9e2ce857cf1d1ab262335e0a">DEFAULT_ALWAYS_ON_TOP</a>).toBool());
<a name="l00126"></a>00126   <span class="keywordflow">if</span> (<a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.chkAlwaysOnTop-&gt;isChecked()) {
<a name="l00127"></a>00127     setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
<a name="l00128"></a>00128   } <span class="keywordflow">else</span> {
<a name="l00129"></a>00129     setWindowFlags(windowFlags() &amp; ~Qt::WindowStaysOnTopHint);
<a name="l00130"></a>00130   }
<a name="l00131"></a>00131 
<a name="l00132"></a>00132   <span class="comment">/* Set the line filter checkboxes accordingly */</span>
<a name="l00133"></a>00133   uint filter = <a class="code" href="class_vidalia_window.html#a52dc2a258fe687778e49a1abf117fade">getSetting</a>(<a class="code" href="_bandwidth_graph_8cpp.html#a12d38dd208054131a53c05b670d8a372">SETTING_FILTER</a>, <a class="code" href="_bandwidth_graph_8cpp.html#aa95e3139cc87a5ce4415baef85d3bcbc">DEFAULT_FILTER</a>).toUInt();
<a name="l00134"></a>00134   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.chkReceiveRate-&gt;setChecked(filter &amp; <a class="code" href="_bandwidth_graph_8cpp.html#a7fe3f4ed004d92946d12b624fcb86071">BWGRAPH_LINE_RECV</a>);
<a name="l00135"></a>00135   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.chkSendRate-&gt;setChecked(filter &amp; <a class="code" href="_bandwidth_graph_8cpp.html#ac36c3925f93963bf3788b12bf4773d57">BWGRAPH_LINE_SEND</a>);
<a name="l00136"></a>00136 
<a name="l00137"></a>00137   <span class="comment">/* Set whether we are plotting bandwidth as area graphs or not */</span>
<a name="l00138"></a>00138   <span class="keywordtype">int</span> graphStyle = <a class="code" href="class_vidalia_window.html#a52dc2a258fe687778e49a1abf117fade">getSetting</a>(<a class="code" href="_bandwidth_graph_8cpp.html#a66fe833f0d8d6ed45e1e61f4acb19381">SETTING_STYLE</a>, <a class="code" href="_bandwidth_graph_8cpp.html#ad0f737d6f892e9d7a566ab5602690c82">DEFAULT_STYLE</a>).toInt();
<a name="l00139"></a>00139   <span class="keywordflow">if</span> (graphStyle &lt; 0 || graphStyle &gt;= <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.cmbGraphStyle-&gt;count()) {
<a name="l00140"></a>00140     graphStyle = <a class="code" href="_bandwidth_graph_8cpp.html#ad0f737d6f892e9d7a566ab5602690c82">DEFAULT_STYLE</a>;
<a name="l00141"></a>00141   }
<a name="l00142"></a>00142   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.cmbGraphStyle-&gt;setCurrentIndex(graphStyle);
<a name="l00143"></a>00143   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.frmGraph-&gt;setGraphStyle((<a class="code" href="class_graph_frame.html#a3b7b5fa094ff22d70a0fe9dead0392ec">GraphFrame::GraphStyle</a>)graphStyle);
<a name="l00144"></a>00144 
<a name="l00145"></a>00145   <span class="comment">/* Set graph frame settings */</span>
<a name="l00146"></a>00146   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.frmGraph-&gt;setShowCounters(<a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.chkReceiveRate-&gt;isChecked(),
<a name="l00147"></a>00147                                <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.chkSendRate-&gt;isChecked());
<a name="l00148"></a>00148 }
<a name="l00149"></a>00149 <span class="comment"></span>
<a name="l00150"></a>00150 <span class="comment">/** Resets the log start time. */</span>
<a name="l00151"></a>00151 <span class="keywordtype">void</span>
<a name="l00152"></a><a class="code" href="class_bandwidth_graph.html#a6a60a338da254a84c451737995ca76b8">00152</a> <a class="code" href="class_bandwidth_graph.html#a6a60a338da254a84c451737995ca76b8">BandwidthGraph::reset</a>()
<a name="l00153"></a>00153 {
<a name="l00154"></a>00154   <span class="comment">/* Set to current time */</span>
<a name="l00155"></a>00155   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.statusbar-&gt;showMessage(tr(<span class="stringliteral">&quot;Since:&quot;</span>) + <span class="stringliteral">&quot; &quot;</span> + 
<a name="l00156"></a>00156           QDateTime::currentDateTime()
<a name="l00157"></a>00157           .toString(<a class="code" href="_bandwidth_graph_8cpp.html#a88d14c36233b470fce94ac3f4fe3d707">DATETIME_FMT</a>));
<a name="l00158"></a>00158   <span class="comment">/* Reset the graph */</span>
<a name="l00159"></a>00159   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.frmGraph-&gt;resetGraph();
<a name="l00160"></a>00160 }
<a name="l00161"></a>00161 <span class="comment"></span>
<a name="l00162"></a>00162 <span class="comment">/** Saves the Bandwidth Graph settings and adjusts the graph if necessary. */</span>
<a name="l00163"></a>00163 <span class="keywordtype">void</span>
<a name="l00164"></a><a class="code" href="class_bandwidth_graph.html#a8f8883f1c0dc8d0b8c9c81cdc05109f3">00164</a> <a class="code" href="class_bandwidth_graph.html#a8f8883f1c0dc8d0b8c9c81cdc05109f3">BandwidthGraph::saveChanges</a>()
<a name="l00165"></a>00165 {
<a name="l00166"></a>00166   <span class="comment">/* Hide the settings frame and reset toggle button */</span>
<a name="l00167"></a>00167   <a class="code" href="class_bandwidth_graph.html#a4f1de4fb621eee0931b4d744401ac22c">showSettingsFrame</a>(<span class="keyword">false</span>);
<a name="l00168"></a>00168   
<a name="l00169"></a>00169   <span class="comment">/* Save the opacity and graph style */</span>
<a name="l00170"></a>00170   <a class="code" href="class_vidalia_window.html#a5974e59c9417724272354f08ef3eb1ac">saveSetting</a>(<a class="code" href="_bandwidth_graph_8cpp.html#a725ac32907a9950c1e76dcc1e2181a29">SETTING_OPACITY</a>, <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.sldrOpacity-&gt;value());
<a name="l00171"></a>00171   <a class="code" href="class_vidalia_window.html#a5974e59c9417724272354f08ef3eb1ac">saveSetting</a>(<a class="code" href="_bandwidth_graph_8cpp.html#a66fe833f0d8d6ed45e1e61f4acb19381">SETTING_STYLE</a>, <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.cmbGraphStyle-&gt;currentIndex());
<a name="l00172"></a>00172 
<a name="l00173"></a>00173   <span class="comment">/* Save the Always On Top setting */</span>
<a name="l00174"></a>00174   <a class="code" href="class_vidalia_window.html#a5974e59c9417724272354f08ef3eb1ac">saveSetting</a>(<a class="code" href="_bandwidth_graph_8cpp.html#aabe6e4d0ad4e484032ee321a641ba780">SETTING_ALWAYS_ON_TOP</a>, <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.chkAlwaysOnTop-&gt;isChecked());
<a name="l00175"></a>00175   <span class="keywordflow">if</span> (<a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.chkAlwaysOnTop-&gt;isChecked()) {
<a name="l00176"></a>00176     setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
<a name="l00177"></a>00177   } <span class="keywordflow">else</span> {
<a name="l00178"></a>00178     setWindowFlags(windowFlags() &amp; ~Qt::WindowStaysOnTopHint);
<a name="l00179"></a>00179   }
<a name="l00180"></a>00180   <a class="code" href="class_bandwidth_graph.html#ae49e83eaab32c01486c33a1bece650ac">setOpacity</a>(<a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.sldrOpacity-&gt;value());
<a name="l00181"></a>00181 
<a name="l00182"></a>00182   <span class="comment">/* Save the line filter values */</span>
<a name="l00183"></a>00183   uint filter = 0;
<a name="l00184"></a>00184   <a class="code" href="_bandwidth_graph_8cpp.html#af08449cd26a1000cfdaf0e26f8f0d9b4">ADD_TO_FILTER</a>(filter, <a class="code" href="_bandwidth_graph_8cpp.html#a7fe3f4ed004d92946d12b624fcb86071">BWGRAPH_LINE_RECV</a>, <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.chkReceiveRate-&gt;isChecked());
<a name="l00185"></a>00185   <a class="code" href="_bandwidth_graph_8cpp.html#af08449cd26a1000cfdaf0e26f8f0d9b4">ADD_TO_FILTER</a>(filter, <a class="code" href="_bandwidth_graph_8cpp.html#ac36c3925f93963bf3788b12bf4773d57">BWGRAPH_LINE_SEND</a>, <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.chkSendRate-&gt;isChecked());
<a name="l00186"></a>00186   <a class="code" href="class_vidalia_window.html#a5974e59c9417724272354f08ef3eb1ac">saveSetting</a>(<a class="code" href="_bandwidth_graph_8cpp.html#a12d38dd208054131a53c05b670d8a372">SETTING_FILTER</a>, filter);
<a name="l00187"></a>00187 
<a name="l00188"></a>00188 
<a name="l00189"></a>00189   <span class="comment">/* Update the graph frame settings */</span>
<a name="l00190"></a>00190   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.frmGraph-&gt;setShowCounters(<a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.chkReceiveRate-&gt;isChecked(),
<a name="l00191"></a>00191                                <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.chkSendRate-&gt;isChecked());
<a name="l00192"></a>00192   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.frmGraph-&gt;setGraphStyle((<a class="code" href="class_graph_frame.html#a3b7b5fa094ff22d70a0fe9dead0392ec">GraphFrame::GraphStyle</a>)<a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.cmbGraphStyle-&gt;currentIndex());
<a name="l00193"></a>00193   
<a name="l00194"></a>00194   <span class="comment">/* A change in window flags causes the window to disappear, so make sure</span>
<a name="l00195"></a>00195 <span class="comment">   * it&#39;s still visible. */</span>
<a name="l00196"></a>00196   showNormal();
<a name="l00197"></a>00197 }
<a name="l00198"></a>00198 <span class="comment"></span>
<a name="l00199"></a>00199 <span class="comment">/** Simply restores the previously saved settings. */</span>
<a name="l00200"></a>00200 <span class="keywordtype">void</span> 
<a name="l00201"></a><a class="code" href="class_bandwidth_graph.html#a3f55822a92f81e06b3135c04cc71e87e">00201</a> <a class="code" href="class_bandwidth_graph.html#a3f55822a92f81e06b3135c04cc71e87e">BandwidthGraph::cancelChanges</a>()
<a name="l00202"></a>00202 {
<a name="l00203"></a>00203   <span class="comment">/* Hide the settings frame and reset toggle button */</span>
<a name="l00204"></a>00204   <a class="code" href="class_bandwidth_graph.html#a4f1de4fb621eee0931b4d744401ac22c">showSettingsFrame</a>(<span class="keyword">false</span>);
<a name="l00205"></a>00205 
<a name="l00206"></a>00206   <span class="comment">/* Reload the settings */</span>
<a name="l00207"></a>00207   <a class="code" href="class_bandwidth_graph.html#addbee4c94373f62cc1e954f469adc39d">loadSettings</a>();
<a name="l00208"></a>00208 }
<a name="l00209"></a>00209 <span class="comment"></span>
<a name="l00210"></a>00210 <span class="comment">/** Toggles the Settings pane on and off, changes toggle button text. */</span>
<a name="l00211"></a>00211 <span class="keywordtype">void</span>
<a name="l00212"></a><a class="code" href="class_bandwidth_graph.html#a4f1de4fb621eee0931b4d744401ac22c">00212</a> <a class="code" href="class_bandwidth_graph.html#a4f1de4fb621eee0931b4d744401ac22c">BandwidthGraph::showSettingsFrame</a>(<span class="keywordtype">bool</span> show)
<a name="l00213"></a>00213 {
<a name="l00214"></a>00214   <span class="keyword">static</span> QSize minSize = minimumSize();
<a name="l00215"></a>00215   
<a name="l00216"></a>00216   QSize newSize = size();
<a name="l00217"></a>00217   <span class="keywordflow">if</span> (show) {
<a name="l00218"></a>00218     <span class="comment">/* Extend the bottom of the bandwidth graph and show the settings */</span>
<a name="l00219"></a>00219     <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.frmSettings-&gt;setVisible(<span class="keyword">true</span>);
<a name="l00220"></a>00220     <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.btnToggleSettings-&gt;setChecked(<span class="keyword">true</span>);
<a name="l00221"></a>00221     <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.btnToggleSettings-&gt;setText(tr(<span class="stringliteral">&quot;Hide Settings&quot;</span>));
<a name="l00222"></a>00222 
<a name="l00223"></a>00223     <span class="comment">/* 6 = vertical spacing between the settings frame and graph frame */</span>
<a name="l00224"></a>00224     newSize.setHeight(newSize.height() + <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.frmSettings-&gt;height() + 6);
<a name="l00225"></a>00225   } <span class="keywordflow">else</span> {
<a name="l00226"></a>00226     <span class="comment">/* Shrink the height of the bandwidth graph and hide the settings */</span>
<a name="l00227"></a>00227     <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.frmSettings-&gt;setVisible(<span class="keyword">false</span>);
<a name="l00228"></a>00228     <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.btnToggleSettings-&gt;setChecked(<span class="keyword">false</span>);
<a name="l00229"></a>00229     <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.btnToggleSettings-&gt;setText(tr(<span class="stringliteral">&quot;Show Settings&quot;</span>));
<a name="l00230"></a>00230     
<a name="l00231"></a>00231     <span class="comment">/* 6 = vertical spacing between the settings frame and graph frame */</span>
<a name="l00232"></a>00232     newSize.setHeight(newSize.height() - <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.frmSettings-&gt;height() - 6);
<a name="l00233"></a>00233     setMinimumSize(minSize);
<a name="l00234"></a>00234   }
<a name="l00235"></a>00235   resize(newSize);
<a name="l00236"></a>00236 }
<a name="l00237"></a>00237 <span class="comment"></span>
<a name="l00238"></a>00238 <span class="comment">/** Sets the opacity of the Bandwidth Graph window. */</span>
<a name="l00239"></a>00239 <span class="keywordtype">void</span>
<a name="l00240"></a><a class="code" href="class_bandwidth_graph.html#ae49e83eaab32c01486c33a1bece650ac">00240</a> <a class="code" href="class_bandwidth_graph.html#ae49e83eaab32c01486c33a1bece650ac">BandwidthGraph::setOpacity</a>(<span class="keywordtype">int</span> value)
<a name="l00241"></a>00241 {
<a name="l00242"></a>00242   qreal newValue = value / 100.0;
<a name="l00243"></a>00243   
<a name="l00244"></a>00244   <span class="comment">/* Opacity only supported by Mac and Win32 */</span>
<a name="l00245"></a>00245 <span class="preprocessor">#if defined(Q_WS_MAC)</span>
<a name="l00246"></a>00246 <span class="preprocessor"></span>  this-&gt;setWindowOpacity(newValue);
<a name="l00247"></a>00247   <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.lblPercentOpacity-&gt;setText(QString::number(value));
<a name="l00248"></a>00248 <span class="preprocessor">#elif defined(Q_WS_WIN)</span>
<a name="l00249"></a>00249 <span class="preprocessor"></span>  <span class="keywordflow">if</span> (QSysInfo::WindowsVersion &amp; QSysInfo::WV_NT_based
<a name="l00250"></a>00250         &amp;&amp; QSysInfo::WindowsVersion &gt;= QSysInfo::WV_2000) {
<a name="l00251"></a>00251     this-&gt;setWindowOpacity(newValue);
<a name="l00252"></a>00252     <a class="code" href="class_bandwidth_graph.html#a21038c5c086ce22874bf852417467467">ui</a>.lblPercentOpacity-&gt;setText(QString::number(value));
<a name="l00253"></a>00253   }
<a name="l00254"></a>00254 <span class="preprocessor">#else</span>
<a name="l00255"></a>00255 <span class="preprocessor"></span>  Q_UNUSED(newValue);
<a name="l00256"></a>00256 <span class="preprocessor">#endif</span>
<a name="l00257"></a>00257 <span class="preprocessor"></span>}
<a name="l00258"></a>00258 <span class="comment"></span>
<a name="l00259"></a>00259 <span class="comment">/** Overloads the default show() slot so we can set opacity. */</span>
<a name="l00260"></a>00260 <span class="keywordtype">void</span>
<a name="l00261"></a><a class="code" href="class_bandwidth_graph.html#aa4de08bc3223389e9b51a90262838329">00261</a> <a class="code" href="class_bandwidth_graph.html#aa4de08bc3223389e9b51a90262838329">BandwidthGraph::showWindow</a>()
<a name="l00262"></a>00262 {
<a name="l00263"></a>00263   <span class="comment">/* Load saved settings */</span>
<a name="l00264"></a>00264   <a class="code" href="class_bandwidth_graph.html#addbee4c94373f62cc1e954f469adc39d">loadSettings</a>();
<a name="l00265"></a>00265   <span class="comment">/* Show the window */</span>
<a name="l00266"></a>00266   <a class="code" href="class_bandwidth_graph.html#aa4de08bc3223389e9b51a90262838329">VidaliaWindow::showWindow</a>();
<a name="l00267"></a>00267 }
<a name="l00268"></a>00268 
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Mon Aug 30 22:58:54 2010 for Vidalia by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>