Changeset 2091
- Timestamp:
- 10/25/07 00:27:52 (10 months ago)
- Location:
- trunk
- Files:
-
- 6 modified
-
CHANGELOG (modified) (1 diff)
-
src/gui/network/circuitlistwidget.cpp (modified) (1 diff)
-
src/gui/network/circuitlistwidget.h (modified) (3 diffs)
-
src/gui/network/netviewer.ui (modified) (2 diffs)
-
src/gui/network/routerlistwidget.cpp (modified) (1 diff)
-
src/gui/network/routerlistwidget.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CHANGELOG
r2090 r2091 14 14 o If we prompt the user to enter a control password and they enter one, 15 15 don't keep trying to use our randomly generated password. 16 o Fix a bug in the network map that would cause the user to sometimes be 17 unable to select a circuit or server after clicking and dragging the mouse 18 in one of the lists. (Ticket #269) 16 19 o Stop leaking memory for pretty much every circuit we plotted on the network 17 20 map. Found by Roger Dingledine and his Valgrind. -
trunk/src/gui/network/circuitlistwidget.cpp
r1627 r2091 50 50 connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), 51 51 this, SLOT(onSelectionChanged(QTreeWidgetItem*,QTreeWidgetItem*))); 52 53 /* Set up the circuit item context menu */ 54 _circuitContextMenu = new QMenu(this); 55 _zoomCircuitAct = new QAction(QIcon(IMG_ZOOM), tr("Zoom to Circuit"), this); 56 _closeCircuitAct = new QAction(QIcon(IMG_CLOSE), tr("Close Circuit"), this); 57 _circuitContextMenu->addAction(_zoomCircuitAct); 58 _circuitContextMenu->addSeparator(); 59 _circuitContextMenu->addAction(_closeCircuitAct); 60 /* Set up the stream item context menu */ 61 _streamContextMenu = new QMenu(this); 62 _closeStreamAct = new QAction(QIcon(IMG_CLOSE), tr("Close Stream"), this); 63 _streamContextMenu->addAction(_closeStreamAct); 64 } 65 66 /** Called when the user presses and releases a mouse button. If the event 67 * indicates a right-click and a circuit or stream is selected, an appropriate 68 * context menu will be displayed. */ 69 void 70 CircuitListWidget::mouseReleaseEvent(QMouseEvent *e) 71 { 72 if (e->button() == Qt::RightButton) { 73 /* Find out which item was right-clicked */ 74 QTreeWidgetItem *item = itemAt(e->pos()); 75 if (!item) { 52 connect(this, SIGNAL(customContextMenuRequested(QPoint)), 53 this, SLOT(customContextMenuRequested(QPoint))); 54 } 55 56 /** Called when the user requests a context menu on a circuit or stream in the 57 * list and displays a context menu appropriate for whichever type of item is 58 * currently selected. */ 59 void 60 CircuitListWidget::customContextMenuRequested(const QPoint &pos) 61 { 62 QMenu menu(this); 63 64 /* Find out which item was right-clicked */ 65 QTreeWidgetItem *item = itemAt(pos); 66 if (!item) 67 return; 68 69 if (!item->parent()) { 70 /* A circuit was selected */ 71 CircuitItem *circuitItem = dynamic_cast<CircuitItem *>(item); 72 if (!circuitItem) 76 73 return; 77 } 78 79 Q Point pos = e->globalPos();80 if (!item->parent()) {81 /* Circuit was right-clicked */82 Circuit circ = ((CircuitItem *)item)->circuit();83 quint64 circid = circ.id();84 _zoomCircuitAct->setEnabled((circ.status() == Circuit::Built));74 75 /* Set up the circuit context menu */ 76 QAction *zoomAct = new QAction(QIcon(IMG_ZOOM),tr("Zoom to Circuit"),this); 77 QAction *closeAct = new QAction(QIcon(IMG_CLOSE), tr("Close Circuit"),this); 78 zoomAct->setEnabled(circuitItem->circuit().status() == Circuit::Built); 79 menu.addAction(zoomAct); 80 menu.addSeparator(); 81 menu.addAction(closeAct); 85 82 86 QAction* action = _circuitContextMenu->exec(pos); 87 if (action == _closeCircuitAct) { 88 emit closeCircuit(circid); 89 } else if (action == _zoomCircuitAct) { 90 emit zoomToCircuit(circid); 91 } 92 } else { 93 /* Stream was right-clicked */ 94 quint64 streamid = ((StreamItem *)item)->id(); 95 QAction* action = _streamContextMenu->exec(pos); 96 if (action == _closeStreamAct) { 97 emit closeStream(streamid); 98 } 99 } 83 /* Display the context menu and find out which (if any) action was 84 * selected */ 85 QAction* action = menu.exec(mapToGlobal(pos)); 86 if (action == closeAct) 87 emit closeCircuit(circuitItem->id()); 88 else if (action == zoomAct) 89 emit zoomToCircuit(circuitItem->id()); 90 } else { 91 /* A stream was selected */ 92 StreamItem *streamItem = dynamic_cast<StreamItem *>(item); 93 if (!streamItem) 94 return; 95 96 /* Set up the stream context menu */ 97 QAction *closeAct = new QAction(QIcon(IMG_ZOOM), tr("Close Stream"), this); 98 menu.addAction(closeAct); 99 100 /* Display the context menu and find out which (if any) action was 101 * selected */ 102 QAction* action = menu.exec(mapToGlobal(pos)); 103 if (action == closeAct) 104 emit closeStream(streamItem->id()); 100 105 } 101 106 } -
trunk/src/gui/network/circuitlistwidget.h
r1641 r2091 78 78 void clearCircuits(); 79 79 80 protected:81 /** Called when the user presses and releases a mouse button. */82 virtual void mouseReleaseEvent(QMouseEvent *e);83 84 80 private slots: 85 81 /** Removes the first circuit scheduled to be removed.*/ … … 89 85 /** Called when the current item selectio has changed. */ 90 86 void onSelectionChanged(QTreeWidgetItem *cur, QTreeWidgetItem *prev); 91 87 /** Called when the user requests a context menu on a circuit or stream in 88 * the list and displays a context menu appropriate for whichever type of 89 * item is currently selected. */ 90 void customContextMenuRequested(const QPoint &pos); 91 92 92 private: 93 93 /** Removes the given circuit item and all streams on that circuit. */ … … 104 104 void scheduleStreamRemoval(StreamItem *stream, int delay); 105 105 106 /* Circuit and stream context menus and items */107 QMenu* _circuitContextMenu; /**< Context menu for circuit items. */108 QAction* _closeCircuitAct; /**< Closes a circuit. */109 QAction* _zoomCircuitAct; /**< Zoom to a circuit. */110 QMenu* _streamContextMenu; /**< Context menu for stream items. */111 QAction* _closeStreamAct; /**< Closes a stream. */112 113 106 /** List of circuit items to be removed. */ 114 107 QList<CircuitItem *> _circuitRemovalList; -
trunk/src/gui/network/netviewer.ui
r2073 r2091 65 65 </property> 66 66 <property name="contextMenuPolicy" > 67 <enum>Qt:: NoContextMenu</enum>67 <enum>Qt::CustomContextMenu</enum> 68 68 </property> 69 69 <property name="statusTip" > … … 172 172 </property> 173 173 <property name="contextMenuPolicy" > 174 <enum>Qt:: NoContextMenu</enum>174 <enum>Qt::CustomContextMenu</enum> 175 175 </property> 176 176 <property name="statusTip" > -
trunk/src/gui/network/routerlistwidget.cpp
r2057 r2091 50 50 connect(this, SIGNAL(itemSelectionChanged()), 51 51 this, SLOT(onSelectionChanged())); 52 53 /* Set up the router item context menu */ 54 _routerContextMenu = new QMenu(this); 55 _zoomToRouterAct = new QAction(QIcon(IMG_ZOOM), tr("Zoom to Relay"), this); 56 _routerContextMenu->addAction(_zoomToRouterAct); 57 } 58 59 /** Called when the user presses and releases a mouse button. If the event 60 * indicates a right-click on a router item, a context menu will be displayed 61 * providing a list of actions, including zooming in on the server. */ 62 void 63 RouterListWidget::mouseReleaseEvent(QMouseEvent *e) 64 { 65 if (e->button() == Qt::RightButton) { 66 /* Find out which server was right-clicked */ 67 RouterListItem *item = (RouterListItem *)itemAt(e->pos()); 68 if (!item) { 69 return; 70 } 71 72 /* Display a context menu for this router item */ 73 QPoint pos = e->globalPos(); 74 QAction *action = _routerContextMenu->exec(pos); 75 if (action == _zoomToRouterAct) { 76 /* Zoom in on this router */ 77 emit zoomToRouter(item->id()); 78 } 79 } 52 connect(this, SIGNAL(customContextMenuRequested(QPoint)), 53 this, SLOT(customContextMenuRequested(QPoint))); 54 } 55 56 /** Called when the user requests a context menu for a router in the list. A 57 * context menu will be displayed providing a list of actions, including 58 * zooming in on the server. */ 59 void 60 RouterListWidget::customContextMenuRequested(const QPoint &pos) 61 { 62 QMenu menu(this); 63 64 /* Find out which (if any) router in the list is selected */ 65 RouterListItem *item = dynamic_cast<RouterListItem *>(itemAt(pos)); 66 if (!item) 67 return; 68 69 /* Set up the context menu */ 70 QAction *zoomAction = 71 new QAction(QIcon(IMG_ZOOM), tr("Zoom to Relay"), &menu); 72 menu.addAction(zoomAction); 73 74 /* Display the menu and find out which (if any) action was selected */ 75 QAction *action = menu.exec(mapToGlobal(pos)); 76 if (action == zoomAction) 77 emit zoomToRouter(item->id()); 80 78 } 81 79 -
trunk/src/gui/network/routerlistwidget.h
r1638 r2091 79 79 void clearRouters(); 80 80 81 protected:82 /** Called when the user presses and releases a moust button. */83 virtual void mouseReleaseEvent(QMouseEvent *e);84 85 81 private slots: 86 82 /** Called when the user clicks on an item in the list. */ 87 83 void onSelectionChanged(); 84 /** Called when the user requests a context menu for some router in the 85 * list. */ 86 void customContextMenuRequested(const QPoint &pos); 88 87 89 88 protected: … … 97 96 /** Maps a server ID to that server's list item. */ 98 97 QHash<QString,RouterListItem*> _idmap; 99 100 /** Router item context menu and items. */101 QMenu* _routerContextMenu; /**< Context menu for router items. */102 QAction* _zoomToRouterAct; /**< Zooms in on the selected router. */103 98 quint32 _onlineRouterCount; /**< Number of online routers. */ 104 99 };
