void DlgEncrypt::PopulateCombo() { if (ui) { ui->comboBoxNym->blockSignals(true); // ---------------------------- int nDefaultNymIndex = 0; bool bFoundNymDefault = false; // ----------------------------------------------- const int32_t nym_count = opentxs::OTAPI_Wrap::It()->GetNymCount(); // ----------------------------------------------- for (int32_t ii = 0; ii < nym_count; ++ii) { QString OT_nym_id = QString::fromStdString(opentxs::OTAPI_Wrap::It()->GetNym_ID(ii)); QString OT_nym_name(""); // ----------------------------------------------- if (!OT_nym_id.isEmpty()) { if (!m_nymId.isEmpty() && (OT_nym_id == m_nymId)) { bFoundNymDefault = true; nDefaultNymIndex = ii; } // ----------------------------------------------- MTNameLookupQT theLookup; OT_nym_name = QString::fromStdString(theLookup.GetNymName(OT_nym_id.toStdString(), "")); // ----------------------------------------------- m_mapNyms.insert(OT_nym_id, OT_nym_name); ui->comboBoxNym->insertItem(ii, OT_nym_name); } } // ----------------------------------------------- if (m_mapNyms.size() > 0) { SetCurrentNymIDBasedOnIndex(nDefaultNymIndex); ui->comboBoxNym->setCurrentIndex(nDefaultNymIndex); } else SetCurrentNymIDBasedOnIndex(-1); // ----------------------------------------------- ui->comboBoxNym->blockSignals(false); } }
void DlgMarkets::on_comboBoxNym_currentIndexChanged(int index) { m_pMarketDetails->ClearRecords(); m_pOfferDetails->ClearRecords(); ClearMarketMap(); ClearOfferMap(); SetCurrentNymIDBasedOnIndex(index); m_pOfferDetails->SetMarketID(""); // RefreshRecords(); emit needToLoadOrRetrieveMarkets(); }
void DlgEncrypt::on_comboBoxNym_currentIndexChanged(int index) { SetCurrentNymIDBasedOnIndex(index); }
// Top level... // (For servers and nyms.) // void DlgMarkets::RefreshRecords() { ui->comboBoxServer->blockSignals(true); ui->comboBoxNym ->blockSignals(true); // ---------------------------- m_mapServers.clear(); m_mapNyms .clear(); // ---------------------------- ClearOfferMap(); ClearMarketMap(); // ---------------------------- ui->comboBoxServer->clear(); ui->comboBoxNym ->clear(); // ---------------------------- int nDefaultServerIndex = 0; int nDefaultNymIndex = 0; // ---------------------------- bool bFoundServerDefault = false; // ---------------------------- QString qstrAllID = tr("all"); QString qstrAllName = tr("All Servers"); m_mapServers.insert(qstrAllID, qstrAllName); ui->comboBoxServer->insertItem(0, qstrAllName); // ---------------------------- if (!m_serverId.isEmpty() && (m_serverId == qstrAllID)) { bFoundServerDefault = true; nDefaultServerIndex = 0; } // ---------------------------- const int32_t server_count = OTAPI_Wrap::GetServerCount(); // ----------------------------------------------- for (int32_t ii = 0; ii < server_count; ++ii) { //Get OT Server ID // QString OT_server_id = QString::fromStdString(OTAPI_Wrap::GetServer_ID(ii)); QString OT_server_name(""); // ----------------------------------------------- if (!OT_server_id.isEmpty()) { if (!m_serverId.isEmpty() && (OT_server_id == m_serverId)) { bFoundServerDefault = true; nDefaultServerIndex = ii+1; // the +1 is because of "all" in the 0 position. (Servers only.) } // ----------------------------------------------- OT_server_name = QString::fromStdString(OTAPI_Wrap::GetServer_Name(OT_server_id.toStdString())); // ----------------------------------------------- m_mapServers.insert(OT_server_id, OT_server_name); ui->comboBoxServer->insertItem(ii+1, OT_server_name); } } // ----------------------------------------------- // ----------------------------------------------- bool bFoundNymDefault = false; const int32_t nym_count = OTAPI_Wrap::GetNymCount(); // ----------------------------------------------- for (int32_t ii = 0; ii < nym_count; ++ii) { //Get OT Nym ID QString OT_nym_id = QString::fromStdString(OTAPI_Wrap::GetNym_ID(ii)); QString OT_nym_name(""); // ----------------------------------------------- if (!OT_nym_id.isEmpty()) { if (!m_nymId.isEmpty() && (OT_nym_id == m_nymId)) { bFoundNymDefault = true; nDefaultNymIndex = ii; } // ----------------------------------------------- MTNameLookupQT theLookup; OT_nym_name = QString::fromStdString(theLookup.GetNymName(OT_nym_id.toStdString())); // ----------------------------------------------- m_mapNyms.insert(OT_nym_id, OT_nym_name); ui->comboBoxNym->insertItem(ii, OT_nym_name); } } // ----------------------------------------------- // ----------------------------------------------- if (m_mapNyms.size() > 0) { SetCurrentNymIDBasedOnIndex(nDefaultNymIndex); ui->comboBoxNym->setCurrentIndex(nDefaultNymIndex); } else SetCurrentNymIDBasedOnIndex(-1); // ----------------------------------------------- if (m_mapServers.size() > 0) { SetCurrentServerIDBasedOnIndex(nDefaultServerIndex); ui->comboBoxServer->setCurrentIndex(nDefaultServerIndex); } else SetCurrentServerIDBasedOnIndex(-1); // ----------------------------------------------- ui->comboBoxServer->blockSignals(false); ui->comboBoxNym ->blockSignals(false); // ----------------------------------------------- emit needToLoadOrRetrieveMarkets(); }