From 9d3d457630c4ccd9329b47207c756f00464aa165 Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 13 Aug 2012 22:53:55 +0000 Subject: [PATCH] replaced QListWidget with QTreeWidget for Display the Identities git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5413 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- .../src/gui/profile/ProfileManager.cpp | 52 ++++++++++++++++--- .../src/gui/profile/ProfileManager.h | 15 +++--- .../src/gui/profile/ProfileManager.ui | 26 +++++++++- 3 files changed, 76 insertions(+), 17 deletions(-) diff --git a/retroshare-gui/src/gui/profile/ProfileManager.cpp b/retroshare-gui/src/gui/profile/ProfileManager.cpp index 9f36370a9..55ae7a28a 100644 --- a/retroshare-gui/src/gui/profile/ProfileManager.cpp +++ b/retroshare-gui/src/gui/profile/ProfileManager.cpp @@ -25,17 +25,18 @@ #include #include "ProfileManager.h" #include "gui/GenCertDialog.h" +#include "gui/common/RSTreeWidgetItem.h" #include #include #include -#include #include +#include + #include +#define IMAGE_EXPORT ":/images/exportpeers_16x16.png" -/* Define the format used for displaying the date and time */ -#define DATETIME_FMT "MMM dd hh:mm:ss" /** Default constructor */ @@ -45,19 +46,42 @@ ProfileManager::ProfileManager(QWidget *parent, Qt::WFlags flags) /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); + connect(ui.identityTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( identityTreeWidgetCostumPopupMenu( QPoint ) ) ); connect(ui.newIdentity_PB, SIGNAL(clicked()), this, SLOT(newIdentity())); connect(ui.importIdentity_PB, SIGNAL(clicked()), this, SLOT(importIdentity())); connect(ui.exportIdentity_PB, SIGNAL(clicked()), this, SLOT(exportIdentity())); + ui.identityTreeWidget -> setColumnCount(3); init() ; } +void ProfileManager::identityTreeWidgetCostumPopupMenu( QPoint ) +{ + QTreeWidgetItem *wi = getCurrentIdentity(); + if (!wi) + return; + + QMenu contextMnu( this ); + + //QAction* exportidentityAct = new QAction(QIcon(IMAGE_EXPORT), tr( "Export Identity" ), &contextMnu ); + //connect( exportidentityAct , SIGNAL( triggered() ), this, SLOT( exportIdentity() ) ); + //contextMnu.addAction( exportidentityAct); + + contextMnu.exec(QCursor::pos()); +} + void ProfileManager::init() { std::cerr << "Finding PGPUsers" << std::endl; + + QTreeWidget *identityTreeWidget = ui.identityTreeWidget; - QString titleString("%1"); +#define COLUMN_NAME 0 +#define COLUMN_EMAIL 1 +#define COLUMN_GID 2 + + QTreeWidgetItem *item; std::list pgpIds; std::list::iterator it; @@ -72,16 +96,21 @@ void ProfileManager::init() std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl; QString gid = QString::fromStdString(*it).right(8) ; ui.genPGPuser->addItem(QString::fromUtf8(name.c_str()) + " <" + QString::fromUtf8(email.c_str()) + "> (" + gid + ")", userData); - ui.listWidget->addItem(QString::fromUtf8(name.c_str()) + " <" + QString::fromUtf8(email.c_str()) + "> (" + gid + ")"); + + item = new RSTreeWidgetItem(NULL, 0); + item -> setText(COLUMN_NAME, QString::fromUtf8(name.c_str())); + item -> setText(COLUMN_EMAIL, QString::fromUtf8(email.c_str())); + item -> setText(COLUMN_GID, gid); + identityTreeWidget->addTopLevelItem(item); foundGPGKeys = true; } } + + identityTreeWidget->update(); /* update display */ } - - void ProfileManager::exportIdentity() { QString fname = QFileDialog::getSaveFileName(this,tr("Export Identity"), "",tr("RetroShare Identity files (*.asc)")) ; @@ -98,6 +127,7 @@ void ProfileManager::exportIdentity() else QMessageBox::information(this,tr("Identity not saved"),tr("Your identity was not saved. An error occured.")) ; } + void ProfileManager::importIdentity() { QString fname = QFileDialog::getOpenFileName(this,tr("Export Identity"), "",tr("RetroShare Identity files (*.asc)")) ; @@ -199,3 +229,11 @@ void ProfileManager::newIdentity() gd.exec (); } +QTreeWidgetItem *ProfileManager::getCurrentIdentity() +{ + if (ui.identityTreeWidget->selectedItems().size() != 0) { + return ui.identityTreeWidget -> currentItem(); + } + + return NULL; +} diff --git a/retroshare-gui/src/gui/profile/ProfileManager.h b/retroshare-gui/src/gui/profile/ProfileManager.h index f0de98338..a8545584a 100644 --- a/retroshare-gui/src/gui/profile/ProfileManager.h +++ b/retroshare-gui/src/gui/profile/ProfileManager.h @@ -39,23 +39,22 @@ public: /** Default destructor */ private slots: + void identityTreeWidgetCostumPopupMenu( QPoint point ); void selectFriend(); void importIdentity(); void exportIdentity(); void checkChanged(int i); - void newIdentity(); + void newIdentity(); private: + QTreeWidgetItem *getCurrentIdentity(); - void init() ; + void init() ; - /** Loads the saved connectidialog settings */ - // void loadSettings(); - void loadCertificates(); - - - QMovie *movie; + /** Loads the saved connectidialog settings */ + // void loadSettings(); + void loadCertificates(); /** Qt Designer generated object */ Ui::ProfileManager ui; diff --git a/retroshare-gui/src/gui/profile/ProfileManager.ui b/retroshare-gui/src/gui/profile/ProfileManager.ui index 945d5e8fe..2066efe31 100644 --- a/retroshare-gui/src/gui/profile/ProfileManager.ui +++ b/retroshare-gui/src/gui/profile/ProfileManager.ui @@ -7,7 +7,7 @@ 0 0 625 - 356 + 402 @@ -699,7 +699,26 @@ border: 1px solid #CCCCCC;} - + + + Qt::CustomContextMenu + + + + Name + + + + + Email + + + + + GID + + + @@ -808,6 +827,9 @@ p, li { white-space: pre-wrap; } + + +