From b7340ef7ee6f580921738c61ec2ff34ca880e692 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 6 Jan 2019 20:58:32 +0100 Subject: [PATCH] fixed case insensitive sorting in Keyring, and cleanup dead code --- retroshare-gui/src/gui/NetworkDialog.cpp | 224 +----------------- retroshare-gui/src/gui/NetworkDialog.h | 41 +--- .../gui/NetworkDialog/pgpid_item_model.cpp | 4 +- .../src/gui/NetworkDialog/pgpid_item_proxy.h | 6 + 4 files changed, 15 insertions(+), 260 deletions(-) diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 7a811046f..ff41dd658 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -56,32 +56,10 @@ #define IMAGE_COPYLINK ":/images/copyrslink.png" #define IMAGE_MESSAGE ":/images/mail_new.png" -/* Images for Status icons */ - -//following defined in model -/*#define IMAGE_AUTHED ":/images/accepted16.png" -#define IMAGE_DENIED ":/images/denied16.png" -#define IMAGE_TRUSTED ":/images/rs-2.png" */ - -// Defines for key list columns - -//following defined in model -/*#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 */ - -//RsPeerId getNeighRsCertId(QTreeWidgetItem *i); - /****** * #define NET_DEBUG 1 *****/ -//static const unsigned int ROLE_SORT = Qt::UserRole + 1 ; - /** Constructor */ NetworkDialog::NetworkDialog(QWidget */*parent*/) { @@ -113,33 +91,13 @@ NetworkDialog::NetworkDialog(QWidget */*parent*/) 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 */ -/* QHeaderView * _header = ui.connectTreeWidget->header () ; - QHeaderView_setSectionResizeModeColumn(_header, COLUMN_CHECK, QHeaderView::Custom); - QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEERNAME, QHeaderView::Interactive); - QHeaderView_setSectionResizeModeColumn(_header, COLUMN_I_AUTH_PEER, QHeaderView::Interactive); - QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEER_AUTH_ME, QHeaderView::Interactive); - QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEERID, QHeaderView::Interactive); - QHeaderView_setSectionResizeModeColumn(_header, COLUMN_LAST_USED, QHeaderView::Interactive); */ - - ui.onlyTrustedKeys->setMinimumWidth(20*f); -/* QMenu *menu = new QMenu(); - menu->addAction(ui.actionTabsright); - menu->addAction(ui.actionTabswest); - menu->addAction(ui.actionTabssouth); - menu->addAction(ui.actionTabsnorth); - menu->addSeparator(); - menu->addAction(ui.actionTabsTriangular); - menu->addAction(ui.actionTabsRounded); */ - /* add filter actions */ 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->setCurrentFilter(COLUMN_PEERNAME); connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), PGPIdItemProxy, SLOT(setFilterWildcard(QString))); - } void NetworkDialog::changeEvent(QEvent *e) @@ -173,13 +131,6 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ ) if(!rsPeers->getGPGDetails(peer_id, detail)) // that is not suppose to fail. return ; -// if(peer_id != rsPeers->getGPGOwnId()) -// { -// if(detail.accept_connection) -// contextMnu->addAction(QIcon(IMAGE_DENIED), tr("Deny friend"), this, SLOT(denyFriend())); -// else // not a friend -// contextMnu->addAction(QIcon(IMAGE_MAKEFRIEND), tr("Make friend..."), this, SLOT(makeFriend())); -// } if(peer_id == rsPeers->getGPGOwnId()) contextMnu->addAction(QIcon(IMAGE_EXPORT), tr("Export/create a new node"), this, SLOT(on_actionExportKey_activated())); @@ -269,21 +220,6 @@ void NetworkDialog::denyFriend() securedUpdateDisplay(); } -/*void NetworkDialog::deleteCert() -{ -#ifdef TODO - // do whatever is needed to remove the certificate completely, hopping this - // will eventually remove the signature we've stamped on it. - std::cout << "Deleting friend !" << std::endl ; - - QTreeWidgetItem *wi = getCurrentNeighbour(); - std::string peer_id = wi->text(9).toStdString() ; - rsPeers->deleteCertificate(peer_id) ; - - securedUpdateDisplay(); -#endif -}*/ - void NetworkDialog::makeFriend() { @@ -322,162 +258,10 @@ void NetworkDialog::copyLink() RSLinkClipboard::copyLinks(urls); } -//void NetworkDialog::sendDistantMessage() -//{ -// QTreeWidgetItem *wi = getCurrentNeighbour(); -// if (wi == NULL) { -// return; -// } -// -// MessageComposer *nMsgDialog = MessageComposer::newMsg(); -// if (nMsgDialog == NULL) { -// return; -// } -// -// DistantMsgPeerId pid ; -// RsPgpId mGpgId(wi->text(COLUMN_PEERID).toStdString()) ; -// -// if(rsMsgs->getDistantMessagePeerId(mGpgId,pid)) -// { -// nMsgDialog->addRecipient(MessageComposer::TO, pid, mGpgId); -// nMsgDialog->show(); -// nMsgDialog->activateWindow(); -// } -// -// /* window will destroy itself! */ -//} - - - -/* Utility Fns */ -/*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 */ -// use misc::getOpenFileName -// QFileDialog dialog (this, tr("Select a pem/pqi File")); -// //dialog.setDirectory(QFileInfo(ui.lineTorConfig->text()).absoluteDir()); -// //dialog.selectFile(QFileInfo(ui.lineTorConfig->text()).fileName()); -// dialog.setFileMode(QFileDialog::AnyFile); -// dialog.setReadOnly(false); -// -// /* Prompt the user to select a file or create a new one */ -// if (!dialog.exec() || dialog.selectedFiles().isEmpty()) { -// return; -// } -// QString filename = QDir::convertSeparators(dialog.selectedFiles().at(0)); -// -// /* Check if the file exists */ -// QFile torrcFile(filename); -// if (!QFileInfo(filename).exists()) { -// /* The given file does not exist. Should we create it? */ -// int response = VMessageBox::question(this, -// tr("File Not Found"), -// tr("%1 does not exist. Would you like to create it?") -// .arg(filename), -// VMessageBox::Yes, VMessageBox::No); -// -// if (response == VMessageBox::No) { -// /* Don't create it. Just bail. */ -// return; -// } -// /* Attempt to create the specified file */ -// if (!torrcFile.open(QIODevice::WriteOnly)) { -// VMessageBox::warning(this, -// tr("Failed to Create File"), -// tr("Unable to create %1 [%2]").arg(filename) -// .arg(torrcFile.errorString()), -// VMessageBox::Ok); -// return; -// } -// } -// //ui.lineTorConfig->setText(filename); -} - - -void NetworkDialog::on_actionExportKey_activated() -{ - ProfileManager prof ; - prof.exec() ; -} - -void NetworkDialog::on_actionCreate_New_Profile_activated() -{ -// GenCertDialog gencertdialog (this); -// gencertdialog.exec (); -} - -// void NetworkDialog::on_actionTabsnorth_activated() +// void NetworkDialog::on_actionExportKey_activated() // { -// ui.networkTab->setTabPosition(QTabWidget::North); -// -// Settings->setValueToGroup("NetworkDialog", "TabWidget_Position",ui.networkTab->tabPosition()); -// } -// -// void NetworkDialog::on_actionTabssouth_activated() -// { -// ui.networkTab->setTabPosition(QTabWidget::South); -// -// Settings->setValueToGroup("NetworkDialog", "TabWidget_Position",ui.networkTab->tabPosition()); -// -// } -// -// void NetworkDialog::on_actionTabswest_activated() -// { -// ui.networkTab->setTabPosition(QTabWidget::West); -// -// Settings->setValueToGroup("NetworkDialog", "TabWidget_Position",ui.networkTab->tabPosition()); -// } -// -// void NetworkDialog::on_actionTabsright_activated() -// { -// ui.networkTab->setTabPosition(QTabWidget::East); -// -// Settings->setValueToGroup("NetworkDialog", "TabWidget_Position",ui.networkTab->tabPosition()); -// } -// -// void NetworkDialog::on_actionTabsTriangular_activated() -// { -// ui.networkTab->setTabShape(QTabWidget::Triangular); -// ui.tabBottom->setTabShape(QTabWidget::Triangular); -// } -// -// void NetworkDialog::on_actionTabsRounded_activated() -// { -// ui.networkTab->setTabShape(QTabWidget::Rounded); -// ui.tabBottom->setTabShape(QTabWidget::Rounded); -// } -// -// void NetworkDialog::loadtabsettings() -// { -// Settings->beginGroup("NetworkDialog"); -// -// if(Settings->value("TabWidget_Position","0").toInt() == 0) -// { -// qDebug() << "Tab North"; -// ui.networkTab->setTabPosition(QTabWidget::North); -// } -// else if (Settings->value("TabWidget_Position","1").toInt() == 1) -// { -// qDebug() << "Tab South"; -// ui.networkTab->setTabPosition(QTabWidget::South); -// } -// else if (Settings->value("TabWidget_Position","2").toInt() ==2) -// { -// qDebug() << "Tab West"; -// ui.networkTab->setTabPosition(QTabWidget::West); -// } -// else if(Settings->value("TabWidget_Position","3").toInt() ==3) -// { -// qDebug() << "Tab East"; -// ui.networkTab->setTabPosition(QTabWidget::East); -// } -// -// Settings->endGroup(); +// ProfileManager prof ; +// prof.exec() ; // } void NetworkDialog::filterColumnChanged(int col) @@ -487,8 +271,6 @@ void NetworkDialog::filterColumnChanged(int col) //filterItems(ui.filterLineEdit->text()); } - - void NetworkDialog::updateDisplay() { if (!rsPeers) diff --git a/retroshare-gui/src/gui/NetworkDialog.h b/retroshare-gui/src/gui/NetworkDialog.h index 2e2f36a09..8391ad476 100644 --- a/retroshare-gui/src/gui/NetworkDialog.h +++ b/retroshare-gui/src/gui/NetworkDialog.h @@ -60,12 +60,6 @@ public: void setBackgroundColorHasSignedMe(QColor color) { PGPIdItemModel->setBackgroundColorHasSignedMe(color); mBackgroundColorHasSignedMe = color; } void setBackgroundColorDenied(QColor color) { PGPIdItemModel->setBackgroundColorDenied(color); mBackgroundColorDenied = color; } -private: -// void insertConnect(); -// std::string loadneighbour(); - /* void loadneighbour(); */ - //void updateNewDiscoveryInfo() ; - protected: void changeEvent(QEvent *e); @@ -74,49 +68,22 @@ private slots: void removeUnusedKeys() ; void makeFriend() ; void denyFriend() ; -// void deleteCert() ; void peerdetails(); void copyLink(); -// void sendDistantMessage(); + /** Create the context popup menu and it's submenus */ void connectTreeWidgetCostumPopupMenu( QPoint point ); - //void unvalidGPGKeyWidgetCostumPopupMenu( QPoint point ); /** Called when user clicks "Load Cert" to choose location of a Cert file */ -// void loadcert(); -// void authneighbour(); -// void addneighbour(); - - void on_actionAddFriend_activated(); - //void on_actionCopyKey_activated(); - void on_actionExportKey_activated(); - - void on_actionCreate_New_Profile_activated(); + //void on_actionAddFriend_activated(); + //void on_actionExportKey_activated(); + //void on_actionCreate_New_Profile_activated(); - //void updateNetworkStatus(); - -// void loadtabsettings(); - -// void on_actionTabsright_activated(); -// void on_actionTabsnorth_activated(); -// void on_actionTabssouth_activated(); -// void on_actionTabswest_activated(); -// -// void on_actionTabsRounded_activated(); -// void on_actionTabsTriangular_activated(); - void filterColumnChanged(int); -// void filterItems(const QString &text); - - private: -// class NetworkView *networkview; - -// bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn); - /* Color definitions (for standard see qss.default) */ QColor mBackgroundColorSelf; QColor mBackgroundColorOwnSign; diff --git a/retroshare-gui/src/gui/NetworkDialog/pgpid_item_model.cpp b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_model.cpp index d3048358b..cd4ff009b 100644 --- a/retroshare-gui/src/gui/NetworkDialog/pgpid_item_model.cpp +++ b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_model.cpp @@ -48,7 +48,7 @@ QVariant pgpid_item_model::headerData(int section, Qt::Orientation orientation, return QString(tr("Name of the profile")); break; case COLUMN_I_AUTH_PEER: - return QString(tr("This column indicates trust level and whether you signed the profile PGP key")); + return QString(tr("This column indicates the trust level you indicated and whether you signed the profile PGP key")); break; case COLUMN_PEER_AUTH_ME: return QString(tr("Did that peer sign your own profile PGP key")); @@ -234,7 +234,7 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const } else { - return tr(" - "); + return tr("Denied"); } } break; diff --git a/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.h b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.h index 567425480..f59e73a51 100644 --- a/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.h +++ b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.h @@ -33,6 +33,12 @@ class pgpid_item_proxy : public: pgpid_item_proxy(QObject *parent = nullptr); bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; + + bool lessThan(const QModelIndex &left, const QModelIndex &right) const override + { + return left.data(Qt::DisplayRole).toString().toUpper() < right.data(Qt::DisplayRole).toString().toUpper(); + } + public slots: void use_only_trusted_keys(bool val);