int main(int argc, char** argv) { QVarLengthArray<char*, 8> arguments; for (int i = 0; i < argc; ++i) arguments.append(argv[i]); arguments.append(const_cast<char*>("-import")); arguments.append(const_cast<char*>(IMPORT_DIR)); argc = arguments.count(); argv = arguments.data(); suppressDebugOutput(); addQtWebProcessToPath(); // Instantiate QApplication to prevent quick_test_main to instantiate a QGuiApplication. // This can be removed as soon as we do not use QtWidgets any more. QGuiApplication app(argc, argv); qmlRegisterType<ByteArrayTestData>("Test", 1, 0, "ByteArrayTestData"); #ifdef DISABLE_FLICKABLE_VIEWPORT QQuickWebViewExperimental::setFlickableViewportEnabled(false); #endif return quick_test_main(argc, argv, "qmltests", 0, QUICK_TEST_SOURCE_DIR); }
void MocParser::loadIntData(uint *&data) { data = 0; // initialise QVarLengthArray<uint> array; QRegExp rx(QLatin1String("(\\d+|0x[0-9abcdef]+)"), Qt::CaseInsensitive); while (!input->atEnd()) { QString line = QLatin1String(readLine()); int pos = line.indexOf(QLatin1String("//")); if (pos != -1) line.truncate(pos); // drop comments if (line == QLatin1String("};\n")) { // end of data data = new uint[array.count()]; memcpy(data, array.data(), array.count() * sizeof(*data)); return; } pos = 0; while ((pos = rx.indexIn(line, pos)) != -1) { QString num = rx.cap(1); if (num.startsWith(QLatin1String("0x"))) array.append(num.mid(2).toUInt(0, 16)); else array.append(num.toUInt()); pos += rx.matchedLength(); } } parseError(); }
void tst_QVarLengthArray::removeLast() { { QVarLengthArray<char, 2> v; v.append(0); v.append(1); QCOMPARE(v.size(), 2); v.append(2); v.append(3); QCOMPARE(v.size(), 4); v.removeLast(); QCOMPARE(v.size(), 3); v.removeLast(); QCOMPARE(v.size(), 2); } { QVarLengthArray<QString, 2> v; v.append("0"); v.append("1"); QCOMPARE(v.size(), 2); v.append("2"); v.append("3"); QCOMPARE(v.size(), 4); v.removeLast(); QCOMPARE(v.size(), 3); v.removeLast(); QCOMPARE(v.size(), 2); } }
void drawBackground(QPainter *painter, const QRectF &rect) { QGraphicsScene::drawBackground(painter, rect); const int gridSizeX = 1.0f; const int gridSizeY = 60.0f*KLineSize; qreal left = int(rect.left()) - (int(rect.left()) % gridSizeX); qreal top = int(rect.top()) - (int(rect.top()) % gridSizeY); QVarLengthArray<QLineF, 100> lines; for (qreal x = left; x < rect.right(); x += gridSizeX) lines.append(QLineF(x, rect.top(), x, rect.bottom())); for (qreal y = top; y < rect.bottom(); y += gridSizeY) lines.append(QLineF(rect.left(), y, rect.right(), y)); painter->setPen(QPen(QBrush(Qt::darkGray),0,Qt::DashDotDotLine)); painter->drawLines(lines.data(), lines.size()); painter->setPen(QPen(QBrush(Qt::lightGray),0,Qt::DashLine)); painter->drawLine(QLineF(16.66, rect.top(), 16.66, rect.bottom())); painter->drawLine(QLineF(33.33, rect.top(), 33.33, rect.bottom())); }
/*! Creates an OpenCL program object from the list of \a binaries for \a devices. The \a binaries and \a devices lists must have the same number of elements. \sa createProgramFromBinaryCode(), createProgramFromBinaryFile() */ QCLProgram QCLContext::createProgramFromBinaries (const QList<QCLDevice> &devices, const QList<QByteArray> &binaries) { Q_D(QCLContext); if (devices.size() != binaries.size() || devices.isEmpty()) { reportError("QCLContext::createProgramFromBinaries:", CL_INVALID_VALUE); return QCLProgram(); } QVarLengthArray<cl_device_id> devs; QVarLengthArray<const uchar *> bins; QVarLengthArray<size_t> lens; for (int index = 0; index < devices.size(); ++index) { devs.append(devices.at(index).deviceId()); bins.append(reinterpret_cast<const uchar *> (binaries.at(index).constData())); lens.append(binaries.at(index).size()); } cl_int error = CL_INVALID_CONTEXT; cl_program prog = clCreateProgramWithBinary (d->id, devs.size(), devs.data(), lens.data(), bins.data(), 0, &error); reportError("QCLContext::createProgramFromBinaries:", error); if (prog) return QCLProgram(this, prog); else return QCLProgram(); }
void Parser::ParsedObject::insert(uint offset) { const QJsonPrivate::Entry *newEntry = reinterpret_cast<const QJsonPrivate::Entry *>(parser->data + objectPosition + offset); int min = 0; int n = offsets.size(); while (n > 0) { int half = n >> 1; int middle = min + half; if (*entryAt(middle) >= *newEntry) { n = half; } else { min = middle + 1; n -= half + 1; } } if (min < offsets.size() && *entryAt(min) == *newEntry) { offsets[min] = offset; } else { #if QT_VERSION < QT_VERSION_CHECK(4, 8, 0) QVarLengthArray<uint, 64> offsetsN; for (int i=0, n=offsets.size() ; i<n ; ++i) { if (i == min) offsetsN.append(offsets[i]); offsetsN.append(offsets[i]); } offsets = offsetsN; #else offsets.insert(min, offset); #endif } }
void dmz::QtCanvasScene::drawBackground (QPainter *painter, const QRectF &rect) { painter->drawRect (sceneRect ()); if (_drawGrid) { painter->fillRect (sceneRect (), QBrush (QColor (230, 240, 255))); painter->setPen (QPen (Qt::lightGray, 1)); painter->setOpacity(0.75f); const int gridSize = 100; qreal left = int(rect.left ()) - (int(rect.left ()) % gridSize); qreal top = int(rect.top ()) - (int(rect.top ()) % gridSize); QVarLengthArray<QLineF, 100> lines; for (qreal x = left; x < rect.right (); x += gridSize) { lines.append (QLineF (x, rect.top (), x, rect.bottom ())); } for (qreal y = top; y < rect.bottom (); y += gridSize) { lines.append (QLineF (rect.left (), y, rect.right (), y)); } // qDebug () << lines.size (); painter->drawLines (lines.data (), lines.size ()); QGraphicsScene::drawBackground (painter, rect); } }
void QNodeViewCanvas::drawBackground(QPainter* painter, const QRectF& rect) { // GW-TODO: Expose this to QStyle painter->fillRect(rect, QBrush(QColor(50, 50, 50))); const qint32 gridInterval = 50; painter->setWorldMatrixEnabled(true); // GW-TODO: Expose this to QStyle QPen linePen(QColor(80, 80, 80), 1, Qt::DotLine, Qt::FlatCap, Qt::RoundJoin); linePen.setCosmetic(true); // Performance optimization painter->setPen(linePen); const qreal left = qint32(rect.left()) - (qint32(rect.left()) % gridInterval); const qreal top = qint32(rect.top()) - (qint32(rect.top()) % gridInterval); QVarLengthArray<QLineF, 100> linesX; for (qreal x = left; x < rect.right(); x += gridInterval) linesX.append(QLineF(x, rect.top(), x, rect.bottom())); QVarLengthArray<QLineF, 100> linesY; for (qreal y = top; y < rect.bottom(); y += gridInterval) linesY.append(QLineF(rect.left(), y, rect.right(), y)); painter->drawLines(linesX.data(), linesX.size()); painter->drawLines(linesY.data(), linesY.size()); }
void GraphWidget::drawBackground(QPainter *painter, const QRectF &rect) { Q_UNUSED(rect); //return; // Shadow QRectF sceneRect = this->sceneRect(); QRectF rightShadow(sceneRect.right(), sceneRect.top() + 5, 5, sceneRect.height()); QRectF bottomShadow(sceneRect.left() + 5, sceneRect.bottom(), sceneRect.width(), 5); if (rightShadow.intersects(rect) || rightShadow.contains(rect)) painter->fillRect(rightShadow, Qt::darkGray); if (bottomShadow.intersects(rect) || bottomShadow.contains(rect)) painter->fillRect(bottomShadow, Qt::darkGray); // Fill QLinearGradient gradient(sceneRect.topLeft(), sceneRect.bottomRight()); gradient.setColorAt(0, QColor(100,107,126)); gradient.setColorAt(1, QColor(100,107,126)); painter->fillRect(rect.intersect(sceneRect), gradient); //painter->setBrush(Qt::BrushStyle::DiagCrossPattern); painter->drawRect(sceneRect); // Text //QRectF textRect(sceneRect.left() + 4, sceneRect.top() + 4, // sceneRect.width() - 4, sceneRect.height() - 4); //QString message(tr("Click and drag the nodes around, and zoom with the mouse " // "wheel or the '+' and '-' keys")); //QFont font = painter->font(); //font.setBold(true); //font.setPointSize(14); //painter->setFont(font); //painter->setPen(Qt::lightGray); ////painter->drawText(textRect.translated(2, 2), message); //painter->setPen(Qt::black); //painter->drawText(textRect, message); painter->setPen(QColor(135,142,157)); const int gridSize = 25; qreal left = int(rect.left()) - (int(rect.left()) % gridSize); qreal top = int(rect.top()) - (int(rect.top()) % gridSize); QVarLengthArray<QLineF, 100> lines; for (qreal x = left; x < rect.right(); x += gridSize) lines.append(QLineF(x, rect.top(), x, rect.bottom())); for (qreal y = top; y < rect.bottom(); y += gridSize) lines.append(QLineF(rect.left(), y, rect.right(), y)); //qDebug() << lines.size(); painter->drawLines(lines.data(), lines.size()); }
void LosAlamosBoard::addPromotions(int sourceSquare, int targetSquare, QVarLengthArray<Move>& moves) const { moves.append(Move(sourceSquare, targetSquare, Knight)); moves.append(Move(sourceSquare, targetSquare, Rook)); moves.append(Move(sourceSquare, targetSquare, Queen)); }
void JanusBoard::addPromotions(int sourceSquare, int targetSquare, QVarLengthArray<Move>& moves) const { WesternBoard::addPromotions(sourceSquare, targetSquare, moves); moves.append(Move(sourceSquare, targetSquare, Janus)); }
QStringRef UciEngine::parseUciTokens(const QStringRef& first, const QString* types, int typeCount, QVarLengthArray<QStringRef>& tokens, int& type) { QStringRef token(first); type = -1; tokens.clear(); do { bool newType = false; for (int i = 0; i < typeCount; i++) { if (token == types[i]) { if (type != -1) return token; type = i; newType = true; break; } } if (!newType && type != -1) tokens.append(token); } while (!(token = nextToken(token)).isNull()); return token; }
void CrazyhouseBoard::generateMovesForPiece(QVarLengthArray<Move>& moves, int pieceType, int square) const { // Generate drops if (square == 0) { const int size = arraySize(); const int maxRank = height() - 2; for (int i = 0; i < size; i++) { Piece tmp = pieceAt(i); if (!tmp.isEmpty()) continue; if (pieceType == Pawn) { Square sq(chessSquare(i)); if (sq.rank() < 1 || sq.rank() > maxRank) continue; } moves.append(Move(0, i, pieceType)); } } else WesternBoard::generateMovesForPiece(moves, pieceType, square); }
void OukBoard::generateMovesForPiece(QVarLengthArray< Move >& moves, int pieceType, int square) const { MakrukBoard::generateMovesForPiece(moves, pieceType, square); Side side = sideToMove(); // Only consider King and Neang on their initial squares if ((pieceType != King || square != m_initialSquare[side][King]) && (pieceType != Maiden || square != m_initialSquare[side][Maiden])) return; // Return if the piece has moved already if (m_moveCount[side].value((OukPieceType)pieceType, -1) != 0) return; // No special moves for King in check if (pieceType == King && inCheck(side)) return; // Generate initial move option for King (leap of Horse) // and for Neang (forward two squares) int sign = (side == Side::White) ? 1 : -1; for (const auto& i: m_initialOffsets) { if (pieceType != i.type) continue; int target = square - i.offset * sign; const Piece& piece = pieceAt(target); if (piece.isEmpty()) moves.append(Move(square, target)); } }
static void init(QTextBoundaryFinder::BoundaryType type, const QChar *chars, int length, HB_CharAttributes *attributes) { QVarLengthArray<HB_ScriptItem> scriptItems; const ushort *string = reinterpret_cast<const ushort *>(chars); const ushort *unicode = string; // correctly assign script, isTab and isObject to the script analysis const ushort *uc = unicode; const ushort *e = uc + length; int script = QUnicodeTables::Common; int lastScript = QUnicodeTables::Common; const ushort *start = uc; while (uc < e) { int s = QUnicodeTables::script(*uc); if (s != QUnicodeTables::Inherited) script = s; if (*uc == QChar::ObjectReplacementCharacter || *uc == QChar::LineSeparator || *uc == 9) script = QUnicodeTables::Common; if (script != lastScript) { if (uc != start) { HB_ScriptItem item; item.pos = start - string; item.length = uc - start; item.script = (HB_Script)lastScript; item.bidiLevel = 0; // ### what's the proper value? scriptItems.append(item); start = uc; } lastScript = script; } ++uc; } if (uc != start) { HB_ScriptItem item; item.pos = start - string; item.length = uc - start; item.script = (HB_Script)lastScript; item.bidiLevel = 0; // ### what's the proper value? scriptItems.append(item); } qGetCharAttributes(string, length, scriptItems.data(), scriptItems.count(), attributes); if (type == QTextBoundaryFinder::Word) HB_GetWordBoundaries(string, length, scriptItems.data(), scriptItems.count(), attributes); else if (type == QTextBoundaryFinder::Sentence) HB_GetSentenceBoundaries(string, length, scriptItems.data(), scriptItems.count(), attributes); }
/* array = begin-array [ value *( value-separator value ) ] end-array */ bool Parser::parseArray() { BEGIN << "parseArray"; if (++nestingLevel > nestingLimit) { lastError = QJsonParseError::DeepNesting; return false; } int arrayOffset = reserveSpace(sizeof(QJsonPrivate::Array)); QVarLengthArray<QJsonPrivate::Value, 64> values; if (!eatSpace()) { lastError = QJsonParseError::UnterminatedArray; return false; } if (*json == EndArray) { nextToken(); } else { while (1) { QJsonPrivate::Value val; if (!parseValue(&val, arrayOffset)) return false; values.append(val); char token = nextToken(); if (token == EndArray) break; else if (token != ValueSeparator) { if (!eatSpace()) lastError = QJsonParseError::UnterminatedArray; else lastError = QJsonParseError::MissingValueSeparator; return false; } } } DEBUG << "size =" << values.size(); int table = arrayOffset; // finalize the object if (values.size()) { int tableSize = values.size()*sizeof(QJsonPrivate::Value); table = reserveSpace(tableSize); memcpy(data + table, values.constData(), tableSize); } QJsonPrivate::Array *a = (QJsonPrivate::Array *)(data + arrayOffset); a->tableOffset = table - arrayOffset; a->size = current - arrayOffset; a->is_object = false; a->length = values.size(); DEBUG << "current=" << current; END; --nestingLevel; return true; }
void tst_QVarLengthArray::append() { QVarLengthArray<QString> v; v.append(QString("hello")); QVarLengthArray<int> v2; // rocket! v2.append(5); }
void CapablancaBoard::addPromotions(int sourceSquare, int targetSquare, QVarLengthArray<Move>& moves) const { WesternBoard::addPromotions(sourceSquare, targetSquare, moves); moves.append(Move(sourceSquare, targetSquare, Archbishop)); moves.append(Move(sourceSquare, targetSquare, Chancellor)); }
void UmlCanvas::drawBackground(QPainter& painter, const QRect& clip) { if (show_grid()) { int s = grid_size(); qreal left = int(clip.left())-(int(clip.left()) % s); qreal top = int(clip.top())-(int(clip.top()) % s); QVarLengthArray<QLineF, 100> lines; for (qreal x = left; x < clip.right(); x += s) lines.append(QLineF(x, clip.top(), x, clip.bottom())); for (qreal y = top; y < clip.bottom(); y += s) lines.append(QLineF(clip.left(), y, clip.right(), y)); painter.save(); painter.setPen(Qt::lightGray); painter.drawLines(lines.data(), lines.size()); painter.restore(); } }
void MovementScene::drawForeground(QPainter *painter, const QRectF &rect){ if(gridIsVisible){ painter->setWorldMatrixEnabled(true); QVarLengthArray<QLineF, 100> linesX; QVarLengthArray<QLineF, 100> linesY; qreal left = int(rect.left()) - (int(rect.left()) % gridInterval ); qreal top = int(rect.top()) - (int(rect.top()) % gridInterval ); for (qreal x = left; x < rect.right(); x += gridInterval ) linesX.append(QLineF(x, rect.top(), x, rect.bottom())); for (qreal y = top; y < rect.bottom(); y += gridInterval ) linesY.append(QLineF(rect.left(), y, rect.right(), y)); painter->setPen(QColor(196,220,255)); painter->drawLines(linesX.data(), linesX.size()); painter->drawLines(linesY.data(), linesY.size()); } }
int DirectShowPlayerService::findStreamTypes(IBaseFilter *source) const { QVarLengthArray<IBaseFilter *, 16> filters; source->AddRef(); filters.append(source); int streamTypes = 0; while (!filters.isEmpty()) { IEnumPins *pins = 0; IBaseFilter *filter = filters[filters.size() - 1]; filters.removeLast(); if (SUCCEEDED(filter->EnumPins(&pins))) { for (IPin *pin = 0; pins->Next(1, &pin, 0) == S_OK; pin->Release()) { PIN_DIRECTION direction; if (pin->QueryDirection(&direction) == S_OK && direction == PINDIR_OUTPUT) { AM_MEDIA_TYPE connectionType; if (SUCCEEDED(pin->ConnectionMediaType(&connectionType))) { IPin *peer = 0; if (connectionType.majortype == MEDIATYPE_Audio) { streamTypes |= AudioStream; } else if (connectionType.majortype == MEDIATYPE_Video) { streamTypes |= VideoStream; } else if (SUCCEEDED(pin->ConnectedTo(&peer))) { PIN_INFO peerInfo; if (SUCCEEDED(peer->QueryPinInfo(&peerInfo))) filters.append(peerInfo.pFilter); peer->Release(); } } else { streamTypes |= findStreamType(pin); } } } } filter->Release(); } return streamTypes; }
void QTriangulatingStroker::arcPoints(float cx, float cy, float fromX, float fromY, float toX, float toY, QVarLengthArray<float> &points) { float dx1 = fromX - cx; float dy1 = fromY - cy; float dx2 = toX - cx; float dy2 = toY - cy; // while more than 180 degrees left: while (dx1 * dy2 - dx2 * dy1 < 0) { float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; dx1 = tmpx; dy1 = tmpy; points.append(cx + dx1); points.append(cy + dy1); } // while more than 90 degrees left: while (dx1 * dx2 + dy1 * dy2 < 0) { float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; dx1 = tmpx; dy1 = tmpy; points.append(cx + dx1); points.append(cy + dy1); } // while more than 0 degrees left: while (dx1 * dy2 - dx2 * dy1 > 0) { float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; dx1 = tmpx; dy1 = tmpy; points.append(cx + dx1); points.append(cy + dy1); } // remove last point which was rotated beyond [toX, toY]. if (!points.isEmpty()) points.resize(points.size() - 2); }
void LayoutGrid::paint(QPainter *painter, const QRectF &rect) { if (!isVisible()) return; int gridSizeX = gridSpacingX(); int gridSizeY = gridSpacingY(); qreal left = int(rect.left()) - (int(rect.left()) % gridSizeX); qreal top = int(rect.top()) - (int(rect.top()) % gridSizeY); QVarLengthArray<QLineF, 200> lines; for (qreal x = left; x < rect.right(); x += gridSizeX) lines.append(QLineF(x, rect.top(), x, rect.bottom())); for (qreal y = top; y < rect.bottom(); y += gridSizeY) lines.append(QLineF(rect.left(), y, rect.right(), y)); painter->setPen(m_gridDotColor); painter->drawLines(lines.data(), lines.size()); }
void QGVScene::drawBackground(QPainter * painter, const QRectF & rect) { const int gridSize = 25; const qreal left = int(rect.left()) - (int(rect.left()) % gridSize); const qreal top = int(rect.top()) - (int(rect.top()) % gridSize); QVarLengthArray<QLineF, 100> lines; for (qreal x = left; x < rect.right(); x += gridSize) lines.append(QLineF(x, rect.top(), x, rect.bottom())); for (qreal y = top; y < rect.bottom(); y += gridSize) lines.append(QLineF(rect.left(), y, rect.right(), y)); painter->setRenderHint(QPainter::Antialiasing, false); painter->setPen(QColor(Qt::lightGray).lighter(110)); painter->drawLines(lines.data(), lines.size()); painter->setPen(Qt::black); //painter->drawRect(sceneRect()); }
void tst_QVarLengthArray::last() { // append some items, make sure it stays sane QVarLengthArray<int> list; list.append(27); QCOMPARE(list.last(), 27); list.append(4); QCOMPARE(list.last(), 4); list.append(1987); QCOMPARE(list.last(), 1987); QCOMPARE(list.length(), 3); // remove some, make sure it stays sane list.removeLast(); QCOMPARE(list.last(), 4); QCOMPARE(list.length(), 2); list.removeLast(); QCOMPARE(list.last(), 27); QCOMPARE(list.length(), 1); }
void tst_QVarLengthArray::count() { // tests size(), count() and length(), since they're the same thing { const QVarLengthArray<int> list; QCOMPARE(list.length(), 0); QCOMPARE(list.count(), 0); QCOMPARE(list.size(), 0); } { QVarLengthArray<int> list; list.append(0); QCOMPARE(list.length(), 1); QCOMPARE(list.count(), 1); QCOMPARE(list.size(), 1); } { QVarLengthArray<int> list; list.append(0); list.append(1); QCOMPARE(list.length(), 2); QCOMPARE(list.count(), 2); QCOMPARE(list.size(), 2); } { QVarLengthArray<int> list; list.append(0); list.append(0); list.append(0); QCOMPARE(list.length(), 3); QCOMPARE(list.count(), 3); QCOMPARE(list.size(), 3); } // test removals too { QVarLengthArray<int> list; list.append(0); list.append(0); list.append(0); QCOMPARE(list.length(), 3); QCOMPARE(list.count(), 3); QCOMPARE(list.size(), 3); list.removeLast(); QCOMPARE(list.length(), 2); QCOMPARE(list.count(), 2); QCOMPARE(list.size(), 2); list.removeLast(); QCOMPARE(list.length(), 1); QCOMPARE(list.count(), 1); QCOMPARE(list.size(), 1); list.removeLast(); QCOMPARE(list.length(), 0); QCOMPARE(list.count(), 0); QCOMPARE(list.size(), 0); } }
void BaseGraphicsView::drawBackground(QPainter *paint, const QRectF &rect) { QColor bgColor = QColor(57,57,57); paint->fillRect(rect, bgColor); // Draw grid QColor gridColor = QColor(47,47,47); int gridInterval = 20; //interval to draw grid lines at paint->setWorldMatrixEnabled(true); qreal left = int(rect.left()) - (int(rect.left()) % gridInterval ); qreal top = int(rect.top()) - (int(rect.top()) % gridInterval ); QVarLengthArray<QLineF, 100> lines; for (qreal x = left; x < rect.right(); x += gridInterval) lines.append(QLineF(x, rect.top(), x, rect.bottom())); for (qreal y = top; y < rect.bottom(); y += gridInterval) lines.append(QLineF(rect.left(), y, rect.right(), y)); paint->setPen(gridColor); paint->drawLines(lines.data(), lines.size()); }
void tst_QVarLengthArray::contains() { QVarLengthArray<QString> myvec; myvec << "aaa" << "bbb" << "ccc"; QVERIFY(myvec.contains(QLatin1String("aaa"))); QVERIFY(myvec.contains(QLatin1String("bbb"))); QVERIFY(myvec.contains(QLatin1String("ccc"))); QVERIFY(!myvec.contains(QLatin1String("I don't exist"))); // add it and make sure it does :) myvec.append(QLatin1String("I don't exist")); QVERIFY(myvec.contains(QLatin1String("I don't exist"))); }
void AbstractTileTool::updateStatusInfo() { if (mBrushVisible) { Cell cell; if (const TileLayer *tileLayer = currentTileLayer()) { const QPoint pos = tilePosition() - tileLayer->position(); cell = tileLayer->cellAt(pos); } QString tileIdString = cell.tileId() >= 0 ? QString::number(cell.tileId()) : tr("empty"); QVarLengthArray<QChar, 3> flippedBits; if (cell.flippedHorizontally()) flippedBits.append(QLatin1Char('H')); if (cell.flippedVertically()) flippedBits.append(QLatin1Char('V')); if (cell.flippedAntiDiagonally()) flippedBits.append(QLatin1Char('D')); if (!flippedBits.isEmpty()) { tileIdString.append(QLatin1Char(' ')); tileIdString.append(flippedBits.first()); for (int i = 1; i < flippedBits.size(); ++i) { tileIdString.append(QLatin1Char(',')); tileIdString.append(flippedBits.at(i)); } } setStatusInfo(QString(QLatin1String("%1, %2 [%3]")) .arg(mTilePosition.x()) .arg(mTilePosition.y()) .arg(tileIdString)); } else { setStatusInfo(QString()); } }
QVariant parseNumber() { QVarLengthArray<QChar> str; QChar c = next(); if(c == '-') { str.append(c); c = nextNoSkip(); } for(; c.isDigit(); c = nextNoSkip()) { str.append(c); } bool hasDecimal = false; if(c == '.') { str.append(c); hasDecimal = true; c = nextNoSkip(); for(; c.isDigit(); c = nextNoSkip()) { str.append(c); } } if(c == 'e' || c == 'E') { // Exponent. str.append(c); c = nextNoSkip(); if(c == '+' || c == '-') { str.append(c); c = nextNoSkip(); } for(; c.isDigit(); c = nextNoSkip()) { str.append(c); } } // Rewind one char (the loop was broken when a non-digit was read). pos--; skipWhite(); double value = QString(str.constData(), str.size()).toDouble(); if(hasDecimal) { return QVariant(value); } else { return QVariant(int(value)); } }