patch from sss to make the keyring view a table with item model

This commit is contained in:
csoler 2017-10-08 21:00:15 +02:00
parent d61a5cd5ab
commit c36267f640
5 changed files with 120 additions and 270 deletions

View file

@ -81,85 +81,67 @@ static const unsigned int ROLE_SORT = Qt::UserRole + 1 ;
/** Constructor */ /** Constructor */
NetworkDialog::NetworkDialog(QWidget *parent) NetworkDialog::NetworkDialog(QWidget *parent)
: RsAutoUpdatePage(10000,parent) // updates every 10 sec.
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
connect( ui.connectTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connectTreeWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.connectTreeWidget, SIGNAL( itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT( peerdetails () ) );
connect( ui.filterLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterItems(QString))); connect( ui.filterLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterItems(QString)));
connect( ui.filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int))); connect( ui.filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int)));
connect( ui.onlyTrustedKeys, SIGNAL(clicked()), this, SLOT(securedUpdateDisplay())); connect( ui.onlyTrustedKeys, SIGNAL(clicked()), this, SLOT(securedUpdateDisplay()));
/* hide the Tree +/- */
ui.connectTreeWidget -> setRootIsDecorated( false );
ui.connectTreeWidget -> setColumnCount(6);
compareNetworkRole = new RSTreeWidgetItemCompareRole; /* compareNetworkRole = new RSTreeWidgetItemCompareRole;
compareNetworkRole->setRole(COLUMN_LAST_USED, ROLE_SORT); compareNetworkRole->setRole(COLUMN_LAST_USED, ROLE_SORT); */
//list data model
float f = QFontMetricsF(font()).height()/14.0 ;
PGPIdItemModel = new pgpid_item_model(neighs, f, this);
PGPIdItemProxy = new pgpid_item_proxy(this);
PGPIdItemProxy->setSourceModel(PGPIdItemModel);
PGPIdItemProxy->setFilterKeyColumn(COLUMN_PEERNAME);
PGPIdItemProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui.connectTreeWidget->setModel(PGPIdItemProxy);
ui.connectTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
ui.connectTreeWidget->verticalHeader()->hide();
ui.connectTreeWidget->setShowGrid(false);
ui.connectTreeWidget->setUpdatesEnabled(true);
ui.connectTreeWidget->setSortingEnabled(true);
ui.connectTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
connect(ui.connectTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connectTreeWidgetCostumPopupMenu( QPoint ) ) );
connect(ui.connectTreeWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(peerdetails()));
/* Set header resize modes and initial section sizes */ /* Set header resize modes and initial section sizes */
QHeaderView * _header = ui.connectTreeWidget->header () ; /* QHeaderView * _header = ui.connectTreeWidget->header () ;
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_CHECK, QHeaderView::Custom); QHeaderView_setSectionResizeModeColumn(_header, COLUMN_CHECK, QHeaderView::Custom);
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEERNAME, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEERNAME, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_I_AUTH_PEER, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(_header, COLUMN_I_AUTH_PEER, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEER_AUTH_ME, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEER_AUTH_ME, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEERID, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEERID, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_LAST_USED, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(_header, COLUMN_LAST_USED, QHeaderView::Interactive); */
_header->model()->setHeaderData(COLUMN_CHECK, Qt::Horizontal, tr(""));
_header->model()->setHeaderData(COLUMN_PEERNAME, Qt::Horizontal, tr("Profile"));
_header->model()->setHeaderData(COLUMN_I_AUTH_PEER, Qt::Horizontal, tr("Trust level"));
_header->model()->setHeaderData(COLUMN_PEER_AUTH_ME, Qt::Horizontal, tr("Has signed your key?"));
_header->model()->setHeaderData(COLUMN_PEERID, Qt::Horizontal, tr("Id"));
_header->model()->setHeaderData(COLUMN_LAST_USED, Qt::Horizontal, tr("Last used"));
_header->model()->setHeaderData(COLUMN_CHECK, Qt::Horizontal, tr(" Do you accept connections signed by this profile?"),Qt::ToolTipRole);
_header->model()->setHeaderData(COLUMN_PEERNAME, Qt::Horizontal, tr("Name of the profile"),Qt::ToolTipRole);
_header->model()->setHeaderData(COLUMN_I_AUTH_PEER, Qt::Horizontal, tr("This column indicates trust level and whether you signed the profile PGP key"),Qt::ToolTipRole);
_header->model()->setHeaderData(COLUMN_PEER_AUTH_ME, Qt::Horizontal, tr("Did that peer sign your own profile PGP key"),Qt::ToolTipRole);
_header->model()->setHeaderData(COLUMN_PEERID, Qt::Horizontal, tr("PGP Key Id of that profile"),Qt::ToolTipRole);
_header->model()->setHeaderData(COLUMN_LAST_USED, Qt::Horizontal, tr("Last time this key was used (received time, or to check connection)"),Qt::ToolTipRole);
float f = QFontMetricsF(font()).height()/14.0 ;
_header->resizeSection ( COLUMN_CHECK, 25*f );
_header->resizeSection ( COLUMN_PEERNAME, 200*f );
_header->resizeSection ( COLUMN_I_AUTH_PEER, 200*f );
_header->resizeSection ( COLUMN_PEER_AUTH_ME, 200*f );
_header->resizeSection ( COLUMN_LAST_USED, 75*f );
// set header text aligment
QTreeWidgetItem * headerItem = ui.connectTreeWidget->headerItem();
headerItem->setTextAlignment(COLUMN_CHECK, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(COLUMN_PEERNAME, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(COLUMN_I_AUTH_PEER, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(COLUMN_PEER_AUTH_ME, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(COLUMN_PEERID, Qt::AlignVCenter);
headerItem->setTextAlignment(COLUMN_LAST_USED, Qt::AlignVCenter);
headerItem->setText(0,QString()) ;
ui.connectTreeWidget->sortItems( COLUMN_PEERNAME, Qt::AscendingOrder );
ui.onlyTrustedKeys->setMinimumWidth(20*f); ui.onlyTrustedKeys->setMinimumWidth(20*f);
QMenu *menu = new QMenu();
/* QMenu *menu = new QMenu();
menu->addAction(ui.actionTabsright); menu->addAction(ui.actionTabsright);
menu->addAction(ui.actionTabswest); menu->addAction(ui.actionTabswest);
menu->addAction(ui.actionTabssouth); menu->addAction(ui.actionTabssouth);
menu->addAction(ui.actionTabsnorth); menu->addAction(ui.actionTabsnorth);
menu->addSeparator(); menu->addSeparator();
menu->addAction(ui.actionTabsTriangular); menu->addAction(ui.actionTabsTriangular);
menu->addAction(ui.actionTabsRounded); menu->addAction(ui.actionTabsRounded); */
/* add filter actions */ /* add filter actions */
ui.filterLineEdit->addFilter(QIcon(), tr("Name"), COLUMN_PEERNAME, tr("Search name")); ui.filterLineEdit->addFilter(QIcon(), tr("Name"), COLUMN_PEERNAME, tr("Search name"));
ui.filterLineEdit->addFilter(QIcon(), tr("Peer ID"), COLUMN_PEERID, tr("Search peer ID")); ui.filterLineEdit->addFilter(QIcon(), tr("Peer ID"), COLUMN_PEERID, tr("Search peer ID"));
ui.filterLineEdit->setCurrentFilter(COLUMN_PEERNAME); ui.filterLineEdit->setCurrentFilter(COLUMN_PEERNAME);
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), PGPIdItemProxy, SLOT(setFilterWildcard(QString)));
} }
void NetworkDialog::changeEvent(QEvent *e) void NetworkDialog::changeEvent(QEvent *e)
@ -177,14 +159,14 @@ void NetworkDialog::changeEvent(QEvent *e)
void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ ) void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
{ {
//std::cerr << "NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint point ) called" << std::endl;
QTreeWidgetItem *wi = getCurrentNeighbour(); QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes();
if (!wi) if(l.empty())
return; return;
QMenu *contextMnu = new QMenu; QMenu *contextMnu = new QMenu;
RsPgpId peer_id(wi->text(COLUMN_PEERID).toStdString()) ; RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()) ;
// That's what context menus are made for // That's what context menus are made for
RsPeerDetails detail; RsPeerDetails detail;
@ -276,8 +258,11 @@ void NetworkDialog::removeUnusedKeys()
void NetworkDialog::denyFriend() void NetworkDialog::denyFriend()
{ {
QTreeWidgetItem *wi = getCurrentNeighbour(); QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes();
RsPgpId peer_id( wi->text(COLUMN_PEERID).toStdString() ); if(l.empty())
return;
RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString());
rsPeers->removeFriend(peer_id) ; rsPeers->removeFriend(peer_id) ;
securedUpdateDisplay(); securedUpdateDisplay();
@ -300,27 +285,32 @@ void NetworkDialog::denyFriend()
void NetworkDialog::makeFriend() void NetworkDialog::makeFriend()
{ {
PGPKeyDialog::showIt(RsPgpId(getCurrentNeighbour()->text(COLUMN_PEERID).toStdString()), PGPKeyDialog::PageDetails);
QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes();
if(l.empty())
return;
PGPKeyDialog::showIt(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()), PGPKeyDialog::PageDetails);
} }
/** Shows Peer Information/Auth Dialog */ /** Shows Peer Information/Auth Dialog */
void NetworkDialog::peerdetails() void NetworkDialog::peerdetails()
{ {
QTreeWidgetItem* item = getCurrentNeighbour(); QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes();
if (item == NULL) { if(l.empty())
return; return;
}
PGPKeyDialog::showIt(RsPgpId(item->text(COLUMN_PEERID).toStdString()), PGPKeyDialog::PageDetails); PGPKeyDialog::showIt(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()), PGPKeyDialog::PageDetails);
} }
void NetworkDialog::copyLink() void NetworkDialog::copyLink()
{ {
QTreeWidgetItem *wi = getCurrentNeighbour(); QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes();
if (wi == NULL) { if(l.empty())
return; return;
}
RsPgpId peer_id ( wi->text(COLUMN_PEERID).toStdString() ) ;
RsPgpId peer_id (ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()) ;
QList<RetroShareLink> urls; QList<RetroShareLink> urls;
RetroShareLink link = RetroShareLink::createPerson(peer_id); RetroShareLink link = RetroShareLink::createPerson(peer_id);
@ -356,137 +346,39 @@ void NetworkDialog::copyLink()
// /* window will destroy itself! */ // /* window will destroy itself! */
//} //}
void NetworkDialog::updateDisplay()
{
insertConnect() ;
}
/* get the list of Neighbours from the RsIface. */ /* get the list of Neighbours from the RsIface. */
void NetworkDialog::insertConnect() void NetworkDialog::insertConnect()
{ {
// static time_t last_time = 0 ; // static time_t last_time = 0 ;
if (!rsPeers) // if (!rsPeers)
return; // return;
// // Because this is called from a qt signal, there's no limitation between calls. //these are GPG ids
time_t now = time(NULL); // std::list<RsPgpId>::iterator it;
// rsPeers->getGPGAllList(neighs);
std::list<RsPgpId> neighs; //these are GPG ids
std::list<RsPgpId>::iterator it;
rsPeers->getGPGAllList(neighs);
/* get a link to the table */ /* get a link to the table */
QTreeWidget *connectWidget = ui.connectTreeWidget; // QTreeView *connectWidget = ui.connectTreeWidget;
/* disable sorting while editing the table */ /* disable sorting while editing the table */
connectWidget->setSortingEnabled(false); // connectWidget->setSortingEnabled(false);
//remove items //remove items
int index = 0; // 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;
}
for(it = neighs.begin(); it != neighs.end(); ++it) /* for(it = neighs.begin(); it != neighs.end(); ++it)
{ {
#ifdef NET_DEBUG #ifdef NET_DEBUG
std::cerr << "NetworkDialog::insertConnect() inserting gpg key : " << *it << std::endl; std::cerr << "NetworkDialog::insertConnect() inserting gpg key : " << *it << std::endl;
#endif #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(compareNetworkRole, 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("Yes");
else
PeerAuthenticationString = tr("No");
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 )) ;
QString lst_used_sort_str = QString::number(detail.lastUsed,'f',10);
item->setText(COLUMN_LAST_USED,lst_used_str) ;
item->setData(COLUMN_LAST_USED,ROLE_SORT,lst_used_sort_str) ;
/** /**
* Determinated the Background Color * Determinated the Background Color
*/ */
QColor backgrndcolor; /* QColor backgrndcolor;
if (detail.accept_connection) if (detail.accept_connection)
{ {
item -> setText(COLUMN_CHECK, "0");
item -> setIcon(COLUMN_CHECK,(QIcon(IMAGE_AUTHED)));
if (detail.ownsign) if (detail.ownsign)
{ {
backgrndcolor = backgroundColorOwnSign(); backgrndcolor = backgroundColorOwnSign();
@ -498,19 +390,14 @@ void NetworkDialog::insertConnect()
} }
else else
{ {
item -> setText(COLUMN_CHECK, "1");
if (detail.hasSignedMe) if (detail.hasSignedMe)
{ {
backgrndcolor = backgroundColorHasSignedMe(); 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 else
{ {
backgrndcolor = backgroundColorDenied(); backgrndcolor = backgroundColorDenied();
item -> setIcon(COLUMN_CHECK,(QIcon(IMAGE_DENIED)));
} }
} }
@ -520,14 +407,14 @@ void NetworkDialog::insertConnect()
item -> setBackground(i,QBrush(backgrndcolor)); item -> setBackground(i,QBrush(backgrndcolor));
if( (detail.accept_connection || detail.validLvl >= RS_TRUST_LVL_MARGINAL) || !ui.onlyTrustedKeys->isChecked()) if( (detail.accept_connection || detail.validLvl >= RS_TRUST_LVL_MARGINAL) || !ui.onlyTrustedKeys->isChecked())
connectWidget->addTopLevelItem(item); connectWidget->addTopLevelItem(item); */
} // }
// add self to network. // add self to network.
RsPeerDetails ownGPGDetails; // RsPeerDetails ownGPGDetails;
rsPeers->getGPGDetails(rsPeers->getGPGOwnId(), ownGPGDetails); // rsPeers->getGPGDetails(rsPeers->getGPGOwnId(), ownGPGDetails);
/* make a widget per friend */ /* make a widget per friend */
QTreeWidgetItem *self_item; /* QTreeWidgetItem *self_item;
QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString(ownGPGDetails.gpg_id.toStdString()), Qt::MatchExactly, COLUMN_PEERID); QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString(ownGPGDetails.gpg_id.toStdString()), Qt::MatchExactly, COLUMN_PEERID);
if (list.size() == 1) { if (list.size() == 1) {
self_item = list.front(); self_item = list.front();
@ -546,28 +433,19 @@ void NetworkDialog::insertConnect()
{ {
self_item->setBackground(i,backgroundColorSelf()) ; self_item->setBackground(i,backgroundColorSelf()) ;
} }
connectWidget->addTopLevelItem(self_item); connectWidget->addTopLevelItem(self_item); */
/* enable sorting */ /* enable sorting */
connectWidget->setSortingEnabled(true); // connectWidget->setSortingEnabled(true);
/* update display */ /* update display */
connectWidget->update(); // connectWidget->update();
if (ui.filterLineEdit->text().isEmpty() == false) { // if (ui.filterLineEdit->text().isEmpty() == false) {
filterItems(ui.filterLineEdit->text()); // filterItems(ui.filterLineEdit->text());
} // }
} }
QTreeWidgetItem *NetworkDialog::getCurrentNeighbour()
{
if (ui.connectTreeWidget->selectedItems().size() != 0)
{
return ui.connectTreeWidget -> currentItem();
}
return NULL;
}
/* Utility Fns */ /* Utility Fns */
RsPeerId getNeighRsCertId(QTreeWidgetItem *i) RsPeerId getNeighRsCertId(QTreeWidgetItem *i)
@ -700,12 +578,14 @@ void NetworkDialog::on_actionCreate_New_Profile_activated()
// Settings->endGroup(); // Settings->endGroup();
// } // }
void NetworkDialog::filterColumnChanged(int) void NetworkDialog::filterColumnChanged(int col)
{ {
filterItems(ui.filterLineEdit->text()); if(PGPIdItemProxy)
PGPIdItemProxy->setFilterKeyColumn(col);
//filterItems(ui.filterLineEdit->text());
} }
void NetworkDialog::filterItems(const QString &text) /*void NetworkDialog::filterItems(const QString &text)
{ {
int filterColumn = ui.filterLineEdit->currentFilter(); int filterColumn = ui.filterLineEdit->currentFilter();
@ -713,7 +593,7 @@ void NetworkDialog::filterItems(const QString &text)
for (int index = 0; index < count; ++index) { for (int index = 0; index < count; ++index) {
filterItem(ui.connectTreeWidget->topLevelItem(index), text, filterColumn); filterItem(ui.connectTreeWidget->topLevelItem(index), text, filterColumn);
} }
} }*/
bool NetworkDialog::filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn) bool NetworkDialog::filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn)
{ {
@ -741,3 +621,15 @@ bool NetworkDialog::filterItem(QTreeWidgetItem *item, const QString &text, int f
return (visible || visibleChildCount); return (visible || visibleChildCount);
} }
void NetworkDialog::updateDisplay()
{
if (!rsPeers)
return;
//update ids list
std::list<RsPgpId> new_neighs;
rsPeers->getGPGAllList(new_neighs);
//refresh model
PGPIdItemModel->data_updated(new_neighs);
}

View file

@ -25,6 +25,11 @@
#include "ui_NetworkDialog.h" #include "ui_NetworkDialog.h"
#include "RsAutoUpdatePage.h" #include "RsAutoUpdatePage.h"
#include "gui/NetworkDialog/pgpid_item_model.h"
#include "gui/NetworkDialog/pgpid_item_proxy.h"
//tmp
class QTreeWidgetItem;
class RSTreeWidgetItemCompareRole ; class RSTreeWidgetItemCompareRole ;
@ -42,7 +47,6 @@ public:
/** Default Constructor */ /** Default Constructor */
NetworkDialog(QWidget *parent = 0); NetworkDialog(QWidget *parent = 0);
//void load();
virtual void updateDisplay() ; // overloaded from RsAutoUpdatePage virtual void updateDisplay() ; // overloaded from RsAutoUpdatePage
QColor backgroundColorSelf() const { return mBackgroundColorSelf; } QColor backgroundColorSelf() const { return mBackgroundColorSelf; }
@ -104,10 +108,11 @@ private slots:
// void on_actionTabsTriangular_activated(); // void on_actionTabsTriangular_activated();
void filterColumnChanged(int); void filterColumnChanged(int);
void filterItems(const QString &text); // void filterItems(const QString &text);
private: private:
QTreeWidgetItem *getCurrentNeighbour();
// class NetworkView *networkview; // class NetworkView *networkview;
@ -122,6 +127,12 @@ private:
RSTreeWidgetItemCompareRole *compareNetworkRole ; RSTreeWidgetItemCompareRole *compareNetworkRole ;
//iinternal long lived data
std::list<RsPgpId> neighs;
pgpid_item_model *PGPIdItemModel;
pgpid_item_proxy *PGPIdItemProxy;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::NetworkDialog ui; Ui::NetworkDialog ui;
}; };

View file

@ -41,7 +41,7 @@
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<widget class="QTreeWidget" name="connectTreeWidget"> <widget class="QTableView" name="connectTreeWidget">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -66,63 +66,6 @@
<height>16</height> <height>16</height>
</size> </size>
</property> </property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="animated">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<attribute name="headerCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string/>
</property>
</column>
<column>
<property name="text">
<string>Profile</string>
</property>
</column>
<column>
<property name="text">
<string>Did I authenticated peer</string>
</property>
<property name="toolTip">
<string>Did I sign his PGP key</string>
</property>
</column>
<column>
<property name="text">
<string>Has signed my key</string>
</property>
</column>
<column>
<property name="text">
<string>Cert Id</string>
</property>
</column>
<column>
<property name="text">
<string>Last used</string>
</property>
</column>
</widget> </widget>
</widget> </widget>
</item> </item>

View file

@ -416,7 +416,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool)));
QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus()));
QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->friendsDialog->networkDialog,SLOT(setLogInfo(QString))) ; // QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->friendsDialog->networkDialog,SLOT(setLogInfo(QString))) ;
QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->friendsDialog->networkView,SLOT(update()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->friendsDialog->networkView,SLOT(update()),Qt::QueuedConnection) ;
QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ; QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ;

View file

@ -565,7 +565,9 @@ HEADERS += rshare.h \
gui/GetStartedDialog.h \ gui/GetStartedDialog.h \
gui/statistics/BWGraph.h \ gui/statistics/BWGraph.h \
util/RsSyntaxHighlighter.h \ util/RsSyntaxHighlighter.h \
util/imageutil.h util/imageutil.h \
gui/NetworkDialog/pgpid_item_model.h \
gui/NetworkDialog/pgpid_item_proxy.h
# gui/ForumsDialog.h \ # gui/ForumsDialog.h \
# gui/forums/ForumDetails.h \ # gui/forums/ForumDetails.h \
@ -925,7 +927,9 @@ SOURCES += main.cpp \
gui/statistics/RttStatistics.cpp \ gui/statistics/RttStatistics.cpp \
gui/statistics/BWGraph.cpp \ gui/statistics/BWGraph.cpp \
util/RsSyntaxHighlighter.cpp \ util/RsSyntaxHighlighter.cpp \
util/imageutil.cpp util/imageutil.cpp \
gui/NetworkDialog/pgpid_item_model.cpp \
gui/NetworkDialog/pgpid_item_proxy.cpp
# gui/ForumsDialog.cpp \ # gui/ForumsDialog.cpp \
# gui/forums/ForumDetails.cpp \ # gui/forums/ForumDetails.cpp \