#include <routerlistwidget.h>
Public Types | |
enum | Columns { StatusColumn = 0, CountryColumn = 1, NameColumn = 2 } |
Public Slots | |
void | clearRouters () |
Signals | |
void | routerSelected (RouterDescriptor rd) |
void | zoomToRouter (QString id) |
Public Member Functions | |
RouterListWidget (QWidget *parent=0) | |
void | addRouter (RouterDescriptor rd) |
RouterListItem * | findRouterByName (QString name) |
RouterListItem * | findRouterById (QString id) |
void | deselectAll () |
Protected Member Functions | |
virtual void | mouseReleaseEvent (QMouseEvent *e) |
void | keyPressEvent (QKeyEvent *event) |
Private Slots | |
void | onSelectionChanged () |
Private Member Functions | |
void | insertSorted (RouterListItem *item) |
Private Attributes | |
QHash< QString, RouterListItem * > | _idmap |
QMenu * | _routerContextMenu |
QAction * | _zoomToRouterAct |
quint32 | _onlineRouterCount |
Definition at line 43 of file routerlistwidget.h.
Columns in the list.
StatusColumn | Status column, indicating bandwidth. |
CountryColumn | Router's country flag. |
NameColumn | Router's name. |
Definition at line 49 of file routerlistwidget.h.
RouterListWidget::RouterListWidget | ( | QWidget * | parent = 0 |
) |
Default constructor.
Definition at line 36 of file routerlistwidget.cpp.
References _onlineRouterCount, _routerContextMenu, _zoomToRouterAct, IMG_ZOOM, onSelectionChanged(), and StatusColumn.
void RouterListWidget::addRouter | ( | RouterDescriptor | rd | ) |
Adds a new descriptor the list.
Adds a router descriptor to the list.
Definition at line 208 of file routerlistwidget.cpp.
References _idmap, _onlineRouterCount, RouterListItem::descriptor(), findRouterById(), RouterDescriptor::id(), insertSorted(), and RouterDescriptor::online().
RouterListItem * RouterListWidget::findRouterByName | ( | QString | name | ) |
Finds the list item whose router nickname matches name. If more than one router exists with given name, the first match will be returned. Returns 0 if not found.
Finds the list item whose router nickname matches name. If more than one router exists with given name, the first match will be returned. Returns 0 if not found.
Definition at line 192 of file routerlistwidget.cpp.
References NameColumn.
RouterListItem * RouterListWidget::findRouterById | ( | QString | id | ) |
Finds the list item whose key ID matches id. Returns 0 if not found.
Definition at line 180 of file routerlistwidget.cpp.
References _idmap.
Referenced by addRouter().
void RouterListWidget::deselectAll | ( | ) |
Deselects all currently selected routers.
Definition at line 84 of file routerlistwidget.cpp.
Referenced by keyPressEvent().
void RouterListWidget::routerSelected | ( | RouterDescriptor | rd | ) | [signal] |
Emitted when the user selects a router from the list.
Referenced by onSelectionChanged().
void RouterListWidget::zoomToRouter | ( | QString | id | ) | [signal] |
Emitted when the user selects a router to zoom in on.
Referenced by mouseReleaseEvent().
void RouterListWidget::clearRouters | ( | ) | [slot] |
Clears the list of router items.
Clear the list of router items.
Definition at line 94 of file routerlistwidget.cpp.
References _idmap, and _onlineRouterCount.
void RouterListWidget::mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Called when the user presses and releases a moust button.
Called when the user presses and releases a mouse button. If the event indicates a right-click on a router item, a context menu will be displayed providing a list of actions, including zooming in on the server.
Definition at line 63 of file routerlistwidget.cpp.
References _routerContextMenu, _zoomToRouterAct, RouterListItem::id(), and zoomToRouter().
void RouterListWidget::onSelectionChanged | ( | ) | [private, slot] |
Called when the user clicks on an item in the list.
Called when the selected items have changed. This emits the routerSelected() signal with the descriptor for the selected router.
Definition at line 240 of file routerlistwidget.cpp.
References routerSelected().
Referenced by RouterListWidget().
void RouterListWidget::keyPressEvent | ( | QKeyEvent * | event | ) | [protected] |
Called when the user presses a key while the list has focus.
Called when the user selects a router from the list. This will search the list for a router whose names starts with the key pressed.
Definition at line 144 of file routerlistwidget.cpp.
References deselectAll(), and NameColumn.
void RouterListWidget::insertSorted | ( | RouterListItem * | item | ) | [private] |
Inserts a new item into the router list, maintaining the current order.
Inserts a new router list item into the list, in its proper sorted place according to the current sort column.
Definition at line 104 of file routerlistwidget.cpp.
Referenced by addRouter().
QHash<QString,RouterListItem*> RouterListWidget::_idmap [private] |
Maps a server ID to that server's list item.
Definition at line 98 of file routerlistwidget.h.
Referenced by addRouter(), clearRouters(), and findRouterById().
QMenu* RouterListWidget::_routerContextMenu [private] |
Router item context menu and items. Context menu for router items.
Definition at line 101 of file routerlistwidget.h.
Referenced by mouseReleaseEvent(), and RouterListWidget().
QAction* RouterListWidget::_zoomToRouterAct [private] |
Zooms in on the selected router.
Definition at line 102 of file routerlistwidget.h.
Referenced by mouseReleaseEvent(), and RouterListWidget().
quint32 RouterListWidget::_onlineRouterCount [private] |
Number of online routers.
Definition at line 103 of file routerlistwidget.h.
Referenced by addRouter(), clearRouters(), and RouterListWidget().