Vidalia
0.2.15
|
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.torproject.org/projects/vidalia.html. No part of Vidalia, 00007 ** including this file, may be copied, modified, propagated, or distributed 00008 ** except according to the terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file RouterListItem.h 00013 ** \brief Item representing a single router and status in a RouterListWidget 00014 */ 00015 00016 #ifndef _ROUTERLISTITEM_H 00017 #define _ROUTERLISTITEM_H 00018 00019 #include "RouterDescriptor.h" 00020 #include "RouterListWidget.h" 00021 #include "GeoIpRecord.h" 00022 00023 #include <QCoreApplication> 00024 #include <QTreeWidgetItem> 00025 #include <QString> 00026 00027 class RouterListWidget; 00028 00029 00030 class RouterListItem : public QTreeWidgetItem 00031 { 00032 Q_DECLARE_TR_FUNCTIONS(RouterListItem) 00033 00034 public: 00035 /** Default constructor. */ 00036 RouterListItem(RouterListWidget *list, RouterDescriptor rd); 00037 /** Destructor. */ 00038 ~RouterListItem(); 00039 00040 /** Updates this router item using a new descriptor. */ 00041 void update(const RouterDescriptor &rd); 00042 /** Returns the router's ID. */ 00043 QString id() const { return _rd->id(); } 00044 /** Returns the router's name. */ 00045 QString name() const { return _rd->name(); } 00046 /** Returns the descriptor for this router. */ 00047 RouterDescriptor descriptor() const { return *_rd; } 00048 /** Sets the location information for this router item. */ 00049 void setLocation(const GeoIpRecord &geoip); 00050 /** Returns the location information set for this router item. */ 00051 GeoIpRecord location() const { return _location; } 00052 00053 /** Overload the comparison operator. */ 00054 virtual bool operator<(const QTreeWidgetItem &other) const; 00055 00056 private: 00057 RouterDescriptor* _rd; /**< Descriptor for this router item. */ 00058 RouterListWidget* _list; /**< The list for this list item. */ 00059 qint64 _statusValue; /**< Value used to sort items by status. */ 00060 GeoIpRecord _location; /**< Location information for this router. */ 00061 QString _countryCode; 00062 }; 00063 00064 #endif 00065