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 routerlistitem.h 00013 ** \version $Id: routerlistitem.h 2362 2008-02-29 04:30:11Z edmanm $ 00014 ** \brief Item representing a single router and status in a RouterListWidget 00015 */ 00016 00017 #ifndef _ROUTERLISTITEM_H 00018 #define _ROUTERLISTITEM_H 00019 00020 #include <QCoreApplication> 00021 #include <QTreeWidgetItem> 00022 #include <QString> 00023 #include <routerdescriptor.h> 00024 00025 #include "geoip.h" 00026 #include "routerlistwidget.h" 00027 00028 class RouterListWidget; 00029 00030 00031 class RouterListItem : public QTreeWidgetItem 00032 { 00033 Q_DECLARE_TR_FUNCTIONS(RouterListItem) 00034 00035 public: 00036 /** Default constructor. */ 00037 RouterListItem(RouterListWidget *list, RouterDescriptor rd); 00038 /** Destructor. */ 00039 ~RouterListItem(); 00040 00041 /** Updates this router item using a new descriptor. */ 00042 void update(const RouterDescriptor &rd); 00043 /** Returns the router's ID. */ 00044 QString id() const { return _rd->id(); } 00045 /** Returns the router's name. */ 00046 QString name() const { return _rd->name(); } 00047 /** Returns the descriptor for this router. */ 00048 RouterDescriptor descriptor() const { return *_rd; } 00049 /** Sets the location information for this router item. */ 00050 void setLocation(const GeoIp &geoip); 00051 00052 /** Overload the comparison operator. */ 00053 virtual bool operator<(const QTreeWidgetItem &other) const; 00054 00055 private: 00056 RouterDescriptor* _rd; /**< Descriptor for this router item. */ 00057 RouterListWidget* _list; /**< The list for this list item. */ 00058 qint64 _statusValue; /**< Value used to sort items by status. */ 00059 QString _country; /**< Country in which this router is likely 00060 located. */ 00061 }; 00062 00063 #endif 00064