diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 5dc999740..1b02cbc7c 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -133,21 +133,22 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ ) contextMnu->addAction(QIcon(IMAGE_PEERDETAILS), tr("Profile details..."), this, SLOT(peerdetails())); contextMnu->addSeparator() ; contextMnu->addAction(QIcon(), tr("Remove unused keys..."), this, SLOT(removeUnusedKeys())); + contextMnu->addAction(QIcon(), tr("Remove this key"), this, SLOT(removeSelectedKeys())); contextMnu->exec(QCursor::pos()); } void NetworkDialog::removeUnusedKeys() { - std::set pre_selected ; - std::list ids ; + std::set pre_selected ; + std::list ids ; rsPeers->getGPGAllList(ids) ; RsPeerDetails details ; time_t now = time(NULL) ; - time_t THREE_MONTHS = 3*31*24*60*60 ;//3*DayPerMonth*HoursPerDay*MinPerHour*SecPerMin + time_t THREE_MONTHS = 3*31*24*60*60 ;//3*DayPerMonth*HoursPerDay*MinPerHour*SecPerMin - for(std::list::const_iterator it(ids.begin());it!=ids.end();++it) + for(std::list::const_iterator it(ids.begin());it!=ids.end();++it) { rsPeers->getGPGDetails(*it,details) ; @@ -159,17 +160,34 @@ void NetworkDialog::removeUnusedKeys() if(now > (time_t) (THREE_MONTHS + details.lastUsed) && !details.accept_connection) { std::cerr << "Adding " << *it << " to pre-selection." << std::endl; - pre_selected.insert(*it) ; + pre_selected.insert(*it) ; } } - std::set selected = FriendSelectionDialog::selectFriends_PGP(NULL, - tr("Clean keyring"), - tr("The selected keys below haven't been used in the last 3 months. \nDo you want to delete them permanently ? \n\nNotes: Your old keyring will be backed up.\n The removal may fail when running multiple Retroshare instances on the same machine."),FriendSelectionWidget::MODUS_CHECK,FriendSelectionWidget::SHOW_GPG | FriendSelectionWidget::SHOW_NON_FRIEND_GPG, - pre_selected) ; - + std::set selected = FriendSelectionDialog::selectFriends_PGP(NULL, + tr("Clean keyring"), + tr("The selected keys below haven't been used in the last 3 months. \nDo you want to delete them permanently ? \n\nNotes: Your old keyring will be backed up.\n The removal may fail when running multiple Retroshare instances on the same machine."),FriendSelectionWidget::MODUS_CHECK,FriendSelectionWidget::SHOW_GPG | FriendSelectionWidget::SHOW_NON_FRIEND_GPG, + pre_selected) ; + + removeKeys(selected); +} + +void NetworkDialog::removeSelectedKeys() +{ + QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes(); + if(l.empty()) + return; + + std::set selected; + selected.insert(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString())); + + removeKeys(selected); +} + +void NetworkDialog::removeKeys(std::set selected) +{ std::cerr << "Removing these keys from the keyring: " << std::endl; - for(std::set::const_iterator it(selected.begin());it!=selected.end();++it) + for(std::set::const_iterator it(selected.begin());it!=selected.end();++it) std::cerr << " " << *it << std::endl; std::string backup_file ; @@ -200,7 +218,7 @@ void NetworkDialog::removeUnusedKeys() } QMessageBox::warning(NULL,tr("Keyring info"),tr("Key removal has failed. Your keyring remains intact.\n\nReported error:")+" "+error_string ) ; } - updateDisplay(); + updateDisplay(); // insertConnect() ; } diff --git a/retroshare-gui/src/gui/NetworkDialog.h b/retroshare-gui/src/gui/NetworkDialog.h index 9561c1db3..6a5b1c367 100644 --- a/retroshare-gui/src/gui/NetworkDialog.h +++ b/retroshare-gui/src/gui/NetworkDialog.h @@ -68,6 +68,7 @@ protected: private slots: void removeUnusedKeys() ; + void removeSelectedKeys() ; void makeFriend() ; void denyFriend() ; void peerdetails(); @@ -86,6 +87,8 @@ private slots: private: + void removeKeys(std::set selected) ; + /* Color definitions (for standard see qss.default) */ QColor mBackgroundColorSelf; QColor mBackgroundColorOwnSign; diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index d253691bf..bb5e693ba 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -185,7 +185,7 @@ int FriendSelectionWidget::addColumn(const QString &title) return column; } -void FriendSelectionWidget::showEvent(QShowEvent *e) +void FriendSelectionWidget::showEvent(QShowEvent */*e*/) { if(gxsIds.empty()) loadIdentities(); @@ -838,6 +838,9 @@ void FriendSelectionWidget::contextMenuRequested(const QPoint &/*pos*/) contextMenu->addAction(QIcon(), tr("Mark all"), this, SLOT(selectAll())); contextMenu->addAction(QIcon(), tr("Mark none"), this, SLOT(deselectAll())); } + if (mListModus == MODUS_CHECK) { + contextMenu->addAction(QIcon(), tr("Mark none"), this, SLOT(deselectAll())); + } if (!mContextMenuActions.isEmpty()) { bool addSeparator = false;