예제 #1
1
QWidget* CarManagePage::CreateStructureWidget()
{
	QGroupBox* structureWidget = new QGroupBox();

	QHBoxLayout* hBox = new QHBoxLayout();
	QToolButton* add = new QToolButton();
	add->setText("+");
	QToolButton* remove = new QToolButton();
	remove->setText( "-" );
	hBox->addWidget( add );
	hBox->addWidget( remove );
	hBox->addStretch( 1 );

	QTreeWidget* tree = new QTreeWidget();
	tree->setColumnCount( 1 );
	QTreeWidgetItem* root = new QTreeWidgetItem( QStringList( tr( "DaQing GPS Center") ) );
	QTreeWidgetItem* child1 = new QTreeWidgetItem( QStringList( tr( "test1" ) ) );
	QTreeWidgetItem* child2 = new QTreeWidgetItem( QStringList( tr( "test2" ) ) );
	root->addChild( child1 );
	root->addChild( child2 );
	root->setCheckState( 0, Qt::Unchecked );
	child1->setCheckState( 0, Qt::Unchecked );
	child2->setCheckState( 0, Qt::Unchecked );

	tree->addTopLevelItem( root );
	tree->expandAll();
	QVBoxLayout* vBox = new QVBoxLayout();
	vBox->addLayout( hBox );
	vBox->addWidget( tree );

	structureWidget->setLayout( vBox );
	return structureWidget;
}
예제 #2
0
void EditTache::loadProjects()
{
    ProjetManager& manager = ProjetManager::Instance();
    unsigned int nbProj = manager.getNb();

    QTreeWidget * tree = ui->treeWidget;


    for(int i = 0; i < nbProj; i++)
    {
        QTreeWidgetItem * projet = new QTreeWidgetItem();

        Projet& proj = manager.getProjet(i);
        unsigned int nbTaches = proj.getNb();
        projet->setText(0, QString::fromStdString(proj.getTitre()));

        for(int i=0; i < nbTaches; i++)
        {
            QTreeWidgetItem * tache = new QTreeWidgetItem();
            Tache& t = proj.getTache(i);
            tache->setText(0, QString::fromStdString(t.getTitre()));
            projet->addChild(tache);
        }
        tree->addTopLevelItem(projet);
    }

}
예제 #3
0
void StatsView::addToTree(std::vector<StatsContainer *>& stats, QTreeWidgetItem *parent) {
	QTreeWidget *statsTree = this->findChild<QTreeWidget *>("statsTree");
	for (int i=0; i<stats.size(); ++i) {
		StatsContainer *stat = stats[i];
		DataContainerTreeItem *boostNode;
		if (parent != 0) {
			boostNode = new DataContainerTreeItem(parent);
		}
		else {
			boostNode = new DataContainerTreeItem();
			statsTree->addTopLevelItem(boostNode);
		}
		std::string statText = stat->getArg(0);
		boostNode->setData(statText);
		if (nameMappings.find(statText) != nameMappings.end()) {
			statText = nameMappings[statText] + "    (" + statText + ")";
		} else if (stat->getPrefixList().size() > 0 || stat->getSuffixList().size() > 0) {
			if (stat->getPrefixList().size() > 0) {
				statText = stat->getPrefixList()[0] + "    (" + statText + ")";
			} else if (stat->getSuffixList().size() > 0) {
				statText = stat->getSuffixList()[0] + "    (" + statText + ")";
			}
		}
		boostNode->setText(0, statText.c_str());
	}
}
void PListEditorWidget::reloadGui(void )
{
	QTreeWidget* tree = m_ui.plistTree;
	tree->clear();

	QTreeWidgetItem* rootNode = NULL;
	
	if (m_currentPlist)
	{
		// Add information
		if (m_currentPlist->GetType() == PLIST_ARRAY)
		{
			rootNode = generateArrayItem (m_currentPlist);
			rootNode->setText (NameColumn, "Root");
		}
		else if (m_currentPlist->GetType() == PLIST_DICT)
		{
			rootNode = generateDictionaryItem (m_currentPlist);
			rootNode->setText (NameColumn, "Root");
		}
	}
	
	if (rootNode)
		tree->addTopLevelItem(rootNode);
	
	tree->expandAll();
	
	for (int x=0; x < tree->columnCount(); ++x)
		tree->resizeColumnToContents(x);
}
예제 #5
0
DataContainerTreeItem *StatsView::addFolder(std::string folderName) {
	QTreeWidget *statsTree = this->findChild<QTreeWidget *>("statsTree");
	DataContainerTreeItem *item = new DataContainerTreeItem();
	statsTree->addTopLevelItem(item);
	item->setText(0, folderName.c_str());
	return item;
}
예제 #6
0
파일: leyrat.cpp 프로젝트: Leystryku/leyrat
void leyrat::Callback_FileList(const char *ip, char**files, int numfiles)
{
    Log("[R][%s] Listed files!\n", ip);
    //you could also create it dinamically

    if(numfiles==1)
        return;

    QTreeWidget * tree = fbrowser->treeWidget;


    while(tree->topLevelItemCount())
    {
        tree->takeTopLevelItem(0);

    }

    QTreeWidgetItem* header = tree->headerItem();

    const QByteArray headerbytes = header->text(0).toLatin1();

    if(strcmp(files[0], "C:/*.*")!=0)
    {
        QTreeWidgetItem * item = new QTreeWidgetItem();
        item->setText(0, "..");
        tree->addTopLevelItem(item);

    }

    for(int i=1; i<numfiles; i++)
    {

        QTreeWidgetItem * item = new QTreeWidgetItem();

        if(!strcmp(files[i], "..")||!strcmp(files[i], "."))
            continue;

        item->setText(0, files[i]);
        tree->addTopLevelItem(item);
    }

    files[0][strlen(files[0])-3] = 0;

    header->setText(0, files[0]);
}
예제 #7
0
파일: sweeper.cpp 프로젝트: KDE/sweeper
Sweeper::Sweeper(bool automatic)
   : KXmlGuiWindow(0)
   , m_privacyConfGroup(KSharedConfig::openConfig(QLatin1String( "kprivacyrc" ), KConfig::NoGlobals), "Cleaning")
   , m_automatic(automatic)
{
   QWidget *mainWidget = new QWidget(this);
   ui.setupUi(mainWidget);
   setCentralWidget(mainWidget);

   QTreeWidget *sw = ui.privacyListView;

   KStandardAction::quit(this, SLOT(close()), actionCollection());

   createGUI(QLatin1String( "sweeperui.rc" ));

   setAutoSaveSettings();

   generalCLI     = new QTreeWidgetItem(QStringList() << i18nc("General system content", "General"));
   sw->addTopLevelItem(generalCLI);
   webbrowsingCLI = new QTreeWidgetItem(QStringList() << i18nc("Web browsing content", "Web Browsing"));
   sw->addTopLevelItem(webbrowsingCLI);

   generalCLI->setExpanded(true);
   webbrowsingCLI->setExpanded(true);

   this->InitActions();


   connect(ui.cleanupButton, SIGNAL(clicked()), SLOT(cleanup()));
   connect(ui.selectAllButton, SIGNAL(clicked()), SLOT(selectAll()));
   connect(ui.selectNoneButton, SIGNAL(clicked()), SLOT(selectNone()));

   new KsweeperAdaptor(this);
   QDBusConnection::sessionBus().registerObject(QLatin1String( "/ksweeper" ), this);

   load();

   if(automatic) {
      cleanup();
      close();
   }
}
예제 #8
0
void StatsView::addIndividualDataItemToTree(std::string dataName, QTreeWidgetItem *parent) {
	QTreeWidget *statsTree = this->findChild<QTreeWidget *>("statsTree");
	DataContainerTreeItem *dataNode;
	if (parent != 0) {
		dataNode = new DataContainerTreeItem(parent);
	}
	else {
		dataNode = new DataContainerTreeItem();
		statsTree->addTopLevelItem(dataNode);
	}
	dataNode->setData("");
	dataNode->setText(0, dataName.c_str());
}
예제 #9
0
		bool startElement(const QString&, const QString&, const QString& qName, const QXmlAttributes& attrs)
		{
			if (qName == "item")
			{
				//TODO : This will dump items if bookmarks get loaded into a different GUI language
				if (quickHelpIndex->contains(attrs.value(1)))
				{
					bookmarkIndex->insert(attrs.value(0), qMakePair(attrs.value(1), attrs.value(2)));
					view->addTopLevelItem(new QTreeWidgetItem(view, QStringList() << attrs.value(0)));
				}
			}
			return true;
		}
예제 #10
0
void SceneDockWidget::rebuildSceneGraph()
{
    SceneData* data = controller->getSceneData();

    QTreeWidget* sceneGraph = ui->treeWidgetSceneGraph;

    QTreeWidgetItem* top;
    while((top = sceneGraph->takeTopLevelItem(0)) != 0);

    QTreeWidgetItem* root = createNodeItem(data->rootNode);
    sceneGraph->addTopLevelItem(root);

    sceneGraph->expandAll();
}
예제 #11
0
void MostrarArvoreSintatica(ArvoreSintatica *ar)
{
    QStringList headers;
    headers.append("Descricao");
    headers.append("Nivel Lexico");
    headers.append("Terminal");
    QTreeWidget *tree = new QTreeWidget(0);
    QTreeWidgetItem *item = new QTreeWidgetItem();
    ar->toTree(item);
    tree->setColumnCount(3);
    tree->setHeaderLabels(headers);
    tree->addTopLevelItem(item);
    tree->show();
}
예제 #12
0
void StatsView::addToTree(std::vector<LsbObject *>& objects, QTreeWidgetItem *parent) {
	QTreeWidget *statsTree = this->findChild<QTreeWidget *>("statsTree");
	for (int i=0; i<objects.size(); ++i) {
		LsbObject *object = objects[i];
		DataContainerTreeItem *boostNode;
		if (parent != 0) {
			boostNode = new DataContainerTreeItem(parent);
		}
		else {
			boostNode = new DataContainerTreeItem();
			statsTree->addTopLevelItem(boostNode);
		}
		std::string objectText = object->getName();
		boostNode->setData(object->toString());
		boostNode->setText(0, objectText.c_str());
	}
}
예제 #13
0
    typename ItemTypeMap<EntityContainer>::T* add_collection_item(
        Scene&              scene,
        EntityContainer&    entities,
        ProjectBuilder&     project_builder)
    {
        typedef typename ItemTypeMap<EntityContainer>::T ItemType;

        ItemType* item =
            new ItemType(
            scene,
            entities,
            project_builder);

        m_tree_widget->addTopLevelItem(item);

        return item;
    }
예제 #14
0
    EnvironmentItem* add_environment_item(
        Scene&              scene,
        Environment*        environment,
        ProjectBuilder&     project_builder)
    {
        EnvironmentItem* item =
            new EnvironmentItem(
            environment,
            scene,
            project_builder);

        item->set_allow_deletion(false);

        m_tree_widget->addTopLevelItem(item);

        return item;
    }
예제 #15
0
    CameraItem* add_camera_item(
        Scene&              scene,
        Camera*             camera,
        ProjectBuilder&     project_builder)
    {
        CameraItem* item =
            new CameraItem(
            camera,
            scene,
            project_builder);

        item->set_allow_deletion(false);

        m_tree_widget->addTopLevelItem(item);

        return item;
    }
예제 #16
0
    CollectionItem<Entity, Scene>* add_multi_model_collection_item(
        Scene&              scene,
        EntityContainer&    entities,
        ProjectBuilder&     project_builder)
    {
        CollectionItem<Entity, Scene>* item =
            new MultiModelCollectionItem<Entity, Scene>(
            new_guid(),
            EntityTraits<Entity>::get_human_readable_collection_type_name(),
            scene,
            project_builder);

        item->add_items(entities);

        m_tree_widget->addTopLevelItem(item);

        return item;
    }
예제 #17
0
void ProfileManager::fillIdentities()
{
	ui.identityTreeWidget->clear();

	ui.identityTreeWidget->setColumnWidth(COLUMN_NAME, 200);
	ui.identityTreeWidget->setColumnWidth(COLUMN_EMAIL, 200);

	RsPgpId own_pgp_id = rsPeers->getGPGOwnId() ;

	std::cerr << "Finding PGPUsers" << std::endl;

	QTreeWidget *identityTreeWidget = ui.identityTreeWidget;

	QTreeWidgetItem *item;

    std::list<RsPgpId> pgpIds;
    std::list<RsPgpId>::iterator it;

	if (RsAccounts::GetPGPLogins(pgpIds)) {
		for (it = pgpIds.begin(); it != pgpIds.end(); ++it) {
			std::string name, email;
			RsAccounts::GetPGPLoginDetails(*it, name, email);
			std::cerr << "Adding PGPUser: "******" id: " << *it << std::endl;
            QString gid = QString::fromStdString((*it).toStdString());

			item = new RSTreeWidgetItem(NULL, 0);
			item -> setText(COLUMN_NAME, QString::fromUtf8(name.c_str()));
			item -> setText(COLUMN_EMAIL, QString::fromUtf8(email.c_str()));
			item -> setText(COLUMN_GID, gid);
			identityTreeWidget->addTopLevelItem(item);

			if(own_pgp_id == *it) 
			{
				item->setSelected(true) ;
				ui.exportIdentity_PB->setEnabled(true);
			}
		}
	}

//	for (int i = 0; i < ui.identityTreeWidget->columnCount(); ++i) {
//		ui.identityTreeWidget->resizeColumnToContents(i);
//	}
}
예제 #18
0
void PluginViewerController::buildItems() {
    const QList<Plugin*>& plugins = AppContext::getPluginSupport()->getPlugins();
    foreach(Plugin* p, plugins) {
        QTreeWidget* treeWidget = ui.treeWidget;
        PlugViewPluginItem* pluginItem = new PlugViewPluginItem(NULL, p, showServices);
        if (showServices) {
            const QList<Service*>& services = p->getServices();
            //this method is called for default state init also -> look for registered plugin services
            ServiceRegistry* sr = AppContext::getServiceRegistry();
            QList<Service*> registered = sr->getServices();
            foreach(Service* s, services) {
                if (registered.contains(s)) {
                    PlugViewTreeItem* serviceItem = new PlugViewServiceItem(pluginItem, s);
                    pluginItem->addChild(serviceItem);
                }
            }
        }
        treeWidget->addTopLevelItem(pluginItem);
        pluginItem->setExpanded(true);
    }
void moreInfo::setCPU(QStringList data){
    QString * strings = new QString[data.length()];
    for(int i = 0; i < data.length(); i++){
        strings[i] = data.at(i);
    }
    QTreeWidget * widg = new QTreeWidget();
    widg->setColumnCount(2);
    QStringList headers;
    headers.append("Property");
    headers.append("Value");
    widg->setHeaderLabels(headers);
    QTreeWidgetItem *item;
    QStringList stringyListy;
    for(int i = 0; i < data.length(); i++){
        stringyListy = strings[i].split(",");
        item = new QTreeWidgetItem();
        item->setText(0,stringyListy.at(0));
        item->setText(1,stringyListy.at(1));
        widg->addTopLevelItem(item);
    }
    ui->vlCPU->addWidget(widg);
}
예제 #20
0
void MainWindow::usblink_dirlist_callback(struct usblink_file *file, void *data)
{
    QTreeWidget *w = static_cast<QTreeWidget*>(data);

    //End of enumeration or error
    if(!file)
    {
        refresh_filebrowser = true;

        //Find a dir to fill with entries
        for(int i = 0; i < w->topLevelItemCount(); ++i)
            if(usblink_dirlist_nested(w->topLevelItem(i)))
                return;

        return;
    }

    //Add directory entry to tree widget
    QTreeWidgetItem *item = new QTreeWidgetItem({QString::fromUtf8(file->filename), file->is_dir ? "" : naturalSize(file->size)});
    item->setData(0, Qt::UserRole, QVariant(file->is_dir));
    item->setData(1, Qt::UserRole, QVariant(false));
    w->addTopLevelItem(item);
}
// Slot.
void
TransitionEditorWindow::updateEquationsTree()
{
	if (model_ == nullptr) return;

	QTreeWidget* tree = ui_->equationsTree;

	tree->clear();
	for (const auto& group : model_->equationGroupList()) {
		std::unique_ptr<QTreeWidgetItem> item(new QTreeWidgetItem);
		item->setText(0, group.name.c_str());
		item->setFlags(Qt::ItemIsEnabled);

		for (const auto& equation : group.equationList) {
			std::unique_ptr<QTreeWidgetItem> childItem(new QTreeWidgetItem);
			childItem->setText(0, equation->name().c_str());
			childItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
			item->addChild(childItem.release());
		}

		tree->addTopLevelItem(item.release());
	}
	tree->expandAll();
}
예제 #22
0
void CreateCircleDialog::addMember(const QString& keyId, const QString& idtype, const QString& nickname )
{
	QTreeWidget *tree = ui.treeWidget_membership;

	int count = tree->topLevelItemCount();
	for(int i = 0; i < count; ++i){
		QTreeWidgetItem *item = tree->topLevelItem(i);
		if (keyId == item->text(RSCIRCLEID_COL_KEYID)) {
#ifdef DEBUG_CREATE_CIRCLE_DIALOG 
			std::cerr << "CreateCircleDialog::addMember() Already is a Member: " << keyId.toStdString();
			std::cerr << std::endl;
#endif
			return;
		}//if (keyId == item->text(RSCIRCLEID_COL_KEYID))
	}//for(int i = 0; i < count; ++i)

	QTreeWidgetItem *member = new QTreeWidgetItem();
	member->setText(RSCIRCLEID_COL_NICKNAME, nickname);
	member->setText(RSCIRCLEID_COL_KEYID, keyId);
	member->setText(RSCIRCLEID_COL_IDTYPE, idtype);
	//member->setIcon(RSCIRCLEID_COL_NICKNAME, pixmap);

	tree->addTopLevelItem(member);
}
void moreInfo::setHDD(QStringList data){
    QString * strings = new QString[data.length()];
    for(int i = 0; i < data.length(); i++){
        strings[i] = data.at(i);
    }
    QTreeWidget * widg = new QTreeWidget();
    widg->setColumnCount(3);
    QStringList headers;
    headers.append("Drive Label");
    headers.append("Total Capacity");
    headers.append("Used Space");
    widg->setHeaderLabels(headers);
    QTreeWidgetItem *item;
    QStringList stringyListy;
    for(int i = 0; i < data.length(); i++){
        stringyListy = strings[i].split(",");
        item = new QTreeWidgetItem();
        item->setText(0,stringyListy.at(1));
        item->setText(1,stringyListy.at(3));
        item->setText(2,stringyListy.at(5));
        widg->addTopLevelItem(item);
    }
    ui->vlHDD->addWidget(widg);
}
예제 #24
0
void CreateCircleDialog::loadIdentities(uint32_t token)
{
#ifdef DEBUG_CREATE_CIRCLE_DIALOG 
	std::cerr << "CreateCircleDialog::loadIdentities(" << token << ")";
	std::cerr << std::endl;
#endif

	QTreeWidget *tree = ui.treeWidget_IdList;

	tree->clear();

	bool acceptAnonymous = ui.radioButton_ListAll->isChecked();
	bool acceptAllPGP = ui.radioButton_ListAllPGP->isChecked();
	//bool acceptKnownPGP = ui.radioButton_ListKnownPGP->isChecked();

	RsGxsIdGroup data;
	std::vector<RsGxsIdGroup> datavector;
	std::vector<RsGxsIdGroup>::iterator vit;
	if (!rsIdentity->getGroupData(token, datavector)) {
		std::cerr << "CreateCircleDialog::insertIdentities() Error getting GroupData";
		std::cerr << std::endl;
		return;
	}

    for(vit = datavector.begin(); vit != datavector.end(); ++vit) 
    {
	    data = (*vit);

	    /* do filtering */
	    bool ok = false;
	    if (acceptAnonymous) 
		    ok = true;
	    else if (acceptAllPGP) 
		    ok = data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ;
	    else if (data.mPgpKnown)
		    ok = data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ;

	    if (!ok) {
#ifdef DEBUG_CREATE_CIRCLE_DIALOG 
		    std::cerr << "CreateCircleDialog::insertIdentities() Skipping ID: " << data.mMeta.mGroupId;
		    std::cerr << std::endl;
#endif
		    continue;
	    }

	    QString  keyId = QString::fromStdString(data.mMeta.mGroupId.toStdString());
	    QString  nickname = QString::fromUtf8(data.mMeta.mGroupName.c_str());
	    QString  idtype = tr("Anon Id");
	    
	    QPixmap pixmap ;

    if(data.mImage.mSize == 0 || !pixmap.loadFromData(data.mImage.mData, data.mImage.mSize, "PNG"))
        pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId))) ;

	    if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) 
        	{
		    if (data.mPgpKnown) {
			    RsPeerDetails details;
			    rsPeers->getGPGDetails(data.mPgpId, details);
			    idtype = QString::fromUtf8(details.name.c_str());
		    } 
	    		else 
			    idtype = tr("PGP Linked Id");
		    
	    }

	    QTreeWidgetItem *item = new QTreeWidgetItem();
	    item->setText(RSCIRCLEID_COL_NICKNAME, nickname);
        item->setIcon(RSCIRCLEID_COL_NICKNAME, QIcon(pixmap));
	    item->setText(RSCIRCLEID_COL_KEYID, keyId);
	    item->setText(RSCIRCLEID_COL_IDTYPE, idtype);
	    tree->addTopLevelItem(item);

	    // External Circle.
	    if (mIsExistingCircle) 
	    {
		    // check if its in the circle.

		    // We use an explicit cast
		    //

		    if ( mCircleGroup.mInvitedMembers.find(RsGxsId(data.mMeta.mGroupId)) != mCircleGroup.mInvitedMembers.end())  /* found it */
			    addMember(keyId, idtype, nickname);
	    }
    }
}
예제 #25
0
/* get the list of Neighbours from the RsIface.  */
void NetworkDialog::insertConnect()
{
//	static time_t last_time = 0 ;

	if (!rsPeers)
		return;

//	// Because this is called from a qt signal, there's no limitation between calls.
	time_t now = time(NULL);
//	if(last_time + 5 > now)		// never update more often then every 5 seconds.
//		return ;
//
//	last_time = now ;

    std::list<RsPgpId> neighs; //these are GPG ids
    std::list<RsPgpId>::iterator it;
	rsPeers->getGPGAllList(neighs);

	/* get a link to the table */
	QTreeWidget *connectWidget = ui.connectTreeWidget;
	/* disable sorting while editing the table */
	connectWidget->setSortingEnabled(false);

	//remove items
	int index = 0;
	while (index < connectWidget->topLevelItemCount()) 
	{
        RsPgpId gpg_widget_id( (connectWidget->topLevelItem(index))->text(COLUMN_PEERID).toStdString() );
		RsPeerDetails detail;
		if ( (!rsPeers->getGPGDetails(gpg_widget_id, detail)) || (ui.onlyTrustedKeys->isChecked() && (detail.validLvl < RS_TRUST_LVL_MARGINAL && !detail.accept_connection))) 
			delete (connectWidget->takeTopLevelItem(index));
		else 
			++index;
	}
    //QList<QTreeWidgetItem *> validItems;
    //QList<QTreeWidgetItem *> unvalidItems;

	for(it = neighs.begin(); it != neighs.end(); ++it)
	{
#ifdef NET_DEBUG
		std::cerr << "NetworkDialog::insertConnect() inserting gpg key : " << *it << std::endl;
#endif
		if (*it == rsPeers->getGPGOwnId()) {
			continue;
		}

		RsPeerDetails detail;
		if (!rsPeers->getGPGDetails(*it, detail))
		{
			continue; /* BAD */
		}

		/* make a widget per friend */
		QTreeWidgetItem *item;
        QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString( (*it).toStdString() ), Qt::MatchExactly, COLUMN_PEERID);
		if (list.size() == 1) {
			item = list.front();
		} else {
				//create new item
#ifdef NET_DEBUG
				std::cerr << "NetworkDialog::insertConnect() creating new tree widget item : " << *it << std::endl;
#endif
				item = new RSTreeWidgetItem(NULL, 0);
				item -> setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);

				int S = QFontMetricsF(font()).height() ;
                item -> setSizeHint(COLUMN_CHECK, QSize( S,S ) );

				/* (1) Person */
				item -> setText(COLUMN_PEERNAME, QString::fromUtf8(detail.name.c_str()));

				/* (4) key id */
				item -> setText(COLUMN_PEERID, QString::fromStdString(detail.gpg_id.toStdString()));
		}

        //QString TrustLevelString ;

		/* (2) Key validity */
		if (detail.ownsign) 
		{
            item -> setText(COLUMN_I_AUTH_PEER, tr("Personal signature"));
            item -> setToolTip(COLUMN_I_AUTH_PEER, tr("PGP key signed by you"));
		} 
		else 
			switch(detail.trustLvl)
			{
                case RS_TRUST_LVL_MARGINAL: item->setText(COLUMN_I_AUTH_PEER,tr("Marginally trusted peer")) ; break;
				case RS_TRUST_LVL_FULL:
                case RS_TRUST_LVL_ULTIMATE: item->setText(COLUMN_I_AUTH_PEER,tr("Fully trusted peer")) ; break ;
				case RS_TRUST_LVL_UNKNOWN:
				case RS_TRUST_LVL_UNDEFINED: 
				case RS_TRUST_LVL_NEVER:
				default: 							item->setText(2,tr("Untrusted peer")) ; break ;
			}

		/* (3) has me auth */
		QString PeerAuthenticationString ;

		if (detail.hasSignedMe)
			PeerAuthenticationString = tr("Has authenticated me");
		else
			PeerAuthenticationString = tr("Unknown");

        item->setText(COLUMN_PEER_AUTH_ME,PeerAuthenticationString) ;

		uint64_t last_time_used = now - detail.lastUsed ;
		QString lst_used_str ;
		
		if(last_time_used < 3600)
			lst_used_str = tr("Last hour") ;
		else if(last_time_used < 86400)
			lst_used_str = tr("Today") ;
		else if(last_time_used > 86400 * 15000)
			lst_used_str = tr("Never");
		else
			lst_used_str = tr("%1 days ago").arg((int)( last_time_used / 86400 )) ;

		item->setText(COLUMN_LAST_USED,lst_used_str) ;

		/**
		 * Determinated the Background Color
		 */
		QColor backgrndcolor;

		if (detail.accept_connection)
		{
            item -> setText(COLUMN_CHECK, "0");
            item -> setIcon(COLUMN_CHECK,(QIcon(IMAGE_AUTHED)));
			if (detail.ownsign) 
			{
				backgrndcolor = backgroundColorOwnSign();
			} 
			else 
			{
				backgrndcolor = backgroundColorAcceptConnection();
			}
		} 
		else 
		{
            item -> setText(COLUMN_CHECK, "1");

			if (detail.hasSignedMe)
			{
				backgrndcolor = backgroundColorHasSignedMe();
                item -> setIcon(COLUMN_CHECK,(QIcon(IMAGE_DENIED)));
                for(int k=0;k<COLUMN_COUNT;++k)
					item -> setToolTip(k, QString::fromUtf8(detail.name.c_str()) + tr(" has authenticated you. \nRight-click and select 'make friend' to be able to connect."));
			}
			else
			{
				backgrndcolor = backgroundColorDenied();
                item -> setIcon(COLUMN_CHECK,(QIcon(IMAGE_DENIED)));
			}
		}

		// Color each Background column in the Network Tab except the first one => 1-9
		// whith the determinated color
        for(int i = 0; i <COLUMN_COUNT; ++i)
			item -> setBackground(i,QBrush(backgrndcolor));

		if( (detail.accept_connection || detail.validLvl >= RS_TRUST_LVL_MARGINAL) || !ui.onlyTrustedKeys->isChecked()) 
			connectWidget->addTopLevelItem(item);
	}

	// add self to network.
	RsPeerDetails ownGPGDetails;
	rsPeers->getGPGDetails(rsPeers->getGPGOwnId(), ownGPGDetails);
	/* make a widget per friend */
	QTreeWidgetItem *self_item;
    QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString(ownGPGDetails.gpg_id.toStdString()), Qt::MatchExactly, COLUMN_PEERID);
	if (list.size() == 1) {
		self_item = list.front();
	} else {
		self_item = new RSTreeWidgetItem(NULL, 0);
		self_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
	}
    self_item -> setText(COLUMN_CHECK, "0");
    self_item->setIcon(COLUMN_CHECK,(QIcon(IMAGE_AUTHED)));
	self_item->setText(COLUMN_PEERNAME, QString::fromUtf8(ownGPGDetails.name.c_str()) + " (" + tr("yourself") + ")");
    self_item->setText(COLUMN_I_AUTH_PEER,"N/A");
	self_item->setText(COLUMN_PEERID, QString::fromStdString(ownGPGDetails.gpg_id.toStdString()));

	// Color each Background column in the Network Tab except the first one => 1-9
    for(int i=0;i<COLUMN_COUNT;++i)
	{
		self_item->setBackground(i,backgroundColorSelf()) ;
	}
	connectWidget->addTopLevelItem(self_item);

	/* enable sorting */
	connectWidget->setSortingEnabled(true);
	/* update display */
	connectWidget->update();

	if (ui.filterLineEdit->text().isEmpty() == false) {
		filterItems(ui.filterLineEdit->text());
	}

}
예제 #26
0
void IdDialog::insertIdList(uint32_t token)
{
	QTreeWidget *tree = ui.treeWidget_IdList;

	tree->clear();

	std::list<std::string> ids;
	std::list<std::string>::iterator it;

	bool acceptAll = ui.radioButton_ListAll->isChecked();
	bool acceptPseudo = ui.radioButton_ListPseudo->isChecked();
	bool acceptYourself = ui.radioButton_ListYourself->isChecked();
	bool acceptFriends = ui.radioButton_ListFriends->isChecked();
	bool acceptOthers = ui.radioButton_ListOthers->isChecked();

	//rsIdentity->getIdentityList(ids);

	//for(it = ids.begin(); it != ids.end(); it++)
	//{
	RsIdGroup data;
	while(rsIdentity->getGroupData(token, data))
	{

		/* do filtering */
		bool ok = false;
		if (acceptAll)
		{
			ok = true;
		}
		else if (data.mIdType & RSID_TYPE_PSEUDONYM)
		{
 			if (acceptPseudo)
			{
				ok = true;
			}

			if ((data.mIdType & RSID_RELATION_YOURSELF) && (acceptYourself))
			{
				ok = true;
			}
		}
		else
		{
			if (data.mIdType & RSID_RELATION_YOURSELF)
			{
 				if (acceptYourself)
				{
					ok = true;
				}
			}
			else if (data.mIdType & (RSID_RELATION_FRIEND | RSID_RELATION_FOF)) 
			{
				if (acceptFriends)
				{
					ok = true;
				}
			}
			else 
			{
				if (acceptOthers)
				{
					ok = true;
				}
			}
		}

		if (!ok)
		{
			continue;
		}


		QTreeWidgetItem *item = new QTreeWidgetItem();
		//item->setText(RSID_COL_NICKNAME, QString::fromStdString(data.mNickname));
		//item->setText(RSID_COL_KEYID, QString::fromStdString(data.mKeyId));
		item->setText(RSID_COL_NICKNAME, QString::fromStdString(data.mMeta.mGroupName));
		item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId));
		item->setText(RSID_COL_IDTYPE, QString::fromStdString(rsIdTypeToString(data.mIdType)));

                tree->addTopLevelItem(item);
	}

	// fix up buttons.
	updateSelection();
}
예제 #27
0
void DhtWindow::updateDhtPeers()
{

	/* Hackish display of all Dht peers, should be split into buckets (as children) */
        //QString status = QString::fromStdString(mPeerNet->getDhtStatusString());
	//ui->dhtLabel->setText(status);
	
	std::list<RsDhtPeer> allpeers;
	std::list<RsDhtPeer>::iterator it;
	int i;
	for(i = 0; i < 160; i++)
	{
		std::list<RsDhtPeer> peers;
        	rsDht->getDhtPeers(i, peers);

		for(it = peers.begin(); it != peers.end(); it++)
		{
			allpeers.push_back(*it);
		}
	}

	QTreeWidget *dhtTreeWidget = ui->dhtTreeWidget;

	dhtTreeWidget->clear();

	time_t now = time(NULL);
	for(it = allpeers.begin(); it != allpeers.end(); it++)
	{
		/* find the entry */
		QTreeWidgetItem *dht_item = NULL;

		/* insert */
		dht_item = new DhtTreeWidgetItem();

		int dist = it->mBucket;
		std::ostringstream buckstr;
		buckstr << dist;

		std::ostringstream ipstr;
		ipstr << it->mAddr;

		std::ostringstream idstr;
		idstr << it->mDhtId;

		std::ostringstream flagsstr;
		flagsstr << "0x" << std::hex << std::setfill('0') << it->mPeerFlags;
		flagsstr << " EX:0x" << std::hex << std::setfill('0') << it->mExtraFlags;
		std::ostringstream foundstr;
		foundstr << now - it->mFoundTime << " secs ago";

		std::ostringstream lastsendstr;
		if (it->mLastSendTime == 0)
		{
			lastsendstr << "never";
		}
		else
		{
			lastsendstr << now - it->mLastSendTime << " secs ago";
		}

		std::ostringstream lastrecvstr;
		lastrecvstr << now - it->mLastRecvTime << " secs ago";

		dht_item -> setData(DTW_COL_BUCKET, Qt::DisplayRole, QString::fromStdString(buckstr.str()));
		dht_item -> setData(DTW_COL_IPADDR, Qt::DisplayRole, QString::fromStdString(ipstr.str()));
		dht_item -> setData(DTW_COL_PEERID, Qt::DisplayRole, QString::fromStdString(idstr.str()));
		dht_item -> setData(DTW_COL_FLAGS, Qt::DisplayRole, QString::fromStdString(flagsstr.str()));

		dht_item -> setData(DTW_COL_FOUND, Qt::DisplayRole, QString::fromStdString(foundstr.str()));
		dht_item -> setData(DTW_COL_SEND, Qt::DisplayRole, QString::fromStdString(lastsendstr.str()));
		dht_item -> setData(DTW_COL_RECV, Qt::DisplayRole, QString::fromStdString(lastrecvstr.str()));

		dhtTreeWidget->addTopLevelItem(dht_item);
	}

}
예제 #28
0
void DhtWindow::updateRelays()
{

	QTreeWidget *relayTreeWidget = ui->relayTreeWidget;

	std::list<RsDhtRelayEnd> relayEnds;
	std::list<RsDhtRelayProxy> relayProxies;

	std::list<RsDhtRelayEnd>::iterator reit;
	std::list<RsDhtRelayProxy>::iterator rpit;

	rsDht->getRelayEnds(relayEnds);
	rsDht->getRelayProxies(relayProxies);


#define RTW_COL_TYPE		0
#define RTW_COL_SRC		1
#define RTW_COL_PROXY		2
#define RTW_COL_DEST		3
#define RTW_COL_CLASS		4
#define RTW_COL_AGE		5
#define RTW_COL_LASTSEND	6
#define RTW_COL_BANDWIDTH	7

	relayTreeWidget->clear();
	time_t now = time(NULL);

	for(reit = relayEnds.begin(); reit != relayEnds.end(); reit++)
	{
		/* find the entry */
		QTreeWidgetItem *item = new QTreeWidgetItem();
		relayTreeWidget->addTopLevelItem(item);

		std::ostringstream typestr;
		typestr << "RELAY END";

		std::ostringstream srcstr;
		srcstr << "Yourself";

		std::ostringstream proxystr;
		proxystr << reit->mProxyAddr;

		std::ostringstream deststr;
		deststr << reit->mRemoteAddr;
		
		std::ostringstream agestr;
		agestr << "unknown";

		std::ostringstream lastsendstr;
		lastsendstr << "unknown";

		std::ostringstream bandwidthstr;
		bandwidthstr << "unlimited";

		std::ostringstream classstr;
		classstr << "Own Relay";

		//std::ostringstream dhtupdatestr;
		//dhtupdatestr << now - status.mDhtUpdateTS << " secs ago";


		item -> setData(RTW_COL_TYPE, Qt::DisplayRole, QString::fromStdString(typestr.str()));
		item -> setData(RTW_COL_SRC, Qt::DisplayRole, QString::fromStdString(srcstr.str()));
		item -> setData(RTW_COL_PROXY, Qt::DisplayRole, QString::fromStdString(proxystr.str()));
		item -> setData(RTW_COL_DEST, Qt::DisplayRole, QString::fromStdString(deststr.str()));
		item -> setData(RTW_COL_CLASS, Qt::DisplayRole, QString::fromStdString(classstr.str()));
		item -> setData(RTW_COL_AGE, Qt::DisplayRole, QString::fromStdString(agestr.str()));
		item -> setData(RTW_COL_LASTSEND, Qt::DisplayRole, QString::fromStdString(lastsendstr.str()));
		item -> setData(RTW_COL_BANDWIDTH, Qt::DisplayRole, QString::fromStdString(bandwidthstr.str()));

	}


	for(rpit = relayProxies.begin(); rpit != relayProxies.end(); rpit++)
	{
		/* find the entry */
		QTreeWidgetItem *item = new QTreeWidgetItem();
		relayTreeWidget->addTopLevelItem(item);

		std::ostringstream typestr;
		typestr << "RELAY PROXY";

		std::ostringstream srcstr;
		srcstr << rpit->mSrcAddr;
		
		std::ostringstream proxystr;
		proxystr << "Yourself";

		std::ostringstream deststr;
		deststr << rpit->mDestAddr;
		
		std::ostringstream agestr;
		agestr << now - rpit->mCreateTS << " secs ago";

		std::ostringstream lastsendstr;
		lastsendstr << now - rpit->mLastTS << " secs ago";

		std::ostringstream bandwidthstr;
		bandwidthstr << rpit->mBandwidth << "B/s";

		std::ostringstream classstr;
		classstr << rpit->mRelayClass;

		item -> setData(RTW_COL_TYPE, Qt::DisplayRole, QString::fromStdString(typestr.str()));
		item -> setData(RTW_COL_SRC, Qt::DisplayRole, QString::fromStdString(srcstr.str()));
		item -> setData(RTW_COL_PROXY, Qt::DisplayRole, QString::fromStdString(proxystr.str()));
		item -> setData(RTW_COL_DEST, Qt::DisplayRole, QString::fromStdString(deststr.str()));
		item -> setData(RTW_COL_CLASS, Qt::DisplayRole, QString::fromStdString(classstr.str()));
		item -> setData(RTW_COL_AGE, Qt::DisplayRole, QString::fromStdString(agestr.str()));
		item -> setData(RTW_COL_LASTSEND, Qt::DisplayRole, QString::fromStdString(lastsendstr.str()));
		item -> setData(RTW_COL_BANDWIDTH, Qt::DisplayRole, QString::fromStdString(bandwidthstr.str()));

	}
}
예제 #29
0
void DhtWindow::updateNetPeers()
{


	QTreeWidget *peerTreeWidget = ui->peerTreeWidget;

	std::list<std::string> peerIds;
	std::list<std::string>::iterator it;

	rsDht->getNetPeerList(peerIds);

	/* collate peer stats */
	int nPeers = peerIds.size();

	// from DHT peers
	int nOnlinePeers = 0;
	int nUnreachablePeers = 0;
	int nOfflinePeers = 0;

	// Connect States.
	int nDisconnPeers = 0;
	int nDirectPeers = 0;
	int nProxyPeers = 0;
	int nRelayPeers = 0;


#define PTW_COL_RSNAME			0
#define PTW_COL_PEERID			1
#define PTW_COL_DHT_STATUS		2
	
#define PTW_COL_PEER_CONNECTLOGIC	3

#define PTW_COL_PEER_CONNECT_STATUS	4
#define PTW_COL_PEER_CONNECT_MODE	5
#define PTW_COL_PEER_REQ_STATUS		6
	
#define PTW_COL_PEER_CB_MSG		7
#define PTW_COL_RSID			8

#if 0
	/* clear old entries */
	int itemCount = peerTreeWidget->topLevelItemCount();
	for (int nIndex = 0; nIndex < itemCount;) 
	{
		QTreeWidgetItem *tmp_item = peerTreeWidget->topLevelItem(nIndex);
		std::string tmpid = tmp_item->data(PTW_COL_PEERID, Qt::DisplayRole).toString().toStdString();
		if (peerIds.end() == std::find(peerIds.begin(), peerIds.end(), tmpid))
		{
			peerTreeWidget->removeItemWidget(tmp_item, 0);
			/* remove it! */
			itemCount--;
		}
		else
		{
			nIndex++;
		}
	}
#endif
	peerTreeWidget->clear();

	for(it = peerIds.begin(); it != peerIds.end(); it++)
	{
		/* find the entry */
		QTreeWidgetItem *peer_item = NULL;
#if 0
		QString qpeerid = QString::fromStdString(*it);
		int itemCount = peerTreeWidget->topLevelItemCount();
		for (int nIndex = 0; nIndex < itemCount; nIndex++) 
		{
			QTreeWidgetItem *tmp_item = peerTreeWidget->topLevelItem(nIndex);
			if (tmp_item->data(PTW_COL_PEERID, Qt::DisplayRole).toString() == qpeerid) 
			{
				peer_item = tmp_item;
				break;
			}
		}
#endif

		if (!peer_item)
		{
			/* insert */
			peer_item = new QTreeWidgetItem();
			peerTreeWidget->addTopLevelItem(peer_item);
		}

		/* update the data */
		RsDhtNetPeer status;
		rsDht->getNetPeerStatus(*it, status);

		std::string name = rsPeers->getPeerName(*it);

		peer_item -> setData(PTW_COL_PEERID, Qt::DisplayRole, QString::fromStdString(status.mDhtId));
		peer_item -> setData(PTW_COL_RSNAME, Qt::DisplayRole, QString::fromStdString(name));
		peer_item -> setData(PTW_COL_RSID, Qt::DisplayRole, QString::fromStdString(status.mRsId));

		std::ostringstream dhtstate;
		switch(status.mDhtState)
		{
			default:
			case RSDHT_PEERDHT_NOT_ACTIVE:
				dhtstate << "Not Active (Maybe Connected!)";
				break;
			case RSDHT_PEERDHT_SEARCHING:
				dhtstate << "Searching";
				break;
			case RSDHT_PEERDHT_FAILURE:
				dhtstate << "Failed";
				break;
			case RSDHT_PEERDHT_OFFLINE:
				dhtstate << "offline";
				nOfflinePeers++;
				break;
			case RSDHT_PEERDHT_UNREACHABLE:
				dhtstate << "Unreachable";
				nUnreachablePeers++;
				break;
			case RSDHT_PEERDHT_ONLINE:
				dhtstate << "ONLINE";
				nOnlinePeers++;
				break;
		}
			
		peer_item -> setData(PTW_COL_DHT_STATUS, Qt::DisplayRole, QString::fromStdString(dhtstate.str()));

		// NOW CONNECT STATE
		std::ostringstream cpmstr;
		switch(status.mPeerConnectMode)
		{
			case RSDHT_TOU_MODE_DIRECT:
				cpmstr << "Direct";
				break;
			case RSDHT_TOU_MODE_PROXY:
				cpmstr << "Proxy VIA ";
				cpmstr << status.mPeerConnectProxyId;
				break;
			case RSDHT_TOU_MODE_RELAY:
				cpmstr << "Relay VIA ";
				cpmstr << status.mPeerConnectProxyId;
				break;
			default:
				cpmstr << "None";
				break;
		}


		std::ostringstream cpsstr;
		switch(status.mPeerConnectState)
		{
			default:
			case RSDHT_PEERCONN_DISCONNECTED:
				cpsstr << "Disconnected";
				nDisconnPeers++;
				break;
			case RSDHT_PEERCONN_UDP_STARTED:
				cpsstr << "Udp Started";
				break;
			case RSDHT_PEERCONN_CONNECTED:
			{
				cpsstr << "Connected";
				break;
				switch(status.mPeerConnectMode)
				{
					default:
					case RSDHT_TOU_MODE_DIRECT:
						nDirectPeers++;
						break;
					case RSDHT_TOU_MODE_PROXY:
						nProxyPeers++;
						break;
					case RSDHT_TOU_MODE_RELAY:
						nRelayPeers++;
						break;
				}
			}
				break;
		}

		peer_item -> setData(PTW_COL_PEER_CONNECT_STATUS, Qt::DisplayRole, QString::fromStdString(cpsstr.str()));
		
		if (status.mPeerConnectState == RSDHT_PEERCONN_DISCONNECTED)
		{
			peer_item -> setData(PTW_COL_PEER_CONNECT_MODE, Qt::DisplayRole, "");
		}
		else 
		{
			peer_item -> setData(PTW_COL_PEER_CONNECT_MODE, Qt::DisplayRole, QString::fromStdString(cpmstr.str()));
		}
	
		// NOW REQ STATE.
		std::ostringstream reqstr;
                if (status.mExclusiveProxyLock)
                {
                        reqstr << "(E) ";
                }
		switch(status.mPeerReqState)
		{
			case RSDHT_PEERREQ_RUNNING:
				reqstr << "Request Active";
				break;
			case RSDHT_PEERREQ_STOPPED:
				reqstr << "No Request";
				break;
			default:
				reqstr << "Unknown";
				break;
		}
		peer_item -> setData(PTW_COL_PEER_REQ_STATUS, Qt::DisplayRole, QString::fromStdString(reqstr.str()));

		peer_item -> setData(PTW_COL_PEER_CB_MSG, Qt::DisplayRole, QString::fromStdString(status.mCbPeerMsg));
		peer_item -> setData(PTW_COL_PEER_CONNECTLOGIC, Qt::DisplayRole, 
						QString::fromStdString(status.mConnectState));
	}


	std::ostringstream connstr;
	connstr << "#Peers: " << nPeers;
	connstr << " DHT: (#off:" << nOfflinePeers;
	connstr << ",unreach:" << nUnreachablePeers;
	connstr << ",online:" << nOnlinePeers;
	connstr << ") Connections: (#dis:" << nDisconnPeers;
	connstr << ",#dir:" << nDirectPeers;
	connstr << ",#proxy:" << nProxyPeers;
	connstr << ",#relay:" << nRelayPeers;
	connstr << ")";

	QLabel *label = ui->peerSummaryLabel;
	label->setText(QString::fromStdString(connstr.str()));

}
예제 #30
0
/* get the list of Neighbours from the RsIface.  */
void NetworkDialog::insertConnect()
{
	static time_t last_time = 0 ;

	if (!rsPeers)
		return;

	if (ui.showUnvalidKeys->isChecked()) {
		ui.unvalidGPGkeyWidget->show();
	} else {
		ui.unvalidGPGkeyWidget->hide();
	}

	// Because this is called from a qt signal, there's no limitation between calls.
	time_t now = time(NULL);
	if(last_time + 5 > now)		// never update more often then every 5 seconds.
		return ;

	last_time = now ;

	std::list<std::string> neighs; //these are GPG ids
	std::list<std::string>::iterator it;
	rsPeers->getGPGAllList(neighs);

	/* get a link to the table */
	QTreeWidget *connectWidget = ui.connecttreeWidget;

	//remove items
	int index = 0;
	while (index < connectWidget->topLevelItemCount()) {
		std::string gpg_widget_id = (connectWidget->topLevelItem(index))->text(COLUMN_PEERID).toStdString();
		RsPeerDetails detail;
		if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || (detail.validLvl < RS_TRUST_LVL_MARGINAL && !detail.accept_connection)) {
			delete (connectWidget->takeTopLevelItem(index));
		} else {
			index++;
		}
	}
	index = 0;
	while (index < ui.unvalidGPGkeyWidget->topLevelItemCount()) {
		std::string gpg_widget_id = (ui.unvalidGPGkeyWidget->topLevelItem(index))->text(COLUMN_PEERID).toStdString();
		RsPeerDetails detail;
		if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl >= RS_TRUST_LVL_MARGINAL || detail.accept_connection) {
			delete (ui.unvalidGPGkeyWidget->takeTopLevelItem(index));
		} else {
			index++;
		}
	}

	QList<QTreeWidgetItem *> validItems;
	QList<QTreeWidgetItem *> unvalidItems;
	for(it = neighs.begin(); it != neighs.end(); it++)
	{
#ifdef NET_DEBUG
		std::cerr << "NetworkDialog::insertConnect() inserting gpg key : " << *it << std::endl;
#endif
		if (*it == rsPeers->getGPGOwnId()) {
			continue;
		}

		RsPeerDetails detail;
		if (!rsPeers->getGPGDetails(*it, detail))
		{
			continue; /* BAD */
		}

		/* make a widget per friend */
		QTreeWidgetItem *item;
		QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 4);
		if (list.size() == 1) {
			item = list.front();
		} else {
			list = ui.unvalidGPGkeyWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 4);
			if (list.size() == 1) {
				item = list.front();
			} else {
				//create new item
#ifdef NET_DEBUG
				std::cerr << "NetworkDialog::insertConnect() creating new tree widget item : " << *it << std::endl;
#endif
				item = new RSTreeWidgetItem(NULL, 0);
				item -> setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
				item -> setSizeHint(0, QSize( 18,18 ) );

				/* (1) Person */
				item -> setText(COLUMN_PEERNAME, QString::fromUtf8(detail.name.c_str()));

				/* (4) key id */
				item -> setText(COLUMN_PEERID, QString::fromStdString(detail.id));
			}
		}

		QString TrustLevelString ;

		/* (2) Key validity */
		if (detail.ownsign) 
		{
			item -> setText(2, tr("Personal signature"));
			item -> setToolTip(2, tr("PGP key signed by you"));
		} 
		else 
			switch(detail.trustLvl)
			{
				case RS_TRUST_LVL_MARGINAL: item->setText(2,tr("Marginally trusted peer")) ; break;
				case RS_TRUST_LVL_FULL:
				case RS_TRUST_LVL_ULTIMATE: item->setText(2,tr("Fully trusted peer")) ; break ;
				case RS_TRUST_LVL_UNKNOWN:
				case RS_TRUST_LVL_UNDEFINED: 
				case RS_TRUST_LVL_NEVER:
				default: 							item->setText(2,tr("Untrusted peer")) ; break ;
			}

		QString PeerAuthenticationString = tr("Unknown") ;
		/* (3) has me auth */
		if (detail.hasSignedMe)
			PeerAuthenticationString = tr("Has authenticated me");

		item->setText(3,PeerAuthenticationString) ;

		/**
		 * Determinated the Background Color
		 */
		QColor backgrndcolor;

		if (detail.accept_connection)
		{
			if (detail.ownsign) 
			{
				item -> setText(0, "0");
				item -> setIcon(0,(QIcon(IMAGE_AUTHED)));
				backgrndcolor = backgroundColorOwnSign();
			} 
			else 
			{
				item -> setText(0, "0");
				item -> setIcon(0,(QIcon(IMAGE_AUTHED)));
				backgrndcolor = backgroundColorAcceptConnection();
			}
		} 
		else 
		{
			item -> setText(0, "1");

			if (detail.hasSignedMe)
			{
				backgrndcolor = backgroundColorHasSignedMe();
				item -> setIcon(0,(QIcon(IMAGE_DENIED)));
				for(int k=0;k<8;++k)
					item -> setToolTip(k, QString::fromUtf8(detail.name.c_str()) + tr(" has authenticated you. \nRight-click and select 'make friend' to be able to connect."));
			}
			else
			{
				backgrndcolor = backgroundColorDenied();
				item -> setIcon(0,(QIcon(IMAGE_DENIED)));
			}
		}

		// Color each Background column in the Network Tab except the first one => 1-9
		// whith the determinated color
		for(int i = 0; i <10; i++)
			item -> setBackground(i,QBrush(backgrndcolor));

		/* add to the list */
		if (detail.accept_connection || detail.validLvl >= RS_TRUST_LVL_MARGINAL) 
		{
			/* add gpg item to the list. If item is already in the list, it won't be duplicated thanks to Qt */
			connectWidget->addTopLevelItem(item);
		} 
		else 
		{
			ui.unvalidGPGkeyWidget->addTopLevelItem(item);
		}

	}

	// add self to network.
	RsPeerDetails ownGPGDetails;
	rsPeers->getGPGDetails(rsPeers->getGPGOwnId(), ownGPGDetails);
	/* make a widget per friend */
	QTreeWidgetItem *self_item;
	QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString(ownGPGDetails.gpg_id), Qt::MatchExactly, 4);
	if (list.size() == 1) {
		self_item = list.front();
	} else {
		self_item = new RSTreeWidgetItem(NULL, 0);
		self_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
	}
	self_item -> setText(0, "0");
	self_item->setIcon(0,(QIcon(IMAGE_AUTHED)));
	self_item->setText(COLUMN_PEERNAME, QString::fromUtf8(ownGPGDetails.name.c_str()) + " (" + tr("yourself") + ")");
	self_item->setText(2,"N/A");
	self_item->setText(COLUMN_PEERID, QString::fromStdString(ownGPGDetails.id));

	// Color each Background column in the Network Tab except the first one => 1-9
	for(int i=0;i<10;++i)
	{
		self_item->setBackground(i,backgroundColorSelf()) ;
	}
	connectWidget->addTopLevelItem(self_item);

	connectWidget->update(); /* update display */
	ui.unvalidGPGkeyWidget->update(); /* update display */

	if (ui.filterLineEdit->text().isEmpty() == false) {
		filterItems(ui.filterLineEdit->text());
	}

}