mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed display of warning in posting into forums without proper credentials
This commit is contained in:
parent
9dc7328dc7
commit
7d8001b60d
@ -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<QIcon> 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<QSortFilterProxyModel*>(QComboBox::model());
|
||||
//QStandardItem* item = model->item(index);
|
||||
// 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;
|
||||
}
|
||||
|
||||
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<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 ;
|
||||
}
|
||||
|
||||
void GxsIdChooser::loadPrivateIds()
|
||||
|
@ -62,6 +62,8 @@ public:
|
||||
|
||||
void setIdConstraintSet(const std::set<RsGxsId>& s) ;
|
||||
bool isInConstraintSet(const RsGxsId& id) const ;
|
||||
|
||||
uint32_t countEnabledEntries() const ;
|
||||
signals:
|
||||
// emitted after first load of own ids
|
||||
void idsLoaded();
|
||||
|
@ -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() ;
|
||||
|
Loading…
Reference in New Issue
Block a user