Esempio n. 1
0
void MTCompose::on_fromButton_clicked()
{
    // Select from Nyms in local wallet.
    //
    DlgChooser theChooser(this);
    // -----------------------------------------------
    mapIDName & the_map = theChooser.m_map;

    bool bFoundDefault = false;
    // -----------------------------------------------
    const int32_t nym_count = OTAPI_Wrap::It()->GetNymCount();
    // -----------------------------------------------
    for (int32_t ii = 0; ii < nym_count; ++ii)
    {
        //Get OT Nym ID
        QString OT_nym_id = QString::fromStdString(OTAPI_Wrap::It()->GetNym_ID(ii));
        QString OT_nym_name("");
        // -----------------------------------------------
        if (!OT_nym_id.isEmpty())
        {
            if (!m_senderNymId.isEmpty() && (OT_nym_id == m_senderNymId))
                bFoundDefault = true;
            // -----------------------------------------------
            MTNameLookupQT theLookup;

            OT_nym_name = QString::fromStdString(theLookup.GetNymName(OT_nym_id.toStdString()));
            // -----------------------------------------------
            the_map.insert(OT_nym_id, OT_nym_name);
        }
     }
    // -----------------------------------------------
    if (bFoundDefault && !m_senderNymId.isEmpty())
        theChooser.SetPreSelected(m_senderNymId);
    // -----------------------------------------------
    theChooser.setWindowTitle(tr("Choose your Sender identity"));
    // -----------------------------------------------
    if (theChooser.exec() == QDialog::Accepted)
    {
        qDebug() << QString("SELECT was clicked for NymID: %1").arg(theChooser.m_qstrCurrentID);

        if (!theChooser.m_qstrCurrentID.isEmpty())
        {
            m_senderNymId = theChooser.m_qstrCurrentID;
            // -----------------------------------------
            if (theChooser.m_qstrCurrentName.isEmpty())
                ui->fromButton->setText(QString(""));
            else
                ui->fromButton->setText(theChooser.m_qstrCurrentName);
            // -----------------------------------------
            return;
        }
    }
    else
    {
      qDebug() << "CANCEL was clicked";
    }
    // -----------------------------------------------
    m_senderNymId = QString("");
    ui->fromButton->setText(tr("<Click to choose Sender>"));
}
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);
    }
}
Esempio n. 3
0
// 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();
}