Merge pull request #1458 from csoler/v0.6-ImprovedGUI

V0.6 improved gui
This commit is contained in:
csoler 2019-01-12 15:02:06 +01:00 committed by GitHub
commit b3ecfe1504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 46 deletions

View File

@ -334,6 +334,7 @@ public:
* @jsonapi{development} * @jsonapi{development}
* @param[in] hash file identifier * @param[in] hash file identifier
* @param[in] flags action to perform. Pict into { RS_FILE_CTRL_PAUSE, RS_FILE_CTRL_START, RS_FILE_CTRL_FORCE_CHECK } } * @param[in] flags action to perform. Pict into { RS_FILE_CTRL_PAUSE, RS_FILE_CTRL_START, RS_FILE_CTRL_FORCE_CHECK } }
* @return false if error occured such as unknown hash.
*/ */
virtual bool FileControl(const RsFileHash& hash, uint32_t flags) = 0; virtual bool FileControl(const RsFileHash& hash, uint32_t flags) = 0;

View File

@ -54,8 +54,7 @@
#define COLUMN_NAME 0 #define COLUMN_NAME 0
#define COLUMN_USER_COUNT 1 #define COLUMN_USER_COUNT 1
#define COLUMN_TOPIC 2 #define COLUMN_TOPIC 2
#define COLUMN_SUBSCRIBED 3 #define COLUMN_COUNT 3
#define COLUMN_COUNT 4
#define COLUMN_DATA 0 #define COLUMN_DATA 0
#define ROLE_SORT Qt::UserRole #define ROLE_SORT Qt::UserRole
@ -115,17 +114,14 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
headerItem->setText(COLUMN_NAME, tr("Name")); headerItem->setText(COLUMN_NAME, tr("Name"));
headerItem->setText(COLUMN_USER_COUNT, tr("Count")); headerItem->setText(COLUMN_USER_COUNT, tr("Count"));
headerItem->setText(COLUMN_TOPIC, tr("Topic")); headerItem->setText(COLUMN_TOPIC, tr("Topic"));
headerItem->setText(COLUMN_SUBSCRIBED, tr("Subscribed"));
headerItem->setTextAlignment(COLUMN_NAME, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(COLUMN_NAME, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(COLUMN_TOPIC, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(COLUMN_TOPIC, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(COLUMN_USER_COUNT, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(COLUMN_USER_COUNT, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(COLUMN_SUBSCRIBED, Qt::AlignHCenter | Qt::AlignVCenter);
QHeaderView *header = ui.lobbyTreeWidget->header(); QHeaderView *header = ui.lobbyTreeWidget->header();
QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(header, COLUMN_USER_COUNT, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(header, COLUMN_USER_COUNT, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(header, COLUMN_TOPIC, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(header, COLUMN_TOPIC, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(header, COLUMN_SUBSCRIBED, QHeaderView::Interactive);
privateSubLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER); privateSubLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER);
privateSubLobbyItem->setText(COLUMN_NAME, tr("Private Subscribed chat rooms")); privateSubLobbyItem->setText(COLUMN_NAME, tr("Private Subscribed chat rooms"));
@ -159,7 +155,6 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
ui.lobbyTreeWidget->setColumnHidden(COLUMN_NAME,false) ; ui.lobbyTreeWidget->setColumnHidden(COLUMN_NAME,false) ;
ui.lobbyTreeWidget->setColumnHidden(COLUMN_USER_COUNT,true) ; ui.lobbyTreeWidget->setColumnHidden(COLUMN_USER_COUNT,true) ;
ui.lobbyTreeWidget->setColumnHidden(COLUMN_TOPIC,true) ; ui.lobbyTreeWidget->setColumnHidden(COLUMN_TOPIC,true) ;
ui.lobbyTreeWidget->setColumnHidden(COLUMN_SUBSCRIBED,true) ;
ui.lobbyTreeWidget->setSortingEnabled(true) ; ui.lobbyTreeWidget->setSortingEnabled(true) ;
float fact = QFontMetricsF(font()).height()/14.0f; float fact = QFontMetricsF(font()).height()/14.0f;
@ -176,9 +171,6 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
showTopicAct= new QAction(headerItem->text(COLUMN_TOPIC),this); showTopicAct= new QAction(headerItem->text(COLUMN_TOPIC),this);
showTopicAct->setCheckable(true); showTopicAct->setToolTip(tr("Show")+" "+showTopicAct->text()+" "+tr("column")); showTopicAct->setCheckable(true); showTopicAct->setToolTip(tr("Show")+" "+showTopicAct->text()+" "+tr("column"));
connect(showTopicAct,SIGNAL(triggered(bool)),this,SLOT(setShowTopicColumn(bool))) ; connect(showTopicAct,SIGNAL(triggered(bool)),this,SLOT(setShowTopicColumn(bool))) ;
showSubscribeAct= new QAction(headerItem->text(COLUMN_SUBSCRIBED),this);
showSubscribeAct->setCheckable(true); showSubscribeAct->setToolTip(tr("Show")+" "+showSubscribeAct->text()+" "+tr("column"));
connect(showSubscribeAct,SIGNAL(triggered(bool)),this,SLOT(setShowSubscribeColumn(bool))) ;
// Set initial size of the splitter // Set initial size of the splitter
ui.splitter->setStretchFactor(0, 0); ui.splitter->setStretchFactor(0, 0);
@ -351,12 +343,10 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint)
showUserCountAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_USER_COUNT)); showUserCountAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_USER_COUNT));
showTopicAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_TOPIC)); showTopicAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_TOPIC));
showSubscribeAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_SUBSCRIBED));
QMenu *menu = contextMnu.addMenu(tr("Columns")); QMenu *menu = contextMnu.addMenu(tr("Columns"));
menu->addAction(showUserCountAct); menu->addAction(showUserCountAct);
menu->addAction(showTopicAct); menu->addAction(showTopicAct);
menu->addAction(showSubscribeAct);
contextMnu.exec(QCursor::pos()); contextMnu.exec(QCursor::pos());
} }
@ -385,8 +375,6 @@ static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobby
//item->setText(COLUMN_USER_COUNT, QString::number(count)); //item->setText(COLUMN_USER_COUNT, QString::number(count));
item->setData(COLUMN_USER_COUNT, Qt::EditRole, count); item->setData(COLUMN_USER_COUNT, Qt::EditRole, count);
item->setText(COLUMN_SUBSCRIBED, subscribed?qApp->translate("ChatLobbyWidget", "Yes"):qApp->translate("ChatLobbyWidget", "No"));
item->setData(COLUMN_DATA, ROLE_ID, (qulonglong)id); item->setData(COLUMN_DATA, ROLE_ID, (qulonglong)id);
item->setData(COLUMN_DATA, ROLE_SUBSCRIBED, subscribed); item->setData(COLUMN_DATA, ROLE_SUBSCRIBED, subscribed);
item->setData(COLUMN_DATA, ROLE_FLAGS, lobby_flags.toUInt32()); item->setData(COLUMN_DATA, ROLE_FLAGS, lobby_flags.toUInt32());
@ -1283,7 +1271,6 @@ void ChatLobbyWidget::processSettings(bool bLoad)
setShowUserCountColumn(Settings->value("showUserCountColumn", !ui.lobbyTreeWidget->isColumnHidden(COLUMN_USER_COUNT)).toBool()); setShowUserCountColumn(Settings->value("showUserCountColumn", !ui.lobbyTreeWidget->isColumnHidden(COLUMN_USER_COUNT)).toBool());
setShowTopicColumn(Settings->value("showTopicColumn", !ui.lobbyTreeWidget->isColumnHidden(COLUMN_TOPIC)).toBool()); setShowTopicColumn(Settings->value("showTopicColumn", !ui.lobbyTreeWidget->isColumnHidden(COLUMN_TOPIC)).toBool());
setShowSubscribeColumn(Settings->value("showSubscribeColumn", !ui.lobbyTreeWidget->isColumnHidden(COLUMN_SUBSCRIBED)).toBool());
} else { } else {
// save settings // save settings
Settings->setValue("splitter", ui.splitter->saveState()); Settings->setValue("splitter", ui.splitter->saveState());
@ -1292,7 +1279,6 @@ void ChatLobbyWidget::processSettings(bool bLoad)
Settings->setValue("showUserCountColumn", !ui.lobbyTreeWidget->isColumnHidden(COLUMN_USER_COUNT)); Settings->setValue("showUserCountColumn", !ui.lobbyTreeWidget->isColumnHidden(COLUMN_USER_COUNT));
Settings->setValue("showTopicColumn", !ui.lobbyTreeWidget->isColumnHidden(COLUMN_TOPIC)); Settings->setValue("showTopicColumn", !ui.lobbyTreeWidget->isColumnHidden(COLUMN_TOPIC));
Settings->setValue("showSubscribeColumn", !ui.lobbyTreeWidget->isColumnHidden(COLUMN_SUBSCRIBED));
} }
Settings->endGroup(); Settings->endGroup();
@ -1315,14 +1301,6 @@ void ChatLobbyWidget::setShowTopicColumn(bool show)
ui.lobbyTreeWidget->header()->setVisible(getNumColVisible()>1); ui.lobbyTreeWidget->header()->setVisible(getNumColVisible()>1);
} }
void ChatLobbyWidget::setShowSubscribeColumn(bool show)
{
if (ui.lobbyTreeWidget->isColumnHidden(COLUMN_SUBSCRIBED) == show) {
ui.lobbyTreeWidget->setColumnHidden(COLUMN_SUBSCRIBED, !show);
}
ui.lobbyTreeWidget->header()->setVisible(getNumColVisible()>1);
}
int ChatLobbyWidget::getNumColVisible() int ChatLobbyWidget::getNumColVisible()
{ {
int iNumColVis=0; int iNumColVis=0;

View File

@ -105,7 +105,6 @@ private slots:
void setShowUserCountColumn(bool show); void setShowUserCountColumn(bool show);
void setShowTopicColumn(bool show); void setShowTopicColumn(bool show);
void setShowSubscribeColumn(bool show);
void updateNotify(ChatLobbyId id, unsigned int count) ; void updateNotify(ChatLobbyId id, unsigned int count) ;
void idChooserCurrentIndexChanged(int index); void idChooserCurrentIndexChanged(int index);
@ -136,7 +135,6 @@ private:
/** Defines the actions for the header context menu */ /** Defines the actions for the header context menu */
QAction* showUserCountAct; QAction* showUserCountAct;
QAction* showTopicAct; QAction* showTopicAct;
QAction* showSubscribeAct;
int getNumColVisible(); int getNumColVisible();
ChatLobbyUserNotify* myChatLobbyUserNotify; ChatLobbyUserNotify* myChatLobbyUserNotify;

View File

@ -228,15 +228,11 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
break; break;
case COLUMN_CHECK: case COLUMN_CHECK:
{ {
if (detail.accept_connection) if (detail.accept_connection || rsPeers->getGPGOwnId() == detail.gpg_id)
{
return tr("Accepted"); return tr("Accepted");
}
else else
{
return tr("Denied"); return tr("Denied");
} }
}
break; break;

View File

@ -277,7 +277,7 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
contextMnu->addAction(showInPeopleAct); contextMnu->addAction(showInPeopleAct);
distantChatAct->setEnabled(false); distantChatAct->setEnabled(false);
sendMessageAct->setEnabled(true); sendMessageAct->setEnabled(false);
muteAct->setEnabled(false); muteAct->setEnabled(false);
muteAct->setCheckable(true); muteAct->setCheckable(true);
muteAct->setChecked(false); muteAct->setChecked(false);
@ -299,6 +299,7 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid)) if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid))
{ {
distantChatAct->setEnabled(true); distantChatAct->setEnabled(true);
sendMessageAct->setEnabled(true);
votePositiveAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_POSITIVE); votePositiveAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_POSITIVE);
voteNeutralAct->setEnabled((rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_POSITIVE) || (rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) ); voteNeutralAct->setEnabled((rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_POSITIVE) || (rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) );
voteNegativeAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_NEGATIVE); voteNegativeAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_NEGATIVE);

View File

@ -335,6 +335,26 @@ void GxsGroupFrameDialog::removeAllSearches()
mSearchGroupsItems.clear(); mSearchGroupsItems.clear();
mKnownGroups.clear(); mKnownGroups.clear();
} }
// Same function than the one in rsgxsnetservice.cc, so that all times are automatically consistent
static uint32_t checkDelay(uint32_t time_in_secs)
{
if(time_in_secs < 1 * 86400)
return 0 ;
if(time_in_secs <= 10 * 86400)
return 5 * 86400;
if(time_in_secs <= 20 * 86400)
return 15 * 86400;
if(time_in_secs <= 60 * 86400)
return 30 * 86400;
if(time_in_secs <= 120 * 86400)
return 90 * 86400;
if(time_in_secs <= 250 * 86400)
return 180 * 86400;
return 365 * 86400;
}
void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point)
{ {
// First separately handle the case of search top level items // First separately handle the case of search top level items
@ -402,8 +422,8 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point)
action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Details"), this, SLOT(editGroupDetails())); action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Details"), this, SLOT(editGroupDetails()));
action->setEnabled (!mGroupId.isNull() && isAdmin); action->setEnabled (!mGroupId.isNull() && isAdmin);
uint32_t current_store_time = mInterface->getStoragePeriod(mGroupId)/86400 ; uint32_t current_store_time = checkDelay(mInterface->getStoragePeriod(mGroupId))/86400 ;
uint32_t current_sync_time = mInterface->getSyncPeriod(mGroupId)/86400 ; uint32_t current_sync_time = checkDelay(mInterface->getSyncPeriod(mGroupId))/86400 ;
std::cerr << "Got sync=" << current_sync_time << ". store=" << current_store_time << std::endl; std::cerr << "Got sync=" << current_sync_time << ". store=" << current_store_time << std::endl;
QAction *actnn = NULL; QAction *actnn = NULL;
@ -414,7 +434,7 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point)
actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_sync_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_sync_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_sync_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_sync_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_sync_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_sync_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(372)) ; if(current_sync_time ==372) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_sync_time ==365) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
ctxMenu2 = contextMnu.addMenu(tr("Store posts for at most...")) ; ctxMenu2 = contextMnu.addMenu(tr("Store posts for at most...")) ;
@ -423,7 +443,7 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point)
actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_store_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_store_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_store_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_store_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_store_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_store_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(372)) ; if(current_store_time ==372) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_store_time ==365) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));}
if (shareKeyType()) { if (shareKeyType()) {

View File

@ -128,10 +128,6 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail
if (!chooser) if (!chooser)
return; return;
int current_index = chooser->currentIndex();
QString current_id = (current_index >= 0)? chooser->itemData(current_index).toString() : "" ;
// this prevents the objects that depend on what's in the combo-box to activate and // 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. // perform any change.Only user-changes should cause this.
chooser->blockSignals(true) ; chooser->blockSignals(true) ;
@ -187,15 +183,29 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail
chooser->model()->sort(0); chooser->model()->sort(0);
// now restore the current item. Problem is, we cannot use the ID position because it may have changed. // now restore the current item. Problem is, we cannot use the ID position because it may have changed.
#ifdef IDCHOOSER_DEBUG
if(current_id != "") std::cerr << "GxsIdChooser: default ID = " << chooser->defaultId() << std::endl;
#endif
if(!chooser->defaultId().isNull())
{
for(int indx=0;indx<chooser->count();++indx) for(int indx=0;indx<chooser->count();++indx)
if(chooser->itemData(indx).toString() == current_id) if(RsGxsId(chooser->itemData(indx).toString().toStdString()) == chooser->defaultId())
{ {
chooser->setCurrentIndex(indx); chooser->setCurrentIndex(indx);
std::cerr << "GxsIdChooser-003" << (void*)chooser << " setting current index to " << indx << std::endl; #ifdef IDCHOOSER_DEBUG
std::cerr << "GxsIdChooser-003 " << (void*)chooser << " setting current index to " << indx << " because it has ID=" << chooser->defaultId() << std::endl;
#endif
break; break;
} }
}
else
{
RsGxsId id;
GxsIdChooser::ChosenId_Ret cid = chooser->getChosenId(id) ;
if(cid == GxsIdChooser::UnKnowId || cid == GxsIdChooser::KnowId)
chooser->setDefaultId(id) ;
}
chooser->blockSignals(false) ; chooser->blockSignals(false) ;
} }
@ -395,6 +405,11 @@ void GxsIdChooser::myCurrentIndexChanged(int index)
} else { } else {
setToolTip(""); setToolTip("");
} }
QVariant var = itemData(index);
RsGxsId gxsId(var.toString().toStdString());
if(!gxsId.isNull())
mDefaultId = gxsId;
} }
void GxsIdChooser::indexActivated(int index) void GxsIdChooser::indexActivated(int index)

View File

@ -50,7 +50,9 @@ public:
enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ; enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ;
void loadIds(uint32_t chooserFlags, const RsGxsId &defId); void loadIds(uint32_t chooserFlags, const RsGxsId &defId);
void setDefaultId(const RsGxsId &defId); void setDefaultId(const RsGxsId &defId);
const RsGxsId defaultId() const { return mDefaultId ; }
bool setChosenId(const RsGxsId &gxsId); bool setChosenId(const RsGxsId &gxsId);
ChosenId_Ret getChosenId(RsGxsId &gxsId); ChosenId_Ret getChosenId(RsGxsId &gxsId);