void SharedEventModel::AddExpenseItem(ExpenseItemModel *model){ ExpenseItemPtr item = model->getRawExpenseItem(); this->rawSharedEvent->AddExpenseItem(item); expensesListModel.Sync(); expenseListChanged(); resultChanged(); }
void QueryLabel::setResult( const Tomahawk::result_ptr& result ) { if ( result.isNull() ) return; if ( !m_text.isEmpty() && contentsMargins().left() != 0 ) // FIXME: hacky m_textMargins = contentsMargins(); setContentsMargins( BOXMARGIN * 2, BOXMARGIN / 2, BOXMARGIN * 2, BOXMARGIN / 2); if ( m_result.isNull() || m_result.data() != result.data() ) { m_result = result; m_query = m_result->toQuery(); QList<Tomahawk::result_ptr> rl; rl << m_result; m_query->addResults( rl ); updateLabel(); emit textChanged( text() ); emit resultChanged( m_result ); } }
void PingPong::readSocket() { if (!socket) return; const char sep = ' '; QByteArray line; while (socket->canReadLine()) { line = socket->readLine(); //qDebug() << QString::fromUtf8(line.constData(), line.length()); if (line.contains("result")) { QList<QByteArray> result = line.split(sep); if (result.size() > 2) { QByteArray leftSide = result.at(1); QByteArray rightSide = result.at(2); m_resultLeft = leftSide.toInt(); m_resultRight = rightSide.toInt(); Q_EMIT resultChanged(); checkResult(); } } } if ((m_proportionX == 0 || m_proportionY == 0)) { QList<QByteArray> boardSize = line.split(sep); if (boardSize.size() > 1) { QByteArray boardWidth = boardSize.at(0); QByteArray boardHeight = boardSize.at(1); m_proportionX = m_boardWidth/boardWidth.toFloat(); m_proportionY = m_boardHeight/boardHeight.toFloat(); setMessage("Screen adjusted. Get ready!"); QTimer::singleShot(3000, this, SLOT(startGame())); } } else if (m_role == 1) { QList<QByteArray> boardSize = line.split(sep); if (boardSize.size() > 1) { QByteArray rightBlockY = boardSize.at(0); m_rightBlockY = m_proportionY * rightBlockY.toFloat(); Q_EMIT rightBlockChanged(); } } else if (m_role == 2) { QList<QByteArray> boardSize = line.split(sep); if (boardSize.size() > 2) { QByteArray ballX = boardSize.at(0); QByteArray ballY = boardSize.at(1); QByteArray leftBlockY = boardSize.at(2); m_ballX = m_proportionX * ballX.toFloat(); m_ballY = m_proportionY * ballY.toFloat(); m_leftBlockY = m_proportionY * leftBlockY.toFloat(); Q_EMIT leftBlockChanged(); Q_EMIT ballChanged(); } } }
void QAbstractFilterProxyModel::updateResult() { // reset last result count d->lastResultCount = -1; emit resultAboutToChange(); // invalidate filter invalidateFilter(); // emit resultChanged(); // emit result count changed emitResultCountChanged(); }
void QueryLabel::setText( const QString& text ) { setContentsMargins( m_textMargins ); m_result.clear(); m_query.clear(); m_text = text; updateLabel(); emit textChanged( m_text ); emit resultChanged( m_result ); }
void Calculator::getResult() { resultToShow.setNum(result, 'f', 2); double preResult = result; if (operation == "+") preResult = firstOperand + secondOperand; else if (operation == "-") preResult = firstOperand - secondOperand; else if (operation == "*") preResult = firstOperand * secondOperand; else if ((operation == "/") && (secondOperand != 0)) preResult = (double)firstOperand / (double)secondOperand; else resultToShow = "E"; if (resultToShow != "E") { result = preResult; resultToShow.setNum(result, 'f', 2); emit resultChanged(result); } emit resultChanged(resultToShow); }
void LevelAnalyzedImage::checkResult() { // first time if (heightsCache_.size() == 0) { return; } if (lastHeights_.empty()) { lastHeights_ = std::vector<int>(targetRects_.size(), 0); } bool isSteady = true; for (int i = 1; i < heightsCache_.size(); ++i) { for (int j = 0; j < heightsCache_[i].size() && j < heightsCache_[i-1].size(); ++j) { bool changed = heightsCache_[i][j] != heightsCache_[i-1][j]; bool ignored = ignoreRectMap_[j]; if (changed && !ignored) { isSteady = false; break; } } if (!isSteady) break; } if (isSteady) { // result = { 0, 0, 0, 1, 1, 0, ... } // lastResult = { 1, 1, 0, 0, 1, 0, ... } // --> {-1,-1, 0, 1, 0, 0, ... } auto currentHeights = heightsCache_[0]; std::vector<int> newResult( currentHeights.size() ); bool isResultChanged = false; for (int i = 0; i < currentHeights.size() && i < lastHeights_.size(); ++i) { auto deltaHeight = currentHeights[i] - lastHeights_[i]; if (ignoreRectMap_[i]) deltaHeight = 0; if (deltaHeight != 0) isResultChanged = true; newResult[i] = deltaHeight; } if (isResultChanged) { lastHeights_ = currentHeights; result_ = newResult; emit resultChanged(); emit lastHeightsChanged(); } } }
void PingPong::checkBoundaries() { float ballWidth = m_boardWidth/54; float blockSize = m_boardWidth/27; float blockHeight = m_boardHeight/5; //! [Checking the boundaries] if (((m_ballX + ballWidth) > (m_boardWidth - blockSize)) && ((m_ballY + ballWidth) < (m_rightBlockY + blockHeight)) && (m_ballY > m_rightBlockY)) { m_targetY = 2 * m_ballY - m_ballPreviousY; m_targetX = m_ballPreviousX; interval = -5; updateDirection(); } else if ((m_ballX < blockSize) && ((m_ballY + ballWidth) < (m_leftBlockY + blockHeight)) && (m_ballY > m_leftBlockY)) { m_targetY = 2 * m_ballY - m_ballPreviousY; m_targetX = m_ballPreviousX; interval = 5; updateDirection(); } else if (m_ballY < 0 || (m_ballY + ballWidth > m_boardHeight)) { m_targetY = m_ballPreviousY; m_targetX = m_ballX + interval; updateDirection(); } //! [Checking the boundaries] else if ((m_ballX + ballWidth) > m_boardWidth) { m_resultLeft++; m_targetX = m_boardWidth; m_targetY = m_boardHeight/2; m_ballPreviousX = m_ballX = m_boardWidth/2; m_ballPreviousY = m_ballY = m_boardHeight - m_boardWidth/54; updateDirection(); checkResult(); QByteArray result; result.append("result "); QByteArray res; res.setNum(m_resultLeft); result.append(res); result.append(' '); res.setNum(m_resultRight); result.append(res); result.append(" \n"); socket->write(result); qDebug() << result; Q_EMIT resultChanged(); } else if (m_ballX < 0) { m_resultRight++; m_targetX = 0; m_targetY = m_boardHeight/2; m_ballPreviousX = m_ballX = m_boardWidth/2; m_ballPreviousY = m_ballY = m_boardHeight - m_boardWidth/54; updateDirection(); checkResult(); QByteArray result; result.append("result "); QByteArray res; res.setNum(m_resultLeft); result.append(res); result.append(' '); res.setNum(m_resultRight); result.append(res); result.append(" \n"); socket->write(result); Q_EMIT resultChanged(); } }
void BarcodeQMLModel::setResult(QString value) { result = value; emit resultChanged(); }
void RequestError::setResult(const QString& result) { _result = result; emit resultChanged(result); }