From 6dfac8f4e0fdbf4b9202dc587384459ecd04fc57 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Mon, 9 Oct 2017 04:44:32 +0300 Subject: retroshare: pgpid ui patch update --- .../retroshare/files/abstractitemmodel_test.patch | 184 ++++++++++++++++----- 1 file changed, 140 insertions(+), 44 deletions(-) (limited to 'net-p2p/retroshare/files/abstractitemmodel_test.patch') diff --git a/net-p2p/retroshare/files/abstractitemmodel_test.patch b/net-p2p/retroshare/files/abstractitemmodel_test.patch index 0a3fde5..a48d75f 100644 --- a/net-p2p/retroshare/files/abstractitemmodel_test.patch +++ b/net-p2p/retroshare/files/abstractitemmodel_test.patch @@ -16,10 +16,19 @@ index 833173029..d22af1418 100644 wikipoos { SUBDIRS += pegmarkdown diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp -index bdeda264c..76dc61aa4 100644 +index bdeda264c..d7b864094 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp -@@ -81,85 +81,67 @@ static const unsigned int ROLE_SORT = Qt::UserRole + 1 ; +@@ -71,7 +71,7 @@ + #define COLUMN_LAST_USED 5 + #define COLUMN_COUNT 6 + +-RsPeerId getNeighRsCertId(QTreeWidgetItem *i); ++//RsPeerId getNeighRsCertId(QTreeWidgetItem *i); + + /****** + * #define NET_DEBUG 1 +@@ -81,85 +81,69 @@ static const unsigned int ROLE_SORT = Qt::UserRole + 1 ; /** Constructor */ NetworkDialog::NetworkDialog(QWidget *parent) @@ -34,14 +43,11 @@ index bdeda264c..76dc61aa4 100644 connect( ui.filterLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterItems(QString))); connect( ui.filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int))); - connect( ui.onlyTrustedKeys, SIGNAL(clicked()), this, SLOT(securedUpdateDisplay())); - -- /* hide the Tree +/- */ -- ui.connectTreeWidget -> setRootIsDecorated( false ); -- ui.connectTreeWidget -> setColumnCount(6); - -- compareNetworkRole = new RSTreeWidgetItemCompareRole; -- compareNetworkRole->setRole(COLUMN_LAST_USED, ROLE_SORT); +- connect( ui.onlyTrustedKeys, SIGNAL(clicked()), this, SLOT(securedUpdateDisplay())); ++// connect( ui.onlyTrustedKeys, SIGNAL(clicked()), this, SLOT(securedUpdateDisplay())); ++ ++ ++ +/* compareNetworkRole = new RSTreeWidgetItemCompareRole; + compareNetworkRole->setRole(COLUMN_LAST_USED, ROLE_SORT); */ + @@ -49,6 +55,7 @@ index bdeda264c..76dc61aa4 100644 + float f = QFontMetricsF(font()).height()/14.0 ; + PGPIdItemModel = new pgpid_item_model(neighs, f, this); + PGPIdItemProxy = new pgpid_item_proxy(this); ++ connect(ui.onlyTrustedKeys, SIGNAL(toggled(bool)), PGPIdItemProxy, SLOT(use_only_trusted_keys(bool))); + PGPIdItemProxy->setSourceModel(PGPIdItemModel); + PGPIdItemProxy->setFilterKeyColumn(COLUMN_PEERNAME); + PGPIdItemProxy->setFilterCaseSensitivity(Qt::CaseInsensitive); @@ -61,8 +68,13 @@ index bdeda264c..76dc61aa4 100644 + ui.connectTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows); + connect(ui.connectTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connectTreeWidgetCostumPopupMenu( QPoint ) ) ); + connect(ui.connectTreeWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(peerdetails())); -+ -+ + +- /* hide the Tree +/- */ +- ui.connectTreeWidget -> setRootIsDecorated( false ); +- ui.connectTreeWidget -> setColumnCount(6); + +- compareNetworkRole = new RSTreeWidgetItemCompareRole; +- compareNetworkRole->setRole(COLUMN_LAST_USED, ROLE_SORT); /* Set header resize modes and initial section sizes */ - QHeaderView * _header = ui.connectTreeWidget->header () ; @@ -87,10 +99,10 @@ index bdeda264c..76dc61aa4 100644 - _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 ; + QHeaderView_setSectionResizeModeColumn(_header, COLUMN_LAST_USED, QHeaderView::Interactive); */ -- 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 ); @@ -105,14 +117,14 @@ index bdeda264c..76dc61aa4 100644 - 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.onlyTrustedKeys->setMinimumWidth(20*f); +- headerItem->setText(0,QString()) ; + - ui.connectTreeWidget->sortItems( COLUMN_PEERNAME, Qt::AscendingOrder ); - ui.onlyTrustedKeys->setMinimumWidth(20*f); - +- - QMenu *menu = new QMenu(); +/* QMenu *menu = new QMenu(); menu->addAction(ui.actionTabsright); @@ -133,7 +145,7 @@ index bdeda264c..76dc61aa4 100644 } void NetworkDialog::changeEvent(QEvent *e) -@@ -177,14 +159,14 @@ void NetworkDialog::changeEvent(QEvent *e) +@@ -177,14 +161,14 @@ void NetworkDialog::changeEvent(QEvent *e) void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ ) { @@ -153,7 +165,14 @@ index bdeda264c..76dc61aa4 100644 // That's what context menus are made for RsPeerDetails detail; -@@ -276,8 +258,11 @@ void NetworkDialog::removeUnusedKeys() +@@ -271,13 +255,17 @@ void NetworkDialog::removeUnusedKeys() + } + QMessageBox::warning(NULL,tr("Keyring info"),tr("Key removal has failed. Your keyring remains intact.\n\nReported error:")+" "+error_string ) ; + } +- insertConnect() ; ++ updateDisplay(); ++// insertConnect() ; + } void NetworkDialog::denyFriend() { @@ -167,7 +186,7 @@ index bdeda264c..76dc61aa4 100644 rsPeers->removeFriend(peer_id) ; securedUpdateDisplay(); -@@ -300,27 +285,32 @@ void NetworkDialog::denyFriend() +@@ -300,27 +288,32 @@ void NetworkDialog::denyFriend() void NetworkDialog::makeFriend() { @@ -211,7 +230,7 @@ index bdeda264c..76dc61aa4 100644 QList urls; RetroShareLink link = RetroShareLink::createPerson(peer_id); -@@ -356,137 +346,39 @@ void NetworkDialog::copyLink() +@@ -356,137 +349,39 @@ void NetworkDialog::copyLink() // /* window will destroy itself! */ //} @@ -221,8 +240,10 @@ index bdeda264c..76dc61aa4 100644 -} - /* get the list of Neighbours from the RsIface. */ - void NetworkDialog::insertConnect() - { +-void NetworkDialog::insertConnect() +-{ ++//void NetworkDialog::insertConnect() ++//{ // static time_t last_time = 0 ; - if (!rsPeers) @@ -361,7 +382,7 @@ index bdeda264c..76dc61aa4 100644 if (detail.ownsign) { backgrndcolor = backgroundColorOwnSign(); -@@ -498,19 +390,14 @@ void NetworkDialog::insertConnect() +@@ -498,19 +393,14 @@ void NetworkDialog::insertConnect() } else { @@ -381,7 +402,7 @@ index bdeda264c..76dc61aa4 100644 } } -@@ -520,14 +407,14 @@ void NetworkDialog::insertConnect() +@@ -520,14 +410,14 @@ void NetworkDialog::insertConnect() item -> setBackground(i,QBrush(backgrndcolor)); if( (detail.accept_connection || detail.validLvl >= RS_TRUST_LVL_MARGINAL) || !ui.onlyTrustedKeys->isChecked()) @@ -401,7 +422,7 @@ index bdeda264c..76dc61aa4 100644 QList list = connectWidget->findItems(QString::fromStdString(ownGPGDetails.gpg_id.toStdString()), Qt::MatchExactly, COLUMN_PEERID); if (list.size() == 1) { self_item = list.front(); -@@ -546,28 +433,19 @@ void NetworkDialog::insertConnect() +@@ -546,35 +436,26 @@ void NetworkDialog::insertConnect() { self_item->setBackground(i,backgroundColorSelf()) ; } @@ -413,30 +434,40 @@ index bdeda264c..76dc61aa4 100644 +// connectWidget->setSortingEnabled(true); /* update display */ - connectWidget->update(); -+// connectWidget->update(); - +- - if (ui.filterLineEdit->text().isEmpty() == false) { - filterItems(ui.filterLineEdit->text()); - } ++// connectWidget->update(); + +-} +// if (ui.filterLineEdit->text().isEmpty() == false) { +// filterItems(ui.filterLineEdit->text()); +// } - } - -QTreeWidgetItem *NetworkDialog::getCurrentNeighbour() -{ - if (ui.connectTreeWidget->selectedItems().size() != 0) - { - return ui.connectTreeWidget -> currentItem(); - } -- ++//} + - return NULL; -} /* Utility Fns */ - RsPeerId getNeighRsCertId(QTreeWidgetItem *i) -@@ -700,12 +578,14 @@ void NetworkDialog::on_actionCreate_New_Profile_activated() +-RsPeerId getNeighRsCertId(QTreeWidgetItem *i) ++/*RsPeerId getNeighRsCertId(QTreeWidgetItem *i) + { + RsPeerId id ( (i -> text(COLUMN_PEERID)).toStdString() ); + return id; +-} ++} */ + void NetworkDialog::on_actionAddFriend_activated() + { + // /* Create a new input dialog, which allows users to create files, too */ +@@ -700,12 +581,14 @@ void NetworkDialog::on_actionCreate_New_Profile_activated() // Settings->endGroup(); // } @@ -454,19 +485,23 @@ index bdeda264c..76dc61aa4 100644 { int filterColumn = ui.filterLineEdit->currentFilter(); -@@ -713,7 +593,7 @@ void NetworkDialog::filterItems(const QString &text) +@@ -713,9 +596,9 @@ void NetworkDialog::filterItems(const QString &text) for (int index = 0; index < count; ++index) { 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) ++/*bool NetworkDialog::filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn) { -@@ -741,3 +621,15 @@ bool NetworkDialog::filterItem(QTreeWidgetItem *item, const QString &text, int f + bool visible = true; + +@@ -740,4 +623,16 @@ bool NetworkDialog::filterItem(QTreeWidgetItem *item, const QString &text, int f + } return (visible || visibleChildCount); - } ++} */ + +void NetworkDialog::updateDisplay() +{ @@ -477,10 +512,10 @@ index bdeda264c..76dc61aa4 100644 + rsPeers->getGPGAllList(new_neighs); + //refresh model + PGPIdItemModel->data_updated(new_neighs); -+} + } + diff --git a/retroshare-gui/src/gui/NetworkDialog.h b/retroshare-gui/src/gui/NetworkDialog.h -index 2d90e98e7..084b04126 100644 +index 2d90e98e7..5c73c0a51 100644 --- a/retroshare-gui/src/gui/NetworkDialog.h +++ b/retroshare-gui/src/gui/NetworkDialog.h @@ -25,6 +25,11 @@ @@ -506,6 +541,15 @@ index 2d90e98e7..084b04126 100644 QColor backgroundColorSelf() const { return mBackgroundColorSelf; } QColor backgroundColorOwnSign() const { return mBackgroundColorOwnSign; } QColor backgroundColorAcceptConnection() const { return mBackgroundColorAcceptConnection; } +@@ -58,7 +62,7 @@ public: + void setBackgroundColorDenied(QColor color) { mBackgroundColorDenied = color; } + + private: +- void insertConnect(); ++// void insertConnect(); + // std::string loadneighbour(); + /* void loadneighbour(); */ + //void updateNewDiscoveryInfo() ; @@ -68,7 +72,7 @@ protected: private slots: @@ -515,7 +559,7 @@ index 2d90e98e7..084b04126 100644 void makeFriend() ; void denyFriend() ; // void deleteCert() ; -@@ -104,10 +108,11 @@ private slots: +@@ -104,14 +108,15 @@ private slots: // void on_actionTabsTriangular_activated(); void filterColumnChanged(int); @@ -529,6 +573,11 @@ index 2d90e98e7..084b04126 100644 // class NetworkView *networkview; +- bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn); ++// bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn); + + /* Color definitions (for standard see qss.default) */ + QColor mBackgroundColorSelf; @@ -122,6 +127,12 @@ private: RSTreeWidgetItemCompareRole *compareNetworkRole ; @@ -1056,12 +1105,31 @@ index 000000000..84bae523b +#endif // KEY_ITEM_MODEL_H diff --git a/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.cpp b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.cpp new file mode 100644 -index 000000000..da42db568 +index 000000000..5df377f5a --- /dev/null +++ b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.cpp -@@ -0,0 +1,50 @@ +@@ -0,0 +1,91 @@ +#include "pgpid_item_proxy.h" + ++//TODO: include only required headers here ++#include ++#include ++#include ++#include ++ ++ ++//TODO: set this defines in one place ++// Defines for key list columns ++#define COLUMN_CHECK 0 ++#define COLUMN_PEERNAME 1 ++#define COLUMN_I_AUTH_PEER 2 ++#define COLUMN_PEER_AUTH_ME 3 ++#define COLUMN_PEERID 4 ++#define COLUMN_LAST_USED 5 ++#define COLUMN_COUNT 6 ++ ++ ++ +pgpid_item_proxy::pgpid_item_proxy(QObject *parent) : + //QAbstractProxyModel(parent) + QSortFilterProxyModel(parent) @@ -1110,12 +1178,34 @@ index 000000000..da42db568 + return sourceModel()->columnCount(parent); +} +*/ ++ ++void pgpid_item_proxy::use_only_trusted_keys(bool val) ++{ ++ only_trusted_keys = val; ++ filterChanged(); ++} ++ ++bool pgpid_item_proxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const ++{ ++ if(only_trusted_keys) ++ { ++ if(!rsPeers) ++ return false; ++ RsPgpId peer_id (sourceModel()->data(sourceModel()->index(sourceRow, COLUMN_PEERID, sourceParent)).toString().toStdString()); ++ RsPeerDetails details; ++ if(!rsPeers->getGPGDetails(peer_id, details)) ++ return false; ++ if(details.validLvl < RS_TRUST_LVL_MARGINAL) ++ return false; ++ } ++ return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); ++} diff --git a/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.h b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.h new file mode 100644 -index 000000000..d33bc9666 +index 000000000..5713ad7c9 --- /dev/null +++ b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.h -@@ -0,0 +1,23 @@ +@@ -0,0 +1,29 @@ +#ifndef PGPID_ITEM_PROXY_H +#define PGPID_ITEM_PROXY_H + @@ -1136,6 +1226,12 @@ index 000000000..d33bc9666 + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; +*/ ++ bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; ++public slots: ++ void use_only_trusted_keys(bool val); ++ ++private: ++ bool only_trusted_keys = false; +}; + +#endif // PGPID_ITEM_PROXY_H -- cgit v1.2.3