/** Constructor */ NetworkDialog::NetworkDialog(QWidget *parent) : MainPage(parent), connectdialog(NULL) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); connect( ui.connecttreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) ); /* create a single connect dialog */ connectdialog = new ConnectDialog(); connect(ui.infoLog, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoLogMenu(const QPoint&))); /* hide the Tree +/- */ ui.connecttreeWidget -> setRootIsDecorated( false ); /* Set header resize modes and initial section sizes */ QHeaderView * _header = ui.connecttreeWidget->header () ; _header->setResizeMode (0, QHeaderView::Custom); _header->setResizeMode (1, QHeaderView::Interactive); _header->setResizeMode (2, QHeaderView::Interactive); _header->setResizeMode (3, QHeaderView::Interactive); _header->setResizeMode (4, QHeaderView::Interactive); _header->setResizeMode (5, QHeaderView::Interactive); _header->setResizeMode (6, QHeaderView::Interactive); _header->setResizeMode (7, QHeaderView::Interactive); _header->setResizeMode (8, QHeaderView::Interactive); _header->setResizeMode (9, QHeaderView::Interactive); _header->resizeSection ( 0, 25 ); _header->resizeSection ( 1, 100 ); _header->resizeSection ( 2, 100 ); _header->resizeSection ( 3, 100 ); _header->resizeSection ( 4, 100 ); _header->resizeSection ( 5, 200); _header->resizeSection ( 6, 100 ); _header->resizeSection ( 7, 100 ); _header->resizeSection ( 8, 100 ); _header->resizeSection ( 9, 100 ); // set header text aligment QTreeWidgetItem * headerItem = ui.connecttreeWidget->headerItem(); headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(4, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(5, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(6, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(7, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(8, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(9, Qt::AlignHCenter | Qt::AlignVCenter); /*networkview = new NetworkView(ui.networkviewTab); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(networkview); ui.networkviewTab->setLayout(layout); layout->setSpacing( 0 ); layout->setMargin( 0 );*/ ui.networkTab->addTab(new NetworkView(),QString(tr("Network View"))); ui.networkTab->addTab(new TrustView(),QString(tr("Trust matrix"))); // Set Log infos setLogInfo(tr("RetroShare %1 started.", "e.g: RetroShare v0.x started.").arg(retroshareVersion())); setLogInfo(tr("Welcome to RetroShare."), QString::fromUtf8("blue")); QMenu *menu = new QMenu(tr("View")); menu->addAction(ui.actionTabsright); menu->addAction(ui.actionTabswest); menu->addAction(ui.actionTabssouth); menu->addAction(ui.actionTabsnorth); menu->addSeparator(); menu->addAction(ui.actionTabsTriangular); menu->addAction(ui.actionTabsRounded); ui.viewButton->setMenu(menu); QTimer *timer = new QTimer(this); timer->connect(timer, SIGNAL(timeout()), this, SLOT(getNetworkStatus())); timer->start(100000); QTimer *timer2 = new QTimer(this); timer2->connect(timer, SIGNAL(timeout()), this, SLOT(updateNetworkStatus())); timer2->start(1000); getNetworkStatus(); updateNetworkStatus(); //load(); /* Hide platform specific features */ #ifdef Q_WS_WIN #endif }
void Kommute::customEvent(QEvent *e) { int c; QModelIndex index; bool found = false; switch(e->type()) { case KommuteDefs::EVENTTYPE_CLEARCONNECTIONS: c = ConnectionsListModel->rowCount(); ConnectionsListModel->removeRows(0,c); break; case KommuteDefs::EVENTTYPE_CONNECTION: c = ConnectionsListModel->rowCount(); ConnectionsListModel->insertRow(c); index = ConnectionsListModel->index(c, ConnectionsListDelegate::CICON); ConnectionsListModel->setData(index, QIcon(QString::fromUtf8(":/resources/contact0.png")), Qt::DecorationRole); if (static_cast<ConnectionEvent*>(e)->queuedCount > 0) { ConnectionsListModel->setData(index, QIcon(QString::fromUtf8(":/resources/contact2.png")), Qt::DecorationRole); } if (static_cast<ConnectionEvent*>(e)->queuedCount > 100) { ConnectionsListModel->setData(index, QIcon(QString::fromUtf8(":/resources/contact3.png")), Qt::DecorationRole); } index = ConnectionsListModel->index(c, ConnectionsListDelegate::ADDRESS); ConnectionsListModel->setData(index, static_cast<ConnectionEvent*>(e)->address); index = ConnectionsListModel->index(c, ConnectionsListDelegate::PORT); ConnectionsListModel->setData(index, static_cast<ConnectionEvent*>(e)->port); index = ConnectionsListModel->index(c, ConnectionsListDelegate::SENT); ConnectionsListModel->setData(index, static_cast<ConnectionEvent*>(e)->sentCount); index = ConnectionsListModel->index(c, ConnectionsListDelegate::QUEUED); ConnectionsListModel->setData(index, static_cast<ConnectionEvent*>(e)->queuedCount); index = ConnectionsListModel->index(c, ConnectionsListDelegate::DROPPED); ConnectionsListModel->setData(index, static_cast<ConnectionEvent*>(e)->droppedCount); break; case KommuteDefs::EVENTTYPE_CONNECTIONCOUNT: emit connectionCountChanged(static_cast<ConnectionCountEvent*>(e)->connectionCount); break; case KommuteDefs::EVENTTYPE_CONNECTIONATTEMPT: emit currentConnectionAttempt(static_cast<ConnectionAttemptEvent*>(e)->attemptAddress, static_cast<ConnectionAttemptEvent*>(e)->attemptPort ); break; case KommuteDefs::EVENTTYPE_UPLOAD: for (QTreeWidgetItemIterator it(uploadsList); *it; ++it ) { if(static_cast<UploadEvent*>(e)->uploadID == static_cast<UploadListItem*>(*it)->uploadID()) { // Update existing upload found = true; static_cast<UploadListItem*>(*it)->setProgress(static_cast<UploadEvent*>(e)->lastChunkSent, static_cast<UploadEvent*>(e)->chunksInFile, static_cast<UploadDefs::UploadStatus>(static_cast<UploadEvent*>(e)->status)); break; } } if(!found) { // Create new upload entry new UploadListItem( uploadsList, static_cast<UploadEvent*>(e)->filePath, static_cast<UploadEvent*>(e)->host, static_cast<UploadEvent*>(e)->uploadID ); } break; case KommuteDefs::EVENTTYPE_UPLOADSCOUNT: emit numberOfUploadsChanged( static_cast<UploadsCountEvent*>(e)->uploadsCount ); break; case KommuteDefs::EVENTTYPE_SHAREDFILES: { c = SFListModel->rowCount(); SFListModel->insertRow(c); index = SFListModel->index(c, SFListDelegate::SFNAME); SFListModel->setData(index, static_cast<SharedFilesEvent*>(e)->fileName); index = SFListModel->index(c, SFListDelegate::SFSIZE); SFListModel->setData(index, static_cast<unsigned long long int>(static_cast<SharedFilesEvent*>(e)->fileLength)); index = SFListModel->index(c, SFListDelegate::SFHASH); SFListModel->setData(index, static_cast<SharedFilesEvent*>(e)->fileHash); index = SFListModel->index(c, SFListDelegate::SFFULLPATH); SFListModel->setData(index, static_cast<SharedFilesEvent*>(e)->filePath); QString ext = QFileInfo(static_cast<SharedFilesEvent*>(e)->fileName).suffix(); KommuteDefs::FileType fileType = misc::fileType(ext); SFListModel->setData(SFListModel->index(c,SFListDelegate::SFNAME), QIcon(KommuteDefs::FileTypeResourcePath[fileType]), Qt::DecorationRole); SFListModel->setData(SFListModel->index(c,SFListDelegate::SFTYPE), KommuteDefs::tr(KommuteDefs::FileTypeName[fileType])); break; } case KommuteDefs::EVENTTYPE_ADDLOG: setLogInfo( static_cast<AddLogEvent*>(e)->logText); break; default: break; } }
void NetworkDialog::getNetworkStatus() { rsiface->lockData(); /* Lock Interface */ /* now the extra bit .... switch on check boxes */ const RsConfig &config = rsiface->getConfig(); /****** Log Tab **************************/ if(config.netUpnpOk) { setLogInfo(tr("UPNP is active."), QString::fromUtf8("blue")); } else { setLogInfo(tr("UPNP NOT FOUND."), QString::fromUtf8("red")); } if(config.netDhtOk) { setLogInfo(tr("DHT OK"), QString::fromUtf8("green")); } else { setLogInfo(tr("DHT is not working (down)."), QString::fromUtf8("red")); } if(config.netExtOk) { setLogInfo(tr("Stable External IP Address"), QString::fromUtf8("green")); } else { setLogInfo(tr("Not Found External Address"), QString::fromUtf8("red")); } if(config.netUdpOk) { setLogInfo(tr("UDP Port is active (UDP Connections)"), QString::fromUtf8("green")); } else { setLogInfo(tr("UDP Port is not active"), QString::fromUtf8("red")); } if(config.netTcpOk) { setLogInfo(tr("TCP Port is active (TCP Server)"), QString::fromUtf8("green")); } else { setLogInfo(tr("TCP Port is not active"), QString::fromUtf8("red")); } if (config.netExtOk) { if (config.netUpnpOk || config.netTcpOk) { setLogInfo(tr("RetroShare Server"), QString::fromUtf8("green")); } else { setLogInfo(tr("UDP Server"), QString::fromUtf8("green")); } } else if (config.netOk) { setLogInfo(tr("Net Limited"), QString::fromUtf8("magenta")); } else { setLogInfo(tr("No Conectivity"), QString::fromUtf8("red")); } rsiface->unlockData(); /* UnLock Interface */ }