mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 16:39:29 -05:00
fixed sorting by last time used in keyring
This commit is contained in:
parent
006e5423db
commit
0fea0e0bfe
@ -24,6 +24,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
#include <retroshare/rsiface.h>
|
#include <retroshare/rsiface.h>
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
@ -76,6 +77,8 @@ RsPeerId getNeighRsCertId(QTreeWidgetItem *i);
|
|||||||
* #define NET_DEBUG 1
|
* #define NET_DEBUG 1
|
||||||
*****/
|
*****/
|
||||||
|
|
||||||
|
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.
|
: RsAutoUpdatePage(10000,parent) // updates every 10 sec.
|
||||||
@ -95,6 +98,9 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
|||||||
ui.connectTreeWidget -> setRootIsDecorated( false );
|
ui.connectTreeWidget -> setRootIsDecorated( false );
|
||||||
ui.connectTreeWidget -> setColumnCount(6);
|
ui.connectTreeWidget -> setColumnCount(6);
|
||||||
|
|
||||||
|
compareNetworkRole = new RSTreeWidgetItemCompareRole;
|
||||||
|
compareNetworkRole->setRole(COLUMN_LAST_USED, ROLE_SORT);
|
||||||
|
|
||||||
/* 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);
|
||||||
@ -118,11 +124,13 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
|||||||
_header->model()->setHeaderData(COLUMN_PEERID, Qt::Horizontal, tr("Certificat ID"),Qt::ToolTipRole);
|
_header->model()->setHeaderData(COLUMN_PEERID, Qt::Horizontal, tr("Certificat ID"),Qt::ToolTipRole);
|
||||||
_header->model()->setHeaderData(COLUMN_LAST_USED, Qt::Horizontal, tr("Since when I use this certificate"),Qt::ToolTipRole);
|
_header->model()->setHeaderData(COLUMN_LAST_USED, Qt::Horizontal, tr("Since when I use this certificate"),Qt::ToolTipRole);
|
||||||
|
|
||||||
_header->resizeSection ( COLUMN_CHECK, 25 );
|
float f = QFontMetricsF(font()).height()/14.0 ;
|
||||||
_header->resizeSection ( COLUMN_PEERNAME, 200 );
|
|
||||||
_header->resizeSection ( COLUMN_I_AUTH_PEER, 200 );
|
_header->resizeSection ( COLUMN_CHECK, 25*f );
|
||||||
_header->resizeSection ( COLUMN_PEER_AUTH_ME, 200 );
|
_header->resizeSection ( COLUMN_PEERNAME, 200*f );
|
||||||
_header->resizeSection ( COLUMN_LAST_USED, 75 );
|
_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
|
// set header text aligment
|
||||||
QTreeWidgetItem * headerItem = ui.connectTreeWidget->headerItem();
|
QTreeWidgetItem * headerItem = ui.connectTreeWidget->headerItem();
|
||||||
@ -137,17 +145,9 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
|||||||
|
|
||||||
ui.connectTreeWidget->sortItems( COLUMN_PEERNAME, Qt::AscendingOrder );
|
ui.connectTreeWidget->sortItems( COLUMN_PEERNAME, Qt::AscendingOrder );
|
||||||
|
|
||||||
// ui.networkTab->addTab(new TrustView(),QString(tr("Authentication matrix")));
|
ui.onlyTrustedKeys->setMinimumWidth(20*f);
|
||||||
// ui.networkTab->addTab(networkview = new NetworkView(),QString(tr("Network View")));
|
|
||||||
|
|
||||||
ui.onlyTrustedKeys->setMinimumWidth(20);
|
|
||||||
|
|
||||||
QMenu *menu = new QMenu();
|
QMenu *menu = new QMenu();
|
||||||
//menu->addAction(ui.actionAddFriend);
|
|
||||||
//menu->addAction(ui.actionCopyKey);
|
|
||||||
//menu->addAction(ui.actionExportKey);
|
|
||||||
//menu->addAction(ui.actionCreate_New_Profile);
|
|
||||||
//menu->addSeparator();
|
|
||||||
menu->addAction(ui.actionTabsright);
|
menu->addAction(ui.actionTabsright);
|
||||||
menu->addAction(ui.actionTabswest);
|
menu->addAction(ui.actionTabswest);
|
||||||
menu->addAction(ui.actionTabssouth);
|
menu->addAction(ui.actionTabssouth);
|
||||||
@ -155,20 +155,11 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
|||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(ui.actionTabsTriangular);
|
menu->addAction(ui.actionTabsTriangular);
|
||||||
menu->addAction(ui.actionTabsRounded);
|
menu->addAction(ui.actionTabsRounded);
|
||||||
//ui.viewButton->setMenu(menu);
|
|
||||||
|
|
||||||
QTimer *timer2 = new QTimer(this);
|
|
||||||
connect(timer2, SIGNAL(timeout()), this, SLOT(updateNetworkStatus()));
|
|
||||||
timer2->start(1000);
|
|
||||||
|
|
||||||
/* 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);
|
||||||
|
|
||||||
//updateNetworkStatus();
|
|
||||||
//loadtabsettings();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkDialog::changeEvent(QEvent *e)
|
void NetworkDialog::changeEvent(QEvent *e)
|
||||||
@ -200,19 +191,17 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
|
|||||||
if(!rsPeers->getGPGDetails(peer_id, detail)) // that is not suppose to fail.
|
if(!rsPeers->getGPGDetails(peer_id, detail)) // that is not suppose to fail.
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
if(peer_id != rsPeers->getGPGOwnId())
|
// if(peer_id != rsPeers->getGPGOwnId())
|
||||||
{
|
// {
|
||||||
if(detail.accept_connection)
|
// if(detail.accept_connection)
|
||||||
contextMnu->addAction(QIcon(IMAGE_DENIED), tr("Deny friend"), this, SLOT(denyFriend()));
|
// contextMnu->addAction(QIcon(IMAGE_DENIED), tr("Deny friend"), this, SLOT(denyFriend()));
|
||||||
else // not a friend
|
// else // not a friend
|
||||||
contextMnu->addAction(QIcon(IMAGE_MAKEFRIEND), tr("Make friend..."), this, SLOT(makeFriend()));
|
// contextMnu->addAction(QIcon(IMAGE_MAKEFRIEND), tr("Make friend..."), this, SLOT(makeFriend()));
|
||||||
}
|
// }
|
||||||
if(peer_id == rsPeers->getGPGOwnId())
|
if(peer_id == rsPeers->getGPGOwnId())
|
||||||
contextMnu->addAction(QIcon(IMAGE_EXPORT), tr("Export/create a new node"), this, SLOT(on_actionExportKey_activated()));
|
contextMnu->addAction(QIcon(IMAGE_EXPORT), tr("Export/create a new node"), this, SLOT(on_actionExportKey_activated()));
|
||||||
|
|
||||||
contextMnu->addAction(QIcon(IMAGE_PEERDETAILS), tr("Peer details..."), this, SLOT(peerdetails()));
|
contextMnu->addAction(QIcon(IMAGE_PEERDETAILS), tr("Profile details..."), this, SLOT(peerdetails()));
|
||||||
//contextMnu->addAction(QIcon(IMAGE_MESSAGE), tr("Send Message"), this, SLOT(sendDistantMessage()));
|
|
||||||
//contextMnu->addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyLink()));
|
|
||||||
contextMnu->addSeparator() ;
|
contextMnu->addSeparator() ;
|
||||||
contextMnu->addAction(QIcon(IMAGE_CLEAN_UNUSED), tr("Remove unused keys..."), this, SLOT(removeUnusedKeys()));
|
contextMnu->addAction(QIcon(IMAGE_CLEAN_UNUSED), tr("Remove unused keys..."), this, SLOT(removeUnusedKeys()));
|
||||||
|
|
||||||
@ -382,10 +371,6 @@ void NetworkDialog::insertConnect()
|
|||||||
|
|
||||||
// // Because this is called from a qt signal, there's no limitation between calls.
|
// // Because this is called from a qt signal, there's no limitation between calls.
|
||||||
time_t now = time(NULL);
|
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> neighs; //these are GPG ids
|
||||||
std::list<RsPgpId>::iterator it;
|
std::list<RsPgpId>::iterator it;
|
||||||
@ -407,8 +392,6 @@ void NetworkDialog::insertConnect()
|
|||||||
else
|
else
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
//QList<QTreeWidgetItem *> validItems;
|
|
||||||
//QList<QTreeWidgetItem *> unvalidItems;
|
|
||||||
|
|
||||||
for(it = neighs.begin(); it != neighs.end(); ++it)
|
for(it = neighs.begin(); it != neighs.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -435,7 +418,7 @@ void NetworkDialog::insertConnect()
|
|||||||
#ifdef NET_DEBUG
|
#ifdef NET_DEBUG
|
||||||
std::cerr << "NetworkDialog::insertConnect() creating new tree widget item : " << *it << std::endl;
|
std::cerr << "NetworkDialog::insertConnect() creating new tree widget item : " << *it << std::endl;
|
||||||
#endif
|
#endif
|
||||||
item = new RSTreeWidgetItem(NULL, 0);
|
item = new RSTreeWidgetItem(compareNetworkRole, 0);
|
||||||
item -> setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
item -> setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||||
|
|
||||||
int S = QFontMetricsF(font()).height() ;
|
int S = QFontMetricsF(font()).height() ;
|
||||||
@ -490,7 +473,10 @@ void NetworkDialog::insertConnect()
|
|||||||
else
|
else
|
||||||
lst_used_str = tr("%1 days ago").arg((int)( last_time_used / 86400 )) ;
|
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->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
|
||||||
@ -546,7 +532,7 @@ void NetworkDialog::insertConnect()
|
|||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
self_item = list.front();
|
self_item = list.front();
|
||||||
} else {
|
} else {
|
||||||
self_item = new RSTreeWidgetItem(NULL, 0);
|
self_item = new RSTreeWidgetItem(compareNetworkRole, 0);
|
||||||
self_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
self_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||||
}
|
}
|
||||||
self_item -> setText(COLUMN_CHECK, "0");
|
self_item -> setText(COLUMN_CHECK, "0");
|
||||||
@ -589,58 +575,6 @@ RsPeerId getNeighRsCertId(QTreeWidgetItem *i)
|
|||||||
RsPeerId id ( (i -> text(COLUMN_PEERID)).toStdString() );
|
RsPeerId id ( (i -> text(COLUMN_PEERID)).toStdString() );
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* So from the Neighbours Dialog we can call the following control Functions:
|
|
||||||
* (1) Load Certificate NeighLoadCertificate(std::string file)
|
|
||||||
* (2) Neigh Auth NeighAuthFriend(id, code)
|
|
||||||
* (4) Neigh Add NeighAddFriend(id)
|
|
||||||
*
|
|
||||||
* All of these rely on the finding of the current Id.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//std::string NetworkDialog::loadneighbour()
|
|
||||||
//{
|
|
||||||
//#ifdef NET_DEBUG
|
|
||||||
// std::cerr << "NetworkDialog::loadneighbour()" << std::endl;
|
|
||||||
//#endif
|
|
||||||
// use misc::getOpenFileName
|
|
||||||
// QString fileName = QFileDialog::getOpenFileName(this, tr("Select Certificate"), "",
|
|
||||||
// tr("Certificates (*.pqi *.pem)"));
|
|
||||||
//
|
|
||||||
// std::string file = fileName.toStdString();
|
|
||||||
// std::string id;
|
|
||||||
// std::string gpg_id;
|
|
||||||
// if (file != "")
|
|
||||||
// {
|
|
||||||
// rsPeers->loadCertificateFromFile(file, id, gpg_id);
|
|
||||||
// }
|
|
||||||
// return id;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//void NetworkDialog::addneighbour()
|
|
||||||
//{
|
|
||||||
//// QTreeWidgetItem *c = getCurrentNeighbour();
|
|
||||||
//#ifdef NET_DEBUG
|
|
||||||
// std::cerr << "NetworkDialog::addneighbour()" << std::endl;
|
|
||||||
//#endif
|
|
||||||
// /*
|
|
||||||
// rsServer->NeighAddFriend(getNeighRsCertId(c));
|
|
||||||
// */
|
|
||||||
//}
|
|
||||||
|
|
||||||
//void NetworkDialog::authneighbour()
|
|
||||||
//{
|
|
||||||
//// QTreeWidgetItem *c = getCurrentNeighbour();
|
|
||||||
//#ifdef NET_DEBUG
|
|
||||||
// std::cerr << "NetworkDialog::authneighbour()" << std::endl;
|
|
||||||
//#endif
|
|
||||||
// /*
|
|
||||||
// RsAuthId code;
|
|
||||||
// rsServer->NeighAuthFriend(getNeighRsCertId(c), code);
|
|
||||||
// */
|
|
||||||
//}
|
|
||||||
|
|
||||||
/** Open a QFileDialog to browse for a pem/pqi file. */
|
|
||||||
void NetworkDialog::on_actionAddFriend_activated()
|
void NetworkDialog::on_actionAddFriend_activated()
|
||||||
{
|
{
|
||||||
// /* Create a new input dialog, which allows users to create files, too */
|
// /* Create a new input dialog, which allows users to create files, too */
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
#include "ui_NetworkDialog.h"
|
#include "ui_NetworkDialog.h"
|
||||||
#include "RsAutoUpdatePage.h"
|
#include "RsAutoUpdatePage.h"
|
||||||
|
|
||||||
class NetworkDialog : public RsAutoUpdatePage
|
class RSTreeWidgetItemCompareRole ;
|
||||||
|
|
||||||
|
class NetworkDialog : public RsAutoUpdatePage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -118,6 +120,8 @@ private:
|
|||||||
QColor mBackgroundColorHasSignedMe;
|
QColor mBackgroundColorHasSignedMe;
|
||||||
QColor mBackgroundColorDenied;
|
QColor mBackgroundColorDenied;
|
||||||
|
|
||||||
|
RSTreeWidgetItemCompareRole *compareNetworkRole ;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::NetworkDialog ui;
|
Ui::NetworkDialog ui;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user