diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp index a16d1811b..36c46fa82 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp @@ -135,6 +135,8 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail QString text = GxsIdDetails::getNameForType(type, details); QString id = QString::fromStdString(details.mId.toStdString()); + std::cerr << "chooser: in callback. details.mId=" << details.mId << ", name=" << details.mNickname << " count before=" << chooser->count()<< std::endl; + /* Find and replace text of exisiting item */ int index = chooser->findData(id); if (index >= 0) { @@ -144,6 +146,7 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail chooser->addItem(text, id); index = chooser->count() - 1; } + std::cerr << "chooser: in callback. count after=" << chooser->count()<< std::endl; QList icons; @@ -194,21 +197,47 @@ bool GxsIdChooser::isInConstraintSet(const RsGxsId& id) const } void GxsIdChooser::setEntryEnabled(int indx,bool enabled) { - bool disable = !enabled ; + removeItem(indx) ; - QSortFilterProxyModel* model = qobject_cast(QComboBox::model()); - //QStandardItem* item = model->item(index); +// bool disable = !enabled ; +// +// QSortFilterProxyModel* model = qobject_cast(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; +} + +uint32_t GxsIdChooser::countEnabledEntries() const +{ + return count() ; - 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); - - // 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) ; +// uint32_t res = 0 ; +// QSortFilterProxyModel* model = qobject_cast(QComboBox::model()); +// +// for(uint32_t i=0;irowCount();++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 ; } void GxsIdChooser::loadPrivateIds() diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.h b/retroshare-gui/src/gui/gxs/GxsIdChooser.h index bb7395b34..8e339508d 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.h +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.h @@ -62,6 +62,8 @@ public: void setIdConstraintSet(const std::set& s) ; bool isInConstraintSet(const RsGxsId& id) const ; + + uint32_t countEnabledEntries() const ; signals: // emitted after first load of own ids void idsLoaded(); diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index 381077819..9753b09f3 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -507,7 +507,7 @@ void CreateGxsForumMsg::loadForumCircleInfo(const uint32_t& token) ui.idChooser->setFlags(IDCHOOSER_NO_CREATE | ui.idChooser->flags()) ; // since there's a circle involved, no ID creation can be needed RsGxsId tmpid ; - if(ui.idChooser->getChosenId(tmpid) == GxsIdChooser::None) + if(ui.idChooser->countEnabledEntries() == 0) { QMessageBox::information(NULL,tr("No compatible ID for this forum"),tr("Sorry, but this forum is restricted to a circle that contains none of your identities. As a consequence you cannot post in this forum, since your posts could not be propagated.")) ; close() ;