mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 23:49:38 -05: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
@ -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
|
||||
{
|
||||
std::string id = item->text(RSID_COL_KEYID).toStdString();
|
||||
requestIdDetails(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::blankSelection()
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
/* 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);
|
||||
if (accept & RSID_FILTER_FRIENDS)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (accept & RSID_FILTER_OTHERS)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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"));
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
IdEditDialog dlg(this);
|
||||
dlg.setupNewId(false);
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
|
||||
void IdDialog::OpenOrShowEditDialog()
|
||||
void IdDialog::editIdentity()
|
||||
{
|
||||
if (!mEditDialog)
|
||||
{
|
||||
mEditDialog = new IdEditDialog(NULL);
|
||||
}
|
||||
|
||||
|
||||
/* */
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MRK_IDENTITY_DIALOG_H
|
||||
#define MRK_IDENTITY_DIALOG_H
|
||||
#ifndef IDENTITYDIALOG_H
|
||||
#define IDENTITYDIALOG_H
|
||||
|
||||
#include "retroshare-gui/mainpage.h"
|
||||
#include "ui_IdDialog.h"
|
||||
@ -34,6 +34,8 @@
|
||||
#include "gui/Identity/IdEditDialog.h"
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
class UIStateHelper;
|
||||
|
||||
class IdDialog : public MainPage, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -44,24 +46,26 @@ public:
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
private slots:
|
||||
void filterComboBoxChanged();
|
||||
void filterChanged(const QString &text);
|
||||
|
||||
|
||||
void ListTypeToggled(bool checked);
|
||||
void checkUpdate();
|
||||
void OpenOrShowAddDialog();
|
||||
void OpenOrShowEditDialog();
|
||||
void addIdentity();
|
||||
void editIdentity();
|
||||
|
||||
void updateSelection();
|
||||
|
||||
private:
|
||||
void todo();
|
||||
|
||||
void blankSelection();
|
||||
private:
|
||||
void requestIdDetails(std::string &id);
|
||||
void insertIdDetails(uint32_t token);
|
||||
|
||||
void requestIdList();
|
||||
void requestIdData(std::list<std::string> &ids);
|
||||
bool fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const std::string &ownPgpId, int accept);
|
||||
void insertIdList(uint32_t token);
|
||||
void filterIds();
|
||||
|
||||
void requestRepList(const RsGxsGroupId &aboutId);
|
||||
void insertRepList(uint32_t token);
|
||||
@ -69,14 +73,12 @@ private:
|
||||
void requestIdEdit(std::string &id);
|
||||
void showIdEdit(uint32_t token);
|
||||
|
||||
IdEditDialog *mEditDialog;
|
||||
|
||||
private:
|
||||
TokenQueue *mIdQueue;
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::IdDialog ui;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -15,40 +15,48 @@
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<layout class="QVBoxLayout" name="leftLayout">
|
||||
<property name="bottomMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<item>
|
||||
<widget class="QFrame" name="titleBarFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="margin">
|
||||
<number>1</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<widget class="QLabel" name="titleBarPixmap">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../images.qrc">:/images/groupchat.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_10">
|
||||
<widget class="QLabel" name="titleBarLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -57,7 +65,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<spacer name="titleBarSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@ -76,79 +84,38 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Showing:</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_ListYourself">
|
||||
<widget class="QPushButton" name="todoPushButton">
|
||||
<property name="text">
|
||||
<string>Yourself</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_ListFriends">
|
||||
<property name="text">
|
||||
<string>Friends / Friends of Friends</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_ListOthers">
|
||||
<property name="text">
|
||||
<string>Others</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_ListPseudo">
|
||||
<property name="text">
|
||||
<string>Pseudonyms</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_ListAll">
|
||||
<property name="text">
|
||||
<string>All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="text">
|
||||
<string>filter</string>
|
||||
<string>Todo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QTreeWidget" name="treeWidget_IdList">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="filterLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="filterLabel">
|
||||
<property name="text">
|
||||
<string>Show:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="filterComboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LineEditClear" name="filterLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="RSTreeWidget" name="treeWidget_IdList">
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Nickname</string>
|
||||
@ -169,12 +136,18 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<layout class="QVBoxLayout" name="rightLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<widget class="QFrame" name="toolBarFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="margin">
|
||||
<number>3</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_Delete">
|
||||
@ -183,13 +156,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_Reputation">
|
||||
<property name="text">
|
||||
<string>Edit Reputation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_EditId">
|
||||
<property name="text">
|
||||
@ -198,7 +164,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<widget class="QPushButton" name="pushButton_Reputation">
|
||||
<property name="text">
|
||||
<string>Edit Reputation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="toolBarSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@ -214,7 +187,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<widget class="QGroupBox" name="detailsGroupBox">
|
||||
<property name="title">
|
||||
<string>Identity Type</string>
|
||||
</property>
|
||||
@ -346,23 +319,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>PGP Email</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_GpgEmail">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_GpgHash">
|
||||
<property name="enabled">
|
||||
@ -401,14 +357,24 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<widget class="QGroupBox" name="reputationGroupBox">
|
||||
<property name="title">
|
||||
<string>Reputation</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Implicit Score</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="line_RatingOverall"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
@ -421,37 +387,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Implicit Score</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="line_RatingImplicit"/>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Your Rating</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="line_RatingOverall"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="line_RatingImplicit"/>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="line_RatingOwn"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QTreeWidget" name="treeWidget_RepList">
|
||||
<item>
|
||||
<widget class="RSTreeWidget" name="treeWidget_RepList">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Friend</string>
|
||||
@ -481,6 +433,42 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global">gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>RSTreeWidget</class>
|
||||
<extends>QTreeWidget</extends>
|
||||
<header>gui/common/RSTreeWidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>pushButton_NewId</tabstop>
|
||||
<tabstop>todoPushButton</tabstop>
|
||||
<tabstop>filterComboBox</tabstop>
|
||||
<tabstop>filterLineEdit</tabstop>
|
||||
<tabstop>treeWidget_IdList</tabstop>
|
||||
<tabstop>pushButton_Delete</tabstop>
|
||||
<tabstop>pushButton_EditId</tabstop>
|
||||
<tabstop>pushButton_Reputation</tabstop>
|
||||
<tabstop>lineEdit_Nickname</tabstop>
|
||||
<tabstop>lineEdit_KeyId</tabstop>
|
||||
<tabstop>lineEdit_GpgHash</tabstop>
|
||||
<tabstop>lineEdit_GpgId</tabstop>
|
||||
<tabstop>lineEdit_GpgName</tabstop>
|
||||
<tabstop>radioButton_IdYourself</tabstop>
|
||||
<tabstop>radioButton_IdFriend</tabstop>
|
||||
<tabstop>radioButton_IdFOF</tabstop>
|
||||
<tabstop>radioButton_IdOther</tabstop>
|
||||
<tabstop>radioButton_IdPseudo</tabstop>
|
||||
<tabstop>line_RatingOverall</tabstop>
|
||||
<tabstop>line_RatingImplicit</tabstop>
|
||||
<tabstop>line_RatingOwn</tabstop>
|
||||
<tabstop>treeWidget_RepList</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
|
@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include "gui/Identity/IdEditDialog.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
@ -33,22 +34,46 @@
|
||||
|
||||
/** Constructor */
|
||||
IdEditDialog::IdEditDialog(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
|
||||
{
|
||||
mIsNew = true;
|
||||
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(ui.radioButton_GpgId, SIGNAL( toggled( bool ) ), this, SLOT( IdTypeToggled( bool ) ) );
|
||||
connect(ui.radioButton_Pseudo, SIGNAL( toggled( bool ) ), this, SLOT( IdTypeToggled( bool ) ) );
|
||||
connect(ui.pushButton_Update, SIGNAL( clicked( void ) ), this, SLOT( updateId( void ) ) );
|
||||
connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelId( void ) ) );
|
||||
/* Setup UI helper */
|
||||
mStateHelper = new UIStateHelper(this);
|
||||
|
||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_Nickname);
|
||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_KeyId);
|
||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_GpgHash);
|
||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_GpgId);
|
||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_GpgName);
|
||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.radioButton_GpgId);
|
||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.radioButton_Pseudo);
|
||||
|
||||
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_Nickname);
|
||||
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_GpgName);
|
||||
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_KeyId);
|
||||
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_GpgHash);
|
||||
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_GpgId);
|
||||
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_GpgName);
|
||||
|
||||
/* Connect signals */
|
||||
connect(ui.radioButton_GpgId, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
|
||||
connect(ui.radioButton_Pseudo, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
|
||||
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(updateId()));
|
||||
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||
|
||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||
}
|
||||
|
||||
void IdEditDialog::setupNewId(bool pseudo)
|
||||
{
|
||||
ui.checkBox_NewId->setChecked(true);
|
||||
ui.checkBox_NewId->setEnabled(false);
|
||||
ui.lineEdit_KeyId->setText("To Be Generated");
|
||||
setWindowTitle(tr("New identity"));
|
||||
|
||||
mIsNew = true;
|
||||
|
||||
ui.lineEdit_KeyId->setText(tr("To be generated"));
|
||||
ui.lineEdit_Nickname->setText("");
|
||||
ui.radioButton_GpgId->setEnabled(true);
|
||||
ui.radioButton_Pseudo->setEnabled(true);
|
||||
@ -63,11 +88,10 @@ void IdEditDialog::setupNewId(bool pseudo)
|
||||
}
|
||||
|
||||
// force - incase it wasn't triggered.
|
||||
IdTypeToggled(true);
|
||||
return;
|
||||
idTypeToggled(true);
|
||||
}
|
||||
|
||||
void IdEditDialog::IdTypeToggled(bool checked)
|
||||
void IdEditDialog::idTypeToggled(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
@ -80,10 +104,9 @@ void IdEditDialog::updateIdType(bool pseudo)
|
||||
{
|
||||
if (pseudo)
|
||||
{
|
||||
ui.lineEdit_GpgHash->setText("N/A");
|
||||
ui.lineEdit_GpgId->setText("N/A");
|
||||
ui.lineEdit_GpgName->setText("N/A");
|
||||
ui.lineEdit_GpgEmail->setText("N/A");
|
||||
ui.lineEdit_GpgHash->setText(tr("N/A"));
|
||||
ui.lineEdit_GpgId->setText(tr("N/A"));
|
||||
ui.lineEdit_GpgName->setText(tr("N/A"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -93,17 +116,21 @@ void IdEditDialog::updateIdType(bool pseudo)
|
||||
rsPeers->getPeerDetails(gpgid, details);
|
||||
|
||||
ui.lineEdit_GpgId->setText(QString::fromStdString(gpgid));
|
||||
ui.lineEdit_GpgHash->setText("To Be Generated");
|
||||
ui.lineEdit_GpgHash->setText(tr("To be generated"));
|
||||
ui.lineEdit_GpgName->setText(QString::fromStdString(details.name));
|
||||
ui.lineEdit_GpgEmail->setText(QString::fromStdString(details.email));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void IdEditDialog::setupExistingId(std::string keyId)
|
||||
{
|
||||
setWindowTitle(tr("Edit identity"));
|
||||
|
||||
mIsNew = false;
|
||||
|
||||
mStateHelper->setLoading(IDEDITDIALOG_LOADID, true);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
std::list<std::string> groupIds;
|
||||
groupIds.push_back(keyId);
|
||||
@ -112,20 +139,16 @@ void IdEditDialog::setupExistingId(std::string keyId)
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDEDITDIALOG_LOADID);
|
||||
}
|
||||
|
||||
|
||||
void IdEditDialog::loadExistingId(uint32_t token)
|
||||
{
|
||||
ui.checkBox_NewId->setChecked(false);
|
||||
ui.checkBox_NewId->setEnabled(false);
|
||||
ui.radioButton_GpgId->setEnabled(false);
|
||||
ui.radioButton_Pseudo->setEnabled(false);
|
||||
mStateHelper->setLoading(IDEDITDIALOG_LOADID, false);
|
||||
|
||||
/* get details from libretroshare */
|
||||
RsGxsIdGroup data;
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
if (!rsIdentity->getGroupData(token, datavector))
|
||||
{
|
||||
ui.lineEdit_KeyId->setText("ERROR GETTING KEY!");
|
||||
ui.lineEdit_KeyId->setText(tr("Error getting key!"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -134,13 +157,12 @@ void IdEditDialog::loadExistingId(uint32_t token)
|
||||
std::cerr << "IdDialog::insertIdDetails() Invalid datavector size";
|
||||
std::cerr << std::endl;
|
||||
|
||||
ui.lineEdit_KeyId->setText("ERROR KEYID INVALID");
|
||||
ui.lineEdit_KeyId->setText(tr("Error KeyID invalid"));
|
||||
ui.lineEdit_Nickname->setText("");
|
||||
|
||||
ui.lineEdit_GpgHash->setText("N/A");
|
||||
ui.lineEdit_GpgId->setText("N/A");
|
||||
ui.lineEdit_GpgName->setText("N/A");
|
||||
ui.lineEdit_GpgEmail->setText("N/A");
|
||||
ui.lineEdit_GpgHash->setText(tr("N/A"));
|
||||
ui.lineEdit_GpgId->setText(tr("N/A"));
|
||||
ui.lineEdit_GpgName->setText(tr("N/A"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -159,7 +181,7 @@ void IdEditDialog::loadExistingId(uint32_t token)
|
||||
|
||||
// DOES THIS TRIGGER ALREADY???
|
||||
// force - incase it wasn't triggered.
|
||||
IdTypeToggled(true);
|
||||
idTypeToggled(true);
|
||||
|
||||
ui.lineEdit_Nickname->setText(QString::fromStdString(data.mMeta.mGroupName));
|
||||
ui.lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId));
|
||||
@ -173,26 +195,21 @@ void IdEditDialog::loadExistingId(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));
|
||||
|
||||
ui.lineEdit_GpgId->setText(QString::fromStdString(data.mPgpId));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.lineEdit_GpgId->setText("Unknown PgpId");
|
||||
ui.lineEdit_GpgName->setText("Unknown Real Name");
|
||||
ui.lineEdit_GpgEmail->setText("Unknown Email");
|
||||
ui.lineEdit_GpgId->setText(tr("Unknown GpgId"));
|
||||
ui.lineEdit_GpgName->setText(tr("Unknown real name"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.lineEdit_GpgHash->setText("N/A");
|
||||
ui.lineEdit_GpgId->setText("N/A");
|
||||
ui.lineEdit_GpgName->setText("N/A");
|
||||
ui.lineEdit_GpgEmail->setText("N/A");
|
||||
ui.lineEdit_GpgHash->setText(tr("N/A"));
|
||||
ui.lineEdit_GpgId->setText(tr("N/A"));
|
||||
ui.lineEdit_GpgName->setText(tr("N/A"));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void IdEditDialog::updateId()
|
||||
@ -200,7 +217,6 @@ void IdEditDialog::updateId()
|
||||
RsGxsIdGroup rid;
|
||||
// Must set, Nickname, KeyId(if existing), mIdType, GpgId.
|
||||
|
||||
|
||||
rid.mMeta.mGroupName = ui.lineEdit_Nickname->text().toStdString();
|
||||
|
||||
if (rid.mMeta.mGroupName.size() < 2)
|
||||
@ -211,7 +227,7 @@ void IdEditDialog::updateId()
|
||||
}
|
||||
|
||||
//rid.mIdType = RSID_RELATION_YOURSELF;
|
||||
if (ui.checkBox_NewId->isChecked())
|
||||
if (mIsNew)
|
||||
{
|
||||
rid.mMeta.mGroupId = "";
|
||||
}
|
||||
@ -227,7 +243,6 @@ void IdEditDialog::updateId()
|
||||
//rid.mGpgId = ui.lineEdit_GpgId->text().toStdString();
|
||||
rid.mPgpIdHash = ui.lineEdit_GpgHash->text().toStdString();
|
||||
//rid.mGpgName = ui.lineEdit_GpgName->text().toStdString();
|
||||
//rid.mGpgEmail = ui.lineEdit_GpgEmail->text().toStdString();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -239,7 +254,6 @@ void IdEditDialog::updateId()
|
||||
//rid.mGpgEmail = "";
|
||||
}
|
||||
|
||||
|
||||
// Can only create Identities for the moment!
|
||||
RsIdentityParameters params;
|
||||
params.nickname = rid.mMeta.mGroupName;
|
||||
@ -248,23 +262,10 @@ void IdEditDialog::updateId()
|
||||
uint32_t dummyToken = 0;
|
||||
rsIdentity->createIdentity(dummyToken, params);
|
||||
|
||||
hide();
|
||||
return;
|
||||
close();
|
||||
}
|
||||
|
||||
void IdEditDialog::cancelId()
|
||||
{
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
|
||||
void IdEditDialog::clearDialog()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void IdEditDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
void IdEditDialog::loadRequest(const TokenQueue */*queue*/, const TokenRequest &req)
|
||||
{
|
||||
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
@ -272,5 +273,3 @@ void IdEditDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
// only one here!
|
||||
loadExistingId(req.mToken);
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MRK_ID_EDIT_DIALOG_H
|
||||
#define MRK_ID_EDIT_DIALOG_H
|
||||
#ifndef IDEDITDIALOG_H
|
||||
#define IDEDITDIALOG_H
|
||||
|
||||
#include "ui_IdEditDialog.h"
|
||||
|
||||
@ -30,7 +30,9 @@
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
class IdEditDialog : public QWidget, public TokenResponse
|
||||
class UIStateHelper;
|
||||
|
||||
class IdEditDialog : public QDialog, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -39,26 +41,23 @@ public:
|
||||
|
||||
void setupNewId(bool pseudo);
|
||||
void setupExistingId(std::string keyId);
|
||||
void loadExistingId(uint32_t token);
|
||||
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
private slots:
|
||||
|
||||
void IdTypeToggled(bool checked);
|
||||
void idTypeToggled(bool checked);
|
||||
void updateId();
|
||||
void cancelId();
|
||||
|
||||
private:
|
||||
void updateIdType(bool pseudo);
|
||||
void clearDialog();
|
||||
void loadExistingId(uint32_t token);
|
||||
|
||||
protected:
|
||||
|
||||
Ui::IdEditDialog ui;
|
||||
bool mIsNew;
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
TokenQueue *mIdQueue;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,18 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>IdEditDialog</class>
|
||||
<widget class="QWidget" name="IdEditDialog">
|
||||
<widget class="QDialog" name="IdEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>557</width>
|
||||
<height>229</height>
|
||||
<height>179</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
@ -31,7 +34,39 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_KeyId"/>
|
||||
<widget class="QLineEdit" name="lineEdit_KeyId">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>PGP Hash</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_GpgHash">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>PGP Id</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_GpgId">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
@ -41,19 +76,13 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_GpgName"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>PGP Email</string>
|
||||
<widget class="QLineEdit" name="lineEdit_GpgName">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_GpgEmail"/>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -66,50 +95,10 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_GpgHash"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>PGP Hash</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_GpgId"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>PGP Id</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_NewId">
|
||||
<property name="text">
|
||||
<string>New Identity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
@ -126,43 +115,42 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_Cancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>288</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_Update">
|
||||
<property name="text">
|
||||
<string>Create/Update ID</string>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>lineEdit_Nickname</tabstop>
|
||||
<tabstop>lineEdit_KeyId</tabstop>
|
||||
<tabstop>lineEdit_GpgHash</tabstop>
|
||||
<tabstop>lineEdit_GpgId</tabstop>
|
||||
<tabstop>lineEdit_GpgName</tabstop>
|
||||
<tabstop>radioButton_GpgId</tabstop>
|
||||
<tabstop>radioButton_Pseudo</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
465
retroshare-gui/src/gui/common/UIStateHelper.cpp
Normal file
465
retroshare-gui/src/gui/common/UIStateHelper.cpp
Normal file
@ -0,0 +1,465 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2013 RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* 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 <QLabel>
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
|
||||
#include "UIStateHelper.h"
|
||||
#include "RSTreeWidget.h"
|
||||
#include "LinkTextBrowser.h"
|
||||
|
||||
class UIStateHelperObject
|
||||
{
|
||||
public:
|
||||
UIStateHelperObject(QLabel *widget)
|
||||
{
|
||||
init();
|
||||
mLabel = widget;
|
||||
}
|
||||
UIStateHelperObject(QLineEdit *widget)
|
||||
{
|
||||
init();
|
||||
mLineEdit = widget;
|
||||
}
|
||||
UIStateHelperObject(RSTreeWidget *widget)
|
||||
{
|
||||
init();
|
||||
mTreeWidget = widget;
|
||||
}
|
||||
UIStateHelperObject(LinkTextBrowser *widget)
|
||||
{
|
||||
init();
|
||||
mLinkTextBrowser = widget;
|
||||
}
|
||||
|
||||
void setPlaceholder(bool loading, const QString &text, bool clear) const
|
||||
{
|
||||
if (mLabel) {
|
||||
mLabel->setText(text);
|
||||
}
|
||||
|
||||
if (mLineEdit) {
|
||||
if (loading && clear) {
|
||||
mLineEdit->clear();
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK (4, 8, 0)
|
||||
mLineEdit->setPlaceholderText(text);
|
||||
#else
|
||||
mLineEdit->setText(text);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (mTreeWidget) {
|
||||
if (loading && clear) {
|
||||
mTreeWidget->clear();
|
||||
}
|
||||
|
||||
mTreeWidget->setPlaceholderText(text);
|
||||
}
|
||||
|
||||
if (mLinkTextBrowser) {
|
||||
if (loading && clear) {
|
||||
mLinkTextBrowser->clear();
|
||||
}
|
||||
|
||||
mLinkTextBrowser->setPlaceholderText(text);
|
||||
}
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
if (mLabel) {
|
||||
mLabel->clear();
|
||||
}
|
||||
|
||||
if (mLineEdit) {
|
||||
mLineEdit->clear();
|
||||
}
|
||||
|
||||
if (mTreeWidget) {
|
||||
mTreeWidget->clear();
|
||||
}
|
||||
|
||||
if (mLinkTextBrowser) {
|
||||
mLinkTextBrowser->clear();
|
||||
}
|
||||
}
|
||||
|
||||
bool operator ==(const UIStateHelperObject &data) const
|
||||
{
|
||||
if (mLabel == data.mLabel &&
|
||||
mLineEdit == data.mLineEdit &&
|
||||
mTreeWidget == data.mTreeWidget &&
|
||||
mLinkTextBrowser == data.mLinkTextBrowser) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator <(const UIStateHelperObject &data) const
|
||||
{
|
||||
if (mLabel < data.mLabel ||
|
||||
mLineEdit < data.mLineEdit ||
|
||||
mTreeWidget < data.mTreeWidget ||
|
||||
mLinkTextBrowser < data.mLinkTextBrowser) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
void init()
|
||||
{
|
||||
mLabel = NULL;
|
||||
mLineEdit = NULL;
|
||||
mTreeWidget = NULL;
|
||||
mLinkTextBrowser = NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
QLabel *mLabel;
|
||||
QLineEdit *mLineEdit;
|
||||
RSTreeWidget *mTreeWidget;
|
||||
LinkTextBrowser *mLinkTextBrowser;
|
||||
};
|
||||
|
||||
class UIStateHelperData
|
||||
{
|
||||
public:
|
||||
UIStateHelperData()
|
||||
{
|
||||
mLoading = false;
|
||||
mActive = true;
|
||||
}
|
||||
|
||||
public:
|
||||
bool mLoading;
|
||||
bool mActive;
|
||||
QMap<QWidget*, UIStates> mWidgets;
|
||||
QMap<UIStateHelperObject, QPair<QString, bool> > mLoad;
|
||||
QList<UIStateHelperObject> mClear;
|
||||
};
|
||||
|
||||
UIStateHelper::UIStateHelper(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
UIStateHelper::~UIStateHelper()
|
||||
{
|
||||
QMap<long, UIStateHelperData*>::iterator it;
|
||||
for (it = mData.begin(); it != mData.end(); ++it) {
|
||||
delete(it.value());
|
||||
}
|
||||
}
|
||||
|
||||
UIStateHelperData *UIStateHelper::findData(int index, bool create)
|
||||
{
|
||||
UIStateHelperData *data = NULL;
|
||||
|
||||
QMap<long, UIStateHelperData*>::iterator it = mData.find(index);
|
||||
if (it == mData.end()) {
|
||||
if (create) {
|
||||
data = new UIStateHelperData;
|
||||
mData[index] = data;
|
||||
}
|
||||
} else {
|
||||
data = it.value();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void UIStateHelper::addWidget(int index, QWidget *widget, UIStates states)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, true);
|
||||
data->mWidgets.insert(widget, states);
|
||||
}
|
||||
|
||||
void UIStateHelper::addLoadPlaceholder(int index, QLabel *widget, bool clear, const QString &text)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, true);
|
||||
data->mLoad.insert(UIStateHelperObject(widget), QPair<QString, bool>(text.isEmpty() ? tr("Loading") : text, clear));
|
||||
}
|
||||
|
||||
void UIStateHelper::addLoadPlaceholder(int index, QLineEdit *widget, bool clear, const QString &text)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, true);
|
||||
data->mLoad.insert(UIStateHelperObject(widget), QPair<QString, bool>(text.isEmpty() ? tr("Loading") : text, clear));
|
||||
}
|
||||
|
||||
void UIStateHelper::addLoadPlaceholder(int index, RSTreeWidget *widget, bool clear, const QString &text)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, true);
|
||||
data->mLoad.insert(UIStateHelperObject(widget), QPair<QString, bool>(text.isEmpty() ? tr("Loading") : text, clear));
|
||||
}
|
||||
|
||||
void UIStateHelper::addLoadPlaceholder(int index, LinkTextBrowser *widget, bool clear, const QString &text)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, true);
|
||||
data->mLoad.insert(UIStateHelperObject(widget), QPair<QString, bool>(text.isEmpty() ? tr("Loading") : text, clear));
|
||||
}
|
||||
|
||||
void UIStateHelper::addClear(int index, QLabel *widget)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, true);
|
||||
if (data->mClear.contains(widget)) {
|
||||
return;
|
||||
}
|
||||
data->mClear.push_back(UIStateHelperObject(widget));
|
||||
}
|
||||
|
||||
void UIStateHelper::addClear(int index, QLineEdit *widget)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, true);
|
||||
if (data->mClear.contains(widget)) {
|
||||
return;
|
||||
}
|
||||
data->mClear.push_back(UIStateHelperObject(widget));
|
||||
}
|
||||
|
||||
void UIStateHelper::addClear(int index, RSTreeWidget *widget)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, true);
|
||||
if (data->mClear.contains(widget)) {
|
||||
return;
|
||||
}
|
||||
data->mClear.push_back(UIStateHelperObject(widget));
|
||||
}
|
||||
|
||||
void UIStateHelper::addClear(int index, LinkTextBrowser *widget)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, true);
|
||||
if (data->mClear.contains(widget)) {
|
||||
return;
|
||||
}
|
||||
data->mClear.push_back(UIStateHelperObject(widget));
|
||||
}
|
||||
|
||||
bool UIStateHelper::isWidgetVisible(QWidget *widget)
|
||||
{
|
||||
bool visible = true;
|
||||
|
||||
QMap<QWidget*, bool>::iterator itVisible = mWidgetVisible.find(widget);
|
||||
if (itVisible != mWidgetVisible.end()) {
|
||||
visible = itVisible.value();
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
QMap<long, UIStateHelperData*>::iterator dataIt;
|
||||
for (dataIt = mData.begin(); dataIt != mData.end(); ++dataIt) {
|
||||
UIStateHelperData *data = dataIt.value();
|
||||
QMap<QWidget*, UIStates>::iterator it = data->mWidgets.find(widget);
|
||||
if (it == data->mWidgets.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
UIStates states = it.value();
|
||||
|
||||
if (states & (UISTATE_LOADING_VISIBLE | UISTATE_LOADING_INVISIBLE)) {
|
||||
if (states & UISTATE_LOADING_VISIBLE) {
|
||||
if (!data->mLoading) {
|
||||
visible = false;
|
||||
break;
|
||||
}
|
||||
} else if (states & UISTATE_LOADING_INVISIBLE) {
|
||||
if (data->mLoading) {
|
||||
visible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (states & (UISTATE_ACTIVE_VISIBLE | UISTATE_ACTIVE_INVISIBLE)) {
|
||||
if (states & UISTATE_ACTIVE_VISIBLE) {
|
||||
if (!data->mActive) {
|
||||
visible = false;
|
||||
break;
|
||||
}
|
||||
} else if (states & UISTATE_ACTIVE_INVISIBLE) {
|
||||
if (data->mActive) {
|
||||
visible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return visible;
|
||||
}
|
||||
|
||||
bool UIStateHelper::isWidgetEnabled(QWidget *widget)
|
||||
{
|
||||
bool enabled = true;
|
||||
|
||||
QMap<QWidget*, bool>::iterator itEnabled = mWidgetEnabled.find(widget);
|
||||
if (itEnabled != mWidgetEnabled.end()) {
|
||||
enabled = itEnabled.value();
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
QMap<long, UIStateHelperData*>::iterator dataIt;
|
||||
for (dataIt = mData.begin(); dataIt != mData.end(); ++dataIt) {
|
||||
UIStateHelperData *data = dataIt.value();
|
||||
QMap<QWidget*, UIStates>::iterator it = data->mWidgets.find(widget);
|
||||
if (it == data->mWidgets.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
UIStates states = it.value();
|
||||
|
||||
if (states & (UISTATE_LOADING_ENABLED | UISTATE_LOADING_DISABLED)) {
|
||||
if (states & UISTATE_LOADING_ENABLED) {
|
||||
if (!data->mLoading) {
|
||||
enabled = false;
|
||||
break;
|
||||
}
|
||||
} else if (states & UISTATE_LOADING_DISABLED) {
|
||||
if (data->mLoading) {
|
||||
enabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (states & (UISTATE_ACTIVE_ENABLED | UISTATE_ACTIVE_DISABLED)) {
|
||||
if (states & UISTATE_ACTIVE_ENABLED) {
|
||||
if (!data->mActive) {
|
||||
enabled = false;
|
||||
break;
|
||||
}
|
||||
} else if (states & UISTATE_ACTIVE_DISABLED) {
|
||||
if (data->mActive) {
|
||||
enabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void UIStateHelper::updateData(UIStateHelperData *data)
|
||||
{
|
||||
QMap<QWidget*, UIStates>::iterator it;
|
||||
for (it = data->mWidgets.begin(); it != data->mWidgets.end(); ++it) {
|
||||
QWidget *widget = it.key();
|
||||
UIStates states = it.value();
|
||||
|
||||
if (states & (UISTATE_LOADING_VISIBLE | UISTATE_LOADING_INVISIBLE | UISTATE_ACTIVE_VISIBLE | UISTATE_ACTIVE_INVISIBLE)) {
|
||||
widget->setVisible(isWidgetVisible(widget));
|
||||
}
|
||||
|
||||
if (states & (UISTATE_LOADING_ENABLED | UISTATE_LOADING_DISABLED | UISTATE_ACTIVE_ENABLED | UISTATE_ACTIVE_DISABLED)) {
|
||||
widget->setEnabled(isWidgetEnabled(widget));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UIStateHelper::setLoading(int index, bool loading)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, false);
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
data->mLoading = loading;
|
||||
|
||||
updateData(data);
|
||||
|
||||
QMap<UIStateHelperObject, QPair<QString, bool> >::iterator it;
|
||||
for (it = data->mLoad.begin(); it != data->mLoad.end(); ++it) {
|
||||
if (loading) {
|
||||
it.key().setPlaceholder(loading, it.value().first, it.value().second);
|
||||
} else {
|
||||
it.key().setPlaceholder(loading, "", it.value().second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UIStateHelper::setActive(int index, bool active)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, false);
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
data->mActive = active;
|
||||
|
||||
updateData(data);
|
||||
}
|
||||
|
||||
void UIStateHelper::clear(int index)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, false);
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
QList<UIStateHelperObject>::iterator it;
|
||||
for (it = data->mClear.begin(); it != data->mClear.end(); ++it) {
|
||||
it->clear();
|
||||
}
|
||||
}
|
||||
|
||||
bool UIStateHelper::isLoading(int index)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, false);
|
||||
if (data) {
|
||||
return data->mLoading;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UIStateHelper::isActive(int index)
|
||||
{
|
||||
UIStateHelperData *data = findData(index, false);
|
||||
if (data) {
|
||||
return data->mActive;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void UIStateHelper::setWidgetVisible(QWidget *widget, bool visible)
|
||||
{
|
||||
mWidgetVisible[widget] = visible;
|
||||
|
||||
QMap<long, UIStateHelperData*>::iterator dataIt;
|
||||
for (dataIt = mData.begin(); dataIt != mData.end(); ++dataIt) {
|
||||
updateData(*dataIt);
|
||||
}
|
||||
}
|
||||
|
||||
void UIStateHelper::setWidgetEnabled(QWidget *widget, bool enabled)
|
||||
{
|
||||
mWidgetEnabled[widget] = enabled;
|
||||
|
||||
QMap<long, UIStateHelperData*>::iterator dataIt;
|
||||
for (dataIt = mData.begin(); dataIt != mData.end(); ++dataIt) {
|
||||
updateData(*dataIt);
|
||||
}
|
||||
}
|
95
retroshare-gui/src/gui/common/UIStateHelper.h
Normal file
95
retroshare-gui/src/gui/common/UIStateHelper.h
Normal file
@ -0,0 +1,95 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2013 RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* 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 UISTATEHELPER_H
|
||||
#define UISTATEHELPER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
|
||||
class QWidget;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class RSTreeWidget;
|
||||
class UIStateHelperData;
|
||||
class LinkTextBrowser;
|
||||
|
||||
enum UIState // State is untouched when bit is not set
|
||||
{
|
||||
/* State for ::setLoading */
|
||||
UISTATE_LOADING_VISIBLE = 0x00000001, // visible when loading
|
||||
UISTATE_LOADING_INVISIBLE = 0x00000002, // invisible when loading
|
||||
UISTATE_LOADING_ENABLED = 0x00000004, // enabled when loading
|
||||
UISTATE_LOADING_DISABLED = 0x00000008, // disabled when loading
|
||||
/* State for ::setActive */
|
||||
UISTATE_ACTIVE_VISIBLE = 0x00000010, // visible when active
|
||||
UISTATE_ACTIVE_INVISIBLE = 0x00000020, // invisible when active
|
||||
UISTATE_ACTIVE_ENABLED = 0x00000040, // enabled when active
|
||||
UISTATE_ACTIVE_DISABLED = 0x00000080 // disabled when active
|
||||
};
|
||||
Q_DECLARE_FLAGS(UIStates, UIState)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(UIStates)
|
||||
|
||||
class UIStateHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UIStateHelper(QObject *parent = 0);
|
||||
~UIStateHelper();
|
||||
|
||||
/* Add widgets */
|
||||
void addWidget(int index, QWidget *widget, UIStates states = UISTATE_LOADING_DISABLED | UISTATE_ACTIVE_ENABLED);
|
||||
void addLoadPlaceholder(int index, QLabel *widget, bool clear = true, const QString &text = "" /* ="Loading" */);
|
||||
void addLoadPlaceholder(int index, QLineEdit *widget, bool clear = true, const QString &text = "" /* ="Loading" */);
|
||||
void addLoadPlaceholder(int index, RSTreeWidget *widget, bool clear = true, const QString &text = "" /* ="Loading" */);
|
||||
void addLoadPlaceholder(int index, LinkTextBrowser *widget, bool clear = true, const QString &text = "" /* ="Loading" */);
|
||||
void addClear(int index, QLabel *widget);
|
||||
void addClear(int index, QLineEdit *widget);
|
||||
void addClear(int index, RSTreeWidget *widget);
|
||||
void addClear(int index, LinkTextBrowser *widget);
|
||||
|
||||
/* Set state */
|
||||
void setLoading(int index, bool loading);
|
||||
void setActive(int index, bool active);
|
||||
void clear(int index);
|
||||
|
||||
/* State */
|
||||
bool isLoading(int index);
|
||||
bool isActive(int index);
|
||||
|
||||
/* Set state of widget */
|
||||
void setWidgetVisible(QWidget *widget, bool visible);
|
||||
void setWidgetEnabled(QWidget *widget, bool enabled);
|
||||
|
||||
private:
|
||||
UIStateHelperData *findData(int index, bool create);
|
||||
void updateData(UIStateHelperData *data);
|
||||
bool isWidgetVisible(QWidget *widget);
|
||||
bool isWidgetEnabled(QWidget *widget);
|
||||
|
||||
private:
|
||||
QMap<long, UIStateHelperData*> mData;
|
||||
QMap<QWidget*, bool> mWidgetVisible;
|
||||
QMap<QWidget*, bool> mWidgetEnabled;
|
||||
};
|
||||
|
||||
#endif // UISTATEHELPER_H
|
@ -428,6 +428,7 @@ HEADERS += rshare.h \
|
||||
gui/common/UserNotify.h \
|
||||
gui/common/HeaderFrame.h \
|
||||
gui/common/MimeTextEdit.h \
|
||||
gui/common/UIStateHelper.h \
|
||||
gui/style/RSStyle.h \
|
||||
gui/style/StyleDialog.h \
|
||||
gui/MessagesDialog.h \
|
||||
@ -704,6 +705,7 @@ SOURCES += main.cpp \
|
||||
gui/common/UserNotify.cpp \
|
||||
gui/common/HeaderFrame.cpp \
|
||||
gui/common/MimeTextEdit.cpp \
|
||||
gui/common/UIStateHelper.cpp \
|
||||
gui/style/RSStyle.cpp \
|
||||
gui/style/StyleDialog.cpp \
|
||||
gui/settings/rsharesettings.cpp \
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <QTimer>
|
||||
#include <retroshare-gui/RsAutoUpdatePage.h>
|
||||
#include <iostream>
|
||||
|
||||
#define PROTECTED_TIMER_DEBUG
|
||||
|
||||
@ -45,7 +46,7 @@ class RsProtectedTimer: public QTimer
|
||||
}
|
||||
|
||||
#ifdef PROTECTED_TIMER_DEBUG
|
||||
std::cerr << "Timer has passsed protection." << std::endl;
|
||||
std::cerr << "Timer has passed protection." << std::endl;
|
||||
#endif
|
||||
QTimer::timerEvent(e) ;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user