2013-03-15 17:02:43 -04:00
|
|
|
/*
|
|
|
|
* Retroshare Gxs Support
|
2012-11-19 17:14:45 -05:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* Copyright 2012-2013 by Robert Fernie.
|
2012-11-19 17:14:45 -05:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2.1 as published by the Free Software Foundation.
|
2012-11-19 17:14:45 -05:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
2012-11-19 17:14:45 -05:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
2012-11-19 17:14:45 -05:00
|
|
|
|
|
|
|
#include "GxsIdChooser.h"
|
2014-02-02 06:25:11 -05:00
|
|
|
#include "GxsIdDetails.h"
|
2014-07-06 07:19:58 -04:00
|
|
|
#include "RsGxsUpdateBroadcastBase.h"
|
2014-12-24 09:43:06 -05:00
|
|
|
#include "gui/Identity/IdEditDialog.h"
|
2012-11-19 17:14:45 -05:00
|
|
|
|
2013-06-23 14:55:30 -04:00
|
|
|
#include <QSortFilterProxyModel>
|
2015-10-24 12:48:17 -04:00
|
|
|
#include <QStandardItemModel>
|
2012-11-19 17:14:45 -05:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2013-06-23 14:55:30 -04:00
|
|
|
#define ROLE_SORT Qt::UserRole + 1 // Qt::UserRole is reserved for data
|
2014-07-06 07:19:58 -04:00
|
|
|
#define ROLE_TYPE Qt::UserRole + 2 //
|
|
|
|
|
2014-12-23 14:07:57 -05:00
|
|
|
/* Used for sorting too */
|
2014-07-06 07:19:58 -04:00
|
|
|
#define TYPE_NO_ID 1
|
|
|
|
#define TYPE_FOUND_ID 2
|
|
|
|
#define TYPE_UNKNOWN_ID 3
|
2014-12-23 14:07:57 -05:00
|
|
|
#define TYPE_CREATE_ID 4
|
2014-07-06 07:19:58 -04:00
|
|
|
|
2015-10-10 21:25:06 -04:00
|
|
|
#define BANNED_ICON ":/icons/yellow_biohazard64.png"
|
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
#define IDCHOOSER_REFRESH 1
|
2013-06-23 14:55:30 -04:00
|
|
|
|
2014-12-23 14:07:57 -05:00
|
|
|
//#define IDCHOOSER_DEBUG
|
|
|
|
|
2012-11-19 17:14:45 -05:00
|
|
|
/** Constructor */
|
|
|
|
GxsIdChooser::GxsIdChooser(QWidget *parent)
|
2014-12-23 14:07:57 -05:00
|
|
|
: QComboBox(parent), mFlags(IDCHOOSER_ANON_DEFAULT)
|
2012-11-19 17:14:45 -05:00
|
|
|
{
|
2014-07-06 07:19:58 -04:00
|
|
|
mBase = new RsGxsUpdateBroadcastBase(rsIdentity, this);
|
|
|
|
connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplay(bool)));
|
|
|
|
|
2014-12-23 19:10:15 -05:00
|
|
|
/* Initialize ui */
|
|
|
|
setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
|
|
|
2014-12-23 14:07:57 -05:00
|
|
|
mFirstLoad = true;
|
2016-03-24 00:05:54 -04:00
|
|
|
mAllowedCount = 0 ;
|
2014-07-06 07:19:58 -04:00
|
|
|
|
2014-04-26 12:32:33 -04:00
|
|
|
mDefaultId.clear() ;
|
2013-06-23 14:55:30 -04:00
|
|
|
|
|
|
|
/* Enable sort with own role */
|
|
|
|
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
|
|
|
|
proxy->setSourceModel(model());
|
2015-03-20 10:52:10 -04:00
|
|
|
proxy->setDynamicSortFilter(false);
|
2013-06-23 14:55:30 -04:00
|
|
|
model()->setParent(proxy);
|
|
|
|
setModel(proxy);
|
|
|
|
|
|
|
|
proxy->setSortRole(ROLE_SORT);
|
2014-12-23 14:07:57 -05:00
|
|
|
|
|
|
|
/* Connect signals */
|
|
|
|
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(myCurrentIndexChanged(int)));
|
|
|
|
connect(this, SIGNAL(activated(int)), this, SLOT(indexActivated(int)));
|
2014-07-06 07:19:58 -04:00
|
|
|
}
|
|
|
|
|
2014-11-24 16:02:18 -05:00
|
|
|
void GxsIdChooser::setFlags(uint32_t flags)
|
|
|
|
{
|
2014-12-23 14:07:57 -05:00
|
|
|
mFlags = flags ;
|
|
|
|
updateDisplay(true);
|
2014-11-24 16:02:18 -05:00
|
|
|
}
|
2014-12-23 14:07:57 -05:00
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
GxsIdChooser::~GxsIdChooser()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsIdChooser::fillDisplay(bool complete)
|
|
|
|
{
|
|
|
|
updateDisplay(complete);
|
|
|
|
update(); // Qt flush
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsIdChooser::showEvent(QShowEvent *event)
|
|
|
|
{
|
|
|
|
mBase->showEvent(event);
|
|
|
|
QComboBox::showEvent(event);
|
2012-11-19 17:14:45 -05:00
|
|
|
}
|
|
|
|
|
2016-03-24 00:05:54 -04:00
|
|
|
void GxsIdChooser::setIdConstraintSet(const std::set<RsGxsId>& s)
|
|
|
|
{
|
|
|
|
mConstraintIdsSet = s ;
|
|
|
|
|
|
|
|
updateDisplay(true);
|
|
|
|
update(); // Qt flush
|
|
|
|
}
|
2015-02-10 07:55:16 -05:00
|
|
|
void GxsIdChooser::loadIds(uint32_t chooserFlags, const RsGxsId &defId)
|
2012-11-19 17:14:45 -05:00
|
|
|
{
|
|
|
|
mFlags = chooserFlags;
|
|
|
|
mDefaultId = defId;
|
2013-02-27 18:52:27 -05:00
|
|
|
clear();
|
2014-07-06 07:19:58 -04:00
|
|
|
mFirstLoad = true;
|
2016-04-03 17:11:13 -04:00
|
|
|
|
|
|
|
updateDisplay(true);
|
|
|
|
update(); // Qt flush
|
2012-11-19 17:14:45 -05:00
|
|
|
}
|
|
|
|
|
2015-02-10 07:55:16 -05:00
|
|
|
void GxsIdChooser::setDefaultId(const RsGxsId &defId)
|
|
|
|
{
|
|
|
|
mDefaultId = defId;
|
|
|
|
}
|
|
|
|
|
2014-11-26 19:55:48 -05:00
|
|
|
static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetails &details, QObject *object, const QVariant &/*data*/)
|
2012-11-19 17:14:45 -05:00
|
|
|
{
|
2014-11-26 19:55:48 -05:00
|
|
|
GxsIdChooser *chooser = dynamic_cast<GxsIdChooser*>(object);
|
|
|
|
if (!chooser) {
|
|
|
|
return;
|
|
|
|
}
|
2016-03-24 00:05:54 -04:00
|
|
|
|
2013-06-23 14:55:30 -04:00
|
|
|
|
2015-03-06 16:13:23 -05:00
|
|
|
// this prevents the objects that depend on what's in the combo-box to activate and
|
|
|
|
// perform any change.Only user-changes should cause this.
|
|
|
|
chooser->blockSignals(true) ;
|
|
|
|
|
2014-11-26 19:55:48 -05:00
|
|
|
QString text = GxsIdDetails::getNameForType(type, details);
|
|
|
|
QString id = QString::fromStdString(details.mId.toStdString());
|
2013-06-23 14:55:30 -04:00
|
|
|
|
2014-11-26 19:55:48 -05:00
|
|
|
/* Find and replace text of exisiting item */
|
|
|
|
int index = chooser->findData(id);
|
|
|
|
if (index >= 0) {
|
|
|
|
chooser->setItemText(index, text);
|
|
|
|
} else {
|
|
|
|
/* Add new item */
|
|
|
|
chooser->addItem(text, id);
|
|
|
|
index = chooser->count() - 1;
|
|
|
|
}
|
2013-06-23 14:55:30 -04:00
|
|
|
|
2014-12-30 16:22:45 -05:00
|
|
|
QList<QIcon> icons;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case GXS_ID_DETAILS_TYPE_EMPTY:
|
|
|
|
case GXS_ID_DETAILS_TYPE_FAILED:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GXS_ID_DETAILS_TYPE_LOADING:
|
|
|
|
icons.push_back(GxsIdDetails::getLoadingIcon(details.mId));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GXS_ID_DETAILS_TYPE_DONE:
|
2017-01-01 12:07:02 -05:00
|
|
|
GxsIdDetails::getIcons(details, icons, GxsIdDetails::ICON_TYPE_AVATAR);
|
2014-12-30 16:22:45 -05:00
|
|
|
break;
|
2015-10-10 21:25:06 -04:00
|
|
|
|
|
|
|
case GXS_ID_DETAILS_TYPE_BANNED:
|
|
|
|
icons.push_back(QIcon(BANNED_ICON)) ;
|
|
|
|
break;
|
2014-12-30 16:22:45 -05:00
|
|
|
}
|
|
|
|
|
2014-12-23 14:07:57 -05:00
|
|
|
chooser->setItemData(index, QString("%1_%2").arg((type == GXS_ID_DETAILS_TYPE_DONE) ? TYPE_FOUND_ID : TYPE_UNKNOWN_ID).arg(text), ROLE_SORT);
|
2014-11-26 19:55:48 -05:00
|
|
|
chooser->setItemData(index, (type == GXS_ID_DETAILS_TYPE_DONE) ? TYPE_FOUND_ID : TYPE_UNKNOWN_ID, ROLE_TYPE);
|
2014-12-30 16:22:45 -05:00
|
|
|
chooser->setItemIcon(index, icons.empty() ? QIcon() : icons[0]);
|
|
|
|
|
2016-01-26 23:00:10 -05:00
|
|
|
//std::cerr << "ID=" << details.mId << ", chooser->flags()=" << chooser->flags() << ", flags=" << details.mFlags ;
|
2015-10-24 12:48:17 -04:00
|
|
|
|
2015-12-05 16:49:00 -05:00
|
|
|
if((chooser->flags() & IDCHOOSER_NON_ANONYMOUS) && !(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
|
2015-10-24 12:48:17 -04:00
|
|
|
{
|
2016-01-26 23:00:10 -05:00
|
|
|
//std::cerr << " - disabling ID - entry = " << index << std::endl;
|
2015-10-24 12:48:17 -04:00
|
|
|
chooser->setEntryEnabled(index,false) ;
|
|
|
|
}
|
2016-03-24 00:05:54 -04:00
|
|
|
|
|
|
|
if(!chooser->isInConstraintSet(details.mId))
|
|
|
|
chooser->setEntryEnabled(index,false) ;
|
|
|
|
|
2015-03-06 16:13:23 -05:00
|
|
|
chooser->model()->sort(0);
|
|
|
|
|
|
|
|
chooser->blockSignals(false) ;
|
2013-06-23 14:55:30 -04:00
|
|
|
}
|
2012-11-19 17:14:45 -05:00
|
|
|
|
2016-03-24 00:05:54 -04:00
|
|
|
bool GxsIdChooser::isInConstraintSet(const RsGxsId& id) const
|
|
|
|
{
|
|
|
|
if(mConstraintIdsSet.empty()) // special case: empty set means no constraint
|
|
|
|
return true ;
|
|
|
|
|
|
|
|
return mConstraintIdsSet.find(id) != mConstraintIdsSet.end() ;
|
|
|
|
}
|
2016-10-19 09:41:25 -04:00
|
|
|
void GxsIdChooser::setEntryEnabled(int indx,bool /*enabled*/)
|
2015-10-24 12:48:17 -04:00
|
|
|
{
|
2016-03-24 19:23:34 -04:00
|
|
|
removeItem(indx) ;
|
2015-10-24 12:48:17 -04:00
|
|
|
|
2016-03-24 19:46:08 -04:00
|
|
|
#ifdef TO_REMOVE
|
2016-03-24 19:23:34 -04:00
|
|
|
// bool disable = !enabled ;
|
|
|
|
//
|
|
|
|
// QSortFilterProxyModel* model = qobject_cast<QSortFilterProxyModel*>(QComboBox::model());
|
|
|
|
// //QStandardItem* item = model->item(index);
|
|
|
|
//
|
|
|
|
// QModelIndex ii = model->index(indx,0);
|
|
|
|
//
|
|
|
|
// // visually disable by greying out - works only if combobox has been painted already and palette returns the wanted color
|
|
|
|
// //model->setFlags(ii,disable ? (model->flags(ii) & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled)) : (Qt::ItemIsSelectable|Qt::ItemIsEnabled));
|
|
|
|
//
|
|
|
|
// uint32_t v = enabled?(1|32):(0);
|
|
|
|
//
|
|
|
|
// std::cerr << "GxsIdChooser::setEnabledEntry: i=" << indx << ", v=" << v << std::endl;
|
|
|
|
//
|
|
|
|
// // clear item data in order to use default color
|
|
|
|
// //model->setData(ii,disable ? (QComboBox::palette().color(QPalette::Disabled, QPalette::Text)) : QVariant(), Qt::TextColorRole);
|
|
|
|
// model->setData(ii,QVariant(v),Qt::UserRole-1) ;
|
|
|
|
//
|
|
|
|
// std::cerr << "model data after operation: " << model->data(ii,Qt::UserRole-1).toUInt() << std::endl;
|
2016-03-24 19:46:08 -04:00
|
|
|
#endif
|
2016-03-24 19:23:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t GxsIdChooser::countEnabledEntries() const
|
|
|
|
{
|
|
|
|
return count() ;
|
2015-10-24 12:48:17 -04:00
|
|
|
|
2016-03-24 19:46:08 -04:00
|
|
|
#ifdef TO_REMOVE
|
2016-03-24 19:23:34 -04:00
|
|
|
// uint32_t res = 0 ;
|
|
|
|
// QSortFilterProxyModel* model = qobject_cast<QSortFilterProxyModel*>(QComboBox::model());
|
|
|
|
//
|
|
|
|
// for(uint32_t i=0;i<model->rowCount();++i)
|
|
|
|
// {
|
|
|
|
// QModelIndex ii = model->index(i,0);
|
|
|
|
// uint32_t v = model->data(ii,Qt::UserRole-1).toUInt() ;
|
|
|
|
//
|
|
|
|
// std::cerr << "GxsIdChooser::countEnabledEntries(): i=" << i << ", v=" << v << std::endl;
|
|
|
|
// if(v > 0)
|
|
|
|
// ++res ;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// return res ;
|
2016-03-24 19:46:08 -04:00
|
|
|
#endif
|
2015-10-24 12:48:17 -04:00
|
|
|
}
|
|
|
|
|
2015-03-18 09:33:38 -04:00
|
|
|
void GxsIdChooser::loadPrivateIds()
|
2012-11-19 17:14:45 -05:00
|
|
|
{
|
2014-12-23 14:07:57 -05:00
|
|
|
if (mFirstLoad) {
|
|
|
|
clear();
|
|
|
|
}
|
2013-06-23 14:55:30 -04:00
|
|
|
|
2012-11-19 17:14:45 -05:00
|
|
|
std::list<RsGxsId> ids;
|
2015-03-18 09:33:38 -04:00
|
|
|
rsIdentity->getOwnIds(ids);
|
2012-11-19 17:14:45 -05:00
|
|
|
|
|
|
|
//rsIdentity->getDefaultId(defId);
|
|
|
|
// Prefer to use an application specific default???
|
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
if (mFirstLoad) {
|
|
|
|
if (!(mFlags & IDCHOOSER_ID_REQUIRED)) {
|
2014-12-23 14:07:57 -05:00
|
|
|
/* add No Signature option */
|
|
|
|
QString str = tr("No Signature");
|
|
|
|
QString id = "";
|
2012-11-19 17:14:45 -05:00
|
|
|
|
2014-12-23 14:07:57 -05:00
|
|
|
addItem(str, id);
|
|
|
|
setItemData(count() - 1, QString("%1_%2").arg(TYPE_NO_ID).arg(str), ROLE_SORT);
|
2014-07-06 07:19:58 -04:00
|
|
|
setItemData(count() - 1, TYPE_NO_ID, ROLE_TYPE);
|
2014-12-23 14:07:57 -05:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int idx = 0; idx < count(); ++idx) {
|
|
|
|
QVariant type = itemData(idx, ROLE_TYPE);
|
2014-07-06 07:19:58 -04:00
|
|
|
switch (type.toInt()) {
|
2014-12-23 14:07:57 -05:00
|
|
|
case TYPE_NO_ID:
|
|
|
|
case TYPE_CREATE_ID:
|
2014-07-06 07:19:58 -04:00
|
|
|
break;
|
2014-12-23 14:07:57 -05:00
|
|
|
case TYPE_FOUND_ID:
|
|
|
|
case TYPE_UNKNOWN_ID:
|
|
|
|
{
|
2014-07-06 07:19:58 -04:00
|
|
|
QVariant var = itemData(idx);
|
|
|
|
RsGxsId gxsId = RsGxsId(var.toString().toStdString());
|
2014-12-23 14:07:57 -05:00
|
|
|
std::list<RsGxsId>::iterator lit = std::find(ids.begin(), ids.end(), gxsId);
|
2014-07-06 07:19:58 -04:00
|
|
|
if (lit == ids.end()) {
|
|
|
|
removeItem(idx);
|
|
|
|
idx--;
|
2014-12-23 14:07:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::list<RsGxsId>::iterator it = ids.begin(); it != ids.end(); ++it) {
|
2016-03-24 00:05:54 -04:00
|
|
|
GxsIdDetails::process(*it, loadPrivateIdsCallback, this); /* add to Chooser */
|
2014-12-23 14:07:57 -05:00
|
|
|
}
|
2014-07-06 07:19:58 -04:00
|
|
|
|
2014-12-23 19:10:15 -05:00
|
|
|
if (mFirstLoad) {
|
|
|
|
if (!(mFlags & IDCHOOSER_NO_CREATE)) {
|
|
|
|
/* add Create Identity option */
|
|
|
|
QString str = tr("Create new Identity");
|
|
|
|
QString id = "";
|
|
|
|
|
2014-12-30 16:22:45 -05:00
|
|
|
addItem(QIcon(":/images/identity/identity_create_32.png"), str, id);
|
2014-12-23 19:10:15 -05:00
|
|
|
setItemData(count() - 1, QString("%1_%2").arg(TYPE_CREATE_ID).arg(str), ROLE_SORT);
|
|
|
|
setItemData(count() - 1, TYPE_CREATE_ID, ROLE_TYPE);
|
2015-10-24 12:48:17 -04:00
|
|
|
|
|
|
|
|
2014-12-23 19:10:15 -05:00
|
|
|
}
|
2015-04-29 17:05:44 -04:00
|
|
|
setDefaultItem();
|
2015-05-09 05:28:38 -04:00
|
|
|
emit idsLoaded();
|
2015-04-29 17:05:44 -04:00
|
|
|
}
|
2014-12-23 19:10:15 -05:00
|
|
|
|
|
|
|
mFirstLoad = false;
|
2012-11-19 17:14:45 -05:00
|
|
|
}
|
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
void GxsIdChooser::setDefaultItem()
|
2012-11-19 17:14:45 -05:00
|
|
|
{
|
2014-07-06 07:19:58 -04:00
|
|
|
int def = -1;
|
|
|
|
|
|
|
|
if ((mFlags & IDCHOOSER_ANON_DEFAULT) && !(mFlags & IDCHOOSER_ID_REQUIRED)) {
|
|
|
|
def = findData(TYPE_NO_ID, ROLE_TYPE);
|
|
|
|
} else {
|
2014-12-23 19:10:15 -05:00
|
|
|
if (!mDefaultId.isNull()) {
|
|
|
|
QString id = QString::fromStdString(mDefaultId.toStdString());
|
|
|
|
def = findData(id);
|
|
|
|
}
|
2014-12-23 14:07:57 -05:00
|
|
|
}
|
2014-07-06 07:19:58 -04:00
|
|
|
|
|
|
|
if (def >= 0) {
|
|
|
|
setCurrentIndex(def);
|
2014-12-23 14:07:57 -05:00
|
|
|
}
|
2014-07-06 07:19:58 -04:00
|
|
|
}
|
|
|
|
|
2015-02-10 07:55:16 -05:00
|
|
|
bool GxsIdChooser::setChosenId(const RsGxsId &gxsId)
|
2014-12-23 14:07:57 -05:00
|
|
|
{
|
2014-07-06 07:19:58 -04:00
|
|
|
QString id = QString::fromStdString(gxsId.toStdString());
|
|
|
|
|
|
|
|
/* Find text of exisiting item */
|
|
|
|
int index = findData(id);
|
|
|
|
if (index >= 0) {
|
|
|
|
setCurrentIndex(index);
|
|
|
|
return true;
|
2012-11-19 17:14:45 -05:00
|
|
|
}
|
2014-12-23 14:07:57 -05:00
|
|
|
return false;
|
|
|
|
}
|
2012-11-19 17:14:45 -05:00
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
GxsIdChooser::ChosenId_Ret GxsIdChooser::getChosenId(RsGxsId &gxsId)
|
|
|
|
{
|
|
|
|
if (count() < 1) {
|
|
|
|
return None;
|
2014-12-23 14:07:57 -05:00
|
|
|
}
|
2014-07-06 07:19:58 -04:00
|
|
|
|
2012-11-19 17:14:45 -05:00
|
|
|
int idx = currentIndex();
|
|
|
|
|
|
|
|
QVariant var = itemData(idx);
|
2014-07-06 07:19:58 -04:00
|
|
|
gxsId = RsGxsId(var.toString().toStdString());
|
2014-12-23 14:07:57 -05:00
|
|
|
QVariant type = itemData(idx, ROLE_TYPE);
|
2014-07-06 07:19:58 -04:00
|
|
|
switch (type.toInt()) {
|
2014-12-23 14:07:57 -05:00
|
|
|
case TYPE_NO_ID:
|
2014-07-06 07:19:58 -04:00
|
|
|
return NoId;
|
2014-12-23 14:07:57 -05:00
|
|
|
case TYPE_FOUND_ID:
|
2014-07-06 07:19:58 -04:00
|
|
|
return KnowId;
|
2014-12-23 14:07:57 -05:00
|
|
|
case TYPE_UNKNOWN_ID:
|
2014-07-06 07:19:58 -04:00
|
|
|
return UnKnowId;
|
2014-12-23 14:07:57 -05:00
|
|
|
case TYPE_CREATE_ID:
|
|
|
|
break;
|
|
|
|
}
|
2014-07-06 07:19:58 -04:00
|
|
|
|
|
|
|
return None;
|
|
|
|
}
|
2012-11-19 17:14:45 -05:00
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
void GxsIdChooser::myCurrentIndexChanged(int index)
|
|
|
|
{
|
2014-12-23 14:07:57 -05:00
|
|
|
Q_UNUSED(index);
|
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
QFontMetrics fm = QFontMetrics(font());
|
|
|
|
QString text = currentText();
|
2014-12-23 14:07:57 -05:00
|
|
|
if (width() < fm.boundingRect(text).width()) {
|
2014-07-06 07:19:58 -04:00
|
|
|
setToolTip(text);
|
|
|
|
} else {
|
|
|
|
setToolTip("");
|
2014-12-23 14:07:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsIdChooser::indexActivated(int index)
|
|
|
|
{
|
|
|
|
int type = itemData(index, ROLE_TYPE).toInt();
|
|
|
|
if (type == TYPE_CREATE_ID) {
|
|
|
|
IdEditDialog dlg(this);
|
2015-10-24 12:48:17 -04:00
|
|
|
dlg.setupNewId(false, !(mFlags & IDCHOOSER_NON_ANONYMOUS));
|
2015-02-10 07:55:16 -05:00
|
|
|
if (dlg.exec() == QDialog::Accepted) {
|
|
|
|
setDefaultId(RsGxsId(dlg.groupId()));
|
|
|
|
}
|
2014-12-23 14:07:57 -05:00
|
|
|
}
|
2012-11-19 17:14:45 -05:00
|
|
|
}
|
2014-07-06 07:19:58 -04:00
|
|
|
|
2015-03-26 17:20:57 -04:00
|
|
|
void GxsIdChooser::updateDisplay(bool reset)
|
2014-07-06 07:19:58 -04:00
|
|
|
{
|
2015-03-26 17:20:57 -04:00
|
|
|
if(reset)
|
|
|
|
mFirstLoad = true ;
|
2014-12-23 14:07:57 -05:00
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
/* Update identity list */
|
2015-03-18 09:33:38 -04:00
|
|
|
loadPrivateIds();
|
2013-06-23 14:55:30 -04:00
|
|
|
}
|