Vidalia  0.2.21
RouterListItem.h
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If you
4 ** did not receive the LICENSE file with this file, you may obtain it from the
5 ** Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 /*
12 ** \file RouterListItem.h
13 ** \brief Item representing a single router and status in a RouterListWidget
14 */
15 
16 #ifndef _ROUTERLISTITEM_H
17 #define _ROUTERLISTITEM_H
18 
19 #include "RouterDescriptor.h"
20 #include "RouterListWidget.h"
21 #include "GeoIpRecord.h"
22 
23 #include <QCoreApplication>
24 #include <QTreeWidgetItem>
25 #include <QString>
26 
27 class RouterListWidget;
28 
29 
30 class RouterListItem : public QTreeWidgetItem
31 {
32  Q_DECLARE_TR_FUNCTIONS(RouterListItem)
33 
34 public:
35  /** Default constructor. */
37  /** Destructor. */
39 
40  /** Updates this router item using a new descriptor. */
41  void update(const RouterDescriptor &rd);
42  /** Returns the router's ID. */
43  QString id() const { return _rd->id(); }
44  /** Returns the router's name. */
45  QString name() const { return _rd->name(); }
46  /** Returns the descriptor for this router. */
47  RouterDescriptor descriptor() const { return *_rd; }
48  /** Sets the location information for this router item. */
49  void setLocation(const GeoIpRecord &geoip);
50  /** Returns the location information set for this router item. */
51  GeoIpRecord location() const { return _location; }
52 
53  /** Overload the comparison operator. */
54  virtual bool operator<(const QTreeWidgetItem &other) const;
55 
56 private:
57  RouterDescriptor* _rd; /**< Descriptor for this router item. */
58  RouterListWidget* _list; /**< The list for this list item. */
59  qint64 _statusValue; /**< Value used to sort items by status. */
60  GeoIpRecord _location; /**< Location information for this router. */
61  QString _countryCode;
62 };
63 
64 #endif
65