merging gxs_phase2 branch

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6401 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2013-06-04 21:00:43 +00:00
parent 1150366913
commit 325fa4f222
116 changed files with 6050 additions and 3596 deletions

View file

@ -50,7 +50,9 @@ CirclesDialog::CirclesDialog(QWidget *parent)
ui.setupUi(this);
connect( ui.pushButton_refresh, SIGNAL(clicked()), this, SLOT(reloadAll()));
connect( ui.pushButton_circle, SIGNAL(clicked()), this, SLOT(create()));
connect( ui.pushButton_extCircle, SIGNAL(clicked()), this, SLOT(createExternalCircle()));
connect( ui.pushButton_localCircle, SIGNAL(clicked()), this, SLOT(createPersonalCircle()));
connect( ui.pushButton_editCircle, SIGNAL(clicked()), this, SLOT(editExistingCircle()));
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
@ -86,10 +88,31 @@ void CirclesDialog::checkUpdate()
#define CIRCLEGROUP_FRIEND_COL_NAME 0
#define CIRCLEGROUP_FRIEND_COL_ID 1
void CirclesDialog::create()
void CirclesDialog::createExternalCircle()
{
CreateCircleDialog *createDialog = new CreateCircleDialog();
createDialog->editNewId(true);
createDialog->show();
}
void CirclesDialog::createPersonalCircle()
{
CreateCircleDialog *createDialog = new CreateCircleDialog();
createDialog->editNewId(false);
createDialog->show();
}
void CirclesDialog::editExistingCircle()
{
#if 0
std::string id;
CreateCircleDialog *createDialog = new CreateCircleDialog();
createDialog->editExistingId(id);
createDialog->show();
#endif
}
@ -586,9 +609,21 @@ void CirclesDialog::loadGroupMeta(const uint32_t &token)
}
/* add the top level item */
QTreeWidgetItem *circlesItem = new QTreeWidgetItem();
circlesItem->setText(0, "Circles");
ui.treeWidget_membership->addTopLevelItem(circlesItem);
QTreeWidgetItem *personalCirclesItem = new QTreeWidgetItem();
personalCirclesItem->setText(0, "Personal Circles");
ui.treeWidget_membership->addTopLevelItem(personalCirclesItem);
QTreeWidgetItem *externalAdminCirclesItem = new QTreeWidgetItem();
externalAdminCirclesItem->setText(0, "External Circles (Admin)");
ui.treeWidget_membership->addTopLevelItem(externalAdminCirclesItem);
QTreeWidgetItem *externalSubCirclesItem = new QTreeWidgetItem();
externalSubCirclesItem->setText(0, "External Circles (Subscribed)");
ui.treeWidget_membership->addTopLevelItem(externalSubCirclesItem);
QTreeWidgetItem *externalOtherCirclesItem = new QTreeWidgetItem();
externalOtherCirclesItem->setText(0, "External Circles (Other)");
ui.treeWidget_membership->addTopLevelItem(externalOtherCirclesItem);
for(vit = groupInfo.begin(); vit != groupInfo.end(); vit++)
{
@ -600,7 +635,26 @@ void CirclesDialog::loadGroupMeta(const uint32_t &token)
QTreeWidgetItem *groupItem = new QTreeWidgetItem();
groupItem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, QString::fromStdString(vit->mGroupName));
groupItem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPID, QString::fromStdString(vit->mGroupId));
circlesItem->addChild(groupItem);
if (vit->mCircleType == GXS_CIRCLE_TYPE_LOCAL)
{
personalCirclesItem->addChild(groupItem);
}
else
{
if (vit->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)
{
externalAdminCirclesItem->addChild(groupItem);
}
else if (vit->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)
{
externalSubCirclesItem->addChild(groupItem);
}
else
{
externalOtherCirclesItem->addChild(groupItem);
}
}
}
}

View file

@ -44,7 +44,9 @@ void loadRequest(const TokenQueue *queue, const TokenRequest &req);
private slots:
void create();
void createExternalCircle();
void createPersonalCircle();
void editExistingCircle();
void checkUpdate();

View file

@ -17,16 +17,23 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pushButton_localgroup">
<widget class="QPushButton" name="pushButton_localCircle">
<property name="text">
<string>Create Personal Group</string>
<string>Create Personal Circle</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_circle">
<widget class="QPushButton" name="pushButton_extCircle">
<property name="text">
<string>Create Circle</string>
<string>Create External Circle</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_editCircle">
<property name="text">
<string>Edit Circle</string>
</property>
</widget>
</item>
@ -157,6 +164,9 @@
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Permissions</string>
</property>

View file

@ -78,6 +78,9 @@ CreateCircleDialog::CreateCircleDialog()
connect(ui.addButton, SIGNAL(clicked()), this, SLOT(addMember()));
connect(ui.removeButton, SIGNAL(clicked()), this, SLOT(removeMember()));
connect(ui.pushButton_create, SIGNAL(clicked()), this, SLOT(createCircle()));
connect(ui.pushButton_cancel, SIGNAL(clicked()), this, SLOT(cancelDialog()));
//connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums()));
//connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile()));
//connect(ui.pastersButton, SIGNAL(clicked()), this, SLOT(pasteLink()));
@ -87,8 +90,13 @@ CreateCircleDialog::CreateCircleDialog()
ui.removeButton->setEnabled(false);
ui.addButton->setEnabled(false);
ui.radioButton_ListAll->setChecked(true);
requestIdentities();
ui.radioButton_ListKnownPGP->setChecked(true);
mIsExistingCircle = false;
mIsExternalCircle = true;
ui.idChooser->loadIds(0,"");
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL);
}
@ -99,6 +107,83 @@ CreateCircleDialog::~CreateCircleDialog()
delete(mIdQueue);
}
void CreateCircleDialog::editExistingId(std::string circleId)
{
/* load this circle */
mIsExistingCircle = true;
/* setup personal or external circle */
bool isExternal = false;
if (isExternal)
{
setupForExternalCircle();
}
else
{
setupForPersonalCircle();
}
/* lock stuff they cannot edit */
}
void CreateCircleDialog::editNewId(bool isExternal)
{
/* load this circle */
mIsExistingCircle = false;
/* setup personal or external circle */
if (isExternal)
{
setupForExternalCircle();
}
else
{
setupForPersonalCircle();
}
/* enable stuff that might be locked */
}
void CreateCircleDialog::setupForPersonalCircle()
{
mIsExternalCircle = false;
/* hide distribution line */
ui.groupBox_title->setTitle(tr("Personal Circle Details"));
ui.frame_PgpTypes->hide();
ui.frame_Distribution->hide();
ui.idChooserLabel->hide();
ui.idChooser->hide();
getPgpIdentities();
}
void CreateCircleDialog::setupForExternalCircle()
{
mIsExternalCircle = true;
/* show distribution line */
ui.groupBox_title->setTitle(tr("External Circle Details"));
ui.frame_PgpTypes->show();
ui.frame_Distribution->show();
ui.idChooserLabel->show();
ui.idChooser->show();
requestGxsIdentities();
}
void CreateCircleDialog::cancelDialog()
{
close();
}
void CreateCircleDialog::selectedId(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
@ -532,13 +617,29 @@ void CreateCircleDialog::addMember()
{
return;
}
/* check that its not there already */
QString keyId = item->text(RSCIRCLEID_COL_KEYID);
QTreeWidget *tree = ui.treeWidget_membership;
int count = tree->topLevelItemCount();
for(int i = 0; i < count; i++)
{
QTreeWidgetItem *item = tree->topLevelItem(i);
if (keyId == item->text(RSCIRCLEID_COL_KEYID))
{
std::cerr << "CreateCircleDialog::addMember() Already is a Member: " << keyId.toStdString();
std::cerr << std::endl;
return;
}
}
QTreeWidgetItem *member = new QTreeWidgetItem();
member->setText(RSCIRCLEID_COL_NICKNAME, item->text(RSCIRCLEID_COL_NICKNAME));
member->setText(RSCIRCLEID_COL_KEYID, item->text(RSCIRCLEID_COL_KEYID));
member->setText(RSCIRCLEID_COL_IDTYPE, item->text(RSCIRCLEID_COL_IDTYPE));
ui.treeWidget_membership->addTopLevelItem(member);
tree->addTopLevelItem(member);
}
@ -558,6 +659,9 @@ void CreateCircleDialog::removeMember()
void CreateCircleDialog::createCircle()
{
std::cerr << "CreateCircleDialog::createCircle()";
std::cerr << std::endl;
QString name = ui.circleName->text();
QString desc;
@ -588,8 +692,106 @@ void CreateCircleDialog::createCircle()
/* copy Ids from GUI */
QTreeWidget *tree = ui.treeWidget_membership;
int count = tree->topLevelItemCount();
for(int i = 0; i < count; i++)
{
QTreeWidgetItem *item = tree->topLevelItem(i);
QString keyId = item->text(RSCIRCLEID_COL_KEYID);
/* insert into circle */
if (mIsExternalCircle)
{
circle.mInvitedMembers.push_back(keyId.toStdString());
std::cerr << "CreateCircleDialog::createCircle() Inserting Member: " << keyId.toStdString();
std::cerr << std::endl;
}
else
{
circle.mLocalFriends.push_back(keyId.toStdString());
std::cerr << "CreateCircleDialog::createCircle() Inserting Friend: " << keyId.toStdString();
std::cerr << std::endl;
}
}
if (mIsExistingCircle)
{
std::cerr << "CreateCircleDialog::createCircle() Existing Circle TODO";
std::cerr << std::endl;
// cannot edit these yet.
QMessageBox::warning(this, tr("RetroShare"),tr("Cannot Edit Existing Circles Yet"),
QMessageBox::Ok, QMessageBox::Ok);
return;
}
if (mIsExternalCircle)
{
std::cerr << "CreateCircleDialog::createCircle() External Circle";
std::cerr << std::endl;
// set distribution from GUI.
circle.mMeta.mCircleId = "";
if (ui.radioButton_Public->isChecked())
{
std::cerr << "CreateCircleDialog::createCircle() Public Circle";
std::cerr << std::endl;
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
}
else if (ui.radioButton_Self->isChecked())
{
std::cerr << "CreateCircleDialog::createCircle() ExtSelfRef Circle";
std::cerr << std::endl;
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXT_SELF;
}
else if (ui.radioButton_Restricted->isChecked())
{
std::cerr << "CreateCircleDialog::createCircle() External (Other) Circle";
std::cerr << std::endl;
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXTERNAL;
/* grab circle ID from chooser */
RsGxsCircleId chosenId;
if (ui.circleComboBox->getChosenCircle(chosenId))
{
std::cerr << "CreateCircleDialog::createCircle() ChosenId: " << chosenId;
std::cerr << std::endl;
circle.mMeta.mCircleId = chosenId;
}
else
{
std::cerr << "CreateCircleDialog::createCircle() Error no Id Chosen";
std::cerr << std::endl;
QMessageBox::warning(this, tr("RetroShare"),tr("No Restriction Circle Selected"),
QMessageBox::Ok, QMessageBox::Ok);
return;
}
}
else
{
QMessageBox::warning(this, tr("RetroShare"),tr("No Circle Limitations Selected"),
QMessageBox::Ok, QMessageBox::Ok);
return;
}
}
else
{
std::cerr << "CreateCircleDialog::createCircle() Personal Circle";
std::cerr << std::endl;
// set personal distribution
circle.mMeta.mCircleId = "";
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_LOCAL;
}
std::cerr << "CreateCircleDialog::createCircle() Checks and Balances Okay - calling service proper..";
std::cerr << std::endl;
uint32_t token;
rsGxsCircles->createGroup(token, circle);
@ -648,7 +850,37 @@ void CreateCircleDialog::loadCircle(uint32_t token)
}
void CreateCircleDialog::requestIdentities()
void CreateCircleDialog::getPgpIdentities()
{
std::cerr << "CreateCircleDialog::getPgpIdentities()";
std::cerr << std::endl;
QTreeWidget *tree = ui.treeWidget_IdList;
tree->clear();
std::list<std::string> ids;
std::list<std::string>::iterator it;
rsPeers->getGPGAcceptedList(ids);
for(it = ids.begin(); it != ids.end(); it++)
{
QTreeWidgetItem *item = new QTreeWidgetItem();
RsPeerDetails details;
rsPeers->getGPGDetails(*it, details);
item->setText(RSCIRCLEID_COL_IDTYPE, "PGP Identity");
item->setText(RSCIRCLEID_COL_NICKNAME, QString::fromStdString(details.name));
item->setText(RSCIRCLEID_COL_KEYID, QString::fromStdString(details.gpg_id));
tree->addTopLevelItem(item);
}
}
void CreateCircleDialog::requestGxsIdentities()
{
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
@ -676,7 +908,6 @@ void CreateCircleDialog::loadIdentities(uint32_t token)
std::list<std::string> ids;
std::list<std::string>::iterator it;
bool acceptAll = ui.radioButton_ListAll->isChecked();
bool acceptAllPGP = ui.radioButton_ListAllPGP->isChecked();
bool acceptKnownPGP = ui.radioButton_ListKnownPGP->isChecked();
@ -696,11 +927,7 @@ void CreateCircleDialog::loadIdentities(uint32_t token)
/* do filtering */
bool ok = false;
if (acceptAll)
{
ok = true;
}
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
{
if (acceptAllPGP)
{

View file

@ -39,6 +39,9 @@ public:
CreateCircleDialog();
~CreateCircleDialog();
void editNewId(bool isExternal);
void editExistingId(std::string circleId);
#if 0
void newMsg(); /* cleanup */
#endif
@ -53,6 +56,9 @@ private slots:
void selectedId(QTreeWidgetItem*, QTreeWidgetItem*);
void selectedMember(QTreeWidgetItem*, QTreeWidgetItem*);
void createCircle();
void cancelDialog();
#if 0
/** Create the context popup menu and it's submenus */
void forumMessageCostumPopupMenu( QPoint point );
@ -94,13 +100,18 @@ private:
RsGroupMetaData mForumMeta;
#endif
void createCircle();
void setupForPersonalCircle();
void setupForExternalCircle();
bool mIsExistingCircle;
bool mIsExternalCircle;
void loadCircle(uint32_t token);
void loadIdentities(uint32_t token);
void requestCircle(const RsGxsGroupId &groupId);
void requestIdentities();
void requestGxsIdentities();
void getPgpIdentities();
TokenQueue *mCircleQueue;
TokenQueue *mIdQueue;

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>746</width>
<height>568</height>
<width>681</width>
<height>544</height>
</rect>
</property>
<property name="windowTitle">
@ -15,7 +15,7 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox_5">
<widget class="QGroupBox" name="groupBox_title">
<property name="title">
<string>Circle Details</string>
</property>
@ -39,7 +39,7 @@
<widget class="QLineEdit" name="circleName"/>
</item>
<item>
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="idChooserLabel">
<property name="font">
<font>
<weight>75</weight>
@ -57,58 +57,72 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Distribution</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_Public">
<property name="text">
<string>Public</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_Self">
<property name="text">
<string>Self-Restricted</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_Restricted">
<property name="text">
<string>Restricted to:</string>
</property>
</widget>
</item>
<item>
<widget class="GxsCircleChooser" name="circleComboBox"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="QFrame" name="frame_Distribution">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Distribution</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_Public">
<property name="text">
<string>Public</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_Self">
<property name="text">
<string>Self-Restricted</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_Restricted">
<property name="text">
<string>Restricted to:</string>
</property>
</widget>
</item>
<item>
<widget class="GxsCircleChooser" name="circleComboBox"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>147</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
@ -187,29 +201,36 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="radioButton_ListAll">
<property name="text">
<string>All IDs</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_ListAllPGP">
<property name="text">
<string>All PGP IDs</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_ListKnownPGP">
<property name="text">
<string>Known PGP IDs</string>
</property>
</widget>
</item>
</layout>
<widget class="QFrame" name="frame_PgpTypes">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="radioButton_ListAllPGP">
<property name="text">
<string>All PGP IDs</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_ListKnownPGP">
<property name="text">
<string>Known PGP IDs</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
@ -263,14 +284,14 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_publicgroup_2">
<widget class="QPushButton" name="pushButton_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_publicgroup">
<widget class="QPushButton" name="pushButton_create">
<property name="text">
<string>Create Group</string>
</property>

View file

@ -22,6 +22,7 @@
*/
#include "IdDialog.h"
#include "gui/gxs/GxsIdTreeWidgetItem.h"
#include <retroshare/rspeers.h>
#include <retroshare/rsidentity.h>
@ -39,6 +40,7 @@
// Data Requests.
#define IDDIALOG_IDLIST 1
#define IDDIALOG_IDDETAILS 2
#define IDDIALOG_REPLIST 3
/****************************************************************
*/
@ -48,7 +50,10 @@
#define RSID_COL_KEYID 1
#define RSID_COL_IDTYPE 2
#define RSIDREP_COL_NAME 0
#define RSIDREP_COL_OPINION 1
#define RSIDREP_COL_COMMENT 2
#define RSIDREP_COL_REPUTATION 3
#define RSID_REQ_IDLIST 1
#define RSID_REQ_IDDETAILS 2
@ -235,6 +240,28 @@ void IdDialog::insertIdDetails(uint32_t token)
ui.pushButton_Delete->setEnabled(false);
ui.pushButton_EditId->setEnabled(false);
}
/* now fill in the reputation information */
ui.line_RatingOverall->setText("Overall Rating TODO");
ui.line_RatingOwn->setText("Own Rating TODO");
if (data.mPgpKnown)
{
ui.line_RatingImplicit->setText("+50 Known PGP");
}
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
{
ui.line_RatingImplicit->setText("+10 UnKnown PGP");
}
else
{
ui.line_RatingImplicit->setText("+5 Anon Id");
}
/* request network ratings */
requestRepList(data.mMeta.mGroupId);
}
void IdDialog::checkUpdate()
@ -300,11 +327,9 @@ void IdDialog::requestIdList()
uint32_t token;
std::list<std::string> groupIds;
//mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDDIALOG_IDLIST);
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, IDDIALOG_IDLIST);
}
void IdDialog::insertIdList(uint32_t token)
{
QTreeWidget *tree = ui.treeWidget_IdList;
@ -415,6 +440,66 @@ void IdDialog::insertIdList(uint32_t token)
updateSelection();
}
void IdDialog::requestRepList(const RsGxsGroupId &aboutId)
{
std::list<RsGxsGroupId> groupIds;
groupIds.push_back(aboutId);
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
uint32_t token;
mIdQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDDIALOG_REPLIST);
}
void IdDialog::insertRepList(uint32_t token)
{
QTreeWidget *tree = ui.treeWidget_RepList;
tree->clear();
std::list<std::string> ids;
std::list<std::string>::iterator it;
std::vector<RsGxsIdOpinion> opinions;
std::vector<RsGxsIdOpinion>::iterator vit;
if (!rsIdentity->getMsgData(token, opinions))
{
std::cerr << "IdDialog::insertRepList() Error getting Opinions";
std::cerr << std::endl;
return;
}
for(vit = opinions.begin(); vit != opinions.end(); vit++)
{
RsGxsIdOpinion &op = (*vit);
GxsIdTreeWidgetItem *item = new GxsIdTreeWidgetItem();
/* insert 4 columns */
/* friend name */
item->setId(op.mMeta.mGroupId, RSIDREP_COL_NAME);
/* score */
item->setText(RSIDREP_COL_OPINION, QString::number(op.getOpinion()));
/* comment */
item->setText(RSIDREP_COL_COMMENT, QString::fromUtf8(op.mComment.c_str()));
/* local reputation */
item->setText(RSIDREP_COL_REPUTATION, QString::number(op.getReputation()));
tree->addTopLevelItem(item);
}
// fix up buttons.
updateSelection();
}
void IdDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
@ -430,6 +515,10 @@ void IdDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
insertIdDetails(req.mToken);
break;
case IDDIALOG_REPLIST:
insertRepList(req.mToken);
break;
default:
std::cerr << "IdDialog::loadRequest() ERROR";
std::cerr << std::endl;

View file

@ -63,6 +63,9 @@ private:
void requestIdData(std::list<std::string> &ids);
void insertIdList(uint32_t token);
void requestRepList(const RsGxsGroupId &aboutId);
void insertRepList(uint32_t token);
void requestIdEdit(std::string &id);
void showIdEdit(uint32_t token);

View file

@ -13,8 +13,8 @@
<property name="windowTitle">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<property name="bottomMargin">
<number>6</number>
@ -168,12 +168,9 @@
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_4">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QFrame" name="frame">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
@ -216,7 +213,7 @@
</layout>
</widget>
</item>
<item row="1" column="0">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Identity Type</string>
@ -403,35 +400,80 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Reputation</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Your Rating</string>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Overall Rating</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Implicit Score</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Your Rating</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBox"/>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLineEdit" name="line_RatingOverall"/>
</item>
<item>
<widget class="QLineEdit" name="line_RatingImplicit"/>
</item>
<item>
<widget class="QLineEdit" name="line_RatingOwn"/>
</item>
</layout>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Overall Rating</string>
</property>
<item row="1" column="0" colspan="2">
<widget class="QTreeWidget" name="treeWidget_RepList">
<column>
<property name="text">
<string>Friend</string>
</property>
</column>
<column>
<property name="text">
<string>Rating</string>
</property>
</column>
<column>
<property name="text">
<string>Comment</string>
</property>
</column>
<column>
<property name="text">
<string>Local Reputation</string>
</property>
</column>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="lineEdit_3"/>
</item>
<item row="1" column="0" colspan="4">
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</widget>
</item>

View file

@ -32,7 +32,7 @@ PostedCreatePostDialog::PostedCreatePostDialog(TokenQueue* tokenQ, RsPosted *pos
ui(new Ui::PostedCreatePostDialog)
{
ui->setupUi(this);
connect(this, SIGNAL(accepted()), this, SLOT(createPost()));
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(createPost()));
/* fill in the available OwnIds for signing */
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, "");
@ -64,7 +64,7 @@ void PostedCreatePostDialog::createPost()
uint32_t token;
mPosted->createPost(token, post);
mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_POST);
close();
accept();
}
PostedCreatePostDialog::~PostedCreatePostDialog()

View file

@ -117,22 +117,6 @@ p, li { white-space: pre-wrap; }
<include location="../images.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>PostedCreatePostDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>

View file

@ -99,7 +99,7 @@ void PostedItem::setContent(const RsPostedPost &post)
qtime.setTime_t(mPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
dateLabel->setText(timestamp);
fromLabel->setText(QString::fromUtf8(post.mMeta.mAuthorId.c_str()));
fromLabel->setId(post.mMeta.mAuthorId);
titleLabel->setText("<a href=" + QString::fromStdString(post.mLink) +
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
QString::fromStdString(post.mMeta.mMsgName) + "</span></a>");
@ -107,6 +107,51 @@ void PostedItem::setContent(const RsPostedPost &post)
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
QString::fromStdString(post.mLink) + "</span></a>");
//QString score = "Hot" + QString::number(post.mHotScore);
//score += " Top" + QString::number(post.mTopScore);
//score += " New" + QString::number(post.mNewScore);
QString score = QString::number(post.mTopScore);
scoreLabel->setText(score);
// FIX THIS UP LATER.
//notes->setPlainText(QString::fromUtf8(post.mNotes.c_str()));
// differences between Feed or Top of Comment.
if (mParent)
{
// feed.
//frame_notes->hide();
//frame_comment->show();
commentButton->show();
if (post.mComments)
{
QString commentText = QString::number(post.mComments);
commentText += " ";
commentText += tr("Comments");
commentButton->setText(commentText);
}
else
{
commentButton->setText(tr("Comment"));
}
}
else
{
// no feed.
//frame_notes->show();
//frame_comment->hide();
commentButton->hide();
}
// disable voting buttons - if they have already voted.
if (post.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK)
{
voteUpButton->setEnabled(false);
voteDownButton->setEnabled(false);
}
uint32_t up, down, nComments;
#if 0
@ -137,6 +182,9 @@ void PostedItem::makeDownVote()
RsGxsGrpMsgIdPair msgId;
msgId.first = mPost.mMeta.mGroupId;
msgId.second = mPost.mMeta.mMsgId;
voteUpButton->setEnabled(false);
voteDownButton->setEnabled(false);
emit vote(msgId, false);
}
@ -145,6 +193,10 @@ void PostedItem::makeUpVote()
RsGxsGrpMsgIdPair msgId;
msgId.first = mPost.mMeta.mGroupId;
msgId.second = mPost.mMeta.mMsgId;
voteUpButton->setEnabled(false);
voteDownButton->setEnabled(false);
emit vote(msgId, true);
}

View file

@ -42,6 +42,9 @@ public:
RsPostedPost getPost() const;
void setContent(const RsPostedPost& post);
// Make this public so we can sort based on it.
RsPostedPost mPost;
private slots:
void loadComments();
void makeUpVote();
@ -54,13 +57,11 @@ protected:
virtual void loadMessage(const uint32_t &token);
private:
void setup();
uint32_t mType;
bool mSelected;
RsPostedPost mPost;
};

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>638</width>
<height>177</height>
<width>874</width>
<height>117</height>
</rect>
</property>
<property name="font">
@ -18,14 +18,11 @@
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>6</number>
</property>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -66,13 +63,6 @@ border-radius: 10px}</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>score</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="voteDownButton">
<property name="text">
@ -113,167 +103,127 @@ border-radius: 10px}</string>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QHBoxLayout" name="_4">
<item>
<widget class="QLabel" name="dateBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Date</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="dateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">You eyes only</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="_3">
<item>
<widget class="QLabel" name="fromBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>From</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fromLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">Signed by</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="_5">
<item>
<widget class="QLabel" name="fromBoldLabel_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Site</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="siteLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">Signed by</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,1,0">
<item>
<widget class="QLabel" name="numCommentsLabel">
<widget class="QLabel" name="dateBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt; font-weight:600;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt; Comments: 0&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Date</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="QLabel" name="dateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>288</width>
<height>20</height>
</size>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
</spacer>
<property name="text">
<string notr="true">You eyes only</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fromBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>From</string>
</property>
</widget>
</item>
<item>
<widget class="GxsIdLabel" name="fromLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">Signed by</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fromBoldLabel_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Site</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="siteLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">Signed by</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="commentButton">
@ -289,6 +239,13 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GxsIdLabel</class>
<extends>QLabel</extends>
<header>gui/gxs/GxsIdLabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -65,6 +65,8 @@
// token types to deal with
#define POSTED_DEFAULT_LISTING_LENGTH 10
#define POSTED_MAX_INDEX 10000
/** Constructor */
PostedListDialog::PostedListDialog(QWidget *parent)
@ -83,6 +85,14 @@ PostedListDialog::PostedListDialog(QWidget *parent)
connect(ui.hotSortButton, SIGNAL(clicked()), this, SLOT(getRankings()));
connect(ui.newSortButton, SIGNAL(clicked()), this, SLOT(getRankings()));
connect(ui.topSortButton, SIGNAL(clicked()), this, SLOT(getRankings()));
connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(showNext()));
connect(ui.prevButton, SIGNAL(clicked()), this, SLOT(showPrev()));
// default sort method.
mSortMethod = RsPosted::HotRankType;
mLastSortMethod = RsPosted::TopRankType; // to be different.
mPostIndex = 0;
mPostShow = POSTED_DEFAULT_LISTING_LENGTH;
/* create posted tree */
yourTopics = ui.groupTreeWidget->addCategoryItem(tr("My Topics"), QIcon(IMAGE_FOLDER), true);
@ -99,77 +109,77 @@ PostedListDialog::PostedListDialog(QWidget *parent)
refreshTopics();
}
void PostedListDialog::showNext()
{
mPostIndex += mPostShow;
if (mPostIndex > POSTED_MAX_INDEX)
mPostIndex = POSTED_MAX_INDEX;
applyRanking();
updateShowText();
}
void PostedListDialog::showPrev()
{
mPostIndex -= mPostShow;
if (mPostIndex < 0)
mPostIndex = 0;
applyRanking();
updateShowText();
}
void PostedListDialog::updateShowText()
{
QString showText = tr("Showing");
showText += " ";
showText += QString::number(mPostIndex + 1);
showText += "-";
showText += QString::number(mPostIndex + mPostShow);
ui.showLabel->setText(showText);
}
void PostedListDialog::getRankings()
{
#if 0
if(mCurrTopicId.empty())
return;
std::cerr << "PostedListDialog::getHotRankings()";
std::cerr << "PostedListDialog::getRankings()";
std::cerr << std::endl;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
uint32_t token;
int oldSortMethod = mSortMethod;
QObject* button = sender();
if(button == ui.hotSortButton)
{
rsPosted->requestPostRankings(token, RsPosted::HotRankType, mCurrTopicId);
}else if(button == ui.topSortButton)
mSortMethod = RsPosted::HotRankType;
}
else if(button == ui.topSortButton)
{
rsPosted->requestPostRankings(token, RsPosted::TopRankType, mCurrTopicId);
}else if(button == ui.newSortButton)
mSortMethod = RsPosted::TopRankType;
}
else if(button == ui.newSortButton)
{
mSortMethod = RsPosted::NewRankType;
}
else
{
rsPosted->requestPostRankings(token, RsPosted::NewRankType, mCurrTopicId);
}else{
return;
}
mPostedQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_DATA, TOKEN_USER_TYPE_POST_RANKINGS);
#endif
}
#if 0
void PostedListDialog::loadRankings(const uint32_t &token)
{
RsPostedPostRanking rankings;
if(!rsPosted->getPostRanking(token, rankings))
return;
if(rankings.grpId != mCurrTopicId)
return;
applyRanking(rankings.ranking);
}
#endif
#if 0
void PostedListDialog::applyRanking(const PostedRanking& ranks)
{
std::cerr << "PostedListDialog::loadGroupThreadData_InsertThreads()";
std::cerr << std::endl;
shallowClearPosts();
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
PostedRanking::const_iterator mit = ranks.begin();
for(; mit != ranks.end(); mit++)
if (oldSortMethod != mSortMethod)
{
const RsGxsMessageId& msgId = mit->second;
if(mPosts.find(msgId) != mPosts.end())
alayout->addWidget(mPosts[msgId]);
/* Reset Counter */
mPostIndex = 0;
updateShowText();
}
return;
applyRanking();
}
#endif
void PostedListDialog::refreshTopics()
{
@ -180,6 +190,12 @@ void PostedListDialog::refreshTopics()
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
uint32_t token;
mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_USER_TYPE_TOPIC);
/* refresh Id Chooser Too */
RsGxsId currentId = "";
ui.idChooser->getChosenId(currentId);
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, currentId);
}
void PostedListDialog::groupListCustomPopupMenu( QPoint /*point*/ )
@ -251,28 +267,48 @@ void PostedListDialog::subscribeTopic()
}
void PostedListDialog::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
{
#if 0
uint32_t token;
RsPostedVote vote;
/* must grab AuthorId from Layout */
RsGxsId authorId;
if (!ui.idChooser->getChosenId(authorId))
{
std::cerr << "PostedListDialog::createPost() ERROR GETTING AuthorId!, Vote Failed";
std::cerr << std::endl;
QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose a Signing Id before Voting"),
QMessageBox::Ok, QMessageBox::Ok);
return;
}
RsGxsVote vote;
vote.mMeta.mGroupId = msgId.first;
vote.mMeta.mThreadId = msgId.second;
vote.mMeta.mParentId = msgId.second;
vote.mDirection = (uint8_t)up;
rsPosted->submitVote(token, vote);
vote.mMeta.mAuthorId = authorId;
mPostedQueue->queueRequest(token, 0 , RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_VOTE);
#endif
if (up)
{
vote.mVoteType = GXS_VOTE_UP;
}
else
{
vote.mVoteType = GXS_VOTE_DOWN;
}
std::cerr << "PostedListDialog::submitVote()";
std::cerr << std::endl;
std::cerr << "GroupId : " << vote.mMeta.mGroupId << std::endl;
std::cerr << "ThreadId : " << vote.mMeta.mThreadId << std::endl;
std::cerr << "ParentId : " << vote.mMeta.mParentId << std::endl;
std::cerr << "AuthorId : " << vote.mMeta.mAuthorId << std::endl;
uint32_t token;
rsPosted->createVote(token, vote);
mPostedQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_VOTE);
}
@ -317,14 +353,27 @@ void PostedListDialog::updateDisplay()
if (rsPosted->updated(true, true))
{
std::cerr << "rsPosted->updated() returned true";
std::cerr << std::endl;
/* update Forums List */
rsPosted->groupsChanged(groupIds);
if(!groupIds.empty())
{
std::list<std::string>::iterator it = std::find(groupIds.begin(), groupIds.end(), mCurrTopicId);
std::cerr << "rsPosted->groupsChanged():";
std::cerr << std::endl;
std::list<std::string>::iterator it;
for(it = groupIds.begin(); it != groupIds.end(); it++)
{
std::cerr << "\t" << *it;
std::cerr << std::endl;
}
if(it != groupIds.end()){
it = std::find(groupIds.begin(), groupIds.end(), mCurrTopicId);
if(it != groupIds.end())
{
std::cerr << "current Group -> requesting Group Summary";
std::cerr << std::endl;
requestGroupSummary();
return;
}
@ -334,11 +383,16 @@ void PostedListDialog::updateDisplay()
if(!msgs.empty())
{
std::cerr << "rsPosted->msgsChanged():";
std::cerr << std::endl;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit = msgs.find(mCurrTopicId);
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
mit = msgs.find(mCurrTopicId);
if(mit != msgs.end())
{
std::cerr << "current Group -> updating Displayed Items";
std::cerr << std::endl;
updateDisplayedItems(mit->second);
}
}
@ -362,6 +416,13 @@ void PostedListDialog::updateDisplayedItems(const std::vector<RsGxsMessageId> &m
std::cerr << "PostedListDialog::updateDisplayedItems(" << mCurrTopicId << ")";
std::cerr << std::endl;
std::vector<RsGxsMessageId>::const_iterator it;
for(it = msgIds.begin(); it != msgIds.end(); it++)
{
std::cerr << "\t\tMsgId: " << *it;
std::cerr << std::endl;
}
uint32_t token;
mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgs, TOKEN_USER_TYPE_POST_MOD);
@ -465,7 +526,7 @@ void PostedListDialog::acknowledgeVoteMsg(const uint32_t &token)
{
RsGxsGrpMsgIdPair msgId;
rsPosted->acknowledgeMsg(token, msgId);
rsPosted->acknowledgeVote(token, msgId);
}
void PostedListDialog::loadVoteData(const uint32_t &token)
@ -546,19 +607,19 @@ void PostedListDialog::loadCurrentTopicThreads(const std::string &topicId)
void PostedListDialog::requestGroupThreadData_InsertThreads(const std::string &groupId)
{
RsTokReqOptions opts;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
std::list<RsGxsGroupId> grpIds;
std::list<RsGxsGroupId> grpIds;
grpIds.push_back(groupId);
std::cerr << "PostedListDialog::requestGroupThreadData_InsertThreads(" << groupId << ")";
std::cerr << std::endl;
std::cerr << "PostedListDialog::requestGroupThreadData_InsertThreads(" << groupId << ")";
std::cerr << std::endl;
uint32_t token;
mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, TOKEN_USER_TYPE_POST);
mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, TOKEN_USER_TYPE_POST);
}
@ -579,15 +640,128 @@ void PostedListDialog::loadGroupThreadData_InsertThreads(const uint32_t &token)
loadPost(p);
}
applyRanking();
}
void PostedListDialog::loadPost(const RsPostedPost &post)
{
PostedItem *item = new PostedItem(this, 0, post, true);
connect(item, SIGNAL(vote(RsGxsGrpMsgIdPair,bool)), this, SLOT(submitVote(RsGxsGrpMsgIdPair,bool)));
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
mPosts.insert(post.mMeta.mMsgId, item);
alayout->addWidget(item);
//QLayout *alayout = ui.scrollAreaWidgetContents->layout();
//alayout->addWidget(item);
mPostList.push_back(item);
}
bool CmpPIHot(const PostedItem *a, const PostedItem *b)
{
if (a->mPost.mHotScore == b->mPost.mHotScore)
{
(a->mPost.mNewScore > b->mPost.mNewScore);
}
return (a->mPost.mHotScore > b->mPost.mHotScore);
}
bool CmpPITop(const PostedItem *a, const PostedItem *b)
{
if (a->mPost.mTopScore == b->mPost.mTopScore)
{
(a->mPost.mNewScore > b->mPost.mNewScore);
}
return (a->mPost.mTopScore > b->mPost.mTopScore);
}
bool CmpPINew(const PostedItem *a, const PostedItem *b)
{
return (a->mPost.mNewScore > b->mPost.mNewScore);
}
void PostedListDialog::applyRanking()
{
/* uses current settings to sort posts, then add to layout */
std::cerr << "PostedListDialog::applyRanking()";
std::cerr << std::endl;
shallowClearPosts();
/* sort */
switch(mSortMethod)
{
default:
case RsPosted::HotRankType:
std::cerr << "PostedListDialog::applyRanking() HOT";
std::cerr << std::endl;
mPostList.sort(CmpPIHot);
break;
case RsPosted::NewRankType:
std::cerr << "PostedListDialog::applyRanking() NEW";
std::cerr << std::endl;
mPostList.sort(CmpPINew);
break;
case RsPosted::TopRankType:
std::cerr << "PostedListDialog::applyRanking() TOP";
std::cerr << std::endl;
mPostList.sort(CmpPITop);
break;
}
mLastSortMethod = mSortMethod;
std::cerr << "PostedListDialog::applyRanking() Sorted mPostList";
std::cerr << std::endl;
/* go through list (skipping out-of-date items) to get */
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
int counter = 0;
time_t min_ts = 0;
std::list<PostedItem *>::iterator it;
for(it = mPostList.begin(); it != mPostList.end(); it++)
{
PostedItem *item = (*it);
std::cerr << "PostedListDialog::applyRanking() Item: " << item;
std::cerr << std::endl;
if (item->mPost.mMeta.mPublishTs < min_ts)
{
std::cerr << "\t Skipping OLD";
std::cerr << std::endl;
item->hide();
continue;
}
if (counter >= mPostIndex + mPostShow)
{
std::cerr << "\t END - Counter too high";
std::cerr << std::endl;
item->hide();
}
else if (counter >= mPostIndex)
{
std::cerr << "\t Adding to Layout";
std::cerr << std::endl;
/* add it in! */
item->show();
alayout->addWidget(item);
}
else
{
std::cerr << "\t Skipping to Low";
std::cerr << std::endl;
item->hide();
}
counter++;
}
std::cerr << "PostedListDialog::applyRanking() Loaded New Order";
std::cerr << std::endl;
// trigger a redraw.
ui.scrollAreaWidgetContents->update();
}
@ -633,11 +807,12 @@ void PostedListDialog::clearPosts()
}
mPosts.clear();
mPostList.clear();
}
void PostedListDialog::shallowClearPosts()
{
std::cerr << "PostedListDialog::clearPosts()" << std::endl;
std::cerr << "PostedListDialog::shallowClearPosts()" << std::endl;
std::list<PostedItem *> postedItems;
std::list<PostedItem *>::iterator pit;
@ -649,7 +824,7 @@ void PostedListDialog::shallowClearPosts()
QLayoutItem *litem = alayout->itemAt(i);
if (!litem)
{
std::cerr << "PostedListDialog::clearPosts() missing litem";
std::cerr << "PostedListDialog::shallowClearPosts() missing litem";
std::cerr << std::endl;
continue;
}
@ -657,14 +832,14 @@ void PostedListDialog::shallowClearPosts()
PostedItem *item = dynamic_cast<PostedItem *>(litem->widget());
if (item)
{
std::cerr << "PostedListDialog::clearPosts() item: " << item;
std::cerr << "PostedListDialog::shallowClearPosts() item: " << item;
std::cerr << std::endl;
postedItems.push_back(item);
}
else
{
std::cerr << "PostedListDialog::clearPosts() Found Child, which is not a PostedItem???";
std::cerr << "PostedListDialog::shallowClearPosts() Found Child, which is not a PostedItem???";
std::cerr << std::endl;
}
}
@ -679,7 +854,7 @@ void PostedListDialog::shallowClearPosts()
void PostedListDialog::updateCurrentDisplayComplete(const uint32_t &token)
{
std::cerr << "PostedListDialog::loadGroupThreadData_InsertThreads()";
std::cerr << "PostedListDialog::updateCurrentDisplayComplete()";
std::cerr << std::endl;
std::vector<RsPostedPost> posts;
@ -693,9 +868,29 @@ void PostedListDialog::updateCurrentDisplayComplete(const uint32_t &token)
// modify post content
if(mPosts.find(p.mMeta.mMsgId) != mPosts.end())
mPosts[p.mMeta.mMsgId]->setContent(p);
{
std::cerr << "PostedListDialog::updateCurrentDisplayComplete() updating MsgId: " << p.mMeta.mMsgId;
std::cerr << std::endl;
mPosts[p.mMeta.mMsgId]->setContent(p);
}
else
{
std::cerr << "PostedListDialog::updateCurrentDisplayComplete() loading New MsgId: " << p.mMeta.mMsgId;
std::cerr << std::endl;
/* insert new entry */
loadPost(p);
}
}
time_t now = time(NULL);
QMap<RsGxsMessageId, PostedItem*>::iterator pit;
for(pit = mPosts.begin(); pit != mPosts.end(); pit++)
{
(*pit)->mPost.calculateScores(now);
}
applyRanking();
}

View file

@ -83,8 +83,14 @@ private slots:
void subscribeTopic();
void unsubscribeTopic();
void showNext();
void showPrev();
private:
void updateShowText();
void clearPosts();
/*!
@ -124,6 +130,7 @@ private:
//void loadRankings(const uint32_t& token);
//void applyRanking(const PostedRanking& ranks);
void applyRanking();
// update displayed item
@ -143,12 +150,19 @@ private:
QTreeWidgetItem *popularTopics;
QTreeWidgetItem *otherTopics;
int mSortMethod;
int mLastSortMethod;
int mPostIndex;
int mPostShow;
bool mThreadLoading;
RsGxsGroupId mCurrTopicId;
QMap<RsGxsGroupId, RsPostedGroup> mGroups;
QMap<RsGxsMessageId, PostedItem*> mPosts;
std::list<PostedItem *> mPostList;
TokenQueue *mPostedQueue;
//CommentHolder* mCommentHolder;

View file

@ -122,6 +122,9 @@
</item>
</widget>
</item>
<item>
<widget class="GxsIdChooser" name="idChooser"/>
</item>
</layout>
</item>
<item>
@ -188,7 +191,7 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="showLabel">
<property name="text">
<string>Showing 1-100</string>
</property>
@ -221,7 +224,7 @@
<x>0</x>
<y>0</y>
<width>443</width>
<height>316</height>
<height>162</height>
</rect>
</property>
<property name="sizePolicy">
@ -241,6 +244,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GxsIdChooser</class>
<extends>QComboBox</extends>
<header>gui/gxs/GxsIdChooser.h</header>
</customwidget>
<customwidget>
<class>GroupTreeWidget</class>
<extends>QWidget</extends>

View file

@ -67,7 +67,14 @@ bool MakeGxsCircleDesc(const RsGxsCircleId &id, QString &desc)
void GxsCircleChooser::loadGxsCircles()
{
std::list<RsGxsCircleId> ids;
rsGxsCircles->getCircleIdList(ids);
if (mFlags & GXS_CIRCLE_CHOOSER_EXTERNAL)
{
rsGxsCircles->getCircleExternalIdList(ids);
}
if (mFlags & GXS_CIRCLE_CHOOSER_PERSONAL)
{
rsGxsCircles->getCirclePersonalIdList(ids);
}
if (ids.empty())
{

View file

@ -28,6 +28,11 @@
#include <QComboBox>
#include <retroshare/rsgxscircles.h>
#define GXS_CIRCLE_CHOOSER_EXTERNAL 0x0001
#define GXS_CIRCLE_CHOOSER_PERSONAL 0x0002
#define GXS_CIRCLE_CHOOSER_ALLCIRCLES 0x0003 // OR of other two.
class GxsCircleChooser : public QComboBox
{
Q_OBJECT

View file

@ -102,7 +102,8 @@ void GxsGroupDialog::init()
/* Setup Reasonable Defaults */
ui.idChooser->loadIds(0,"");
ui.circleComboBox->loadCircles(0);
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL);
ui.localComboBox->loadCircles(GXS_CIRCLE_CHOOSER_PERSONAL);
initMode();
}
@ -351,7 +352,14 @@ void GxsGroupDialog::createGroup()
meta.mGroupFlags = flags;
meta.mSignFlags = getGroupSignFlags();
setCircleParameters(meta);
if (!setCircleParameters(meta))
{
/* error message */
QMessageBox::warning(this, "RetroShare", tr("Invalid Circle Selection - Personal disabled for now"), QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add with invalid circle.
}
ui.idChooser->getChosenId(meta.mAuthorId);
if (service_CreateGroup(token, meta))
@ -458,9 +466,13 @@ void GxsGroupDialog::updateCircleOptions()
}
}
void GxsGroupDialog::setCircleParameters(RsGroupMetaData &meta)
bool GxsGroupDialog::setCircleParameters(RsGroupMetaData &meta)
{
bool problem = false;
meta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
meta.mCircleId.clear();
meta.mOriginator.clear();
meta.mInternalCircle.clear();
if (ui.typePublic->isChecked())
{
meta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
@ -471,31 +483,26 @@ void GxsGroupDialog::setCircleParameters(RsGroupMetaData &meta)
meta.mCircleType = GXS_CIRCLE_TYPE_EXTERNAL;
if (!ui.circleComboBox->getChosenCircle(meta.mCircleId))
{
problem = true;
return false;
}
}
else if (ui.typeGroup->isChecked())
else if (ui.typeLocal->isChecked())
{
meta.mCircleType = GXS_CIRCLE_TYPE_YOUREYESONLY;
meta.mCircleId.clear();
meta.mOriginator.clear();
meta.mInternalCircle = "Internal Circle Id";
problem = true;
if (!ui.localComboBox->getChosenCircle(meta.mInternalCircle))
{
return false;
}
}
else
{
problem = true;
}
if (problem)
{
// error.
meta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
meta.mCircleId.clear();
meta.mOriginator.clear();
meta.mInternalCircle.clear();
return false;
}
return true;
}

View file

@ -194,7 +194,7 @@ private slots:
void updateCircleOptions();
private:
void setCircleParameters(RsGroupMetaData &meta);
bool setCircleParameters(RsGroupMetaData &meta);
void setGroupSignFlags(uint32_t signFlags);
uint32_t getGroupSignFlags();

View file

@ -316,28 +316,7 @@
</spacer>
</item>
<item>
<widget class="QComboBox" name="localComboBox">
<item>
<property name="text">
<string>Some Friends</string>
</property>
</item>
<item>
<property name="text">
<string>Another Group</string>
</property>
</item>
<item>
<property name="text">
<string>Family?</string>
</property>
</item>
<item>
<property name="text">
<string>Enemies</string>
</property>
</item>
</widget>
<widget class="GxsCircleChooser" name="localComboBox"/>
</item>
</layout>
</item>
@ -480,6 +459,11 @@
<extends>QComboBox</extends>
<header>gui/gxs/GxsIdChooser.h</header>
</customwidget>
<customwidget>
<class>GxsCircleChooser</class>
<extends>QComboBox</extends>
<header>gui/gxs/GxsCircleChooser.h</header>
</customwidget>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
@ -492,11 +476,6 @@
<header>gui/common/FriendSelectionWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GxsCircleChooser</class>
<extends>QComboBox</extends>
<header>gui/gxs/GxsCircleChooser.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>