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 3029 2008-09-02 01:39:36Z 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 #include <QContextMenuEvent> 00024 00025 #include <routerdescriptor.h> 00026 00027 00028 class RouterDescriptorView : public QTextEdit 00029 { 00030 Q_OBJECT 00031 00032 public: 00033 /** Default constructor. */ 00034 RouterDescriptorView(QWidget *parent = 0); 00035 00036 public slots: 00037 /** Shows the given router descriptor. */ 00038 void display(RouterDescriptor rd); 00039 /** Shows all router descriptors in the given list. */ 00040 void display(QList<RouterDescriptor> rdlist); 00041 /** Copies any selected text to the clipboard. */ 00042 void copySelectedText(); 00043 00044 protected: 00045 /** Displays a context menu for the user when they right-click on the 00046 * widget. */ 00047 virtual void contextMenuEvent(QContextMenuEvent *event); 00048 00049 private: 00050 /** Adjusts the displayed uptime to include time since the 00051 * router's descriptor was last published. */ 00052 quint64 adjustUptime(quint64 uptime, QDateTime published); 00053 /** Formats the descriptor's published date. */ 00054 QString formatPublished(QDateTime date); 00055 /** Formats the router's uptime. */ 00056 QString formatUptime(quint64 seconds); 00057 /** Formats the observed bandwidth into KB/s. */ 00058 QString formatBandwidth(quint64 bandwidth); 00059 }; 00060 00061 #endif 00062