00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file routerdescriptorview.h 00013 ** \version $Id: routerdescriptorview.h 2362 2008-02-29 04:30:11Z edmanm $ 00014 ** \brief Formats and displays a router descriptor as HTML 00015 */ 00016 00017 #ifndef _ROUTERDESCRIPTORVIEW_H 00018 #define _ROUTERDESCRIPTORVIEW_H 00019 00020 #include <QObject> 00021 #include <QTextEdit> 00022 #include <QList> 00023 00024 #include <routerdescriptor.h> 00025 00026 00027 class RouterDescriptorView : public QTextEdit 00028 { 00029 Q_OBJECT 00030 00031 public: 00032 /** Default constructor. */ 00033 RouterDescriptorView(QWidget *parent = 0); 00034 00035 public slots: 00036 /** Shows the given router descriptor. */ 00037 void display(RouterDescriptor rd); 00038 /** Shows all router descriptors in the given list. */ 00039 void display(QList<RouterDescriptor> rdlist); 00040 00041 private: 00042 /** Adjusts the displayed uptime to include time since the 00043 * router's descriptor was last published. */ 00044 quint64 adjustUptime(quint64 uptime, QDateTime published); 00045 /** Formats the descriptor's published date. */ 00046 QString formatPublished(QDateTime date); 00047 /** Formats the router's uptime. */ 00048 QString formatUptime(quint64 seconds); 00049 /** Formats the observed bandwidth into KB/s. */ 00050 QString formatBandwidth(quint64 bandwidth); 00051 }; 00052 00053 #endif 00054