mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 21:34:10 -05:00
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:
parent
c6e6d444bf
commit
c90d0d6abd
@ -1017,10 +1017,14 @@ gxsgui {
|
|||||||
gui/gxs/GxsCommentTreeWidget.h \
|
gui/gxs/GxsCommentTreeWidget.h \
|
||||||
gui/gxs/WikiGroupDialog.h \
|
gui/gxs/WikiGroupDialog.h \
|
||||||
gui/gxs/GxsForumGroupDialog.h \
|
gui/gxs/GxsForumGroupDialog.h \
|
||||||
|
gui/gxs/GxsIdChooser.h \
|
||||||
|
gui/gxs/GxsIdLabel.h \
|
||||||
|
gui/gxs/GxsIdTreeWidgetItem.h \
|
||||||
|
|
||||||
# gui/gxs/GxsMsgDialog.h \
|
# gui/gxs/GxsMsgDialog.h \
|
||||||
|
|
||||||
FORMS += gui/gxs/GxsGroupDialog.ui \
|
FORMS += gui/gxs/GxsGroupDialog.ui \
|
||||||
|
|
||||||
# gui/gxs/GxsMsgDialog.ui \
|
# gui/gxs/GxsMsgDialog.ui \
|
||||||
# gui/gxs/GxsCommentTreeWidget.ui \
|
# gui/gxs/GxsCommentTreeWidget.ui \
|
||||||
|
|
||||||
@ -1028,6 +1032,9 @@ gxsgui {
|
|||||||
gui/gxs/GxsCommentTreeWidget.cpp \
|
gui/gxs/GxsCommentTreeWidget.cpp \
|
||||||
gui/gxs/WikiGroupDialog.cpp \
|
gui/gxs/WikiGroupDialog.cpp \
|
||||||
gui/gxs/GxsForumGroupDialog.cpp \
|
gui/gxs/GxsForumGroupDialog.cpp \
|
||||||
|
gui/gxs/GxsIdChooser.cpp \
|
||||||
|
gui/gxs/GxsIdLabel.cpp \
|
||||||
|
gui/gxs/GxsIdTreeWidgetItem.cpp \
|
||||||
|
|
||||||
# gui/gxs/GxsMsgDialog.cpp \
|
# gui/gxs/GxsMsgDialog.cpp \
|
||||||
|
|
||||||
|
@ -241,10 +241,6 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
|||||||
|
|
||||||
ui.threadTreeWidget->installEventFilter(this);
|
ui.threadTreeWidget->installEventFilter(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rsGxsForums->generateDummyData();
|
|
||||||
|
|
||||||
/* Hide platform specific features */
|
/* Hide platform specific features */
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
|
|
||||||
@ -2094,8 +2090,8 @@ void GxsForumsDialog::loadGroupThreadData_InsertThreads(const uint32_t &token)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GxsForumsDialog::convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std::string authorName,
|
bool GxsForumsDialog::convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo,
|
||||||
bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item)
|
bool useChildTS, uint32_t filterColumn, GxsIdTreeWidgetItem *item)
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
|
|
||||||
@ -2120,6 +2116,8 @@ bool GxsForumsDialog::convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std
|
|||||||
|
|
||||||
item->setText(COLUMN_THREAD_TITLE, GxsForumsDialog::titleFromInfo(msgInfo.mMeta));
|
item->setText(COLUMN_THREAD_TITLE, GxsForumsDialog::titleFromInfo(msgInfo.mMeta));
|
||||||
|
|
||||||
|
item->setId(msgInfo.mMeta.mAuthorId, COLUMN_THREAD_AUTHOR);
|
||||||
|
#if 0
|
||||||
text = QString::fromUtf8(authorName.c_str());
|
text = QString::fromUtf8(authorName.c_str());
|
||||||
|
|
||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
@ -2130,6 +2128,7 @@ bool GxsForumsDialog::convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std
|
|||||||
{
|
{
|
||||||
item->setText(COLUMN_THREAD_AUTHOR, text);
|
item->setText(COLUMN_THREAD_AUTHOR, text);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TOGXS
|
#ifdef TOGXS
|
||||||
if (msgInfo.mMeta.mMsgFlags & RS_DISTRIB_AUTHEN_REQ)
|
if (msgInfo.mMeta.mMsgFlags & RS_DISTRIB_AUTHEN_REQ)
|
||||||
@ -2173,11 +2172,13 @@ bool GxsForumsDialog::convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std
|
|||||||
|
|
||||||
void GxsForumsDialog::loadForumBaseThread(const RsGxsForumMsg &msg)
|
void GxsForumsDialog::loadForumBaseThread(const RsGxsForumMsg &msg)
|
||||||
{
|
{
|
||||||
std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId);
|
//std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId);
|
||||||
|
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem(); // no Parent.
|
//QTreeWidgetItem *item = new QTreeWidgetItem(); // no Parent.
|
||||||
|
GxsIdTreeWidgetItem *item = new GxsIdTreeWidgetItem(); // no Parent.
|
||||||
|
|
||||||
convertMsgToThreadWidget(msg, authorName, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, item);
|
//convertMsgToThreadWidget(msg, authorName, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, item);
|
||||||
|
convertMsgToThreadWidget(msg, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, item);
|
||||||
|
|
||||||
/* request Children Data */
|
/* request Children Data */
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
@ -2262,21 +2263,23 @@ void GxsForumsDialog::loadChildData_InsertThreads(const uint32_t &token)
|
|||||||
|
|
||||||
void GxsForumsDialog::loadForumChildMsg(const RsGxsForumMsg &msg, QTreeWidgetItem *parent)
|
void GxsForumsDialog::loadForumChildMsg(const RsGxsForumMsg &msg, QTreeWidgetItem *parent)
|
||||||
{
|
{
|
||||||
std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId);
|
//std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId);
|
||||||
|
|
||||||
QTreeWidgetItem *child = NULL;
|
//QTreeWidgetItem *child = NULL;
|
||||||
|
GxsIdTreeWidgetItem *child = NULL;
|
||||||
|
|
||||||
if (mThreadLoad.FlatView)
|
if (mThreadLoad.FlatView)
|
||||||
{
|
{
|
||||||
child = new QTreeWidgetItem(); // no Parent.
|
child = new GxsIdTreeWidgetItem(); // no Parent.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
child = new QTreeWidgetItem(parent);
|
child = new GxsIdTreeWidgetItem(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
convertMsgToThreadWidget(msg, authorName, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, child);
|
convertMsgToThreadWidget(msg, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, child);
|
||||||
|
//convertMsgToThreadWidget(msg, authorName, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, child);
|
||||||
|
|
||||||
/* request Children Data */
|
/* request Children Data */
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
|
|
||||||
#include <retroshare/rsgxsforums.h>
|
#include <retroshare/rsgxsforums.h>
|
||||||
|
|
||||||
|
#include "gui/gxs/GxsIdTreeWidgetItem.h"
|
||||||
|
|
||||||
class ForumInfo;
|
class ForumInfo;
|
||||||
|
|
||||||
|
|
||||||
@ -202,8 +204,10 @@ private:
|
|||||||
void requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId);
|
void requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId);
|
||||||
void loadMsgData_ReplyMessage(const uint32_t &token);
|
void loadMsgData_ReplyMessage(const uint32_t &token);
|
||||||
|
|
||||||
bool convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std::string authorName,
|
bool convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo,
|
||||||
bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item);
|
bool useChildTS, uint32_t filterColumn, GxsIdTreeWidgetItem *item);
|
||||||
|
//bool convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std::string authorName,
|
||||||
|
// bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item);
|
||||||
|
|
||||||
TokenQueue *mForumQueue;
|
TokenQueue *mForumQueue;
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent
|
|||||||
:GxsGroupDialog(tokenQueue, ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent, "Create New Forum")
|
:GxsGroupDialog(tokenQueue, ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent, "Create New Forum")
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsForumGroupDialog::GxsForumGroupDialog(const RsGxsForumGroup &group, QWidget *parent)
|
GxsForumGroupDialog::GxsForumGroupDialog(const RsGxsForumGroup &group, QWidget *parent)
|
||||||
|
@ -84,11 +84,13 @@ GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenQueue, uint32_t enableFlags, uin
|
|||||||
|
|
||||||
/* Setup Reasonable Defaults */
|
/* Setup Reasonable Defaults */
|
||||||
|
|
||||||
|
ui.idChooser->loadIds(0,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsGroupDialog::GxsGroupDialog(const RsGroupMetaData &grpMeta, uint32_t mode, QWidget *parent)
|
GxsGroupDialog::GxsGroupDialog(const RsGroupMetaData &grpMeta, uint32_t mode, QWidget *parent)
|
||||||
: QDialog(parent), mMode(mode), mGrpMeta(grpMeta) {
|
: QDialog(parent), mMode(mode), mGrpMeta(grpMeta) {
|
||||||
|
|
||||||
|
ui.idChooser->loadIds(0,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsGroupDialog::setMode(uint32_t mode)
|
void GxsGroupDialog::setMode(uint32_t mode)
|
||||||
|
@ -186,6 +186,9 @@ border-radius: 10px;
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="GxsIdChooser" name="idChooser"/>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="pubKeyShare_cb">
|
<widget class="QCheckBox" name="pubKeyShare_cb">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@ -554,6 +557,11 @@ p, li { white-space: pre-wrap; }
|
|||||||
<header>gui/common/FriendSelectionWidget.h</header>
|
<header>gui/common/FriendSelectionWidget.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>GxsIdChooser</class>
|
||||||
|
<extends>QComboBox</extends>
|
||||||
|
<header>gui/gxs/GxsIdChooser.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
|
143
retroshare-gui/src/gui/gxs/GxsIdChooser.cpp
Normal file
143
retroshare-gui/src/gui/gxs/GxsIdChooser.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
50
retroshare-gui/src/gui/gxs/GxsIdChooser.h
Normal file
50
retroshare-gui/src/gui/gxs/GxsIdChooser.h
Normal 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
|
||||||
|
|
124
retroshare-gui/src/gui/gxs/GxsIdLabel.cpp
Normal file
124
retroshare-gui/src/gui/gxs/GxsIdLabel.cpp
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
51
retroshare-gui/src/gui/gxs/GxsIdLabel.h
Normal file
51
retroshare-gui/src/gui/gxs/GxsIdLabel.h
Normal 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
|
||||||
|
|
141
retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp
Normal file
141
retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
53
retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h
Normal file
53
retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h
Normal 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
|
||||||
|
|
@ -104,6 +104,9 @@ void CreateGxsForumMsg::newMsg()
|
|||||||
mParentMsgLoaded = false;
|
mParentMsgLoaded = false;
|
||||||
mForumMetaLoaded = false;
|
mForumMetaLoaded = false;
|
||||||
|
|
||||||
|
/* fill in the available OwnIds for signing */
|
||||||
|
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, "");
|
||||||
|
|
||||||
/* request Data */
|
/* request Data */
|
||||||
{
|
{
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
@ -259,8 +262,29 @@ void CreateGxsForumMsg::createMsg()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((msg.mMsg == "") && (msg.mMeta.mMsgName == ""))
|
if ((msg.mMsg == "") && (msg.mMeta.mMsgName == ""))
|
||||||
return; /* do nothing */
|
return; /* do nothing */
|
||||||
|
|
||||||
|
if (ui.signBox->isChecked())
|
||||||
|
{
|
||||||
|
RsGxsId authorId;
|
||||||
|
if (ui.idChooser->getChosenId(authorId))
|
||||||
|
{
|
||||||
|
msg.mMeta.mAuthorId = authorId;
|
||||||
|
std::cerr << "CreateGxsForumMsg::createMsg() AuthorId: " << authorId;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "CreateGxsForumMsg::createMsg() ERROR GETTING AuthorId!";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "CreateGxsForumMsg::createMsg() No Signature (for now :)";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
rsGxsForums->createMsg(token, msg);
|
rsGxsForums->createMsg(token, msg);
|
||||||
close();
|
close();
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>482</width>
|
<width>482</width>
|
||||||
<height>448</height>
|
<height>497</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -180,6 +180,9 @@ border: 1px solid #CCCCCC;}</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="GxsIdChooser" name="idChooser"/>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -246,8 +249,8 @@ border: 1px solid #CCCCCC;}</string>
|
|||||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html></string>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -319,6 +322,11 @@ p, li { white-space: pre-wrap; }
|
|||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>GxsIdChooser</class>
|
||||||
|
<extends>QComboBox</extends>
|
||||||
|
<header>gui/gxs/GxsIdChooser.h</header>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>HashBox</class>
|
<class>HashBox</class>
|
||||||
<extends>QScrollArea</extends>
|
<extends>QScrollArea</extends>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user