Added Identity stuff into the GUI.

- Generic Classes:
	- GxsIdChooser: gets a list of current OwnIds for user to select AuthorId.
	- GxsIdLabel: retrieves and displays Author Information.
	- GxsIdTreeWidgetItem: retrieves and displays Author Information, in specified column.
 - Added GxsIdChooser into GxsGroupDialog & CreateGxsForumMsg.
 - Added GxsIdTreeWidgetItem into Forum Thread listings.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5849 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-11-19 22:14:45 +00:00
parent c6e6d444bf
commit c90d0d6abd
14 changed files with 639 additions and 22 deletions

View file

@ -58,7 +58,6 @@ GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent
:GxsGroupDialog(tokenQueue, ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent, "Create New Forum")
{
}
GxsForumGroupDialog::GxsForumGroupDialog(const RsGxsForumGroup &group, QWidget *parent)

View file

@ -84,11 +84,13 @@ GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenQueue, uint32_t enableFlags, uin
/* Setup Reasonable Defaults */
ui.idChooser->loadIds(0,"");
}
GxsGroupDialog::GxsGroupDialog(const RsGroupMetaData &grpMeta, uint32_t mode, QWidget *parent)
: QDialog(parent), mMode(mode), mGrpMeta(grpMeta) {
ui.idChooser->loadIds(0,"");
}
void GxsGroupDialog::setMode(uint32_t mode)

View file

@ -186,6 +186,9 @@ border-radius: 10px;
</property>
</spacer>
</item>
<item>
<widget class="GxsIdChooser" name="idChooser"/>
</item>
<item>
<widget class="QCheckBox" name="pubKeyShare_cb">
<property name="toolTip">
@ -554,6 +557,11 @@ p, li { white-space: pre-wrap; }
<header>gui/common/FriendSelectionWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GxsIdChooser</class>
<extends>QComboBox</extends>
<header>gui/gxs/GxsIdChooser.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>

View file

@ -0,0 +1,143 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "GxsIdChooser.h"
#include <algorithm>
#include <retroshare/rspeers.h>
#include <iostream>
/** Constructor */
GxsIdChooser::GxsIdChooser(QWidget *parent)
: QComboBox(parent), mFlags(IDCHOOSER_ANON_DEFAULT), mDefaultId("")
{
return;
}
void GxsIdChooser::loadIds(uint32_t chooserFlags, RsGxsId defId)
{
mFlags = chooserFlags;
mDefaultId = defId;
loadPrivateIds();
}
bool MakeIdDesc(const RsGxsId &id, QString &desc)
{
RsIdentityDetails details;
if (!rsIdentity->getIdDetails(id, details))
{
return false;
}
desc = QString::fromUtf8(details.mNickname.c_str());
if (details.mPgpLinked)
{
desc += " (PGP) [";
}
else
{
desc += " (Anon) [";
}
desc += QString::fromStdString(id.substr(0,5));
desc += "...]";
return true;
}
void GxsIdChooser::loadPrivateIds()
{
std::list<RsGxsId> ids;
rsIdentity->getOwnIds(ids);
if (ids.empty())
{
std::cerr << "GxsIdChooser::loadPrivateIds() ERROR no ids";
std::cerr << std::endl;
return;
}
//rsIdentity->getDefaultId(defId);
// Prefer to use an application specific default???
int def = -1;
if (!(mFlags & IDCHOOSER_ID_REQUIRED))
{
/* add No Signature option */
QString str = "No Signature";
QString id = "";
addItem(str, id);
if (mFlags & IDCHOOSER_ANON_DEFAULT)
{
def = 0;
}
}
int i = 1;
std::list<RsGxsId>::iterator it;
for(it = ids.begin(); it != ids.end(); it++, i++)
{
/* add to Chooser */
QString str;
if (!MakeIdDesc(*it, str))
{
std::cerr << "GxsIdChooser::loadPrivateIds() ERROR Desc for Id: " << *it;
std::cerr << std::endl;
continue;
}
QString id = QString::fromStdString(*it);
addItem(str, id);
if (mDefaultId == *it)
{
def = i;
}
}
if (def >= 0)
{
setCurrentIndex(def);
//ui.comboBox->setCurrentIndex(def);
}
}
bool GxsIdChooser::getChosenId(RsGxsId &id)
{
if (count() < 1)
{
return false;
}
int idx = currentIndex();
QVariant var = itemData(idx);
id = var.toString().toStdString();
return true;
}

View file

@ -0,0 +1,50 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _GXS_ID_CHOOSER_H
#define _GXS_ID_CHOOSER_H
#include <QComboBox>
#include <retroshare/rsidentity.h>
#define IDCHOOSER_ID_REQUIRED 0x0001
#define IDCHOOSER_ANON_DEFAULT 0x0002
class GxsIdChooser : public QComboBox
{
Q_OBJECT
public:
GxsIdChooser(QWidget *parent = NULL);
void loadIds(uint32_t chooserFlags, RsGxsId defId);
bool getChosenId(RsGxsId &id);
private:
void loadPrivateIds();
uint32_t mFlags;
RsGxsId mDefaultId;
};
#endif

View file

@ -0,0 +1,124 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "GxsIdLabel.h"
#include <algorithm>
#include <retroshare/rspeers.h>
#include <iostream>
/** Constructor */
GxsIdLabel::GxsIdLabel(QWidget *parent)
:QLabel(parent), mTimer(NULL), mCount(0)
{
mTimer = new QTimer(this);
mTimer->setSingleShot(true);
connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId()));
return;
}
void GxsIdLabel::setId(const RsGxsId &id)
{
mId = id;
if (mId == "")
{
setText("No Signature");
}
else
{
loadId();
}
}
bool GxsIdLabel::getId(RsGxsId &id)
{
id = mId;
return true;
}
static bool MakeIdDesc(const RsGxsId &id, QString &str)
{
RsIdentityDetails details;
if (!rsIdentity->getIdDetails(id, details))
{
str = "Loading... " + QString::fromStdString(id.substr(0,5));
return false;
}
str = QString::fromUtf8(details.mNickname.c_str());
bool addCode = true;
if (details.mPgpLinked)
{
str += " (PGP) [";
if (details.mPgpKnown)
{
/* look up real name */
std::string authorName = rsPeers->getPeerName(details.mPgpId);
str += QString::fromUtf8(authorName.c_str());
str += "]";
addCode = false;
}
}
else
{
str += " (Anon) [";
}
if (addCode)
{
str += QString::fromStdString(id.substr(0,5));
str += "...]";
}
return true;
}
#define MAX_ATTEMPTS 3
void GxsIdLabel::loadId()
{
mCount++;
/* try and get details - if not there ... set callback */
QString desc;
bool loaded = MakeIdDesc(mId, desc);
setText(desc);
if (loaded)
{
return;
}
if (mCount < MAX_ATTEMPTS)
{
/* timer event to try again */
mTimer->setInterval(mCount * 1000);
mTimer->start();
}
}

View file

@ -0,0 +1,51 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _GXS_ID_LABEL_H
#define _GXS_ID_LABEL_H
#include <QTimer>
#include <QLabel>
#include <retroshare/rsidentity.h>
class GxsIdLabel : public QLabel
{
Q_OBJECT
public:
GxsIdLabel(QWidget *parent = NULL);
void setId(const RsGxsId &id);
bool getId(RsGxsId &id);
private slots:
void loadId();
private:
QTimer *mTimer;
RsGxsId mId;
int mCount;
};
#endif

View file

@ -0,0 +1,141 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "GxsIdTreeWidgetItem.h"
#include <algorithm>
#include <retroshare/rspeers.h>
#include <iostream>
/** Constructor */
GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(QTreeWidget *parent)
:QTreeWidgetItem(parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0)
{
mTimer = new QTimer(this);
mTimer->setSingleShot(true);
connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId()));
return;
}
GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(QTreeWidgetItem *parent)
:QTreeWidgetItem(parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0)
{
mTimer = new QTimer(this);
mTimer->setSingleShot(true);
connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId()));
return;
}
void GxsIdTreeWidgetItem::setId(const RsGxsId &id, int column)
{
std::cerr << " GxsIdTreeWidgetItem::setId(" << id << "," << column << ")";
std::cerr << std::endl;
mId = id;
mColumn = column;
if (mId == "")
{
setText(mColumn, "No Signature");
}
else
{
loadId();
}
}
bool GxsIdTreeWidgetItem::getId(RsGxsId &id)
{
id = mId;
return true;
}
static bool MakeIdDesc(const RsGxsId &id, QString &str)
{
RsIdentityDetails details;
if (!rsIdentity->getIdDetails(id, details))
{
str = "Loading... " + QString::fromStdString(id.substr(0,5));
return false;
}
str = QString::fromUtf8(details.mNickname.c_str());
bool addCode = true;
if (details.mPgpLinked)
{
str += " (PGP) [";
if (details.mPgpKnown)
{
/* look up real name */
std::string authorName = rsPeers->getPeerName(details.mPgpId);
str += QString::fromUtf8(authorName.c_str());
str += "]";
addCode = false;
}
}
else
{
str += " (Anon) [";
}
if (addCode)
{
str += QString::fromStdString(id.substr(0,5));
str += "...]";
}
return true;
}
#define MAX_ATTEMPTS 5
void GxsIdTreeWidgetItem::loadId()
{
std::cerr << " GxsIdTreeWidgetItem::loadId() Id: " << mId << ", mCount: " << mCount;
std::cerr << std::endl;
mCount++;
/* try and get details - if not there ... set callback */
QString desc;
bool loaded = MakeIdDesc(mId, desc);
setText(mColumn, desc);
if (loaded)
{
return;
}
if (mCount < MAX_ATTEMPTS)
{
/* timer event to try again */
mTimer->setInterval(mCount * 1000);
mTimer->start();
}
}

View file

@ -0,0 +1,53 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _GXS_ID_TREEWIDGETITEM_H
#define _GXS_ID_TREEWIDGETITEM_H
#include <QTreeWidget>
#include <QTimer>
#include <retroshare/rsidentity.h>
class GxsIdTreeWidgetItem : public QObject, public QTreeWidgetItem
{
Q_OBJECT
public:
GxsIdTreeWidgetItem(QTreeWidget *parent = NULL);
GxsIdTreeWidgetItem(QTreeWidgetItem *parent);
void setId(const RsGxsId &id, int column);
bool getId(RsGxsId &id);
private slots:
void loadId();
private:
QTimer *mTimer;
RsGxsId mId;
int mCount;
int mColumn;
};
#endif