]> cloud.milkyroute.net Git - dolphin.git/commitdiff
refactor: replace QString() with QStringLiteral() for better performance
authorZhangzhi Hu <integral@member.fsf.org>
Tue, 29 Oct 2024 16:18:57 +0000 (00:18 +0800)
committerMéven Car <meven@kde.org>
Thu, 31 Oct 2024 10:04:40 +0000 (10:04 +0000)
src/dolphincontextmenu.cpp
src/dolphinmainwindow.cpp
src/tests/dolphinmainwindowtest.cpp
src/tests/dolphinsearchboxtest.cpp
src/tests/kfileitemmodeltest.cpp
src/tests/kitemlistcontrollertest.cpp

index af0ae37c079cd31e7ee0ba41cca676cf641b3666..77034dadbec6a307b13e3d620949571cc15d7fdd 100644 (file)
@@ -350,7 +350,7 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties
     addAction(collection->action(KStandardAction::name(KStandardAction::Cut)));
     addAction(collection->action(KStandardAction::name(KStandardAction::Copy)));
     if (ContextMenuSettings::showCopyLocation()) {
-        QAction *copyPathAction = collection->action(QString("copy_location"));
+        QAction *copyPathAction = collection->action(QStringLiteral("copy_location"));
         copyPathAction->setEnabled(m_selectedItems.size() == 1);
         addAction(copyPathAction);
     }
index b0eccde0dab6719d5d91580822d7ad7d3b71c5bd..a8ef550d68cdf527ff4e5c7080532e5518a509e8 100644 (file)
@@ -2454,7 +2454,7 @@ void DolphinMainWindow::updateFileAndEditActions()
     QAction *addToPlacesAction = col->action(QStringLiteral("add_to_places"));
     QAction *copyToOtherViewAction = col->action(QStringLiteral("copy_to_inactive_split_view"));
     QAction *moveToOtherViewAction = col->action(QStringLiteral("move_to_inactive_split_view"));
-    QAction *copyLocation = col->action(QString("copy_location"));
+    QAction *copyLocation = col->action(QStringLiteral("copy_location"));
 
     if (list.isEmpty()) {
         stateChanged(QStringLiteral("has_no_selection"));
index 61a72ad51b055d92e2f00ceb9b520031d196c02f..8fd5be7cba8a10a30b18d14331e71bbb2a98cc3d 100644 (file)
@@ -749,7 +749,7 @@ void DolphinMainWindowTest::testAccessibilityAncestorTree()
             }
             while (accessibleInterface != accessibleInterfaceOfMainWindow) {
                 QVERIFY2(accessibleInterface,
-                         qPrintable(QString("%1's accessibleInterface or one of its accessible children doesn't have the main window as an ancestor.")
+                         qPrintable(QStringLiteral("%1's accessibleInterface or one of its accessible children doesn't have the main window as an ancestor.")
                                         .arg(currentlyFocusedObject->metaObject()->className())));
                 accessibleInterface = accessibleInterface->parent();
             }
index f21a7512123f8890fa26dac517684df283ec5a82..bda60909d8ce8daa4debe8210d1778e4af94995e 100644 (file)
@@ -52,7 +52,7 @@ void DolphinSearchBoxTest::testTextClearing()
     m_searchBox->setText("xyz");
     m_searchBox->setVisible(false, WithoutAnimation);
     m_searchBox->setVisible(true, WithoutAnimation);
-    QCOMPARE(m_searchBox->text(), QString("xyz"));
+    QCOMPARE(m_searchBox->text(), QStringLiteral("xyz"));
 
     QTest::keyClick(m_searchBox, Qt::Key_Escape);
     QVERIFY(m_searchBox->text().isEmpty());
index fad825dc018b48f7208ee9f7bc73b8b3f28fd2f7..7af5690ff30c5334da8305bde490286478a6b2e0 100644 (file)
@@ -157,9 +157,9 @@ void KFileItemModelTest::testDefaultSortRole()
     QVERIFY(itemsInsertedSpy.wait());
 
     QCOMPARE(m_model->count(), 3);
-    QCOMPARE(m_model->data(0).value("text").toString(), QString("a.txt"));
-    QCOMPARE(m_model->data(1).value("text").toString(), QString("b.txt"));
-    QCOMPARE(m_model->data(2).value("text").toString(), QString("c.txt"));
+    QCOMPARE(m_model->data(0).value("text").toString(), QStringLiteral("a.txt"));
+    QCOMPARE(m_model->data(1).value("text").toString(), QStringLiteral("b.txt"));
+    QCOMPARE(m_model->data(2).value("text").toString(), QStringLiteral("c.txt"));
 }
 
 void KFileItemModelTest::testDefaultGroupedSorting()
@@ -262,8 +262,8 @@ void KFileItemModelTest::testSetData()
     QCOMPARE(itemsChangedSpy.count(), 1);
 
     values = m_model->data(0);
-    QCOMPARE(values.value("customRole1").toString(), QString("Test1"));
-    QCOMPARE(values.value("customRole2").toString(), QString("Test2"));
+    QCOMPARE(values.value("customRole1").toString(), QStringLiteral("Test1"));
+    QCOMPARE(values.value("customRole2").toString(), QStringLiteral("Test2"));
     QVERIFY(m_model->isConsistent());
 }
 
index 18ad1186d439002786d6b6e7b2ee35dcccbe0b79..de40331e6da65be42b7a746d698baec1901cd15d 100644 (file)
@@ -478,7 +478,7 @@ void KItemListControllerTest::testKeyboardNavigation_data()
                                      << qMakePair(KeyPress(Qt::Key_Home), ViewState(0, KItemSet() << 0));
                         }
 
-                        const QString testName = layoutNames[layout] + ", " + QString("%1 columns, ").arg(columnCount)
+                        const QString testName = layoutNames[layout] + ", " + QStringLiteral("%1 columns, ").arg(columnCount)
                             + selectionBehaviorNames[selectionBehavior] + ", " + groupingEnabledNames[groupingEnabled] + ", "
                             + layoutDirectionNames[layoutDirection];
 
@@ -543,13 +543,14 @@ void KItemListControllerTest::testKeyboardNavigation()
 
         QTest::keyClick(m_container, key, modifier);
 
-        QVERIFY2(m_selectionManager->currentItem() == current,
-                 qPrintable(QString("currentItem() returns index %1 but %2 would be expected. Before this, key \"%3\" was pressed. This test case is defined "
-                                    "in row %4 of the testList from KItemListControllerTest::testKeyboardNavigation_data().")
-                                .arg(m_selectionManager->currentItem())
-                                .arg(current)
-                                .arg(QKeySequence(key).toString())
-                                .arg(rowCount)));
+        QVERIFY2(
+            m_selectionManager->currentItem() == current,
+            qPrintable(QStringLiteral("currentItem() returns index %1 but %2 would be expected. Before this, key \"%3\" was pressed. This test case is defined "
+                                      "in row %4 of the testList from KItemListControllerTest::testKeyboardNavigation_data().")
+                           .arg(m_selectionManager->currentItem())
+                           .arg(current)
+                           .arg(QKeySequence(key).toString())
+                           .arg(rowCount)));
         switch (selectionBehavior) {
         case KItemListController::NoSelection:
             QVERIFY(m_selectionManager->selectedItems().isEmpty());