mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-03-22 23:07:14 -04:00
added these missign files
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1541 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a293a39d1b
commit
53dd3019fb
96
retroshare-gui/src/gui/TurtleRouterDialog.cpp
Normal file
96
retroshare-gui/src/gui/TurtleRouterDialog.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
#include <iostream>
|
||||
#include <QTimer>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <rsiface/rsturtle.h>
|
||||
#include "TurtleRouterDialog.h"
|
||||
|
||||
TurtleRouterDialog *TurtleRouterDialog::_instance = NULL ;
|
||||
|
||||
TurtleRouterDialog::TurtleRouterDialog(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this) ;
|
||||
|
||||
_timer = new QTimer ;
|
||||
|
||||
connect(_timer,SIGNAL(timeout()),this,SLOT(update())) ;
|
||||
|
||||
_timer->start(2000) ;
|
||||
|
||||
connect( _hashes_TW, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showCtxMenu(const QPoint&)));
|
||||
}
|
||||
|
||||
void TurtleRouterDialog::showCtxMenu(const QPoint& point)
|
||||
{
|
||||
std::cerr << "execing context menu" << std::endl ;
|
||||
// create context menus.
|
||||
QMenu contextMnu( this );
|
||||
QAction *removeHashAction = new QAction(QIcon(":/images/delete.png"), tr("Stop handling this hash"), this);
|
||||
connect(removeHashAction , SIGNAL(triggered()), this, SLOT(removeFileHash()));
|
||||
contextMnu.addAction(removeHashAction);
|
||||
|
||||
QMouseEvent *mevent = new QMouseEvent(QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier ) ;
|
||||
contextMnu.exec( mevent->globalPos() );
|
||||
}
|
||||
|
||||
void TurtleRouterDialog::showUp()
|
||||
{
|
||||
if(_instance == NULL)
|
||||
_instance = new TurtleRouterDialog ;
|
||||
|
||||
_instance->show() ;
|
||||
}
|
||||
|
||||
void TurtleRouterDialog::removeFileHash()
|
||||
{
|
||||
QTableWidgetItem *item = _hashes_TW->currentItem();
|
||||
|
||||
std::cout << "in remove hash " << std::endl ;
|
||||
if(item == NULL)
|
||||
return ;
|
||||
|
||||
std::cout << "item->row = " << item->row() << std::endl ;
|
||||
std::string hash = _hashes_TW->item(item->row(),0)->text().toStdString() ;
|
||||
|
||||
std::cout << "remove ing hash: " << hash << std::endl ;
|
||||
|
||||
rsTurtle->stopMonitoringFileTunnels(hash) ;
|
||||
}
|
||||
|
||||
void TurtleRouterDialog::update()
|
||||
{
|
||||
std::cout << "updatign turtle router console."<< std::endl ;
|
||||
|
||||
std::vector<std::vector<std::string> > hashes_info ;
|
||||
std::vector<std::vector<std::string> > tunnels_info ;
|
||||
std::vector<std::vector<std::string> > search_reqs_info ;
|
||||
std::vector<std::vector<std::string> > tunnel_reqs_info ;
|
||||
|
||||
rsTurtle->getInfo(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ;
|
||||
|
||||
// now display this in the QTableWidgets
|
||||
|
||||
fillTable( _hashes_TW, hashes_info) ;
|
||||
fillTable( _tunnels_TW, tunnels_info) ;
|
||||
fillTable( _tunnel_reqs_TW, tunnel_reqs_info) ;
|
||||
fillTable( _search_reqs_TW, search_reqs_info) ;
|
||||
}
|
||||
|
||||
void TurtleRouterDialog::fillTable(QTableWidget *table,const std::vector<std::vector<std::string> >& data)
|
||||
{
|
||||
// table->clearContents() ;
|
||||
|
||||
for(uint i=0;i<data.size();++i)
|
||||
{
|
||||
if(table->rowCount() <= i)
|
||||
table->insertRow(i) ;
|
||||
|
||||
for(uint j=0;j<data[i].size();++j)
|
||||
table->setItem(i,j,new QTableWidgetItem(QString::fromStdString(data[i][j]))) ;
|
||||
}
|
||||
|
||||
for(uint i=data.size();i<table->rowCount();)
|
||||
table->removeRow(i) ;
|
||||
}
|
||||
|
25
retroshare-gui/src/gui/TurtleRouterDialog.h
Normal file
25
retroshare-gui/src/gui/TurtleRouterDialog.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <QPoint>
|
||||
#include "ui_TurtleRouterDialog.h"
|
||||
|
||||
class TurtleRouterDialog: public QWidget, public Ui::TurtleRouterDialogForm
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static void showUp() ;
|
||||
|
||||
/** Default Constructor */
|
||||
protected slots:
|
||||
void update() ;
|
||||
void showCtxMenu(const QPoint&) ;
|
||||
void removeFileHash() ;
|
||||
|
||||
private:
|
||||
void fillTable(QTableWidget *table,const std::vector<std::vector<std::string> >&) ;
|
||||
TurtleRouterDialog(QWidget *parent = NULL) ;
|
||||
QTimer *_timer ;
|
||||
|
||||
static TurtleRouterDialog *_instance ;
|
||||
} ;
|
199
retroshare-gui/src/gui/TurtleRouterDialog.ui
Normal file
199
retroshare-gui/src/gui/TurtleRouterDialog.ui
Normal file
@ -0,0 +1,199 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TurtleRouterDialogForm</class>
|
||||
<widget class="QWidget" name="TurtleRouterDialogForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>462</width>
|
||||
<height>512</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Hashes and Tunnels</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Handled file hashes</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="_hashes_TW">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>File hash</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>File Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Active tunnels</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Last tunnel request</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Current tunnels</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="_tunnels_TW">
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Tunnel id</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Source</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Destination</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Hash</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Last transfer</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
<string>Tunnels / Search Requests</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Tunnel Requests</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="_tunnel_reqs_TW">
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Request id</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Origin</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Age</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Search Requests</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="_search_reqs_TW">
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Request id</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Origin</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Age</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
x
Reference in New Issue
Block a user