mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04: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 "ProfileManager.h"
|
||||
#include "gui/GenCertDialog.h"
|
||||
#include "gui/common/RSTreeWidgetItem.h"
|
||||
|
||||
#include <QAbstractEventDispatcher>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QMovie>
|
||||
#include <QTreeWidget>
|
||||
#include <QMenu>
|
||||
|
||||
#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 */
|
||||
@ -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("<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>::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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>625</width>
|
||||
<height>356</height>
|
||||
<height>402</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -699,7 +699,26 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<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>
|
||||
</layout>
|
||||
</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"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
Loading…
Reference in New Issue
Block a user