mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05:00
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
This commit is contained in:
parent
878855e356
commit
9d3d457630
@ -25,17 +25,18 @@
|
|||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
#include "ProfileManager.h"
|
#include "ProfileManager.h"
|
||||||
#include "gui/GenCertDialog.h"
|
#include "gui/GenCertDialog.h"
|
||||||
|
#include "gui/common/RSTreeWidgetItem.h"
|
||||||
|
|
||||||
#include <QAbstractEventDispatcher>
|
#include <QAbstractEventDispatcher>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMovie>
|
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#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 */
|
/** Default constructor */
|
||||||
@ -45,19 +46,42 @@ ProfileManager::ProfileManager(QWidget *parent, Qt::WFlags flags)
|
|||||||
/* Invoke Qt Designer generated QObject setup routine */
|
/* Invoke Qt Designer generated QObject setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
connect(ui.identityTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( identityTreeWidgetCostumPopupMenu( QPoint ) ) );
|
||||||
connect(ui.newIdentity_PB, SIGNAL(clicked()), this, SLOT(newIdentity()));
|
connect(ui.newIdentity_PB, SIGNAL(clicked()), this, SLOT(newIdentity()));
|
||||||
connect(ui.importIdentity_PB, SIGNAL(clicked()), this, SLOT(importIdentity()));
|
connect(ui.importIdentity_PB, SIGNAL(clicked()), this, SLOT(importIdentity()));
|
||||||
connect(ui.exportIdentity_PB, SIGNAL(clicked()), this, SLOT(exportIdentity()));
|
connect(ui.exportIdentity_PB, SIGNAL(clicked()), this, SLOT(exportIdentity()));
|
||||||
|
|
||||||
|
ui.identityTreeWidget -> setColumnCount(3);
|
||||||
|
|
||||||
init() ;
|
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()
|
void ProfileManager::init()
|
||||||
{
|
{
|
||||||
std::cerr << "Finding PGPUsers" << std::endl;
|
std::cerr << "Finding PGPUsers" << std::endl;
|
||||||
|
|
||||||
|
QTreeWidget *identityTreeWidget = ui.identityTreeWidget;
|
||||||
|
|
||||||
QString titleString("<span style=\"font-size:17pt; font-weight:500;" "color:white;\">%1</span>");
|
#define COLUMN_NAME 0
|
||||||
|
#define COLUMN_EMAIL 1
|
||||||
|
#define COLUMN_GID 2
|
||||||
|
|
||||||
|
QTreeWidgetItem *item;
|
||||||
|
|
||||||
std::list<std::string> pgpIds;
|
std::list<std::string> pgpIds;
|
||||||
std::list<std::string>::iterator it;
|
std::list<std::string>::iterator it;
|
||||||
@ -72,16 +96,21 @@ void ProfileManager::init()
|
|||||||
std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl;
|
std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl;
|
||||||
QString gid = QString::fromStdString(*it).right(8) ;
|
QString gid = QString::fromStdString(*it).right(8) ;
|
||||||
ui.genPGPuser->addItem(QString::fromUtf8(name.c_str()) + " <" + QString::fromUtf8(email.c_str()) + "> (" + gid + ")", userData);
|
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;
|
foundGPGKeys = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
identityTreeWidget->update(); /* update display */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ProfileManager::exportIdentity()
|
void ProfileManager::exportIdentity()
|
||||||
{
|
{
|
||||||
QString fname = QFileDialog::getSaveFileName(this,tr("Export Identity"), "",tr("RetroShare Identity files (*.asc)")) ;
|
QString fname = QFileDialog::getSaveFileName(this,tr("Export Identity"), "",tr("RetroShare Identity files (*.asc)")) ;
|
||||||
@ -98,6 +127,7 @@ void ProfileManager::exportIdentity()
|
|||||||
else
|
else
|
||||||
QMessageBox::information(this,tr("Identity not saved"),tr("Your identity was not saved. An error occured.")) ;
|
QMessageBox::information(this,tr("Identity not saved"),tr("Your identity was not saved. An error occured.")) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileManager::importIdentity()
|
void ProfileManager::importIdentity()
|
||||||
{
|
{
|
||||||
QString fname = QFileDialog::getOpenFileName(this,tr("Export Identity"), "",tr("RetroShare Identity files (*.asc)")) ;
|
QString fname = QFileDialog::getOpenFileName(this,tr("Export Identity"), "",tr("RetroShare Identity files (*.asc)")) ;
|
||||||
@ -199,3 +229,11 @@ void ProfileManager::newIdentity()
|
|||||||
gd.exec ();
|
gd.exec ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem *ProfileManager::getCurrentIdentity()
|
||||||
|
{
|
||||||
|
if (ui.identityTreeWidget->selectedItems().size() != 0) {
|
||||||
|
return ui.identityTreeWidget -> currentItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@ -39,23 +39,22 @@ public:
|
|||||||
/** Default destructor */
|
/** Default destructor */
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void identityTreeWidgetCostumPopupMenu( QPoint point );
|
||||||
|
|
||||||
void selectFriend();
|
void selectFriend();
|
||||||
void importIdentity();
|
void importIdentity();
|
||||||
void exportIdentity();
|
void exportIdentity();
|
||||||
void checkChanged(int i);
|
void checkChanged(int i);
|
||||||
void newIdentity();
|
void newIdentity();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QTreeWidgetItem *getCurrentIdentity();
|
||||||
|
|
||||||
void init() ;
|
void init() ;
|
||||||
|
|
||||||
/** Loads the saved connectidialog settings */
|
/** Loads the saved connectidialog settings */
|
||||||
// void loadSettings();
|
// void loadSettings();
|
||||||
void loadCertificates();
|
void loadCertificates();
|
||||||
|
|
||||||
|
|
||||||
QMovie *movie;
|
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::ProfileManager ui;
|
Ui::ProfileManager ui;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>625</width>
|
<width>625</width>
|
||||||
<height>356</height>
|
<height>402</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -699,7 +699,26 @@ border: 1px solid #CCCCCC;}</string>
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QListWidget" name="listWidget"/>
|
<widget class="QTreeWidget" name="identityTreeWidget">
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Name</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Email</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>GID</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@ -808,6 +827,9 @@ p, li { white-space: pre-wrap; }
|
|||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
|
<include location="../images.qrc"/>
|
||||||
|
<include location="../images.qrc"/>
|
||||||
|
<include location="../images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user