00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file routerdescriptorview.h 00024 * \version $Id: routerdescriptorview.h 1563 2006-12-26 06:06:04Z edmanm $ 00025 * \brief Formats and displays a router descriptor as HTML 00026 */ 00027 00028 #ifndef _ROUTERDESCRIPTORVIEW_H 00029 #define _ROUTERDESCRIPTORVIEW_H 00030 00031 #include <QObject> 00032 #include <QTextEdit> 00033 #include <QList> 00034 00035 #include <control/routerdescriptor.h> 00036 00037 00038 class RouterDescriptorView : public QTextEdit 00039 { 00040 Q_OBJECT 00041 00042 public: 00043 /** Default constructor. */ 00044 RouterDescriptorView(QWidget *parent = 0); 00045 00046 public slots: 00047 /** Shows the given router descriptor. */ 00048 void display(RouterDescriptor rd); 00049 /** Shows all router descriptors in the given list. */ 00050 void display(QList<RouterDescriptor> rdlist); 00051 00052 private: 00053 /** Adjusts the displayed uptime to include time since the 00054 * router's descriptor was last published. */ 00055 quint64 adjustUptime(quint64 uptime, QDateTime published); 00056 /** Formats the descriptor's published date. */ 00057 QString formatPublished(QDateTime date); 00058 /** Formats the router's uptime. */ 00059 QString formatUptime(quint64 seconds); 00060 /** Formats the observed bandwidth into KB/s. */ 00061 QString formatBandwidth(quint64 bandwidth); 00062 }; 00063 00064 #endif 00065