tests/auto/widgets: Remove some placeholder formatting.
Use QByteArray/QString addition instead in loops and for test row names. Change-Id: Ia067cd966bf13506e6ca19925eae3158da027b83 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
This commit is contained in:
parent
240d768ca6
commit
52d5b27239
@ -942,7 +942,7 @@ void tst_QFiledialog::selectFiles()
|
||||
|
||||
QString filesPath = fd.directory().absolutePath();
|
||||
for (int i=0; i < 5; ++i) {
|
||||
QFile file(filesPath + QString::fromLatin1("/qfiledialog_auto_test_not_pres_%1").arg(i));
|
||||
QFile file(filesPath + QLatin1String("/qfiledialog_auto_test_not_pres_") + QString::number(i));
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.resize(1024);
|
||||
file.flush();
|
||||
|
@ -1149,7 +1149,7 @@ void tst_QFileDialog2::task257579_sideBarWithNonCleanUrls()
|
||||
QLatin1String dirname("autotest_task257579");
|
||||
dir.rmdir(dirname); //makes sure it doesn't exist any more
|
||||
QVERIFY(dir.mkdir(dirname));
|
||||
QString url = QString::fromLatin1("%1/%2/..").arg(dir.absolutePath()).arg(dirname);
|
||||
QString url = dir.absolutePath() + QLatin1Char('/') + dirname + QLatin1String("/..");
|
||||
QNonNativeFileDialog fd;
|
||||
fd.setSidebarUrls(QList<QUrl>() << QUrl::fromLocalFile(url));
|
||||
QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
|
||||
|
@ -251,15 +251,17 @@ void tst_QFileSystemModel::naturalCompare_data()
|
||||
QTest::addColumn<int>("result");
|
||||
QTest::addColumn<int>("swap");
|
||||
|
||||
#define ROWNAME(name) (qPrintable(QString("prefix=%1, postfix=%2, num=%3, i=%4, test=%5").arg(prefix).arg(postfix).arg(num).arg(i).arg(name)))
|
||||
#define ROWNAME(name) (("prefix=" + prefix.toLatin1() + ", postfix=" + postfix.toLatin1() \
|
||||
+ ", num=" + num.toLatin1() + ", i=" + QByteArray::number(i) \
|
||||
+ ", test=" + name).constData())
|
||||
|
||||
for (int j = 0; j < 4; ++j) { // <- set a prefix and a postfix string (not numbers)
|
||||
QString prefix = (j == 0 || j == 1) ? "b" : "";
|
||||
QString postfix = (j == 1 || j == 2) ? "y" : "";
|
||||
|
||||
for (int k = 0; k < 3; ++k) { // <- make 0 not a special case
|
||||
QString num = QString("%1").arg(k);
|
||||
QString nump = QString("%1").arg(k + 1);
|
||||
const QString num = QString::number(k);
|
||||
const QString nump = QString::number(k + 1);
|
||||
for (int i = 10; i < 12; ++i) { // <- swap s1 and s2 and reverse the result
|
||||
QTest::newRow(ROWNAME("basic")) << prefix + "0" + postfix << prefix + "0" + postfix << int(Qt::CaseInsensitive) << 0;
|
||||
|
||||
@ -470,8 +472,9 @@ void tst_QFileSystemModel::rowsInserted_data()
|
||||
QTest::addColumn<int>("count");
|
||||
QTest::addColumn<int>("ascending");
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
QTest::newRow(QString("Qt::AscendingOrder %1").arg(i).toLocal8Bit().constData()) << i << (int)Qt::AscendingOrder;
|
||||
QTest::newRow(QString("Qt::DescendingOrder %1").arg(i).toLocal8Bit().constData()) << i << (int)Qt::DescendingOrder;
|
||||
const QByteArray iB = QByteArray::number(i);
|
||||
QTest::newRow(("Qt::AscendingOrder " + iB).constData()) << i << (int)Qt::AscendingOrder;
|
||||
QTest::newRow(("Qt::DescendingOrder " + iB).constData()) << i << (int)Qt::DescendingOrder;
|
||||
}
|
||||
}
|
||||
|
||||
@ -499,7 +502,7 @@ void tst_QFileSystemModel::rowsInserted()
|
||||
int oldCount = model->rowCount(root);
|
||||
QStringList files;
|
||||
for (int i = 0; i < count; ++i)
|
||||
files.append(QString("c%1").arg(i));
|
||||
files.append(QLatin1Char('c') + QString::number(i));
|
||||
QVERIFY(createFiles(tmp, files, 5));
|
||||
TRY_WAIT(model->rowCount(root) == oldCount + count);
|
||||
QTRY_COMPARE(model->rowCount(root), oldCount + count);
|
||||
@ -1019,8 +1022,8 @@ void tst_QFileSystemModel::dirsBeforeFiles()
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
QLatin1Char c('a' + i);
|
||||
dir.mkdir(QString("%1-dir").arg(c));
|
||||
QFile file(flatDirTestPath + QString("/%1-file").arg(c));
|
||||
dir.mkdir(c + QLatin1String("-dir"));
|
||||
QFile file(flatDirTestPath + QLatin1Char('/') + c + QLatin1String("-file"));
|
||||
file.open(QIODevice::ReadWrite);
|
||||
file.close();
|
||||
}
|
||||
|
@ -168,10 +168,10 @@ void testGetNumeric(QInputDialog *dialog, SpinBoxType * = 0, ValueType * = 0)
|
||||
const ValueType origValue = sbox->value();
|
||||
|
||||
testInvalidateAndRestore<SpinBoxType, ValueType>(sbox, okButton, ledit);
|
||||
testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->minimum()));
|
||||
testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->maximum()));
|
||||
testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->minimum() - 1));
|
||||
testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->maximum() + 1));
|
||||
testTypingValue<SpinBoxType>(sbox, okButton, QString::number(sbox->minimum()));
|
||||
testTypingValue<SpinBoxType>(sbox, okButton, QString::number(sbox->maximum()));
|
||||
testTypingValue<SpinBoxType>(sbox, okButton, QString::number(sbox->minimum() - 1));
|
||||
testTypingValue<SpinBoxType>(sbox, okButton, QString::number(sbox->maximum() + 1));
|
||||
testTypingValue<SpinBoxType>(sbox, okButton, "0");
|
||||
testTypingValue<SpinBoxType>(sbox, okButton, "0.0");
|
||||
testTypingValue<SpinBoxType>(sbox, okButton, "foobar");
|
||||
|
@ -1625,7 +1625,7 @@ class SetPage : public Operation
|
||||
for (int j = 0; j < page; ++j)
|
||||
wizard->next();
|
||||
}
|
||||
QString describe() const { return QString("set page %1").arg(page); }
|
||||
QString describe() const { return QLatin1String("set page ") + QString::number(page); }
|
||||
const int page;
|
||||
public:
|
||||
SetPage(int page) : page(page) {}
|
||||
@ -1634,7 +1634,7 @@ public:
|
||||
class SetStyle : public Operation
|
||||
{
|
||||
void apply(QWizard *wizard) const { wizard->setWizardStyle(style); }
|
||||
QString describe() const { return QString("set style %1").arg(style); }
|
||||
QString describe() const { return QLatin1String("set style ") + QString::number(style); }
|
||||
const QWizard::WizardStyle style;
|
||||
public:
|
||||
SetStyle(QWizard::WizardStyle style) : style(style) {}
|
||||
@ -1697,7 +1697,8 @@ public:
|
||||
|
||||
QString SetOption::describe() const
|
||||
{
|
||||
return QString("set opt %1 %2").arg(OptionInfo::instance().tag(option)).arg(on);
|
||||
return QLatin1String("set opt ") + OptionInfo::instance().tag(option)
|
||||
+ QLatin1Char(on ? '1' : '0');
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(Operation *)
|
||||
@ -1726,7 +1727,7 @@ public:
|
||||
void createTestRows()
|
||||
{
|
||||
for (int i = 0; i < combinations.count(); ++i) {
|
||||
QTest::newRow((name + QString(", row %1").arg(i)).toLatin1().data())
|
||||
QTest::newRow((name.toLatin1() + ", row " + QByteArray::number(i)).constData())
|
||||
<< (i == 0) << (type == Equality) << *(combinations.at(i));
|
||||
++nRows_;
|
||||
}
|
||||
@ -1827,7 +1828,7 @@ public:
|
||||
foreach (Operation * op, operations) {
|
||||
if (op) {
|
||||
op->apply(this);
|
||||
opsDescr += QString("(%1) ").arg(op->describe());
|
||||
opsDescr += QLatin1Char('(') + op->describe() + QLatin1String(") ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public:
|
||||
{
|
||||
setContentsMargins( 0,0,0,0 );
|
||||
if (name.isEmpty())
|
||||
setData(0, QString::fromLatin1("w%1").arg(quintptr(this)));
|
||||
setData(0, QLatin1Char('w') + QString::number(quintptr(this)));
|
||||
else
|
||||
setData(0, name);
|
||||
}
|
||||
@ -1702,10 +1702,8 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
|
||||
|
||||
// Create dummy widgets
|
||||
QList<QGraphicsWidget *> widgets;
|
||||
for (int i = 0; i < widgetCount; ++i) {
|
||||
TestWidget *w = new TestWidget(0, QString::fromLatin1("W%1").arg(i));
|
||||
widgets << w;
|
||||
}
|
||||
for (int i = 0; i < widgetCount; ++i)
|
||||
widgets << new TestWidget(0, QLatin1Char('W') + QString::number(i));
|
||||
|
||||
// Setup anchor layout
|
||||
TheAnchorLayout *layout = new TheAnchorLayout;
|
||||
|
@ -451,9 +451,10 @@ void tst_QGraphicsGridLayout::addItem_data()
|
||||
int column = b;
|
||||
int rowSpan = c;
|
||||
int columnSpan = d;
|
||||
QString name = QString::fromLatin1("(%1,%2,%3,%4").arg(a).arg(b).arg(c).arg(d);
|
||||
const QByteArray name = '(' + QByteArray::number(a) + ',' + QByteArray::number(b)
|
||||
+ ',' + QByteArray::number(c) + ',' + QByteArray::number(d);
|
||||
Qt::Alignment alignment = Qt::AlignLeft;
|
||||
QTest::newRow(name.toLatin1()) << row << column << rowSpan << columnSpan << alignment;
|
||||
QTest::newRow(name.constData()) << row << column << rowSpan << columnSpan << alignment;
|
||||
}}}}
|
||||
}
|
||||
|
||||
@ -1107,7 +1108,8 @@ void tst_QGraphicsGridLayout::itemAt()
|
||||
if (i >= 0 && i < layout->count()) {
|
||||
QVERIFY(layout->itemAt(i));
|
||||
} else {
|
||||
QTest::ignoreMessage(QtWarningMsg, QString::fromLatin1("QGraphicsGridLayout::itemAt: invalid index %1").arg(i).toLatin1().constData());
|
||||
const QByteArray message = "QGraphicsGridLayout::itemAt: invalid index " + QByteArray::number(i);
|
||||
QTest::ignoreMessage(QtWarningMsg, message.constData());
|
||||
QCOMPARE(layout->itemAt(i), static_cast<QGraphicsLayoutItem*>(0));
|
||||
}
|
||||
}
|
||||
|
@ -4130,9 +4130,9 @@ public:
|
||||
font.setPointSize(4);
|
||||
painter->setFont(font);
|
||||
for (int x = -100; x < 100; x += 25) {
|
||||
for (int y = -100; y < 100; y += 25) {
|
||||
painter->drawText(QRectF(x, y, 25, 25), Qt::AlignCenter, QString("%1x%2").arg(x).arg(y));
|
||||
}
|
||||
const QString prefix = QString::number(x) + QLatin1Char('x');
|
||||
for (int y = -100; y < 100; y += 25)
|
||||
painter->drawText(QRectF(x, y, 25, 25), Qt::AlignCenter, prefix + QString::number(y));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -7658,7 +7658,9 @@ public:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
|
||||
{
|
||||
QGraphicsRectItem::paint(painter, option, widget);
|
||||
painter->drawText(boundingRect(), Qt::AlignCenter, QString("%1x%2\n%3x%4").arg(p.x()).arg(p.y()).arg(sp.x()).arg(sp.y()));
|
||||
const QString text = QString::number(p.x()) + QLatin1Char('x') + QString::number(p.y())
|
||||
+ QLatin1Char('\n') + QString::number(sp.x()) + QLatin1Char('x') + QString::number(sp.y());
|
||||
painter->drawText(boundingRect(), Qt::AlignCenter, text);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -8246,10 +8248,11 @@ void tst_QGraphicsItem::sorting()
|
||||
QGraphicsScene scene;
|
||||
QGraphicsItem *grid[100][100];
|
||||
for (int x = 0; x < 100; ++x) {
|
||||
const QString prefix = QString::number(x) + QLatin1Char('x');
|
||||
for (int y = 0; y < 100; ++y) {
|
||||
PainterItem *item = new PainterItem;
|
||||
item->setPos(x * 25, y * 25);
|
||||
item->setData(0, QString("%1x%2").arg(x).arg(y));
|
||||
item->setData(0, prefix + QString::number(y));
|
||||
grid[x][y] = item;
|
||||
scene.addItem(item);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ void tst_QGraphicsLayoutItem::effectiveSizeHint_data()
|
||||
QTest::addColumn<Qt::SizeHint>("sizeHint");
|
||||
QTest::addColumn<QSizeF>("constraint");
|
||||
for (int i = 0; i < 15; ++i) {
|
||||
QTestData &data = QTest::newRow(QString("%1").arg(i).toLatin1());
|
||||
QTestData &data = QTest::newRow(QByteArray::number(i).constData());
|
||||
switch(i % 5) {
|
||||
case 0: data << Qt::MinimumSize; break;
|
||||
case 1: data << Qt::PreferredSize; break;
|
||||
|
@ -425,10 +425,11 @@ void tst_QGraphicsLinearLayout::dump_data()
|
||||
QTest::addColumn<int>("itemCount");
|
||||
QTest::addColumn<int>("layoutCount");
|
||||
for (int i = -1; i < 3; ++i) {
|
||||
QTest::newRow(QString("%1, 0, 0").arg(i).toLatin1()) << 0 << 0;
|
||||
QTest::newRow(QString("%1, 0, 5").arg(i).toLatin1()) << 5 << 5;
|
||||
QTest::newRow(QString("%1, 5, 0").arg(i).toLatin1()) << 5 << 5;
|
||||
QTest::newRow(QString("%1, 5, 5").arg(i).toLatin1()) << 5 << 5;
|
||||
const QByteArray iB = QByteArray::number(i);
|
||||
QTest::newRow((iB + ", 0, 0").constData()) << 0 << 0;
|
||||
QTest::newRow((iB + ", 0, 5").constData()) << 5 << 5;
|
||||
QTest::newRow((iB + ", 5, 0").constData()) << 5 << 5;
|
||||
QTest::newRow((iB + ", 5, 5").constData()) << 5 << 5;
|
||||
}
|
||||
}
|
||||
|
||||
@ -511,11 +512,13 @@ void tst_QGraphicsLinearLayout::insertItem_data()
|
||||
QTest::addColumn<int>("insertItemAt");
|
||||
QTest::addColumn<bool>("isWidget");
|
||||
for (int i = -1; i < 4; ++i) {
|
||||
const QByteArray iB = QByteArray::number(i);
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
QTest::newRow(QString("0, 0, %1 %2").arg(i).arg(j).toLatin1()) << 0 << 0 << i << (bool)j;
|
||||
QTest::newRow(QString("1, 0, %1 %2").arg(i).arg(j).toLatin1()) << 1 << 0 << i << (bool)j;
|
||||
QTest::newRow(QString("0, 1, %1 %2").arg(i).arg(j).toLatin1()) << 0 << 1 << i << (bool)j;
|
||||
QTest::newRow(QString("2, 2, %1 %2").arg(i).arg(j).toLatin1()) << 2 << 2 << i << (bool)j;
|
||||
const QByteArray postFix = iB + ' ' + QByteArray::number(j);
|
||||
QTest::newRow(("0, 0, " + postFix).constData()) << 0 << 0 << i << (bool)j;
|
||||
QTest::newRow(("1, 0, " + postFix).constData()) << 1 << 0 << i << (bool)j;
|
||||
QTest::newRow(("0, 1, " + postFix).constData()) << 0 << 1 << i << (bool)j;
|
||||
QTest::newRow(("2, 2, " + postFix).constData()) << 2 << 2 << i << (bool)j;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -565,11 +568,13 @@ void tst_QGraphicsLinearLayout::insertStretch_data()
|
||||
QTest::addColumn<int>("insertItemAt");
|
||||
QTest::addColumn<int>("stretch");
|
||||
for (int i = -1; i < 4; ++i) {
|
||||
const QByteArray iB = QByteArray::number(i);
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
QTest::newRow(QString("0, 0, %1 %2").arg(i).arg(j).toLatin1()) << 0 << 0 << i << j;
|
||||
QTest::newRow(QString("1, 0, %1 %2").arg(i).arg(j).toLatin1()) << 1 << 0 << i << j;
|
||||
QTest::newRow(QString("0, 1, %1 %2").arg(i).arg(j).toLatin1()) << 0 << 1 << i << j;
|
||||
QTest::newRow(QString("2, 2, %1 %2").arg(i).arg(j).toLatin1()) << 2 << 2 << i << j;
|
||||
const QByteArray postFix = iB + ' ' + QByteArray::number(j);
|
||||
QTest::newRow(("0, 0, " + postFix).constData()) << 0 << 0 << i << j;
|
||||
QTest::newRow(("1, 0, " + postFix).constData()) << 1 << 0 << i << j;
|
||||
QTest::newRow(("0, 1, " + postFix).constData()) << 0 << 1 << i << j;
|
||||
QTest::newRow(("2, 2, " + postFix).constData()) << 2 << 2 << i << j;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -786,12 +791,13 @@ void tst_QGraphicsLinearLayout::removeAt_data()
|
||||
QTest::addColumn<int>("removeItemAt");
|
||||
QTest::addColumn<Qt::Orientation>("orientation");
|
||||
for (int i = -1; i < 4; ++i) {
|
||||
const QByteArray iB = QByteArray::number(i);
|
||||
for (int k = 0; k < 2; ++k) {
|
||||
Qt::Orientation orientation = (k == 0) ? Qt::Vertical : Qt::Horizontal;
|
||||
QTest::newRow(QString("0, 0, %1").arg(i).toLatin1()) << 0 << 0 << i << orientation;
|
||||
QTest::newRow(QString("1, 0, %1").arg(i).toLatin1()) << 1 << 0 << i << orientation;
|
||||
QTest::newRow(QString("0, 1, %1").arg(i).toLatin1()) << 0 << 1 << i << orientation;
|
||||
QTest::newRow(QString("2, 2, %1").arg(i).toLatin1()) << 2 << 2 << i << orientation;
|
||||
QTest::newRow(("0, 0, " + iB).constData()) << 0 << 0 << i << orientation;
|
||||
QTest::newRow(("1, 0, " + iB).constData()) << 1 << 0 << i << orientation;
|
||||
QTest::newRow(("0, 1, " + iB).constData()) << 0 << 1 << i << orientation;
|
||||
QTest::newRow(("2, 2, " + iB).constData()) << 2 << 2 << i << orientation;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -840,10 +846,11 @@ void tst_QGraphicsLinearLayout::removeItem_data()
|
||||
QTest::addColumn<int>("layoutCount");
|
||||
QTest::addColumn<int>("removeItemAt");
|
||||
for (int i = -1; i < 4; ++i) {
|
||||
QTest::newRow(QString("0, 0, %1").arg(i).toLatin1()) << 0 << 0 << i;
|
||||
QTest::newRow(QString("1, 0, %1").arg(i).toLatin1()) << 1 << 0 << i;
|
||||
QTest::newRow(QString("0, 1, %1").arg(i).toLatin1()) << 0 << 1 << i;
|
||||
QTest::newRow(QString("2, 2, %1").arg(i).toLatin1()) << 2 << 2 << i;
|
||||
const QByteArray iB = QByteArray::number(i);
|
||||
QTest::newRow(("0, 0, " + iB).constData()) << 0 << 0 << i;
|
||||
QTest::newRow(("1, 0, " + iB).constData()) << 1 << 0 << i;
|
||||
QTest::newRow(("0, 1, " + iB).constData()) << 0 << 1 << i;
|
||||
QTest::newRow(("2, 2, " + iB).constData()) << 2 << 2 << i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -543,14 +543,15 @@ void tst_QGraphicsProxyWidget::testEventFilter_data()
|
||||
QTest::newRow("none") << QEvent::None << false;
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
bool fromObject = (i == 0);
|
||||
QTest::newRow(QString("resize %1").arg(fromObject).toLatin1()) << QEvent::Resize << fromObject;
|
||||
QTest::newRow(QString("move %1").arg(fromObject).toLatin1()) << QEvent::Move << fromObject;
|
||||
QTest::newRow(QString("hide %1").arg(fromObject).toLatin1()) << QEvent::Hide << fromObject;
|
||||
QTest::newRow(QString("show %1").arg(fromObject).toLatin1()) << QEvent::Show << fromObject;
|
||||
QTest::newRow(QString("enabled %1").arg(fromObject).toLatin1()) << QEvent::EnabledChange << fromObject;
|
||||
QTest::newRow(QString("focusIn %1").arg(fromObject).toLatin1()) << QEvent::FocusIn << fromObject;
|
||||
QTest::newRow(QString("focusOut %1").arg(fromObject).toLatin1()) << QEvent::FocusOut << fromObject;
|
||||
QTest::newRow(QString("keyPress %1").arg(fromObject).toLatin1()) << QEvent::KeyPress << fromObject;
|
||||
const char fromObjectC = fromObject ? '1' : '0';
|
||||
QTest::newRow((QByteArrayLiteral("resize ") + fromObjectC).constData()) << QEvent::Resize << fromObject;
|
||||
QTest::newRow((QByteArrayLiteral("move ") + fromObjectC).constData()) << QEvent::Move << fromObject;
|
||||
QTest::newRow((QByteArrayLiteral("hide ") + fromObjectC).constData()) << QEvent::Hide << fromObject;
|
||||
QTest::newRow((QByteArrayLiteral("show ") + fromObjectC).constData()) << QEvent::Show << fromObject;
|
||||
QTest::newRow((QByteArrayLiteral("enabled ") + fromObjectC).constData()) << QEvent::EnabledChange << fromObject;
|
||||
QTest::newRow((QByteArrayLiteral("focusIn ") + fromObjectC).constData()) << QEvent::FocusIn << fromObject;
|
||||
QTest::newRow((QByteArrayLiteral("focusOut ") + fromObjectC).constData()) << QEvent::FocusOut << fromObject;
|
||||
QTest::newRow((QByteArrayLiteral("keyPress ") + fromObjectC).constData()) << QEvent::KeyPress << fromObject;
|
||||
}
|
||||
}
|
||||
|
||||
@ -762,8 +763,10 @@ void tst_QGraphicsProxyWidget::focusNextPrevChild_data()
|
||||
bool hasWidget = (j == 0);
|
||||
bool hasScene = (k == 0);
|
||||
bool result = hasScene && hasWidget;
|
||||
QString name = QString("Forward: %1, hasWidget: %2, hasScene: %3, result: %4").arg(next).arg(hasWidget).arg(hasScene).arg(result);
|
||||
QTest::newRow(name.toLatin1()) << hasWidget << hasScene << next << result;
|
||||
QByteArray name = QByteArrayLiteral("Forward: ") + (next ? '1' : '0')
|
||||
+ ", hasWidget: " + (hasWidget ? '1' : '0') + ", hasScene: "
|
||||
+ (hasScene ? '1' : '0') + ", result: " + (result ? '1' : '0');
|
||||
QTest::newRow(name.constData()) << hasWidget << hasScene << next << result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1028,8 +1031,10 @@ void tst_QGraphicsProxyWidget::hoverMoveEvent_data()
|
||||
bool hoverEnabled = (j == 0);
|
||||
bool mouseTracking = (k == 0);
|
||||
bool mouseDown = (l == 0);
|
||||
QString name = QString("hasWidget:%1, hover:%2, mouseTracking:%3, mouseDown: %4").arg(hasWidget).arg(hoverEnabled).arg(mouseTracking).arg(mouseDown);
|
||||
QTest::newRow(name.toLatin1()) << hasWidget << hoverEnabled << mouseTracking << mouseDown;
|
||||
QByteArray name = QByteArrayLiteral("hasWidget:") + (hasWidget ? '1' : '0') + ", hover:"
|
||||
+ (hoverEnabled ? '1' : '0') + ", mouseTracking:"
|
||||
+ (mouseTracking ? '1' : '0') + ", mouseDown: " + (mouseDown ? '1' : '0');
|
||||
QTest::newRow(name.constData()) << hasWidget << hoverEnabled << mouseTracking << mouseDown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2630,7 +2630,8 @@ void tst_QGraphicsScene::render()
|
||||
painter.end();
|
||||
|
||||
const QString renderPath = QLatin1String(SRCDIR) + "/testData/render";
|
||||
QString fileName = renderPath + QString("/%1.png").arg(QTest::currentDataTag());
|
||||
QString fileName = renderPath + QLatin1Char('/') + QLatin1String(QTest::currentDataTag())
|
||||
+ QLatin1String(".png");
|
||||
QImage original(fileName);
|
||||
QVERIFY(!original.isNull());
|
||||
|
||||
|
@ -587,7 +587,7 @@ void tst_QGraphicsView::sceneRect_growing()
|
||||
|
||||
QGraphicsScene scene;
|
||||
for (int i = 0; i < 100; ++i)
|
||||
scene.addText(QString("(0, %1)").arg((i - 50) * 20))->setPos(0, (i - 50) * 20);
|
||||
scene.addText(QLatin1String("(0, ") + QString::number((i - 50) * 20))->setPos(0, (i - 50) * 20);
|
||||
|
||||
QGraphicsView view(&scene, &toplevel);
|
||||
view.setFixedSize(200, 200);
|
||||
|
@ -588,7 +588,7 @@ void tst_QGraphicsWidget::focusPolicy_data()
|
||||
QTest::addColumn<Qt::FocusPolicy>("focusPolicy2");
|
||||
|
||||
for (int i = 0; i < 25; ++i) {
|
||||
QTestData &data = QTest::newRow(QString("%1").arg(i).toLatin1());
|
||||
QTestData &data = QTest::newRow(QByteArray::number(i).constData());
|
||||
switch(i % 5) {
|
||||
case 0: data << Qt::TabFocus; break;
|
||||
case 1: data << Qt::ClickFocus; break;
|
||||
@ -1499,7 +1499,7 @@ void tst_QGraphicsWidget::setTabOrderAndReparent()
|
||||
for (i = 1; i < 4; ++i) {
|
||||
QGraphicsWidget *wid = new QGraphicsWidget;
|
||||
wid->setFocusPolicy(Qt::StrongFocus);
|
||||
wid->setData(0, QString::fromLatin1("w%1").arg(i));
|
||||
wid->setData(0, QLatin1Char('w') + QString::number(i));
|
||||
scene.addItem(wid);
|
||||
if (i == 1)
|
||||
w1 = wid;
|
||||
@ -1539,7 +1539,7 @@ void tst_QGraphicsWidget::setTabOrderAndReparent()
|
||||
for (i = 1; i < 5; ++i) {
|
||||
QGraphicsWidget *wid = new QGraphicsWidget;
|
||||
wid->setFocusPolicy(Qt::StrongFocus);
|
||||
wid->setData(0, QString::fromLatin1("w%1").arg(i));
|
||||
wid->setData(0, QLatin1Char('w') + QString::number(i));
|
||||
scene.addItem(wid);
|
||||
if (i == 1)
|
||||
w1 = wid;
|
||||
|
@ -871,7 +871,7 @@ class DnDTestModel : public QStandardItemModel
|
||||
public:
|
||||
DnDTestModel() : QStandardItemModel(20, 20), dropAction_result(Qt::IgnoreAction) {
|
||||
for (int i = 0; i < rowCount(); ++i)
|
||||
setData(index(i, 0), QString("%1").arg(i));
|
||||
setData(index(i, 0), QString::number(i));
|
||||
}
|
||||
Qt::DropAction dropAction() const { return dropAction_result; }
|
||||
};
|
||||
@ -1276,9 +1276,9 @@ void tst_QAbstractItemView::task250754_fontChange()
|
||||
|
||||
QStandardItemModel *m = new QStandardItemModel(this);
|
||||
for (int i=0; i<20; ++i) {
|
||||
QStandardItem *item = new QStandardItem(QString("Item number %1").arg(i));
|
||||
QStandardItem *item = new QStandardItem(QStringLiteral("Item number ") + QString::number(i));
|
||||
for (int j=0; j<5; ++j) {
|
||||
QStandardItem *child = new QStandardItem(QString("Child Item number %1").arg(j));
|
||||
QStandardItem *child = new QStandardItem(QStringLiteral("Child Item number ") + QString::number(j));
|
||||
item->setChild(j, 0, child);
|
||||
}
|
||||
m->setItem(i, 0, item);
|
||||
@ -1368,7 +1368,7 @@ void tst_QAbstractItemView::shiftArrowSelectionAfterScrolling()
|
||||
{
|
||||
QStandardItemModel model;
|
||||
for (int i=0; i<10; ++i) {
|
||||
QStandardItem *item = new QStandardItem(QString("%1").arg(i));
|
||||
QStandardItem *item = new QStandardItem(QString::number(i));
|
||||
model.setItem(i, 0, item);
|
||||
}
|
||||
|
||||
@ -1405,7 +1405,7 @@ void tst_QAbstractItemView::shiftSelectionAfterRubberbandSelection()
|
||||
{
|
||||
QStandardItemModel model;
|
||||
for (int i=0; i<3; ++i) {
|
||||
QStandardItem *item = new QStandardItem(QString("%1").arg(i));
|
||||
QStandardItem *item = new QStandardItem(QString::number(i));
|
||||
model.setItem(i, 0, item);
|
||||
}
|
||||
|
||||
@ -1482,7 +1482,7 @@ void tst_QAbstractItemView::ctrlRubberbandSelection()
|
||||
{
|
||||
QStandardItemModel model;
|
||||
for (int i=0; i<3; ++i) {
|
||||
QStandardItem *item = new QStandardItem(QString("%1").arg(i));
|
||||
QStandardItem *item = new QStandardItem(QString::number(i));
|
||||
model.setItem(i, 0, item);
|
||||
}
|
||||
|
||||
|
@ -112,12 +112,14 @@ public:
|
||||
for (int j = 0; j < 10; ++j) {
|
||||
QStandardItem *parentItem = invisibleRootItem();
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
QStandardItem *item = new QStandardItem(QString("item %0").arg(i));
|
||||
const QString iS = QString::number(i);
|
||||
const QString itemText = QLatin1String("item ") + iS;
|
||||
QStandardItem *item = new QStandardItem(itemText);
|
||||
parentItem->appendRow(item);
|
||||
QStandardItem *item2 = new QStandardItem(QString("item %0").arg(i));
|
||||
QStandardItem *item2 = new QStandardItem(itemText);
|
||||
parentItem->appendRow(item2);
|
||||
item2->appendRow(new QStandardItem(QString("item %0").arg(i)));
|
||||
parentItem->appendRow(new QStandardItem(QString("file %0").arg(i)));
|
||||
item2->appendRow(new QStandardItem(itemText));
|
||||
parentItem->appendRow(new QStandardItem(QLatin1String("file ") + iS));
|
||||
parentItem = item;
|
||||
}
|
||||
}
|
||||
|
@ -66,8 +66,10 @@ static QStandardItemModel *testModel(QObject *parent = 0)
|
||||
QStandardItemModel *model = new QStandardItemModel(10, 10, parent);
|
||||
|
||||
for (int row = 0; row < 10; ++row) {
|
||||
const QString prefix = QLatin1String("item ") + QString::number(row)
|
||||
+ QLatin1Char(' ');
|
||||
for (int col = 0; col < 10; ++col)
|
||||
model->setData(model->index(row, col), QString("item %1 %2").arg(row).arg(col));
|
||||
model->setData(model->index(row, col), prefix + QString::number(col));
|
||||
}
|
||||
|
||||
return model;
|
||||
|
@ -270,7 +270,8 @@ public:
|
||||
wrongIndex = true;
|
||||
qWarning("Invalid modelIndex [%d,%d,%p]", idx.row(), idx.column(), idx.internalPointer());
|
||||
}
|
||||
return QString("[%1,%2,%3]").arg(idx.row()).arg(idx.column()).arg(0);//idx.data());
|
||||
return QLatin1Char('[') + QString::number(idx.row()) + QLatin1Char(',')
|
||||
+ QString::number(idx.column()) + QLatin1String(",0]");
|
||||
}
|
||||
|
||||
void insertOneColumn(int col)
|
||||
@ -1567,7 +1568,7 @@ public:
|
||||
return QVariant();
|
||||
}
|
||||
if (role == Qt::DisplayRole) {
|
||||
return QString::fromLatin1("%1,%2").arg(index.row()).arg(index.column());
|
||||
return QString::number(index.row()) + QLatin1Char(',') + QString::number(index.column());
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
@ -2240,13 +2241,21 @@ void tst_QHeaderView::QTBUG8650_crashOnInsertSections()
|
||||
model.insertColumn(0, items);
|
||||
}
|
||||
|
||||
static void setModelTexts(QStandardItemModel *model)
|
||||
{
|
||||
const int columnCount = model->columnCount();
|
||||
for (int i = 0, rowCount = model->rowCount(); i < rowCount; ++i) {
|
||||
const QString prefix = QLatin1String("item [") + QString::number(i) + QLatin1Char(',');
|
||||
for (int j = 0; j < columnCount; ++j)
|
||||
model->setData(model->index(i, j), prefix + QString::number(j) + QLatin1Char(']'));
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QHeaderView::QTBUG12268_hiddenMovedSectionSorting()
|
||||
{
|
||||
QTableView view; // ### this test fails on QTableView &view = *m_tableview; !? + shadowing view member
|
||||
QStandardItemModel *model = new QStandardItemModel(4,3, &view);
|
||||
for (int i = 0; i< model->rowCount(); ++i)
|
||||
for (int j = 0; j< model->columnCount(); ++j)
|
||||
model->setData(model->index(i,j), QString("item [%1,%2]").arg(i).arg(j));
|
||||
setModelTexts(model);
|
||||
view.setModel(model);
|
||||
view.horizontalHeader()->setSectionsMovable(true);
|
||||
view.setSortingEnabled(true);
|
||||
@ -2322,9 +2331,7 @@ void tst_QHeaderView::initialSortOrderRole()
|
||||
{
|
||||
QTableView view; // ### Shadowing member view (of type QHeaderView)
|
||||
QStandardItemModel *model = new QStandardItemModel(4, 3, &view);
|
||||
for (int i = 0; i< model->rowCount(); ++i)
|
||||
for (int j = 0; j< model->columnCount(); ++j)
|
||||
model->setData(model->index(i,j), QString("item [%1,%2]").arg(i).arg(j));
|
||||
setModelTexts(model);
|
||||
QStandardItem *ascendingItem = new QStandardItem();
|
||||
QStandardItem *descendingItem = new QStandardItem();
|
||||
ascendingItem->setData(Qt::AscendingOrder, Qt::InitialSortOrderRole);
|
||||
|
@ -288,14 +288,16 @@ void tst_QItemView::populate()
|
||||
const int baseInsert = 26;
|
||||
#endif
|
||||
for (int i = 0; i < 40; ++i) {
|
||||
const QString iS = QString::number(i);
|
||||
parent = treeModel->index(0, 0, parent);
|
||||
treeModel->insertRows(0, baseInsert + i, parent);
|
||||
treeModel->insertColumns(0, baseInsert + i, parent);
|
||||
// Fill in some values to make it easier to debug
|
||||
for (int x = 0; x < treeModel->rowCount(); ++x) {
|
||||
const QString xS = QString::number(x);
|
||||
for (int y = 0; y < treeModel->columnCount(); ++y) {
|
||||
QModelIndex index = treeModel->index(x, y, parent);
|
||||
treeModel->setData(index, QString("%1_%2_%3").arg(x).arg(y).arg(i));
|
||||
treeModel->setData(index, xS + QLatin1Char('_') + QString::number(y) + QLatin1Char('_') + iS);
|
||||
treeModel->setData(index, QVariant(QColor(Qt::blue)), Qt::TextColorRole);
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,15 @@ static inline void setFrameless(QWidget *w)
|
||||
w->setWindowFlags(flags);
|
||||
}
|
||||
|
||||
static QStringList generateList(const QString &prefix, int size)
|
||||
{
|
||||
QStringList result;
|
||||
result.reserve(size);
|
||||
for (int i = 0; i < size; ++i)
|
||||
result.append(prefix + QString::number(i));
|
||||
return result;
|
||||
}
|
||||
|
||||
class tst_QListView : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -255,7 +264,7 @@ public:
|
||||
wrongIndex = true;
|
||||
qWarning("got invalid modelIndex %d/%d", idx.row(), idx.column());
|
||||
}
|
||||
return QString("%1/%2").arg(idx.row()).arg(idx.column());
|
||||
return QString::number(idx.row()) + QLatin1Char('/') + QString::number(idx.column());
|
||||
}
|
||||
|
||||
void removeLastRow()
|
||||
@ -364,10 +373,11 @@ void tst_QListView::cursorMove()
|
||||
view.setModel(&model);
|
||||
|
||||
for (int j = 0; j < columns; ++j) {
|
||||
const QString postfix = QLatin1Char(',') + QString::number(j) + QLatin1Char(']');
|
||||
view.setModelColumn(j);
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
QModelIndex index = model.index(i, j);
|
||||
model.setData(index, QString("[%1,%2]").arg(i).arg(j));
|
||||
model.setData(index, QLatin1Char('[') + QString::number(i) + postfix);
|
||||
view.setCurrentIndex(index);
|
||||
QApplication::processEvents();
|
||||
QCOMPARE(view.currentIndex(), index);
|
||||
@ -468,7 +478,7 @@ void tst_QListView::hideRows()
|
||||
QStandardItemModel sim(0);
|
||||
QStandardItem *root = new QStandardItem("Root row");
|
||||
for (int i=0;i<5;i++)
|
||||
root->appendRow(new QStandardItem(QString("Row %1").arg(i)));
|
||||
root->appendRow(new QStandardItem(QLatin1String("Row ") + QString::number(i)));
|
||||
sim.appendRow(root);
|
||||
view.setModel(&sim);
|
||||
view.setRootIndex(root->index());
|
||||
@ -702,9 +712,11 @@ void tst_QListView::singleSelectionRemoveColumn()
|
||||
int numCols = 3;
|
||||
int numRows = 3;
|
||||
QStandardItemModel model(numCols, numRows);
|
||||
for (int r = 0; r < numRows; ++r)
|
||||
for (int r = 0; r < numRows; ++r) {
|
||||
const QString prefix = QString::number(r) + QLatin1Char(',');
|
||||
for (int c = 0; c < numCols; ++c)
|
||||
model.setData(model.index(r, c), QString("%1,%2").arg(r).arg(c));
|
||||
model.setData(model.index(r, c), prefix + QString::number(c));
|
||||
}
|
||||
|
||||
QListView view;
|
||||
view.setModel(&model);
|
||||
@ -729,10 +741,11 @@ void tst_QListView::modelColumn()
|
||||
int numCols = 3;
|
||||
int numRows = 3;
|
||||
QStandardItemModel model(numCols, numRows);
|
||||
for (int r = 0; r < numRows; ++r)
|
||||
for (int r = 0; r < numRows; ++r) {
|
||||
const QString prefix = QString::number(r) + QLatin1Char(',');
|
||||
for (int c = 0; c < numCols; ++c)
|
||||
model.setData(model.index(r, c), QString("%1,%2").arg(r).arg(c));
|
||||
|
||||
model.setData(model.index(r, c), prefix + QString::number(c));
|
||||
}
|
||||
|
||||
QListView view;
|
||||
view.setModel(&model);
|
||||
@ -811,10 +824,7 @@ void tst_QListView::batchedMode()
|
||||
{
|
||||
const int rowCount = 3;
|
||||
|
||||
QStringList items;
|
||||
for (int i = 0; i < rowCount; ++i)
|
||||
items << QLatin1String("item ") + QString::number(i);
|
||||
QStringListModel model(items);
|
||||
QStringListModel model(generateList(QLatin1String("item "), rowCount));
|
||||
|
||||
QListView view;
|
||||
view.setWindowTitle(QTest::currentTestFunction());
|
||||
@ -840,11 +850,7 @@ void tst_QListView::batchedMode()
|
||||
|
||||
void tst_QListView::setCurrentIndex()
|
||||
{
|
||||
QStringList items;
|
||||
int i;
|
||||
for (i=0; i <20; ++i)
|
||||
items << QString("item %1").arg(i);
|
||||
QStringListModel model(items);
|
||||
QStringListModel model(generateList(QLatin1String("item "), 20));
|
||||
|
||||
QListView view;
|
||||
view.setModel(&model);
|
||||
@ -866,7 +872,7 @@ void tst_QListView::setCurrentIndex()
|
||||
int offset = sb->value();
|
||||
|
||||
// first "scroll" down, verify that we scroll one step at a time
|
||||
i = 0;
|
||||
int i = 0;
|
||||
for (i = 0; i < 20; ++i) {
|
||||
QModelIndex idx = model.index(i,0);
|
||||
view.setCurrentIndex(idx);
|
||||
@ -1289,7 +1295,7 @@ void tst_QListView::scrollBarRanges()
|
||||
QStringListModel model(&lv);
|
||||
QStringList list;
|
||||
for (int i = 0; i < rowCount; ++i)
|
||||
list << QString::fromLatin1("Item %1").arg(i);
|
||||
list << QLatin1String("Item ") + QString::number(i);
|
||||
|
||||
model.setStringList(list);
|
||||
lv.setModel(&model);
|
||||
@ -1387,17 +1393,13 @@ void tst_QListView::scrollBarAsNeeded()
|
||||
QStringList list;
|
||||
int i;
|
||||
for (i = 0; i < rowCounts[r]; ++i)
|
||||
list << QString::fromLatin1("Item %1").arg(i);
|
||||
list << QLatin1String("Item ") + QString::number(i);
|
||||
|
||||
model.setStringList(list);
|
||||
QApplication::processEvents();
|
||||
QTest::qWait(50);
|
||||
|
||||
QStringList replacement;
|
||||
for (i = 0; i < itemCount; ++i) {
|
||||
replacement << QString::fromLatin1("Item %1").arg(i);
|
||||
}
|
||||
model.setStringList(replacement);
|
||||
model.setStringList(generateList(QLatin1String("Item "), itemCount));
|
||||
|
||||
QApplication::processEvents();
|
||||
|
||||
@ -1410,10 +1412,9 @@ void tst_QListView::moveItems()
|
||||
{
|
||||
QStandardItemModel model;
|
||||
for (int r = 0; r < 4; ++r) {
|
||||
for (int c = 0; c < 4; ++c) {
|
||||
QStandardItem* item = new QStandardItem(QString("standard item (%1,%2)").arg(r).arg(c));
|
||||
model.setItem(r, c, item);
|
||||
}
|
||||
const QString prefix = QLatin1String("standard item (") + QString::number(r) + QLatin1Char(',');
|
||||
for (int c = 0; c < 4; ++c)
|
||||
model.setItem(r, c, new QStandardItem(prefix + QString::number(c) + QLatin1Char(')')));
|
||||
}
|
||||
|
||||
PublicListView view;
|
||||
@ -1525,9 +1526,10 @@ void tst_QListView::emptyItemSize()
|
||||
{
|
||||
QStandardItemModel model;
|
||||
for (int r = 0; r < 4; ++r) {
|
||||
QStandardItem* item = new QStandardItem(QString("standard item (%1)").arg(r));
|
||||
model.setItem(r, 0, item);
|
||||
const QString text = QLatin1String("standard item (") + QString::number(r) + QLatin1Char(')');
|
||||
model.setItem(r, new QStandardItem(text));
|
||||
}
|
||||
|
||||
model.setItem(4, 0, new QStandardItem());
|
||||
|
||||
PublicListView view;
|
||||
@ -1994,12 +1996,7 @@ public:
|
||||
|
||||
void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges()
|
||||
{
|
||||
QStringList list;
|
||||
const int nrItems = 8;
|
||||
for (int i = 0; i < nrItems; i++)
|
||||
list << QString::asprintf("item %d", i);
|
||||
|
||||
QStringListModel model(list);
|
||||
QStringListModel model(generateList("item ", 8));
|
||||
ListView_9455 w;
|
||||
setFrameless(&w);
|
||||
w.setModel(&model);
|
||||
|
@ -230,7 +230,7 @@ void tst_QListWidget::populate()
|
||||
void tst_QListWidget::addItem()
|
||||
{
|
||||
int count = testWidget->count();
|
||||
QString label = QString("%1").arg(count);
|
||||
const QString label = QString::number(count);
|
||||
testWidget->addItem(label);
|
||||
QCOMPARE(testWidget->count(), ++count);
|
||||
QCOMPARE(testWidget->item(testWidget->count()-1)->text(), label);
|
||||
@ -244,7 +244,7 @@ void tst_QListWidget::addItem2()
|
||||
testWidget->addItem(0);
|
||||
QCOMPARE(testWidget->count(), count);
|
||||
|
||||
QListWidgetItem *item = new QListWidgetItem(QString("%1").arg(count));
|
||||
QListWidgetItem *item = new QListWidgetItem(QString::number(count));
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
testWidget->addItem(item);
|
||||
QCOMPARE(testWidget->count(), ++count);
|
||||
@ -261,10 +261,10 @@ void tst_QListWidget::addItems()
|
||||
QCOMPARE(testWidget->count(), count);
|
||||
|
||||
QStringList stringList;
|
||||
QString label = QString("%1").arg(count);
|
||||
stringList << QString("%1").arg(testWidget->count() + 1)
|
||||
<< QString("%1").arg(testWidget->count() + 2)
|
||||
<< QString("%1").arg(testWidget->count() + 3)
|
||||
QString label = QString::number(count);
|
||||
stringList << QString::number(testWidget->count() + 1)
|
||||
<< QString::number(testWidget->count() + 2)
|
||||
<< QString::number(testWidget->count() + 3)
|
||||
<< label;
|
||||
testWidget->addItems(stringList);
|
||||
QCOMPARE(testWidget->count(), count + stringList.count());
|
||||
@ -276,7 +276,7 @@ void tst_QListWidget::openPersistentEditor()
|
||||
{
|
||||
// Boundary checking
|
||||
testWidget->openPersistentEditor(0);
|
||||
QListWidgetItem *item = new QListWidgetItem(QString("%1").arg(testWidget->count()));
|
||||
QListWidgetItem *item = new QListWidgetItem(QString::number(testWidget->count()));
|
||||
testWidget->openPersistentEditor(item);
|
||||
|
||||
int childCount = testWidget->viewport()->children().count();
|
||||
@ -290,7 +290,7 @@ void tst_QListWidget::closePersistentEditor()
|
||||
// Boundary checking
|
||||
int childCount = testWidget->viewport()->children().count();
|
||||
testWidget->closePersistentEditor(0);
|
||||
QListWidgetItem *item = new QListWidgetItem(QString("%1").arg(testWidget->count()));
|
||||
QListWidgetItem *item = new QListWidgetItem(QString::number(testWidget->count()));
|
||||
testWidget->closePersistentEditor(item);
|
||||
QCOMPARE(childCount, testWidget->viewport()->children().count());
|
||||
|
||||
@ -316,7 +316,7 @@ void tst_QListWidget::setItemHidden()
|
||||
if (testWidget->isItemHidden(testWidget->item(i)))
|
||||
totalHidden++;
|
||||
|
||||
QListWidgetItem *item = new QListWidgetItem(QString("%1").arg(testWidget->count()));
|
||||
QListWidgetItem *item = new QListWidgetItem(QString::number(testWidget->count()));
|
||||
testWidget->addItem(item);
|
||||
|
||||
// Check that nothing else changed
|
||||
@ -362,7 +362,7 @@ void tst_QListWidget::setCurrentItem()
|
||||
{
|
||||
QFETCH(int, fill);
|
||||
for (int i = 0; i < fill; ++i)
|
||||
testWidget->addItem(QString("%1").arg(i));
|
||||
testWidget->addItem(QString::number(i));
|
||||
|
||||
// Boundary checking
|
||||
testWidget->setCurrentItem((QListWidgetItem *)0);
|
||||
@ -394,7 +394,7 @@ void tst_QListWidget::setCurrentRow()
|
||||
{
|
||||
QFETCH(int, fill);
|
||||
for (int i = 0; i < fill; ++i)
|
||||
testWidget->addItem(QString("%1").arg(i));
|
||||
testWidget->addItem(QString::number(i));
|
||||
|
||||
// Boundary checking
|
||||
testWidget->setCurrentRow(-1);
|
||||
@ -455,7 +455,7 @@ void tst_QListWidget::editItem()
|
||||
{
|
||||
// Boundary checking
|
||||
testWidget->editItem(0);
|
||||
QListWidgetItem *item = new QListWidgetItem(QString("%1").arg(testWidget->count()));
|
||||
QListWidgetItem *item = new QListWidgetItem(QString::number(testWidget->count()));
|
||||
testWidget->editItem(item);
|
||||
|
||||
QFETCH(bool, editable);
|
||||
@ -650,7 +650,7 @@ void tst_QListWidget::item()
|
||||
QCOMPARE(item, static_cast<QListWidgetItem*>(0));
|
||||
QCOMPARE(testWidget->count(), 3);
|
||||
} else {
|
||||
QCOMPARE(item->text(), QString("item%1").arg(row));
|
||||
QCOMPARE(item->text(), QStringLiteral("item") + QString::number(row));
|
||||
QCOMPARE(testWidget->count(), 3);
|
||||
}
|
||||
}
|
||||
@ -683,7 +683,7 @@ void tst_QListWidget::takeItem()
|
||||
QCOMPARE(item, static_cast<QListWidgetItem*>(0));
|
||||
QCOMPARE(testWidget->count(), 3);
|
||||
} else {
|
||||
QCOMPARE(item->text(), QString("item%1").arg(row));
|
||||
QCOMPARE(item->text(), QStringLiteral("item") + QString::number(row));
|
||||
QCOMPARE(testWidget->count(), 2);
|
||||
}
|
||||
|
||||
@ -746,7 +746,7 @@ void tst_QListWidget::selectedItems()
|
||||
|
||||
//insert items
|
||||
for (int i=0; i<itemCount; ++i)
|
||||
new QListWidgetItem(QString("Item%1").arg(i), testWidget);
|
||||
new QListWidgetItem(QStringLiteral("Item") + QString::number(i), testWidget);
|
||||
|
||||
//test the selection
|
||||
testWidget->setSelectionMode(QListWidget::SingleSelection);
|
||||
@ -1245,8 +1245,8 @@ void tst_QListWidget::insertItemsWithSorting_data()
|
||||
QStringList ascendingItems;
|
||||
QStringList reverseItems;
|
||||
for (int i = 'a'; i <= 'z'; ++i) {
|
||||
ascendingItems << QString("%0").arg(QLatin1Char(i));
|
||||
reverseItems << QString("%0").arg(QLatin1Char('z' - i + 'a'));
|
||||
ascendingItems << QString(1, QLatin1Char(i));
|
||||
reverseItems << QString(1, QLatin1Char('z' - i + 'a'));
|
||||
ascendingRows << i - 'a';
|
||||
reverseRows << 'z' - i + 'a';
|
||||
}
|
||||
@ -1490,7 +1490,7 @@ void tst_QListWidget::fastScroll()
|
||||
QWidget topLevel;
|
||||
MyListWidget widget(&topLevel);
|
||||
for (int i = 0; i < 50; ++i)
|
||||
widget.addItem(QString("Item %1").arg(i));
|
||||
widget.addItem(QStringLiteral("Item ") + QString::number(i));
|
||||
|
||||
topLevel.resize(300, 300); // toplevel needs to be wide enough for the item
|
||||
topLevel.show();
|
||||
|
@ -325,8 +325,10 @@ public:
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
return QString("[%1,%2,%3]").arg(idx.row()).arg(idx.column()).arg(0);
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
||||
return QLatin1Char('[') + QString::number(idx.row()) + QLatin1Char(',')
|
||||
+ QString::number(idx.column()) + QLatin1String(",0]");
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
@ -3802,7 +3804,7 @@ public:
|
||||
int role = Qt::DisplayRole) const
|
||||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
return QString("%1 - %2").arg(index.column()).arg(index.row());
|
||||
return QString::number(index.column()) + QLatin1String(" - ") + QString::number(index.row());
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@ -3924,12 +3926,12 @@ void tst_QTableView::task227953_setRootIndex()
|
||||
|
||||
//setup the first table as a child of the first item
|
||||
for ( int row = 0; row < 40; ++row ) {
|
||||
item1.appendRow(QList<QStandardItem*>() << new QStandardItem(QString("row %0").arg(row)));
|
||||
item1.appendRow(QList<QStandardItem*>() << new QStandardItem(QLatin1String("row ") + QString::number(row)));
|
||||
}
|
||||
|
||||
//setup the second table as a child of the second item
|
||||
for ( int row = 0; row < 10; ++row ) {
|
||||
item2.appendRow(QList<QStandardItem*>() << new QStandardItem(QString("row %0").arg(row)));
|
||||
item2.appendRow(QList<QStandardItem*>() << new QStandardItem(QLatin1String("row ") + QString::number(row)));
|
||||
}
|
||||
|
||||
tableView.setModel(&model);
|
||||
|
@ -1473,7 +1473,7 @@ void tst_QTableWidget::task262056_sortDuplicate()
|
||||
for (int i = 0; i<8; i++ ) {
|
||||
QTableWidgetItem *twi = new QTableWidgetItem(items.at(i));
|
||||
testWidget->setItem(i,0,twi);
|
||||
testWidget->setItem(i,1,new QTableWidgetItem(QString("item %1").arg(i)));
|
||||
testWidget->setItem(i,1,new QTableWidgetItem(QLatin1String("item ") + QString::number(i)));
|
||||
}
|
||||
testWidget->sortItems(0, Qt::AscendingOrder);
|
||||
QSignalSpy layoutChangedSpy(testWidget->model(), SIGNAL(layoutChanged()));
|
||||
|
@ -338,9 +338,12 @@ public:
|
||||
qWarning("Invalid modelIndex [%d,%d,%p]", idx.row(), idx.column(),
|
||||
idx.internalPointer());
|
||||
}
|
||||
QString result = QLatin1Char('[') + QString::number(idx.row()) + QLatin1Char(',')
|
||||
+ QString::number(idx.column()) + QLatin1Char(',') + QString::number(level(idx))
|
||||
+ QLatin1Char(']');
|
||||
if (idx.row() & 1)
|
||||
return QString("[%1,%2,%3] - this item is extra wide").arg(idx.row()).arg(idx.column()).arg(level(idx));
|
||||
return QString("[%1,%2,%3]").arg(idx.row()).arg(idx.column()).arg(level(idx));
|
||||
result += QLatin1String(" - this item is extra wide");
|
||||
return result;
|
||||
}
|
||||
if (decorationsEnabled && role == Qt::DecorationRole) {
|
||||
QPixmap pm(16,16);
|
||||
@ -2084,13 +2087,14 @@ void tst_QTreeView::rowsAboutToBeRemoved()
|
||||
{
|
||||
QStandardItemModel model(3, 1);
|
||||
for (int i = 0; i < model.rowCount(); i++) {
|
||||
const QString iS = QString::number(i);
|
||||
QModelIndex index = model.index(i, 0, QModelIndex());
|
||||
model.setData(index, QString("%1").arg(i));
|
||||
model.setData(index, iS);
|
||||
model.insertRows(0, 4, index);
|
||||
model.insertColumns(0,1,index);
|
||||
for (int i1 = 0; i1 < model.rowCount(index); i1++) {
|
||||
QModelIndex index2 = model.index(i1, 0, index);
|
||||
model.setData(index2, QString("%1%2").arg(i).arg(i1));
|
||||
model.setData(index2, iS + QString::number(i1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2228,14 +2232,16 @@ void tst_QTreeView::resizeColumnToContents()
|
||||
{
|
||||
QStandardItemModel model(50,2);
|
||||
for (int r = 0; r < model.rowCount(); ++r) {
|
||||
const QString rS = QString::number(r);
|
||||
for (int c = 0; c < model.columnCount(); ++c) {
|
||||
QModelIndex idx = model.index(r, c);
|
||||
model.setData(idx, QString::fromLatin1("%1,%2").arg(r).arg(c) );
|
||||
model.setData(idx, rS + QLatin1Char(',') + QString::number(c));
|
||||
model.insertColumns(0, 2, idx);
|
||||
model.insertRows(0, 6, idx);
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
const QString iS = QString::number(i);
|
||||
for (int j = 0; j < 2 ; ++j) {
|
||||
model.setData(model.index(i, j, idx), QString::fromLatin1("child%1%2").arg(i).arg(j));
|
||||
model.setData(model.index(i, j, idx), QLatin1String("child") + iS + QString::number(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2390,7 +2396,7 @@ void tst_QTreeView::selectionWithHiddenItems()
|
||||
{
|
||||
QStandardItemModel model;
|
||||
for (int i = 0; i < model.rowCount(); ++i)
|
||||
model.setData(model.index(i,0), QString("row %1").arg(i));
|
||||
model.setData(model.index(i,0), QLatin1String("row ") + QString::number(i));
|
||||
|
||||
QStandardItem item0("row 0");
|
||||
QStandardItem item1("row 1");
|
||||
@ -2464,7 +2470,7 @@ void tst_QTreeView::selectAll()
|
||||
QCOMPARE(view2.selectedIndexes().count(), model.rowCount() * model.columnCount());
|
||||
|
||||
for (int i = 0; i < model.rowCount(); ++i)
|
||||
model.setData(model.index(i,0), QString("row %1").arg(i));
|
||||
model.setData(model.index(i,0), QLatin1String("row ") + QString::number(i));
|
||||
PublicView view;
|
||||
view.setModel(&model);
|
||||
int selectedCount = view.selectedIndexes().count();
|
||||
@ -2818,8 +2824,9 @@ public:
|
||||
if (parentNode->isDead)
|
||||
qFatal("%s: grandparentNode is dead!", Q_FUNC_INFO);
|
||||
}
|
||||
return QString("[%1,%2,%3]").arg(idx.row()).arg(idx.column())
|
||||
.arg(parentNode->isDead ? "dead" : "alive");
|
||||
return QLatin1Char('[') + QString::number(idx.row()) + QLatin1Char(',')
|
||||
+ QString::number(idx.column()) + QLatin1Char(',')
|
||||
+ QLatin1String(parentNode->isDead ? "dead" : "alive") + QLatin1Char(']');
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
@ -3022,7 +3029,7 @@ void tst_QTreeView::filterProxyModelCrash()
|
||||
QStandardItemModel model;
|
||||
QList<QStandardItem *> items;
|
||||
for (int i = 0; i < 100; i++)
|
||||
items << new QStandardItem(QString::fromLatin1("item %1").arg(i));
|
||||
items << new QStandardItem(QLatin1String("item ") + QString::number(i));
|
||||
model.appendColumn(items);
|
||||
|
||||
QSortFilterProxyModel proxy;
|
||||
@ -3389,11 +3396,11 @@ void tst_QTreeView::task203696_hidingColumnsAndRowsn()
|
||||
{
|
||||
QTreeView view;
|
||||
QStandardItemModel *model = new QStandardItemModel(0, 3, &view);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
const QString prefix = QLatin1String("row ") + QString::number(i) + QLatin1String(" col ");
|
||||
model->insertRow(model->rowCount());
|
||||
for (int j = 0; j < model->columnCount(); ++j)
|
||||
model->setData(model->index(i, j), QString("row %1 col %2").arg(i).arg(j));
|
||||
model->setData(model->index(i, j), prefix + QString::number(j));
|
||||
}
|
||||
view.setModel(model);
|
||||
view.show();
|
||||
@ -3415,8 +3422,9 @@ void tst_QTreeView::addRowsWhileSectionsAreHidden()
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
model->insertRow(model->rowCount());
|
||||
const QString prefix = QLatin1String("row ") + QString::number(i) + QLatin1String(" col ");
|
||||
for (int j = 0; j < model->columnCount(); ++j) {
|
||||
model->setData(model->index(i, j), QString("row %1 col %2").arg(i).arg(j));
|
||||
model->setData(model->index(i, j), prefix + QString::number(j));
|
||||
}
|
||||
}
|
||||
int col;
|
||||
@ -3425,8 +3433,9 @@ void tst_QTreeView::addRowsWhileSectionsAreHidden()
|
||||
for (i = 3; i < 6; ++i)
|
||||
{
|
||||
model->insertRow(model->rowCount());
|
||||
const QString prefix = QLatin1String("row ") + QString::number(i) + QLatin1String(" col ");
|
||||
for (int j = 0; j < model->columnCount(); ++j) {
|
||||
model->setData(model->index(i, j), QString("row %1 col %2").arg(i).arg(j));
|
||||
model->setData(model->index(i, j), prefix + QString::number(j));
|
||||
}
|
||||
}
|
||||
for (col = 0; col < pass; ++col)
|
||||
@ -3480,8 +3489,10 @@ void tst_QTreeView::task220298_selectColumns()
|
||||
|
||||
virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const
|
||||
{
|
||||
if(role == Qt::DisplayRole)
|
||||
return QVariant(QString("%1-%2").arg(index.column()).arg(index.row()));
|
||||
if (role == Qt::DisplayRole) {
|
||||
return QVariant(QString::number(index.column()) + QLatin1Char('-')
|
||||
+ QString::number(index.row()));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@ -3519,7 +3530,7 @@ void tst_QTreeView::task224091_appendColumns()
|
||||
|
||||
QList<QStandardItem *> projlist;
|
||||
for (int k = 0; k < 10; ++k)
|
||||
projlist.append(new QStandardItem(QString("Top Level %0").arg(k)));
|
||||
projlist.append(new QStandardItem(QLatin1String("Top Level ") + QString::number(k)));
|
||||
model->appendColumn(projlist);
|
||||
model->invisibleRootItem()->appendRow(new QStandardItem("end"));
|
||||
|
||||
@ -3746,7 +3757,7 @@ void tst_QTreeView::task246536_scrollbarsNotWorking()
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&tree));
|
||||
QList<QStandardItem *> items;
|
||||
for(int i=0; i<100; ++i){
|
||||
items << new QStandardItem(QString::fromLatin1("item %1").arg(i));
|
||||
items << new QStandardItem(QLatin1String("item ") + QString::number(i));
|
||||
}
|
||||
model.invisibleRootItem()->appendColumn(items);
|
||||
QTest::qWait(100);
|
||||
@ -3934,7 +3945,8 @@ void tst_QTreeView::taskQTBUG_6450_selectAllWith1stColumnHidden()
|
||||
QList<QTreeWidgetItem *> items;
|
||||
const int nrRows = 10;
|
||||
for (int i = 0; i < nrRows; ++i) {
|
||||
items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i))));
|
||||
const QString text = QLatin1String("item: ") + QString::number(i);
|
||||
items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(text)));
|
||||
items.last()->setText(1, QString("is an item"));
|
||||
}
|
||||
tree.insertTopLevelItems(0, items);
|
||||
@ -3965,9 +3977,11 @@ public:
|
||||
void tst_QTreeView::taskQTBUG_9216_setSizeAndUniformRowHeightsWrongRepaint()
|
||||
{
|
||||
QStandardItemModel model(10, 10, this);
|
||||
for (int row = 0; row < 10; row++)
|
||||
for (int row = 0; row < 10; row++) {
|
||||
const QString prefix = QLatin1String("row ") + QString::number(row) + QLatin1String(", col ");
|
||||
for (int col = 0; col < 10; col++)
|
||||
model.setItem(row, col, new QStandardItem(QString("row %0, col %1").arg(row).arg(col)));
|
||||
model.setItem(row, col, new QStandardItem(prefix + QString::number(col)));
|
||||
}
|
||||
TreeViewQTBUG_9216 view;
|
||||
view.setUniformRowHeights(true);
|
||||
view.setModel(&model);
|
||||
@ -4340,9 +4354,10 @@ void tst_QTreeView::taskQTBUG_37813_crash()
|
||||
treeWidget.setColumnCount(2);
|
||||
QList<QTreeWidgetItem *> items;
|
||||
for (int r = 0; r < 2; ++r) {
|
||||
const QString prefix = QLatin1String("Row ") + QString::number(r) + QLatin1String(" Column ");
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
for (int c = 0; c < treeWidget.columnCount(); ++c)
|
||||
item->setText(c, QString::fromLatin1("Row %1 Column %2").arg(r).arg(c));
|
||||
item->setText(c, prefix + QString::number(c));
|
||||
items.append(item);
|
||||
}
|
||||
treeWidget.addTopLevelItems(items);
|
||||
|
@ -320,7 +320,7 @@ void tst_QTreeWidget::addTopLevelItem()
|
||||
for (int i = 0; i < 100; i += count) {
|
||||
tops.clear();
|
||||
for (int j = 0; j < count; ++j)
|
||||
tops << new TreeItem(QStringList() << QString("%0").arg(j));
|
||||
tops << new TreeItem(QStringList(QString::number(j)));
|
||||
tree.addTopLevelItems(tops);
|
||||
QCOMPARE(tree.topLevelItemCount(), count + i);
|
||||
for (int j = 0; j < count; ++j)
|
||||
@ -511,10 +511,10 @@ void tst_QTreeWidget::takeItem()
|
||||
|
||||
for (int i=0; i<3; ++i) {
|
||||
QTreeWidgetItem *top = new QTreeWidgetItem(testWidget);
|
||||
top->setText(0, QString("top%1").arg(i));
|
||||
top->setText(0, QStringLiteral("top") + QString::number(i));
|
||||
for (int j=0; j<3; ++j) {
|
||||
QTreeWidgetItem *child = new QTreeWidgetItem(top);
|
||||
child->setText(0, QString("child%1").arg(j));
|
||||
child->setText(0, QStringLiteral("child") + QString::number(j));
|
||||
}
|
||||
}
|
||||
|
||||
@ -528,7 +528,7 @@ void tst_QTreeWidget::takeItem()
|
||||
QCOMPARE(item, (QTreeWidgetItem *)0);
|
||||
QCOMPARE(count, testWidget->topLevelItemCount());
|
||||
} else {
|
||||
QCOMPARE(item->text(0), QString("top%1").arg(index));
|
||||
QCOMPARE(item->text(0), QStringLiteral("top") + QString::number(index));
|
||||
QCOMPARE(count-1, testWidget->topLevelItemCount());
|
||||
delete item;
|
||||
}
|
||||
@ -539,7 +539,7 @@ void tst_QTreeWidget::takeItem()
|
||||
QCOMPARE(item, (QTreeWidgetItem *)0);
|
||||
QCOMPARE(count, testWidget->topLevelItem(0)->childCount());
|
||||
} else {
|
||||
QCOMPARE(item->text(0), QString("child%1").arg(index));
|
||||
QCOMPARE(item->text(0), QStringLiteral("child") + QString::number(index));
|
||||
QCOMPARE(count-1, testWidget->topLevelItem(0)->childCount());
|
||||
delete item;
|
||||
}
|
||||
@ -794,10 +794,11 @@ void tst_QTreeWidget::selectedItems()
|
||||
// create items
|
||||
for (int t=0; t<topLevel; ++t) {
|
||||
QTreeWidgetItem *top = new QTreeWidgetItem(testWidget);
|
||||
top->setText(0, QString("top%1").arg(t));
|
||||
const QString topS = QLatin1String("top") + QString::number(t);
|
||||
top->setText(0, topS);
|
||||
for (int c=0; c<children; ++c) {
|
||||
QTreeWidgetItem *child = new QTreeWidgetItem(top);
|
||||
child->setText(0, QString("top%1child%2").arg(t).arg(c));
|
||||
child->setText(0, topS + QLatin1String("child") + QString::number(c));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1442,11 +1443,10 @@ static void fillTreeWidget(QTreeWidgetItem *parent, int rows)
|
||||
{
|
||||
const int columns = parent->treeWidget()->columnCount();
|
||||
for (int r = 0; r < rows; ++r) {
|
||||
const QString prefix = QLatin1String("[r:") + QString::number(r) + QLatin1String(",c:");
|
||||
QTreeWidgetItem *w = new QTreeWidgetItem(parent);
|
||||
for ( int c = 0; c < columns; ++c ) {
|
||||
QString s = QString("[r:%1,c:%2]").arg(r).arg(c);
|
||||
w->setText(c, s);
|
||||
}
|
||||
for (int c = 0; c < columns; ++c)
|
||||
w->setText(c, prefix + QString::number(c) + QLatin1Char(']'));
|
||||
fillTreeWidget(w, rows - r - 1);
|
||||
}
|
||||
}
|
||||
@ -1455,10 +1455,9 @@ static void fillTreeWidget(QTreeWidget *tree, int rows)
|
||||
{
|
||||
for (int r = 0; r < rows; ++r) {
|
||||
QTreeWidgetItem *w = new QTreeWidgetItem();
|
||||
for ( int c = 0; c < tree->columnCount(); ++c ) {
|
||||
QString s = QString("[r:%1,c:%2]").arg(r).arg(c);
|
||||
w->setText(c, s);
|
||||
}
|
||||
const QString prefix = QLatin1String("[r:") + QString::number(r) + QLatin1String(",c:");
|
||||
for (int c = 0; c < tree->columnCount(); ++c)
|
||||
w->setText(c, prefix + QString::number(c) + QLatin1Char(']'));
|
||||
tree->insertTopLevelItem(r, w);
|
||||
fillTreeWidget(w, rows - r - 1);
|
||||
}
|
||||
@ -1555,7 +1554,7 @@ void tst_QTreeWidget::keyboardNavigation()
|
||||
}
|
||||
|
||||
QTreeWidgetItem *current = testWidget->currentItem();
|
||||
QCOMPARE(current->text(0), QString("[r:%1,c:0]").arg(row));
|
||||
QCOMPARE(current->text(0), QLatin1String("[r:") + QString::number(row) + QLatin1String(",c:0]"));
|
||||
if (current->parent())
|
||||
QCOMPARE(current->parent()->indexOfChild(current), row);
|
||||
else
|
||||
@ -1696,7 +1695,7 @@ void tst_QTreeWidget::addChild()
|
||||
for (int i = 0; i < 100; i += count) {
|
||||
QList<QTreeWidgetItem*> list;
|
||||
for (int j = 0; j < count; ++j)
|
||||
list << new QTreeWidgetItem(QStringList() << QString("%0").arg(j));
|
||||
list << new QTreeWidgetItem(QStringList(QString::number(j)));
|
||||
item->addChildren(list);
|
||||
QCOMPARE(item->childCount(), count + i);
|
||||
for (int j = 0; j < count; ++j) {
|
||||
@ -1743,7 +1742,8 @@ void tst_QTreeWidget::setData()
|
||||
for (int i = 1; i <= 2; ++i) {
|
||||
for (int j = 0; j < 5; ++j) {
|
||||
QVariantList args;
|
||||
QString text = QString("text %0").arg(i);
|
||||
const QString iS = QString::number(i);
|
||||
const QString text = QLatin1String("text ") + iS;
|
||||
item->setText(j, text);
|
||||
QCOMPARE(item->text(j), text);
|
||||
QCOMPARE(itemChangedSpy.count(), 1);
|
||||
@ -1765,7 +1765,7 @@ void tst_QTreeWidget::setData()
|
||||
item->setIcon(j, icon);
|
||||
QCOMPARE(itemChangedSpy.count(), 0);
|
||||
|
||||
QString toolTip = QString("toolTip %0").arg(i);
|
||||
const QString toolTip = QLatin1String("toolTip ") + iS;
|
||||
item->setToolTip(j, toolTip);
|
||||
QCOMPARE(item->toolTip(j), toolTip);
|
||||
QCOMPARE(itemChangedSpy.count(), 1);
|
||||
@ -1775,7 +1775,7 @@ void tst_QTreeWidget::setData()
|
||||
item->setToolTip(j, toolTip);
|
||||
QCOMPARE(itemChangedSpy.count(), 0);
|
||||
|
||||
QString statusTip = QString("statusTip %0").arg(i);
|
||||
const QString statusTip = QLatin1String("statusTip ") + iS;
|
||||
item->setStatusTip(j, statusTip);
|
||||
QCOMPARE(item->statusTip(j), statusTip);
|
||||
QCOMPARE(itemChangedSpy.count(), 1);
|
||||
@ -1785,7 +1785,7 @@ void tst_QTreeWidget::setData()
|
||||
item->setStatusTip(j, statusTip);
|
||||
QCOMPARE(itemChangedSpy.count(), 0);
|
||||
|
||||
QString whatsThis = QString("whatsThis %0").arg(i);
|
||||
const QString whatsThis = QLatin1String("whatsThis ") + iS;
|
||||
item->setWhatsThis(j, whatsThis);
|
||||
QCOMPARE(item->whatsThis(j), whatsThis);
|
||||
QCOMPARE(itemChangedSpy.count(), 1);
|
||||
@ -2147,8 +2147,8 @@ void tst_QTreeWidget::insertItemsWithSorting_data()
|
||||
QStringList ascendingItems;
|
||||
QStringList reverseItems;
|
||||
for (int i = 'a'; i <= 'z'; ++i) {
|
||||
ascendingItems << QString("%0").arg(QLatin1Char(i));
|
||||
reverseItems << QString("%0").arg(QLatin1Char('z' - i + 'a'));
|
||||
ascendingItems << QString(1, QLatin1Char(i));
|
||||
reverseItems << QString(1, QLatin1Char('z' - i + 'a'));
|
||||
ascendingRows << i - 'a';
|
||||
reverseRows << 'z' - i + 'a';
|
||||
}
|
||||
@ -2671,9 +2671,9 @@ void tst_QTreeWidget::expandAndCallapse()
|
||||
QTreeWidgetItem *top = new QTreeWidgetItem(&tw, QStringList() << "top");
|
||||
QTreeWidgetItem *p;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
p = new QTreeWidgetItem(top, QStringList() << QString("%1").arg(i));
|
||||
p = new QTreeWidgetItem(top, QStringList(QString::number(i)));
|
||||
for (int j = 0; j < 10; ++j)
|
||||
new QTreeWidgetItem(p, QStringList() << QString("%1").arg(j));
|
||||
new QTreeWidgetItem(p, QStringList(QString::number(j)));
|
||||
}
|
||||
QSignalSpy spy0(&tw, SIGNAL(itemExpanded(QTreeWidgetItem*)));
|
||||
QSignalSpy spy1(&tw, SIGNAL(itemCollapsed(QTreeWidgetItem*)));
|
||||
@ -3133,7 +3133,7 @@ void tst_QTreeWidget::selectionOrder()
|
||||
testWidget->setColumnCount(1);
|
||||
QList<QTreeWidgetItem *> items;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i))));
|
||||
items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QLatin1String("item: ") + QString::number(i))));
|
||||
testWidget->insertTopLevelItems(0, items);
|
||||
|
||||
QModelIndex idx = testWidget->indexFromItem(items[0]);
|
||||
|
@ -105,7 +105,8 @@ void tst_QTreeWidgetItemIterator::initTestCase()
|
||||
*/
|
||||
for (int i=0; i <= 16; ++i) {
|
||||
QTreeWidgetItem *top = new QTreeWidgetItem(testWidget);
|
||||
top->setText(0, QString("top%1").arg(i));
|
||||
const QString topS = QLatin1String("top") + QString::number(i);
|
||||
top->setText(0, topS);
|
||||
switch (i) {
|
||||
case 0: testWidget->setItemHidden(top, true);break;
|
||||
case 1: testWidget->setItemHidden(top, false);break;
|
||||
@ -136,7 +137,7 @@ void tst_QTreeWidgetItemIterator::initTestCase()
|
||||
}
|
||||
for (int j=0; j <= 16; ++j) {
|
||||
QTreeWidgetItem *child = new QTreeWidgetItem(top);
|
||||
child->setText(0, QString("top%1,child%2").arg(i).arg(j));
|
||||
child->setText(0, topS + QLatin1String(",child") + QString::number(j));
|
||||
switch (j) {
|
||||
case 0: testWidget->setItemHidden(child, true);break;
|
||||
case 1: testWidget->setItemHidden(child, false);break;
|
||||
@ -1074,6 +1075,24 @@ void tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget_data()
|
||||
<< 3 << 3 << 3 << (int)QTreeWidgetItemIterator::All << 1 << 3 << QString("top0,child1") << QString("top0,child1") << 0;
|
||||
}
|
||||
|
||||
static void populate3Levels(QTreeWidget &tw, int topLevelItems, int childItems, int grandChildItems)
|
||||
{
|
||||
for (int i1 = 0; i1 < topLevelItems; ++i1) {
|
||||
QTreeWidgetItem *top = new QTreeWidgetItem(&tw);
|
||||
const QString top1S = QLatin1String("top") + QString::number(i1);
|
||||
top->setText(0, top1S);
|
||||
for (int i2 = 0; i2 < childItems; ++i2) {
|
||||
QTreeWidgetItem *child = new QTreeWidgetItem(top);
|
||||
const QString childS = top1S + QLatin1String(",child") + QString::number(i2);
|
||||
child->setText(0, childS);
|
||||
for (int i3 = 0; i3 < grandChildItems; ++i3) {
|
||||
QTreeWidgetItem *grandChild = new QTreeWidgetItem(child);
|
||||
grandChild->setText(0, childS + QLatin1String(",grandchild") + QString::number(i3));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget()
|
||||
{
|
||||
QFETCH(int, topLevelItems);
|
||||
@ -1089,18 +1108,7 @@ void tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget()
|
||||
QTreeWidget tw;
|
||||
tw.clear();
|
||||
tw.setColumnCount(2);
|
||||
for (int i1=0; i1 < topLevelItems; ++i1) {
|
||||
QTreeWidgetItem *top = new QTreeWidgetItem(&tw);
|
||||
top->setText(0, QString("top%1").arg(i1));
|
||||
for (int i2=0; i2 < childItems; ++i2) {
|
||||
QTreeWidgetItem *child = new QTreeWidgetItem(top);
|
||||
child->setText(0, QString("top%1,child%2").arg(i1).arg(i2));
|
||||
for (int i3=0; i3 < grandChildItems; ++i3) {
|
||||
QTreeWidgetItem *grandChild = new QTreeWidgetItem(child);
|
||||
grandChild->setText(0, QString("top%1,child%2,grandchild%3").arg(i1).arg(i2).arg(i3));
|
||||
}
|
||||
}
|
||||
}
|
||||
populate3Levels(tw, topLevelItems, childItems, grandChildItems);
|
||||
|
||||
QTreeWidgetItemIterator it(&tw, QTreeWidgetItemIterator::IteratorFlags(iteratorflags));
|
||||
it+=expecteditemindex;
|
||||
@ -1161,18 +1169,7 @@ void tst_QTreeWidgetItemIterator::updateIteratorAfterDeletedItem_and_ContinueIte
|
||||
QTreeWidget tw;
|
||||
tw.clear();
|
||||
tw.setColumnCount(2);
|
||||
for (int i1=0; i1 < topLevelItems; ++i1) {
|
||||
QTreeWidgetItem *top = new QTreeWidgetItem(&tw);
|
||||
top->setText(0, QString("top%1").arg(i1));
|
||||
for (int i2=0; i2 < childItems; ++i2) {
|
||||
QTreeWidgetItem *child = new QTreeWidgetItem(top);
|
||||
child->setText(0, QString("top%1,child%2").arg(i1).arg(i2));
|
||||
for (int i3=0; i3 < grandChildItems; ++i3) {
|
||||
QTreeWidgetItem *grandChild = new QTreeWidgetItem(child);
|
||||
grandChild->setText(0, QString("top%1,child%2,grandchild%3").arg(i1).arg(i2).arg(i3));
|
||||
}
|
||||
}
|
||||
}
|
||||
populate3Levels(tw, topLevelItems, childItems, grandChildItems);
|
||||
|
||||
QTreeWidgetItemIterator it(&tw, QTreeWidgetItemIterator::All);
|
||||
it += iterator_initial_index;
|
||||
|
@ -334,9 +334,9 @@ void tst_QAction::task200823_tooltip()
|
||||
action->setShortcut(shortcut);
|
||||
|
||||
// we want a non-standard tooltip that shows the shortcut
|
||||
action->setToolTip(QString("%1 (%2)").arg(action->text()).arg(action->shortcut().toString()));
|
||||
action->setToolTip(action->text() + QLatin1String(" (") + action->shortcut().toString() + QLatin1Char(')'));
|
||||
|
||||
QString ref = QString("foo (%1)").arg(QKeySequence(shortcut).toString());
|
||||
QString ref = QLatin1String("foo (") + QKeySequence(shortcut).toString() + QLatin1Char(')');
|
||||
QCOMPARE(action->toolTip(), ref);
|
||||
}
|
||||
|
||||
|
@ -400,11 +400,12 @@ void tst_QApplication::setFont_data()
|
||||
if (!sizes.size())
|
||||
sizes = fdb.standardSizes();
|
||||
if (sizes.size() > 0) {
|
||||
QTest::newRow(QString("data%1a").arg(cnt).toLatin1().constData())
|
||||
const QByteArray cntB = QByteArray::number(cnt);
|
||||
QTest::newRow(("data" + cntB + "a").constData())
|
||||
<< family
|
||||
<< sizes.first()
|
||||
<< false;
|
||||
QTest::newRow(QString("data%1b").arg(cnt).toLatin1().constData())
|
||||
QTest::newRow(("data" + cntB + "b").constData())
|
||||
<< family
|
||||
<< sizes.first()
|
||||
<< true;
|
||||
|
@ -184,7 +184,7 @@ void tst_QFormLayout::getItemPosition()
|
||||
QList<QLabel*> labels;
|
||||
QList<QLineEdit*> fields;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
labels.append(new QLabel(QString("Label %1").arg(i+1)));
|
||||
labels.append(new QLabel(QLatin1String("Label " ) + QString::number(i + 1)));
|
||||
fields.append(new QLineEdit);
|
||||
fl->addRow(labels[i], fields[i]);
|
||||
}
|
||||
|
@ -538,7 +538,8 @@ public:
|
||||
}
|
||||
private:
|
||||
void init(int numPixels = -1){
|
||||
setText(QString::fromLatin1("(%1,%2)").arg(sh.width()).arg(sh.height()));
|
||||
setText(QLatin1Char('(') + QString::number(sh.width())
|
||||
+ QLatin1Char(',') + QString::number(sh.height()) + QLatin1Char(')'));
|
||||
setFrameStyle(QFrame::Box | QFrame::Plain);
|
||||
setNumberOfPixels(numPixels);
|
||||
}
|
||||
@ -1432,8 +1433,9 @@ void tst_QGridLayout::layoutSpacing_data()
|
||||
w->setLayout(layout);
|
||||
int pw = up->sizeHint().width();
|
||||
int ph = up->sizeHint().height();
|
||||
QByteArray testName = QString::fromLatin1("arrowpad with %1 empty rows, %2 empty columns").arg(yoff).arg(xoff).toLatin1();
|
||||
QTest::newRow(testName.data())
|
||||
QByteArray testName = "arrowpad with " + QByteArray::number(yoff)
|
||||
+ " empty rows, " + QByteArray::number(xoff) + " empty columns";
|
||||
QTest::newRow(testName.constData())
|
||||
<< w << (PointList()
|
||||
<< QPoint(0 + pw + 5, 3)
|
||||
<< QPoint(0, 3 + ph + 10)
|
||||
@ -1686,7 +1688,7 @@ void tst_QGridLayout::replaceWidget()
|
||||
for (int n = 0; n < itemCount; ++n) {
|
||||
int x = n % 3;
|
||||
int y = n / 3;
|
||||
labels[n] = new QLabel(QString("label %1").arg(n));
|
||||
labels[n] = new QLabel(QLatin1String("label ") + QString::number(n));
|
||||
Qt::Alignment align = (n % 3 ? Qt::AlignLeft : Qt::AlignRight);
|
||||
l->addWidget(labels[n], x * 3, y * 3, (n % 2) + 1, (n + 1) % 2 + 1, align);
|
||||
}
|
||||
|
@ -180,12 +180,13 @@ protected:
|
||||
QKeyEvent *ke = static_cast<QKeyEvent*>(e);
|
||||
if (ke->modifiers() && ke->key() > Qt::Key_Any
|
||||
&& ke->key() < Qt::Key_ydiaeresis) {
|
||||
const QChar c = QLatin1Char(char(ke->key()));
|
||||
if (ke->modifiers() == Qt::ControlModifier)
|
||||
insertPlainText(QString("<Ctrl+%1>").arg(char(ke->key())));
|
||||
insertPlainText(QLatin1String("<Ctrl+") + c + QLatin1Char('>'));
|
||||
else if (ke->modifiers() == Qt::AltModifier)
|
||||
insertPlainText(QString("<Alt+%1>").arg(char(ke->key())));
|
||||
insertPlainText(QLatin1String("<Alt+") + c + QLatin1Char('>'));
|
||||
else if (ke->modifiers() == Qt::ShiftModifier)
|
||||
insertPlainText(QString("<Shift+%1>").arg(char(ke->key())));
|
||||
insertPlainText(QLatin1String("<Shift+") + c + QLatin1Char('>'));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -5644,7 +5644,7 @@ void tst_QWidget::setToolTip()
|
||||
for (int pass = 0; pass < 2; ++pass) {
|
||||
QCursor::setPos(0, 0);
|
||||
QScopedPointer<QWidget> popup(new QWidget(0, Qt::Popup));
|
||||
popup->setObjectName(QString::fromLatin1("tst_qwidget setToolTip #%1").arg(pass));
|
||||
popup->setObjectName(QLatin1String("tst_qwidget setToolTip #") + QString::number(pass));
|
||||
popup->setWindowTitle(popup->objectName());
|
||||
popup->setGeometry(50, 50, 150, 50);
|
||||
QFrame *frame = new QFrame(popup.data());
|
||||
|
@ -1814,8 +1814,11 @@ void tst_QStyleSheetStyle::QTBUG36933_brokenPseudoClassLookup()
|
||||
QTableWidget widget(rowCount, columnCount);
|
||||
|
||||
for (int row = 0; row < rowCount; ++row) {
|
||||
for (int column = 0; column < columnCount; ++column)
|
||||
widget.setItem(row, column, new QTableWidgetItem(QStringLiteral("row %1 column %2").arg(row + 1).arg(column + 1)));
|
||||
for (int column = 0; column < columnCount; ++column) {
|
||||
const QString t = QLatin1String("row ") + QString::number(row + 1)
|
||||
+ QLatin1String(" column ") + QString::number(column + 1);
|
||||
widget.setItem(row, column, new QTableWidgetItem(t));
|
||||
}
|
||||
|
||||
// put no visible text for the vertical headers, but still put some text or they will collapse
|
||||
widget.setVerticalHeaderItem(row, new QTableWidgetItem(QStringLiteral(" ")));
|
||||
|
@ -367,7 +367,7 @@ void tst_QCompleter::csMatchingOnCsSortedModel_data()
|
||||
QTest::addColumn<QString>("completion");
|
||||
QTest::addColumn<QString>("completionText");
|
||||
|
||||
#define ROWNAME(name) (qPrintable(QString("%1 %2").arg(name).arg(i)))
|
||||
#define ROWNAME(name) ((QByteArray(name) + ' ' + QByteArray::number(i)).constData())
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (i == 1)
|
||||
@ -1164,7 +1164,7 @@ void tst_QCompleter::dynamicSortOrder()
|
||||
completer.setModelSorting(QCompleter::CaseSensitivelySortedModel);
|
||||
QStandardItem *root = model.invisibleRootItem();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
root->appendRow(new QStandardItem(QString("%1").arg(i)));
|
||||
root->appendRow(new QStandardItem(QString::number(i)));
|
||||
}
|
||||
root->appendRow(new QStandardItem("13"));
|
||||
root->sortChildren(0, Qt::AscendingOrder);
|
||||
@ -1256,7 +1256,7 @@ void tst_QCompleter::task189564_omitNonSelectableItems()
|
||||
|
||||
QStringList strings;
|
||||
for (int i = 0; i < n; ++i)
|
||||
strings << QString("%1%2").arg(prefix).arg(i);
|
||||
strings << prefix + QString::number(i);
|
||||
const QString omitString(strings.at(n / 2));
|
||||
task189564_StringListModel model(omitString);
|
||||
model.setStringList(strings);
|
||||
@ -1553,9 +1553,9 @@ void tst_QCompleter::task247560_keyboardNavigation()
|
||||
QStandardItemModel model;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
for (int j = 0; j < 5; j++) {
|
||||
model.setItem(i, j, new QStandardItem(QString("row %1 column %2").arg(i).arg(j)));
|
||||
}
|
||||
const QString prefix = QLatin1String("row ") + QString::number(i) + QLatin1String(" column ");
|
||||
for (int j = 0; j < 5; j++)
|
||||
model.setItem(i, j, new QStandardItem(prefix + QString::number(j)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -2308,9 +2308,10 @@ void tst_QComboBox::task191329_size()
|
||||
|
||||
QStandardItemModel model(rows, 2);
|
||||
for (int row = 0; row < model.rowCount(); ++row) {
|
||||
const QString rowS = QLatin1String("row ") + QString::number(row);
|
||||
for (int column = 0; column < model.columnCount(); ++column) {
|
||||
QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
|
||||
model.setItem(row, column, item);
|
||||
const QString text = rowS + QLatin1String(", column ") + QString::number(column);
|
||||
model.setItem(row, column, new QStandardItem(text));
|
||||
}
|
||||
}
|
||||
QTableView *table = new QTableView();
|
||||
@ -2860,10 +2861,11 @@ void tst_QComboBox::task_QTBUG_10491_currentIndexAndModelColumn()
|
||||
|
||||
QStandardItemModel model(4, 4, &comboBox);
|
||||
for (int i = 0; i < 4; i++){
|
||||
model.setItem(i, 0, new QStandardItem(QString("Employee Nr %1").arg(i)));
|
||||
model.setItem(i, 1, new QStandardItem(QString("Street Nr %1").arg(i)));
|
||||
model.setItem(i, 2, new QStandardItem(QString("Town Nr %1").arg(i)));
|
||||
model.setItem(i, 3, new QStandardItem(QString("Phone Nr %1").arg(i)));
|
||||
const QString iS = QString::number(i);
|
||||
model.setItem(i, 0, new QStandardItem(QLatin1String("Employee Nr ") + iS));
|
||||
model.setItem(i, 1, new QStandardItem(QLatin1String("Street Nr ") + iS));
|
||||
model.setItem(i, 2, new QStandardItem(QLatin1String("Town Nr ") + iS));
|
||||
model.setItem(i, 3, new QStandardItem(QLatin1String("Phone Nr ") + iS));
|
||||
}
|
||||
comboBox.setModel(&model);
|
||||
comboBox.setModelColumn(0);
|
||||
@ -2909,12 +2911,12 @@ void tst_QComboBox::itemData()
|
||||
// ensure that the currentText(), the DisplayRole and the EditRole
|
||||
// stay in sync when using QComboBox's default model
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
QString itemText = QString("item text %1").arg(i);
|
||||
QString itemText = QLatin1String("item text ") + QString::number(i);
|
||||
comboBox.addItem(itemText);
|
||||
}
|
||||
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
QString itemText = QString("item text %1").arg(i);
|
||||
QString itemText = QLatin1String("item text ") + QString::number(i);
|
||||
QCOMPARE(comboBox.itemText(i), itemText);
|
||||
QCOMPARE(comboBox.itemData(i, Qt::DisplayRole).toString(), itemText);
|
||||
QCOMPARE(comboBox.itemData(i, Qt::EditRole).toString(), itemText);
|
||||
@ -2926,14 +2928,11 @@ void tst_QComboBox::itemData()
|
||||
QCOMPARE(comboBox.currentData(Qt::EditRole).toString(), itemText);
|
||||
}
|
||||
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
// now change by using setItemText
|
||||
QString itemText = QString("setItemText %1").arg(i);
|
||||
comboBox.setItemText(i, itemText);
|
||||
}
|
||||
for (int i = 0; i < itemCount; ++i) // now change by using setItemText
|
||||
comboBox.setItemText(i, QLatin1String("setItemText ") + QString::number(i));
|
||||
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
QString itemText = QString("setItemText %1").arg(i);
|
||||
QString itemText = QLatin1String("setItemText ") + QString::number(i);
|
||||
QCOMPARE(comboBox.itemText(i), itemText);
|
||||
QCOMPARE(comboBox.itemData(i, Qt::DisplayRole).toString(), itemText);
|
||||
QCOMPARE(comboBox.itemData(i, Qt::EditRole).toString(), itemText);
|
||||
@ -2947,12 +2946,12 @@ void tst_QComboBox::itemData()
|
||||
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
// now change by changing the DisplayRole's data
|
||||
QString itemText = QString("setItemData(DisplayRole) %1").arg(i);
|
||||
QString itemText = QLatin1String("setItemData(DisplayRole) ") + QString::number(i);
|
||||
comboBox.setItemData(i, QVariant(itemText), Qt::DisplayRole);
|
||||
}
|
||||
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
QString itemText = QString("setItemData(DisplayRole) %1").arg(i);
|
||||
QString itemText = QLatin1String("setItemData(DisplayRole) ") + QString::number(i);
|
||||
QCOMPARE(comboBox.itemText(i), itemText);
|
||||
QCOMPARE(comboBox.itemData(i, Qt::DisplayRole).toString(), itemText);
|
||||
QCOMPARE(comboBox.itemData(i, Qt::EditRole).toString(), itemText);
|
||||
@ -2966,12 +2965,12 @@ void tst_QComboBox::itemData()
|
||||
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
// now change by changing the EditRole's data
|
||||
QString itemText = QString("setItemData(EditRole) %1").arg(i);
|
||||
QString itemText = QLatin1String("setItemData(EditRole) ") + QString::number(i);
|
||||
comboBox.setItemData(i, QVariant(itemText), Qt::EditRole);
|
||||
}
|
||||
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
QString itemText = QString("setItemData(EditRole) %1").arg(i);
|
||||
QString itemText = QLatin1String("setItemData(EditRole) ") + QString::number(i);
|
||||
QCOMPARE(comboBox.itemText(i), itemText);
|
||||
QCOMPARE(comboBox.itemData(i, Qt::DisplayRole).toString(), itemText);
|
||||
QCOMPARE(comboBox.itemData(i, Qt::EditRole).toString(), itemText);
|
||||
@ -2988,14 +2987,14 @@ void tst_QComboBox::itemData()
|
||||
|
||||
// set additional user data in the addItem call
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
QString itemText = QString("item text %1").arg(i);
|
||||
QString itemDataText = QString("item data %1").arg(i);
|
||||
comboBox.addItem(itemText, QVariant(itemDataText));
|
||||
const QString iS = QString::number(i);
|
||||
comboBox.addItem(QLatin1String("item text ") + iS, QVariant(QLatin1String("item data ") + iS));
|
||||
}
|
||||
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
QString itemText = QString("item text %1").arg(i);
|
||||
QString itemDataText = QString("item data %1").arg(i);
|
||||
const QString iS = QString::number(i);
|
||||
QString itemText = QLatin1String("item text ") + iS;
|
||||
QString itemDataText = QLatin1String("item data ") + iS;
|
||||
QCOMPARE(comboBox.itemData(i, Qt::DisplayRole).toString(), itemText);
|
||||
QCOMPARE(comboBox.itemData(i, Qt::EditRole).toString(), itemText);
|
||||
QCOMPARE(comboBox.itemData(i).toString(), itemDataText);
|
||||
@ -3018,8 +3017,9 @@ void tst_QComboBox::itemData()
|
||||
QString qtlogoPath = QFINDTESTDATA("qtlogo.png");
|
||||
QIcon icon = QIcon(QPixmap(qtlogoPath));
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
QString itemText = QString("item text %1").arg(i);
|
||||
QString itemDataText = QString("item data %1").arg(i);
|
||||
const QString iS = QString::number(i);
|
||||
QString itemText = QLatin1String("item text ") + iS;
|
||||
QString itemDataText = QLatin1String("item data ") + iS;
|
||||
double d = i;
|
||||
comboBox.addItem(itemText);
|
||||
comboBox.setItemData(i, QVariant(itemDataText), Qt::UserRole);
|
||||
@ -3028,8 +3028,9 @@ void tst_QComboBox::itemData()
|
||||
}
|
||||
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
QString itemText = QString("item text %1").arg(i);
|
||||
QString itemDataText = QString("item data %1").arg(i);
|
||||
const QString iS = QString::number(i);
|
||||
QString itemText = QLatin1String("item text ") + iS;
|
||||
QString itemDataText = QLatin1String("item data ") + iS;
|
||||
double d = i;
|
||||
QCOMPARE(comboBox.itemData(i, Qt::DisplayRole).toString(), itemText);
|
||||
QCOMPARE(comboBox.itemData(i, Qt::EditRole).toString(), itemText);
|
||||
|
@ -248,7 +248,7 @@ void tst_QFontComboBox::writingSystem_data()
|
||||
QTest::newRow("Runic") << QFontDatabase::Runic;
|
||||
|
||||
for (int i = 0; i < 31; ++i)
|
||||
QTest::newRow(qPrintable(QString("enum %1").arg(i))) << (QFontDatabase::WritingSystem)i;
|
||||
QTest::newRow(("enum " + QByteArray::number(i)).constData()) << (QFontDatabase::WritingSystem)i;
|
||||
}
|
||||
|
||||
// public QFontDatabase::WritingSystem writingSystem() const
|
||||
|
@ -73,22 +73,24 @@ static void provideFrameData()
|
||||
|
||||
for (int lineWidth = 0; lineWidth < 3; ++lineWidth) {
|
||||
for (int midLineWidth = 0; midLineWidth < 3; ++midLineWidth) {
|
||||
QTest::newRow(qPrintable(QStringLiteral("box_noshadow_%1_%2").arg(lineWidth).arg(midLineWidth)))
|
||||
<< "box_noshadow" << lineWidth << midLineWidth << QFrame::Box << (QFrame::Shadow)0;
|
||||
QTest::newRow(qPrintable(QStringLiteral("box_plain_%1_%2").arg(lineWidth).arg(midLineWidth)))
|
||||
const QByteArray postFix = '_' + QByteArray::number(lineWidth) + '_'
|
||||
+ QByteArray::number(midLineWidth);
|
||||
QTest::newRow(("box_noshadow" + postFix).constData())
|
||||
<< "box_noshadow" << lineWidth << midLineWidth << QFrame::Box << (QFrame::Shadow)0;
|
||||
QTest::newRow(("box_plain" + postFix).constData())
|
||||
<< "box_plain" << lineWidth << midLineWidth << QFrame::Box << QFrame::Plain;
|
||||
QTest::newRow(qPrintable(QStringLiteral("box_raised_%1_%2").arg(lineWidth).arg(midLineWidth)))
|
||||
QTest::newRow(("box_raised" + postFix).constData())
|
||||
<< "box_raised" << lineWidth << midLineWidth << QFrame::Box << QFrame::Raised;
|
||||
QTest::newRow(qPrintable(QStringLiteral("box_sunken_%1_%2").arg(lineWidth).arg(midLineWidth)))
|
||||
QTest::newRow(("box_sunken" + postFix).constData())
|
||||
<< "box_sunken" << lineWidth << midLineWidth << QFrame::Box << QFrame::Sunken;
|
||||
|
||||
QTest::newRow(qPrintable(QStringLiteral("winpanel_noshadow_%1_%2").arg(lineWidth).arg(midLineWidth)))
|
||||
QTest::newRow(("winpanel_noshadow" + postFix).constData())
|
||||
<< "winpanel_noshadow" << lineWidth << midLineWidth << QFrame::WinPanel << (QFrame::Shadow)0;
|
||||
QTest::newRow(qPrintable(QStringLiteral("winpanel_plain_%1_%2").arg(lineWidth).arg(midLineWidth)))
|
||||
QTest::newRow(("winpanel_plain" + postFix).constData())
|
||||
<< "winpanel_plain" << lineWidth << midLineWidth << QFrame::WinPanel << QFrame::Plain;
|
||||
QTest::newRow(qPrintable(QStringLiteral("winpanel_raised_%1_%2").arg(lineWidth).arg(midLineWidth)))
|
||||
QTest::newRow(("winpanel_raised" + postFix).constData())
|
||||
<< "winpanel_raised" << lineWidth << midLineWidth << QFrame::WinPanel << QFrame::Raised;
|
||||
QTest::newRow(qPrintable(QStringLiteral("winpanel_sunken_%1_%2").arg(lineWidth).arg(midLineWidth)))
|
||||
QTest::newRow(("winpanel_sunken" + postFix).constData())
|
||||
<< "winpanel_sunken" << lineWidth << midLineWidth << QFrame::WinPanel << QFrame::Sunken;
|
||||
}
|
||||
}
|
||||
@ -174,7 +176,10 @@ void tst_QFrame::testPainting()
|
||||
|
||||
const QPixmap pixmap = frame.grab();
|
||||
|
||||
const QString referenceFilePath = QFINDTESTDATA(QStringLiteral("images/%1_%2_%3.png").arg(basename).arg(lineWidth).arg(midLineWidth));
|
||||
const QString fileName = QLatin1String("images/") + basename + QLatin1Char('_')
|
||||
+ QString::number(lineWidth) + QLatin1Char('_') + QString::number(midLineWidth)
|
||||
+ QLatin1String(".png");
|
||||
const QString referenceFilePath = QFINDTESTDATA(fileName);
|
||||
const QPixmap referencePixmap(referenceFilePath);
|
||||
QVERIFY2(!referencePixmap.isNull(), qPrintable(QStringLiteral("Could not load reference pixmap %1").arg(referenceFilePath)));
|
||||
QCOMPARE(pixmap, referencePixmap);
|
||||
|
@ -2866,6 +2866,11 @@ void tst_QLineEdit::insert()
|
||||
QCOMPARE(testWidget->text(), QString("No Crash! This is a nice test"));
|
||||
}
|
||||
|
||||
static inline QByteArray selectionTestName(int start, int length)
|
||||
{
|
||||
return "selection start: " + QByteArray::number(start) + " length: " + QByteArray::number(length);
|
||||
}
|
||||
|
||||
void tst_QLineEdit::setSelection_data()
|
||||
{
|
||||
QTest::addColumn<QString>("text");
|
||||
@ -2879,39 +2884,39 @@ void tst_QLineEdit::setSelection_data()
|
||||
int start, length, pos;
|
||||
|
||||
start = 0; length = 1; pos = 1;
|
||||
QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
|
||||
QTest::newRow(selectionTestName(start, length).constData())
|
||||
<< text << start << length << pos << QString("A") << true;
|
||||
|
||||
start = 0; length = 2; pos = 2;
|
||||
QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
|
||||
QTest::newRow(selectionTestName(start, length).constData())
|
||||
<< text << start << length << pos << QString("Ab") << true;
|
||||
|
||||
start = 0; length = 4; pos = 4;
|
||||
QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
|
||||
QTest::newRow(selectionTestName(start, length).constData())
|
||||
<< text << start << length << pos << QString("Abc ") << true;
|
||||
|
||||
start = -1; length = 0; pos = text.length();
|
||||
QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
|
||||
QTest::newRow(selectionTestName(start, length).constData())
|
||||
<< text << start << length << pos << QString() << false;
|
||||
|
||||
start = 34; length = 1; pos = 35;
|
||||
QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
|
||||
QTest::newRow(selectionTestName(start, length).constData())
|
||||
<< text << start << length << pos << QString("z") << true;
|
||||
|
||||
start = 34; length = 2; pos = 35;
|
||||
QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
|
||||
QTest::newRow(selectionTestName(start, length).constData())
|
||||
<< text << start << length << pos << QString("z") << true;
|
||||
|
||||
start = 34; length = -1; pos = 33;
|
||||
QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
|
||||
QTest::newRow(selectionTestName(start, length).constData())
|
||||
<< text << start << length << pos << QString("y") << true;
|
||||
|
||||
start = 1; length = -2; pos = 0;
|
||||
QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
|
||||
QTest::newRow(selectionTestName(start, length).constData())
|
||||
<< text << start << length << pos << QString("A") << true;
|
||||
|
||||
start = -1; length = -1; pos = text.length();
|
||||
QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
|
||||
QTest::newRow(selectionTestName(start, length).constData())
|
||||
<< text << start << length << pos << QString() << false;
|
||||
}
|
||||
|
||||
@ -3292,7 +3297,7 @@ void tst_QLineEdit::inlineCompletion()
|
||||
QStandardItem *root = model->invisibleRootItem();
|
||||
QStandardItem *items[5];
|
||||
for (int i = 0; i < 5; i++) {
|
||||
items[i] = new QStandardItem(QString("item%1").arg(i));
|
||||
items[i] = new QStandardItem(QLatin1String("item") + QString::number(i));
|
||||
if ((i+2)%2 == 0) { // disable 0,2,4
|
||||
items[i]->setFlags(items[i]->flags() & ~Qt::ItemIsEnabled);
|
||||
}
|
||||
|
@ -1369,7 +1369,7 @@ void tst_QMainWindow::restoreStateFromPreviousVersion()
|
||||
QVector<QDockWidget*> docks;
|
||||
|
||||
for(int i = 0; i < 16; ++i) {
|
||||
const QString name = QString::fromLatin1("dock %1").arg(i);
|
||||
const QString name = QStringLiteral("dock ") + QString::number(i);
|
||||
QDockWidget *dock = new QDockWidget(name);
|
||||
docks += dock;
|
||||
dock->setObjectName(name);
|
||||
|
@ -621,6 +621,11 @@ void tst_QMdiArea::showWindows()
|
||||
|
||||
//#define USE_SHOW
|
||||
|
||||
static inline QString windowTitle(const QString &t, const QString &f)
|
||||
{
|
||||
return t + QLatin1String(" - [") + f + QLatin1Char(']');
|
||||
}
|
||||
|
||||
void tst_QMdiArea::changeWindowTitle()
|
||||
{
|
||||
const QString mwc = QString::fromLatin1("MainWindow's Caption");
|
||||
@ -648,7 +653,7 @@ void tst_QMdiArea::changeWindowTitle()
|
||||
widget->setWindowState(Qt::WindowMaximized);
|
||||
#endif
|
||||
#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE)
|
||||
QTRY_COMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc).arg(wc) );
|
||||
QTRY_COMPARE( mw->windowTitle(), windowTitle(mwc, wc) );
|
||||
#endif
|
||||
|
||||
mw->hide();
|
||||
@ -657,7 +662,7 @@ void tst_QMdiArea::changeWindowTitle()
|
||||
QVERIFY(QTest::qWaitForWindowExposed(mw));
|
||||
|
||||
#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE)
|
||||
QTRY_COMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc).arg(wc) );
|
||||
QTRY_COMPARE( mw->windowTitle(), windowTitle(mwc, wc) );
|
||||
#endif
|
||||
|
||||
#ifdef USE_SHOW
|
||||
@ -675,11 +680,11 @@ void tst_QMdiArea::changeWindowTitle()
|
||||
#endif
|
||||
qApp->processEvents();
|
||||
#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE)
|
||||
QTRY_COMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc).arg(wc) );
|
||||
QTRY_COMPARE( mw->windowTitle(), windowTitle(mwc, wc) );
|
||||
widget->setWindowTitle( wc2 );
|
||||
QCOMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc).arg(wc2) );
|
||||
QCOMPARE( mw->windowTitle(), windowTitle(mwc, wc2) );
|
||||
mw->setWindowTitle( mwc2 );
|
||||
QCOMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc2).arg(wc2) );
|
||||
QCOMPARE( mw->windowTitle(), windowTitle(mwc2, wc2) );
|
||||
#endif
|
||||
|
||||
mw->show();
|
||||
@ -693,7 +698,7 @@ void tst_QMdiArea::changeWindowTitle()
|
||||
|
||||
qApp->processEvents();
|
||||
#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE)
|
||||
QCOMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc2).arg(wc2) );
|
||||
QCOMPARE( mw->windowTitle(), windowTitle(mwc2, wc2) );
|
||||
#endif
|
||||
#ifdef USE_SHOW
|
||||
widget->showNormal();
|
||||
@ -714,7 +719,7 @@ void tst_QMdiArea::changeWindowTitle()
|
||||
#endif
|
||||
qApp->processEvents();
|
||||
#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE)
|
||||
QCOMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc2).arg(wc2) );
|
||||
QCOMPARE( mw->windowTitle(), windowTitle(mwc2, wc2) );
|
||||
#endif
|
||||
|
||||
#ifdef USE_SHOW
|
||||
@ -2321,7 +2326,7 @@ void tst_QMdiArea::setViewMode()
|
||||
iconPixmap.fill(Qt::red);
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QWidget);
|
||||
subWindow->setWindowTitle(QString(QLatin1String("Title %1")).arg(i));
|
||||
subWindow->setWindowTitle(QLatin1String("Title ") + QString::number(i));
|
||||
subWindow->setWindowIcon(iconPixmap);
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ void tst_QMdiSubWindow::mainWindowSupport()
|
||||
|
||||
QMdiArea *nestedWorkspace = new QMdiArea; // :-)
|
||||
window->setWidget(nestedWorkspace);
|
||||
window->widget()->setWindowTitle(QString::fromLatin1("Window %1").arg(i));
|
||||
window->widget()->setWindowTitle(QLatin1String("Window ") + QString::number(i));
|
||||
|
||||
workspace->addSubWindow(window);
|
||||
QVERIFY(!window->maximizedButtonsWidget());
|
||||
@ -423,8 +423,9 @@ void tst_QMdiSubWindow::mainWindowSupport()
|
||||
QVERIFY(window->maximizedSystemMenuIconWidget());
|
||||
QCOMPARE(window->maximizedSystemMenuIconWidget(), qobject_cast<QWidget *>(mainWindow.menuBar()
|
||||
->cornerWidget(Qt::TopLeftCorner)));
|
||||
QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]")
|
||||
.arg(originalWindowTitle, window->widget()->windowTitle()));
|
||||
const QString expectedTitle = originalWindowTitle + QLatin1String(" - [")
|
||||
+ window->widget()->windowTitle() + QLatin1Char(']');
|
||||
QCOMPARE(mainWindow.windowTitle(), expectedTitle);
|
||||
#endif
|
||||
|
||||
// Check that nested child windows don't set window title
|
||||
@ -432,7 +433,7 @@ void tst_QMdiSubWindow::mainWindowSupport()
|
||||
QMdiSubWindow *nestedWindow = new QMdiSubWindow;
|
||||
nestedWindow->setWidget(new QWidget);
|
||||
nestedWorkspace->addSubWindow(nestedWindow);
|
||||
nestedWindow->widget()->setWindowTitle(QString::fromLatin1("NestedWindow %1").arg(i));
|
||||
nestedWindow->widget()->setWindowTitle(QLatin1String("NestedWindow ") + QString::number(i));
|
||||
nestedWindow->showMaximized();
|
||||
qApp->processEvents();
|
||||
QVERIFY(nestedWindow->isMaximized());
|
||||
|
@ -554,7 +554,7 @@ void tst_QMenu::widgetActionFocus()
|
||||
QMenu m;
|
||||
QListWidget *l = new QListWidget(&m);
|
||||
for (int i = 1; i<3 ; i++)
|
||||
l->addItem(QString("item%1").arg(i));
|
||||
l->addItem(QStringLiteral("item" ) + QString::number(i));
|
||||
QWidgetAction *wa = new QWidgetAction(&m);
|
||||
wa->setDefaultWidget(l);
|
||||
m.addAction(wa);
|
||||
@ -747,7 +747,7 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition()
|
||||
|
||||
uint i = 2;
|
||||
while (main.columnCount() < 2) {
|
||||
main.addAction(QString("Item %1").arg(i));
|
||||
main.addAction(QLatin1String("Item ") + QString::number(i));
|
||||
++i;
|
||||
QVERIFY(i<1000);
|
||||
}
|
||||
@ -1021,7 +1021,7 @@ public:
|
||||
MyMenu() : m_currentIndex(0)
|
||||
{
|
||||
for (int i = 0; i < 2; ++i)
|
||||
dialogActions[i] = addAction( QString("dialog %1").arg(i), dialogs + i, SLOT(exec()));
|
||||
dialogActions[i] = addAction(QLatin1String("dialog ") + QString::number(i), dialogs + i, SLOT(exec()));
|
||||
}
|
||||
|
||||
void activateAction(int index)
|
||||
|
@ -678,9 +678,9 @@ void tst_QSplitter::task187373_addAbstractScrollAreas_data()
|
||||
classNames << QLatin1String("QTreeView");
|
||||
|
||||
foreach (QString className, classNames) {
|
||||
QTest::newRow(qPrintable(QString("%1 1").arg(className))) << className << false << true;
|
||||
QTest::newRow(qPrintable(QString("%1 2").arg(className))) << className << true << false;
|
||||
QTest::newRow(qPrintable(QString("%1 3").arg(className))) << className << true << true;
|
||||
QTest::newRow(qPrintable(className + QLatin1String(" 1"))) << className << false << true;
|
||||
QTest::newRow(qPrintable(className + QLatin1String(" 2"))) << className << true << false;
|
||||
QTest::newRow(qPrintable(className + QLatin1String(" 3"))) << className << true << true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ private:
|
||||
void createWidgets() {
|
||||
for (int i = 0; i < m_n; ++i) {
|
||||
QLineEdit *le = new QLineEdit(this);
|
||||
le->setObjectName(QString::fromLatin1("lineEdit%1").arg(i));
|
||||
le->setObjectName(QLatin1String("lineEdit") + QString::number(i));
|
||||
layout ()->addWidget(le);
|
||||
m_les << le;
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ public slots:
|
||||
void updateTabText()
|
||||
{
|
||||
count++;
|
||||
setTabText(0, QString("%1").arg(count));
|
||||
setTabText(0, QString::number(count));
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user