// Market is selected from combo box, on Offers page. void MTDetailEdit::on_comboBox_currentIndexChanged(int index) { if (ui && (MTDetailEdit::DetailEditTypeAgreement == m_Type)) { SetCurrentLawyerIDBasedOnIndex(index); } // -------------------------------------------------------- if (ui && (MTDetailEdit::DetailEditTypeOffer == m_Type)) { // ----------------------------- SetCurrentMarketIDBasedOnIndex(index); // ----------------------------- // ----------------------------- // emit NeedToLoadOrRetrieveOffers(m_qstrMarketID); emit CurrentMarketChanged(m_qstrMarketID); // ---------------------------- } }
void MTDetailEdit::on_tableWidget_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn) { Q_UNUSED(currentColumn); Q_UNUSED(previousRow); Q_UNUSED(previousColumn); m_nCurrentRow = currentRow; // ------------------------------------- QString qstrOldID = m_qstrCurrentID; // ------------------------------------- if ((currentRow >= 0) && (currentRow < m_map.size())) { m_pDetailPane->setVisible(true); m_pTabWidget->setVisible(true); int nIndex = -1; // Here we find m_qstrCurrentID and m_qstrCurrentName (display name) // based on its index in the listbox, by iterating through m_map. // Then for (mapIDName::iterator ii = m_map.begin(); ii != m_map.end(); ii++) { ++nIndex; // 0 on first iteration. // ------------------------------------- if (nIndex == m_nCurrentRow) // <===== ONLY HAPPENS ONCE <===== { m_qstrCurrentID = ii.key(); m_qstrCurrentName = ii.value(); if (m_bEnableDelete) ui->deleteButton->setEnabled(true); // qDebug() << "SETTING current row to " << nIndex << " on the tableWidget."; // ---------------------------------------- m_PreSelected = m_qstrCurrentID; if (m_pDetailPane) m_pDetailPane->refresh(m_qstrCurrentID, m_qstrCurrentName); // ---------------------------------------- break; // <=== ONLY HAPPENS ONCE <===== } } } // ------------------------------------- else { m_nCurrentRow = -1; m_qstrCurrentID = QString(""); m_qstrCurrentName = QString(""); ui->deleteButton->setEnabled(false); if (m_pDetailPane) { m_pDetailPane->ClearContents(); m_pDetailPane->setVisible(false); } m_pTabWidget->setVisible(false); } // ------------------------------------- // If this is the markets page, and the current ID has changed, then we need // to notify the offers page. // if ((MTDetailEdit::DetailEditTypeMarket == m_Type) && // (qstrOldID.isEmpty() || (!qstrOldID.isEmpty() && (qstrOldID != m_qstrCurrentID)))) (qstrOldID.isEmpty() || (qstrOldID != m_qstrCurrentID))) { SetMarketID(m_qstrCurrentID); emit CurrentMarketChanged(m_qstrCurrentID); } }
void DlgMarkets::FirstRun() { if (m_bFirstRun) { m_bFirstRun = false; // ----------------------- // Initialization here... // ---------------------------------------------------------------- QPixmap pixmapContacts(":/icons/icons/user.png"); QPixmap pixmapRefresh (":/icons/icons/refresh.png"); // ---------------------------------------------------------------- QIcon contactsButtonIcon(pixmapContacts); QIcon refreshButtonIcon (pixmapRefresh); // ---------------------------------------------------------------- ui->toolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui->toolButton->setAutoRaise(true); ui->toolButton->setIcon(refreshButtonIcon); // ui->toolButton->setIconSize(pixmapRefresh.rect().size()); ui->toolButton->setIconSize(pixmapContacts.rect().size()); ui->toolButton->setText(tr("Refresh")); // ****************************************************** { m_pMarketDetails = new MTDetailEdit(this); m_pMarketDetails->SetMarketMap(m_mapMarkets); // ------------------------------------- m_pMarketDetails->setWindowTitle(tr("Markets")); // ------------------------------------- QVBoxLayout * pLayout = new QVBoxLayout; pLayout->addWidget(m_pMarketDetails); m_pMarketDetails->setContentsMargins(1,1,1,1); pLayout->setContentsMargins(1,1,1,1); ui->tabMarkets->setContentsMargins(1,1,1,1); ui->tabMarkets->setLayout(pLayout); // ------------------------------------- connect(this, SIGNAL(needToLoadOrRetrieveMarkets()), m_pMarketDetails, SLOT(onSetNeedToRetrieveOfferTradeFlags())); // ------------------------------------- connect(this, SIGNAL(needToLoadOrRetrieveMarkets()), this, SLOT(LoadOrRetrieveMarkets())); // ------------------------------------- connect(m_pMarketDetails, SIGNAL(CurrentMarketChanged(QString)), this, SLOT(onCurrentMarketChanged_Markets(QString))); // ------------------------------------- // Connect market panel "current market changed" to *this "onCurrentMarketChanged connect(m_pMarketDetails, SIGNAL(CurrentMarketChanged(QString)), this, SLOT(onNeedToLoadOrRetrieveOffers(QString))); // ------------------------------------- } // ****************************************************** // void CurrentMarketChanged(QString qstrMarketID); // ****************************************************** { m_pOfferDetails = new MTDetailEdit(this); m_pOfferDetails->SetMarketMap(m_mapMarkets); m_pOfferDetails->SetOfferMap (m_mapOffers); // ------------------------------------- m_pOfferDetails->setWindowTitle(tr("Orders")); // NOTE: This gets set already whenever MTDetailEdit::FirstRun // is called. But we want it to be set before that, in this case, // since m_pMarketDetails and m_pOfferDetails are intertwined. // m_pOfferDetails->SetType(MTDetailEdit::DetailEditTypeOffer); // ------------------------------------- QVBoxLayout * pLayout = new QVBoxLayout; pLayout->addWidget(m_pOfferDetails); m_pOfferDetails->setContentsMargins(1,1,1,1); pLayout->setContentsMargins(1,1,1,1); ui->tabOffers->setContentsMargins(1,1,1,1); ui->tabOffers->setLayout(pLayout); // ------------------------------------- connect(m_pOfferDetails, SIGNAL(CurrentMarketChanged(QString)), this, SLOT(onCurrentMarketChanged_Offers(QString))); // ------------------------------------- connect(m_pOfferDetails, SIGNAL(CurrentMarketChanged(QString)), this, SLOT(onNeedToLoadOrRetrieveOffers(QString))); // ------------------------------------- connect(m_pOfferDetails, SIGNAL(NeedToLoadOrRetrieveOffers(QString)), this, SLOT(onNeedToLoadOrRetrieveOffers(QString))); // ------------------------------------- } // ****************************************************** // Whenever the GUI refreshes (say, the list of servers is cleared // and re-populated) then we will set the CURRENT selection as whatever // is in m_serverId / m_nymId. // // The initial state for this comes from the defaults, but once the user // starts changing the selection of the combo box, the new current selection // will go into these variables. // m_nymId = Moneychanger::It()->get_default_nym_id(); m_serverId = Moneychanger::It()->get_default_server_id(); m_pMarketDetails->SetMarketNymID (m_nymId); m_pOfferDetails ->SetMarketNymID (m_nymId); m_pMarketDetails->SetMarketServerID(m_serverId); m_pOfferDetails ->SetMarketServerID(m_serverId); } }