mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-12 00:00:44 -04:00
Identity:
- Redesigned dialog - Fixed high CPU usage when showing reputation list - Added todo button UIStateHelper: - Added new base class for easier handling of ui elements with token request (show "Loading", set enable state, ...) RsProtectedTimer: - Fixed compile on Windows git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6495 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e36557d542
commit
f02cc51409
10 changed files with 1186 additions and 539 deletions
|
@ -21,17 +21,18 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "IdDialog.h"
|
||||
#include "gui/gxs/GxsIdTreeWidgetItem.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
#include <util/RsProtectedTimer.h>
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <util/RsProtectedTimer.h>
|
||||
|
||||
/******
|
||||
* #define ID_DEBUG 1
|
||||
|
@ -45,7 +46,6 @@
|
|||
/****************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#define RSID_COL_NICKNAME 0
|
||||
#define RSID_COL_KEYID 1
|
||||
#define RSID_COL_IDTYPE 2
|
||||
|
@ -55,10 +55,11 @@
|
|||
#define RSIDREP_COL_COMMENT 2
|
||||
#define RSIDREP_COL_REPUTATION 3
|
||||
|
||||
#define RSID_REQ_IDLIST 1
|
||||
#define RSID_REQ_IDDETAILS 2
|
||||
#define RSID_REQ_IDLISTDATA 3
|
||||
#define RSID_REQ_IDEDIT 4
|
||||
#define RSID_FILTER_YOURSELF 0x0001
|
||||
#define RSID_FILTER_FRIENDS 0x0002
|
||||
#define RSID_FILTER_OTHERS 0x0004
|
||||
#define RSID_FILTER_PSEUDONYMS 0x0008
|
||||
#define RSID_FILTER_ALL 0xffff
|
||||
|
||||
/** Constructor */
|
||||
IdDialog::IdDialog(QWidget *parent)
|
||||
|
@ -66,75 +67,309 @@ IdDialog::IdDialog(QWidget *parent)
|
|||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
mEditDialog = NULL;
|
||||
//mPulseSelected = NULL;
|
||||
mIdQueue = NULL;
|
||||
|
||||
ui.radioButton_ListAll->setChecked(true);
|
||||
connect( ui.pushButton_NewId, SIGNAL(clicked()), this, SLOT(OpenOrShowAddDialog()));
|
||||
connect( ui.pushButton_EditId, SIGNAL(clicked()), this, SLOT(OpenOrShowEditDialog()));
|
||||
/* Setup UI helper */
|
||||
mStateHelper = new UIStateHelper(this);
|
||||
mStateHelper->addWidget(IDDIALOG_IDLIST, ui.treeWidget_IdList);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDLIST, ui.treeWidget_IdList, false);
|
||||
mStateHelper->addClear(IDDIALOG_IDLIST, ui.treeWidget_IdList);
|
||||
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_Nickname);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_KeyId);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_GpgHash);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_GpgId);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.pushButton_Reputation);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.pushButton_Delete);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.pushButton_EditId);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingOverall);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingImplicit);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingOwn);
|
||||
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_Nickname);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_KeyId);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgHash);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgId);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingOverall);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingImplicit);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingOwn);
|
||||
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_Nickname);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_KeyId);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgHash);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgId);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingOverall);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingImplicit);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingOwn);
|
||||
|
||||
mStateHelper->addWidget(IDDIALOG_REPLIST, ui.treeWidget_RepList);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_REPLIST, ui.treeWidget_RepList);
|
||||
mStateHelper->addClear(IDDIALOG_REPLIST, ui.treeWidget_RepList);
|
||||
|
||||
/* Connect signals */
|
||||
connect(ui.pushButton_NewId, SIGNAL(clicked()), this, SLOT(addIdentity()));
|
||||
connect(ui.todoPushButton, SIGNAL(clicked()), this, SLOT(todo()));
|
||||
connect(ui.pushButton_EditId, SIGNAL(clicked()), this, SLOT(editIdentity()));
|
||||
connect( ui.treeWidget_IdList, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelection()));
|
||||
|
||||
connect( ui.radioButton_ListYourself, SIGNAL(toggled( bool ) ), this, SLOT(ListTypeToggled( bool ) ) );
|
||||
connect( ui.radioButton_ListFriends, SIGNAL(toggled( bool ) ), this, SLOT(ListTypeToggled( bool ) ) );
|
||||
connect( ui.radioButton_ListOthers, SIGNAL(toggled( bool ) ), this, SLOT(ListTypeToggled( bool ) ) );
|
||||
connect( ui.radioButton_ListPseudo, SIGNAL(toggled( bool ) ), this, SLOT(ListTypeToggled( bool ) ) );
|
||||
connect( ui.radioButton_ListAll, SIGNAL(toggled( bool ) ), this, SLOT(ListTypeToggled( bool ) ) );
|
||||
connect(ui.filterComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterComboBoxChanged()));
|
||||
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
||||
|
||||
/* Add filter types */
|
||||
ui.filterComboBox->addItem(tr("All"), RSID_FILTER_ALL);
|
||||
ui.filterComboBox->addItem(tr("Yourself"), RSID_FILTER_YOURSELF);
|
||||
ui.filterComboBox->addItem(tr("Friends / Friends of Friends"), RSID_FILTER_FRIENDS);
|
||||
ui.filterComboBox->addItem(tr("Others"), RSID_FILTER_OTHERS);
|
||||
ui.filterComboBox->addItem(tr("Pseudonyms"), RSID_FILTER_PSEUDONYMS);
|
||||
ui.filterComboBox->setCurrentIndex(0);
|
||||
|
||||
/* Add filter actions */
|
||||
QTreeWidgetItem *headerItem = ui.treeWidget_IdList->headerItem();
|
||||
QString headerText = headerItem->text(RSID_COL_NICKNAME);
|
||||
ui.filterLineEdit->addFilter(QIcon(), headerText, RSID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText));
|
||||
headerText = headerItem->text(RSID_COL_KEYID);
|
||||
ui.filterLineEdit->addFilter(QIcon(), headerItem->text(RSID_COL_KEYID), RSID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText));
|
||||
|
||||
/* Setup tree */
|
||||
ui.treeWidget_IdList->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder);
|
||||
|
||||
QTimer *timer = new RsProtectedTimer(this);
|
||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
||||
timer->start(1000);
|
||||
|
||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||
|
||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
||||
}
|
||||
|
||||
void IdDialog::ListTypeToggled(bool checked)
|
||||
void IdDialog::todo()
|
||||
{
|
||||
if (checked)
|
||||
QMessageBox::information(this, "Todo",
|
||||
"<b>Open points:</b><ul>"
|
||||
"<li>Initial fill of data"
|
||||
"<li>Delete ID"
|
||||
"<li>Edit ID"
|
||||
"<li>Reputation"
|
||||
"<li>Load/save settings"
|
||||
"</ul>");
|
||||
}
|
||||
|
||||
void IdDialog::filterComboBoxChanged()
|
||||
{
|
||||
requestIdList();
|
||||
}
|
||||
|
||||
void IdDialog::filterChanged(const QString& /*text*/)
|
||||
{
|
||||
filterIds();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void IdDialog::updateSelection()
|
||||
{
|
||||
/* */
|
||||
QTreeWidgetItem *item = ui.treeWidget_IdList->currentItem();
|
||||
std::string id;
|
||||
|
||||
if (!item)
|
||||
if (item)
|
||||
{
|
||||
blankSelection();
|
||||
id = item->text(RSID_COL_KEYID).toStdString();
|
||||
}
|
||||
|
||||
requestIdDetails(id);
|
||||
}
|
||||
|
||||
void IdDialog::requestIdList()
|
||||
{
|
||||
if (!mIdQueue)
|
||||
return;
|
||||
|
||||
mStateHelper->setLoading(IDDIALOG_IDLIST, true);
|
||||
mStateHelper->setLoading(IDDIALOG_IDDETAILS, true);
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, true);
|
||||
|
||||
mIdQueue->cancelActiveRequestTokens(IDDIALOG_IDLIST);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
uint32_t token;
|
||||
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, IDDIALOG_IDLIST);
|
||||
}
|
||||
|
||||
bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const std::string &ownPgpId, int accept)
|
||||
{
|
||||
bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) || (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
||||
|
||||
/* do filtering */
|
||||
bool ok = false;
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
{
|
||||
if (isOwnId && (accept & RSID_FILTER_YOURSELF))
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
if (accept & RSID_FILTER_FRIENDS)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (accept & RSID_FILTER_OTHERS)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string id = item->text(RSID_COL_KEYID).toStdString();
|
||||
requestIdDetails(id);
|
||||
if (accept & RSID_FILTER_PSEUDONYMS)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (isOwnId && (accept & RSID_FILTER_YOURSELF))
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!item)
|
||||
{
|
||||
item = new QTreeWidgetItem();
|
||||
}
|
||||
item->setText(RSID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str()));
|
||||
item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId));
|
||||
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
{
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
RsPeerDetails details;
|
||||
rsPeers->getGPGDetails(data.mPgpId, details);
|
||||
item->setText(RSID_COL_IDTYPE, QString::fromUtf8(details.name.c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setText(RSID_COL_IDTYPE, tr("PGP Linked Id"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setText(RSID_COL_IDTYPE, tr("Anon Id"));
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::blankSelection()
|
||||
{
|
||||
/* blank it all - and fix buttons */
|
||||
ui.lineEdit_Nickname->setText("");
|
||||
ui.lineEdit_KeyId->setText("");
|
||||
ui.lineEdit_GpgHash->setText("");
|
||||
ui.lineEdit_GpgId->setText("");
|
||||
ui.lineEdit_GpgName->setText("");
|
||||
ui.lineEdit_GpgEmail->setText("");
|
||||
|
||||
ui.pushButton_Reputation->setEnabled(false);
|
||||
ui.pushButton_Delete->setEnabled(false);
|
||||
ui.pushButton_EditId->setEnabled(false);
|
||||
ui.pushButton_NewId->setEnabled(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void IdDialog::insertIdList(uint32_t token)
|
||||
{
|
||||
mStateHelper->setLoading(IDDIALOG_IDLIST, false);
|
||||
|
||||
int accept = ui.filterComboBox->itemData(ui.filterComboBox->currentIndex()).toInt();
|
||||
|
||||
RsGxsIdGroup data;
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
std::vector<RsGxsIdGroup>::iterator vit;
|
||||
if (!rsIdentity->getGroupData(token, datavector))
|
||||
{
|
||||
std::cerr << "IdDialog::insertIdList() Error getting GroupData";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setLoading(IDDIALOG_IDDETAILS, false);
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->setActive(IDDIALOG_IDLIST, false);
|
||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->clear(IDDIALOG_IDLIST);
|
||||
mStateHelper->clear(IDDIALOG_IDDETAILS);
|
||||
mStateHelper->clear(IDDIALOG_REPLIST);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setActive(IDDIALOG_IDLIST, true);
|
||||
|
||||
std::string ownPgpId = rsPeers->getGPGOwnId();
|
||||
|
||||
/* Update existing and remove not existing items */
|
||||
QTreeWidgetItemIterator itemIterator(ui.treeWidget_IdList);
|
||||
QTreeWidgetItem *item = NULL;
|
||||
while ((item = *itemIterator) != NULL) {
|
||||
itemIterator++;
|
||||
|
||||
for (vit = datavector.begin(); vit != datavector.end(); ++vit)
|
||||
{
|
||||
if (vit->mMeta.mGroupId == item->text(RSID_COL_KEYID).toStdString())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (vit == datavector.end())
|
||||
{
|
||||
delete(item);
|
||||
} else {
|
||||
if (!fillIdListItem(*vit, item, ownPgpId, accept))
|
||||
{
|
||||
delete(item);
|
||||
}
|
||||
datavector.erase(vit);
|
||||
}
|
||||
}
|
||||
|
||||
/* Insert new items */
|
||||
for (vit = datavector.begin(); vit != datavector.end(); ++vit)
|
||||
{
|
||||
data = (*vit);
|
||||
|
||||
item = NULL;
|
||||
if (fillIdListItem(*vit, item, ownPgpId, accept))
|
||||
{
|
||||
ui.treeWidget_IdList->addTopLevelItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
filterIds();
|
||||
|
||||
// fix up buttons.
|
||||
updateSelection();
|
||||
}
|
||||
|
||||
void IdDialog::requestIdDetails(std::string &id)
|
||||
{
|
||||
mIdQueue->cancelActiveRequestTokens(IDDIALOG_IDDETAILS);
|
||||
|
||||
if (id.empty())
|
||||
{
|
||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->setLoading(IDDIALOG_IDDETAILS, false);
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->clear(IDDIALOG_IDDETAILS);
|
||||
mStateHelper->clear(IDDIALOG_REPLIST);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(IDDIALOG_IDDETAILS, true);
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, true);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
|
@ -145,25 +380,43 @@ void IdDialog::requestIdDetails(std::string &id)
|
|||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDDIALOG_IDDETAILS);
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::insertIdDetails(uint32_t token)
|
||||
{
|
||||
mStateHelper->setLoading(IDDIALOG_IDDETAILS, false);
|
||||
|
||||
/* get details from libretroshare */
|
||||
RsGxsIdGroup data;
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
if (!rsIdentity->getGroupData(token, datavector))
|
||||
{
|
||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->clear(IDDIALOG_IDDETAILS);
|
||||
mStateHelper->clear(IDDIALOG_REPLIST);
|
||||
|
||||
ui.lineEdit_KeyId->setText("ERROR GETTING KEY!");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (datavector.size() != 1)
|
||||
{
|
||||
std::cerr << "IdDialog::insertIdDetails() Invalid datavector size";
|
||||
|
||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->clear(IDDIALOG_IDDETAILS);
|
||||
mStateHelper->clear(IDDIALOG_REPLIST);
|
||||
|
||||
ui.lineEdit_KeyId->setText("INVALID DV SIZE");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, true);
|
||||
|
||||
data = datavector[0];
|
||||
|
||||
/* get GPG Details from rsPeers */
|
||||
|
@ -179,24 +432,20 @@ void IdDialog::insertIdDetails(uint32_t token)
|
|||
RsPeerDetails details;
|
||||
rsPeers->getGPGDetails(data.mPgpId, details);
|
||||
ui.lineEdit_GpgName->setText(QString::fromStdString(details.name));
|
||||
ui.lineEdit_GpgEmail->setText(QString::fromStdString(details.email));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
{
|
||||
ui.lineEdit_GpgName->setText("Unknown Real Name");
|
||||
ui.lineEdit_GpgEmail->setText("Unknown Email");
|
||||
ui.lineEdit_GpgName->setText(tr("Unknown real name"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.lineEdit_GpgName->setText("Anonymous Id");
|
||||
ui.lineEdit_GpgEmail->setText("-- N/A --");
|
||||
ui.lineEdit_GpgName->setText(tr("Anonymous Id"));
|
||||
}
|
||||
}
|
||||
|
||||
bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) ||
|
||||
(data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
||||
bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) || (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
||||
|
||||
if (isOwnId)
|
||||
{
|
||||
|
@ -225,23 +474,22 @@ void IdDialog::insertIdDetails(uint32_t token)
|
|||
ui.radioButton_IdPseudo->setChecked(true);
|
||||
}
|
||||
|
||||
ui.pushButton_NewId->setEnabled(true);
|
||||
|
||||
if (isOwnId)
|
||||
{
|
||||
ui.pushButton_Reputation->setEnabled(false);
|
||||
ui.pushButton_Delete->setEnabled(true);
|
||||
mStateHelper->setWidgetEnabled(ui.pushButton_Reputation, false);
|
||||
// No Delete Ids yet!
|
||||
mStateHelper->setWidgetEnabled(ui.pushButton_Delete, /*true*/ false);
|
||||
// No Editing Ids yet!
|
||||
//ui.pushButton_EditId->setEnabled(true);
|
||||
mStateHelper->setWidgetEnabled(ui.pushButton_EditId, /*true*/ false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.pushButton_Reputation->setEnabled(true);
|
||||
ui.pushButton_Delete->setEnabled(false);
|
||||
ui.pushButton_EditId->setEnabled(false);
|
||||
// No Reputation yet!
|
||||
mStateHelper->setWidgetEnabled(ui.pushButton_Reputation, /*true*/ false);
|
||||
mStateHelper->setWidgetEnabled(ui.pushButton_Delete, false);
|
||||
mStateHelper->setWidgetEnabled(ui.pushButton_EditId, false);
|
||||
}
|
||||
|
||||
|
||||
/* now fill in the reputation information */
|
||||
ui.line_RatingOverall->setText("Overall Rating TODO");
|
||||
ui.line_RatingOwn->setText("Own Rating TODO");
|
||||
|
@ -261,7 +509,6 @@ void IdDialog::insertIdDetails(uint32_t token)
|
|||
|
||||
/* request network ratings */
|
||||
requestRepList(data.mMeta.mGroupId);
|
||||
|
||||
}
|
||||
|
||||
void IdDialog::checkUpdate()
|
||||
|
@ -274,175 +521,46 @@ void IdDialog::checkUpdate()
|
|||
{
|
||||
requestIdList();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::OpenOrShowAddDialog()
|
||||
void IdDialog::addIdentity()
|
||||
{
|
||||
if (!mEditDialog)
|
||||
{
|
||||
mEditDialog = new IdEditDialog(NULL);
|
||||
}
|
||||
bool pseudo = false;
|
||||
mEditDialog->setupNewId(pseudo);
|
||||
|
||||
mEditDialog->show();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::OpenOrShowEditDialog()
|
||||
{
|
||||
if (!mEditDialog)
|
||||
{
|
||||
mEditDialog = new IdEditDialog(NULL);
|
||||
IdEditDialog dlg(this);
|
||||
dlg.setupNewId(false);
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
|
||||
/* */
|
||||
void IdDialog::editIdentity()
|
||||
{
|
||||
QTreeWidgetItem *item = ui.treeWidget_IdList->currentItem();
|
||||
|
||||
if (!item)
|
||||
{
|
||||
std::cerr << "IdDialog::OpenOrShowEditDialog() Invalid item";
|
||||
std::cerr << "IdDialog::editIdentity() Invalid item";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
||||
|
||||
if (mEditDialog)
|
||||
{
|
||||
mEditDialog->setupExistingId(keyId);
|
||||
mEditDialog->show();
|
||||
IdEditDialog dlg(this);
|
||||
dlg.setupExistingId(keyId);
|
||||
dlg.exec();
|
||||
}
|
||||
}
|
||||
|
||||
void IdDialog::requestIdList()
|
||||
void IdDialog::filterIds()
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
int filterColumn = ui.filterLineEdit->currentFilter();
|
||||
QString text = ui.filterLineEdit->text();
|
||||
|
||||
uint32_t token;
|
||||
std::list<std::string> groupIds;
|
||||
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, IDDIALOG_IDLIST);
|
||||
ui.treeWidget_IdList->filterItems(filterColumn, text);
|
||||
}
|
||||
|
||||
void IdDialog::insertIdList(uint32_t token)
|
||||
{
|
||||
QTreeWidget *tree = ui.treeWidget_IdList;
|
||||
|
||||
tree->clear();
|
||||
|
||||
std::list<std::string> ids;
|
||||
std::list<std::string>::iterator it;
|
||||
|
||||
bool acceptAll = ui.radioButton_ListAll->isChecked();
|
||||
bool acceptPseudo = ui.radioButton_ListPseudo->isChecked();
|
||||
bool acceptYourself = ui.radioButton_ListYourself->isChecked();
|
||||
bool acceptFriends = ui.radioButton_ListFriends->isChecked();
|
||||
bool acceptOthers = ui.radioButton_ListOthers->isChecked();
|
||||
|
||||
RsGxsIdGroup data;
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
std::vector<RsGxsIdGroup>::iterator vit;
|
||||
if (!rsIdentity->getGroupData(token, datavector))
|
||||
{
|
||||
std::cerr << "IdDialog::insertIdList() Error getting GroupData";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::string ownPgpId = rsPeers->getGPGOwnId();
|
||||
|
||||
for(vit = datavector.begin(); vit != datavector.end(); vit++)
|
||||
{
|
||||
data = (*vit);
|
||||
|
||||
bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) ||
|
||||
(data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
||||
|
||||
/* do filtering */
|
||||
bool ok = false;
|
||||
if (acceptAll)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
{
|
||||
if (isOwnId && acceptYourself)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
if (acceptFriends)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (acceptOthers)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (acceptPseudo)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (isOwnId && acceptYourself)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
item->setText(RSID_COL_NICKNAME, QString::fromStdString(data.mMeta.mGroupName));
|
||||
item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId));
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
{
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
RsPeerDetails details;
|
||||
rsPeers->getGPGDetails(data.mPgpId, details);
|
||||
item->setText(RSID_COL_IDTYPE, QString::fromStdString(details.name));
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setText(RSID_COL_IDTYPE, "PGP Linked Id");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setText(RSID_COL_IDTYPE, "Anon Id");
|
||||
}
|
||||
|
||||
tree->addTopLevelItem(item);
|
||||
}
|
||||
|
||||
// fix up buttons.
|
||||
updateSelection();
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::requestRepList(const RsGxsGroupId &aboutId)
|
||||
{
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, true);
|
||||
|
||||
mIdQueue->cancelActiveRequestTokens(IDDIALOG_REPLIST);
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(aboutId);
|
||||
|
||||
|
@ -451,18 +569,11 @@ void IdDialog::requestRepList(const RsGxsGroupId &aboutId)
|
|||
|
||||
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;
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
||||
|
||||
std::vector<RsGxsIdOpinion> opinions;
|
||||
std::vector<RsGxsIdOpinion>::iterator vit;
|
||||
|
@ -470,9 +581,15 @@ void IdDialog::insertRepList(uint32_t token)
|
|||
{
|
||||
std::cerr << "IdDialog::insertRepList() Error getting Opinions";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->clear(IDDIALOG_REPLIST);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, true);
|
||||
|
||||
for(vit = opinions.begin(); vit != opinions.end(); vit++)
|
||||
{
|
||||
RsGxsIdOpinion &op = (*vit);
|
||||
|
@ -492,15 +609,11 @@ void IdDialog::insertRepList(uint32_t token)
|
|||
/* local reputation */
|
||||
item->setText(RSIDREP_COL_REPUTATION, QString::number(op.getReputation()));
|
||||
|
||||
|
||||
tree->addTopLevelItem(item);
|
||||
ui.treeWidget_RepList->addTopLevelItem(item);
|
||||
}
|
||||
|
||||
// fix up buttons.
|
||||
updateSelection();
|
||||
}
|
||||
|
||||
void IdDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
void IdDialog::loadRequest(const TokenQueue */*queue*/, const TokenRequest &req)
|
||||
{
|
||||
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
|
@ -523,10 +636,5 @@ void IdDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
|||
std::cerr << "IdDialog::loadRequest() ERROR";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue