diff -Nru kcompletion-5.40.0/autotests/kcombobox_unittest.cpp kcompletion-5.41.0/autotests/kcombobox_unittest.cpp --- kcompletion-5.40.0/autotests/kcombobox_unittest.cpp 2017-11-05 08:25:41.000000000 +0000 +++ kcompletion-5.41.0/autotests/kcombobox_unittest.cpp 2017-12-06 10:15:37.000000000 +0000 @@ -42,9 +42,13 @@ KComboBox w(ctorArg /*initial value for editable*/); w.setEditable(true); w.setCompletionMode(KCompletion::CompletionPopup); - w.addItem("Hello world"); + w.addItem(QStringLiteral("Hello world")); QVERIFY(w.lineEdit()); QVERIFY(qobject_cast(w.lineEdit())); + auto lineEdit = w.lineEdit(); + // set editable again, don't recreate the line edit + w.setEditable(true); + QCOMPARE(w.lineEdit(), lineEdit); // KLineEdit signals QSignalSpy qReturnPressedSpy(w.lineEdit(), SIGNAL(returnPressed())); QSignalSpy kReturnPressedSpy(w.lineEdit(), SIGNAL(returnPressed(QString))); @@ -79,7 +83,7 @@ QSignalSpy comboReturnPressedSpy(&w, SIGNAL(returnPressed())); QSignalSpy comboReturnPressedStringSpy(&w, SIGNAL(returnPressed(QString))); QSignalSpy comboActivatedSpy(&w, SIGNAL(activated(QString))); - QTest::keyClicks(&w, "Hello world"); + QTest::keyClicks(&w, QStringLiteral("Hello world")); QTest::keyClick(&w, Qt::Key_Return); qApp->processEvents(); // QueuedConnection in KHistoryComboBox QCOMPARE(comboReturnPressedSpy.count(), 1); @@ -93,7 +97,7 @@ { KHistoryComboBox w; QStringList items; - items << "One" << "Two" << "Three" << "Four"; + items << QStringLiteral("One") << QStringLiteral("Two") << QStringLiteral("Three") << QStringLiteral("Four"); w.addItems(items); QSignalSpy currentIndexChangedSpy(&w, SIGNAL(currentIndexChanged(int))); w.completionObject()->setItems(items); @@ -108,7 +112,7 @@ { KHistoryComboBox combo; // uic generates code like this, let's make sure it compiles - combo.insertItems(0, QStringList() << "foo"); + combo.insertItems(0, QStringList() << QStringLiteral("foo")); } void testHistoryComboReset() @@ -117,7 +121,7 @@ //TODO: Finish KHistoryComboBox combo; QStringList items; - items << "One" << "Two"; + items << QStringLiteral("One") << QStringLiteral("Two"); combo.addItems(items); combo.reset(); } @@ -132,12 +136,72 @@ delete testCombo; // not needed anymore } + void testLineEditCompletion() + { + QFETCH(bool, editable); + QPointer completion; + QPointer lineEdit, lineEdit2; + + { + // Test for KCombo's KLineEdit inheriting the completion object of the parent + KTestComboBox testCombo(editable, nullptr); + + // we only have a line edit when we are editable already + QCOMPARE(static_cast(testCombo.lineEdit()), editable); + + // we can always get a completion object + // NOTE: for an editable combo, this refers to the completion object of + // the internal line edit + // NOTE: for a not-yet-editable combo, this refers to the completion object + // that belongs to the combo directly + completion = testCombo.completionObject(); + QVERIFY(completion); + + // make editable + testCombo.setEditable(true); + QVERIFY(completion); // completion is still alive + + // verify that the completion object was set on the line edit + lineEdit = qobject_cast(testCombo.lineEdit()); + QVERIFY(lineEdit); + QVERIFY(lineEdit->compObj()); + QCOMPARE(lineEdit->compObj(), completion.data()); + QCOMPARE(testCombo.completionObject(), completion.data()); + + // don't lose the completion and don't crash when we set a new line edit + // NOTE: only reuse the completion when it belongs to the combo box + lineEdit2 = new KLineEdit(&testCombo); + QVERIFY(!lineEdit2->compObj()); + testCombo.setLineEdit(lineEdit2); + QVERIFY(!lineEdit); // first line edit got deleted now + if (editable) { + QVERIFY(!completion); // got deleted with the line edit + // but we get a new one from the second line edit + completion = testCombo.completionObject(); + } + QVERIFY(completion); + QCOMPARE(lineEdit2->compObj(), completion.data()); + QCOMPARE(testCombo.completionObject(), completion.data()); + } + + // ensure nothing gets leaked + QVERIFY(!completion); + QVERIFY(!lineEdit2); + } + + void testLineEditCompletion_data() + { + QTest::addColumn("editable"); + QTest::newRow("deferred-editable") << false; + QTest::newRow("editable") << true; + } + void testSelectionResetOnReturn() { // void QComboBoxPrivate::_q_returnPressed() calls lineEdit->deselect() KHistoryComboBox *testCombo = new KHistoryComboBox(true, nullptr); QCOMPARE(testCombo->insertPolicy(), QComboBox::NoInsert); // not the Qt default; KHistoryComboBox changes that - QTest::keyClicks(testCombo, "Hello world"); + QTest::keyClicks(testCombo, QStringLiteral("Hello world")); testCombo->lineEdit()->setSelection(5, 3); QVERIFY(testCombo->lineEdit()->hasSelectedText()); QTest::keyClick(testCombo, Qt::Key_Return); diff -Nru kcompletion-5.40.0/autotests/klineedit_unittest.cpp kcompletion-5.41.0/autotests/klineedit_unittest.cpp --- kcompletion-5.40.0/autotests/klineedit_unittest.cpp 2017-11-05 08:25:41.000000000 +0000 +++ kcompletion-5.41.0/autotests/klineedit_unittest.cpp 2017-12-06 10:15:37.000000000 +0000 @@ -41,7 +41,7 @@ void testReturnPressed() { KLineEdit w; - w.setText("Hello world"); + w.setText(QStringLiteral("Hello world")); QSignalSpy qReturnPressedSpy(&w, SIGNAL(returnPressed())); QSignalSpy kReturnPressedSpy(&w, SIGNAL(returnPressed(QString))); QTest::keyClick(&w, Qt::Key_Return); @@ -61,7 +61,7 @@ #ifndef KCOMPLETION_NO_DEPRECATED QSignalSpy userTextChangedSpy(&w, SIGNAL(userTextChanged(QString))); #endif - w.setText("Hello worl"); + w.setText(QStringLiteral("Hello worl")); #ifndef KCOMPLETION_NO_DEPRECATED QCOMPARE(userTextChangedSpy.count(), 1); QCOMPARE(userTextChangedSpy[0][0].toString(), w.text()); @@ -89,7 +89,7 @@ QCOMPARE(textEditedSpy[0][0].toString(), w.text()); QVERIFY(w.isModified()); - w.setText("K"); // prepare for next test + w.setText(QStringLiteral("K")); // prepare for next test #ifndef KCOMPLETION_NO_DEPRECATED userTextChangedSpy.clear(); #endif @@ -102,7 +102,7 @@ KCompletion completion; completion.setSoundsEnabled(false); QStringList items; - items << "KDE is cool" << "KDE is really cool"; + items << QStringLiteral("KDE is cool") << QStringLiteral("KDE is really cool"); completion.setItems(items); w.setCompletionObject(&completion); @@ -143,7 +143,7 @@ // Now with popup completion w.setCompletionMode(KCompletion::CompletionPopup); - w.setText("KDE"); + w.setText(QStringLiteral("KDE")); QVERIFY(!w.isModified()); #ifndef KCOMPLETION_NO_DEPRECATED userTextChangedSpy.clear(); @@ -188,7 +188,7 @@ #endif // Now when using the mouse in the popup completion - w.setText("KDE"); + w.setText(QStringLiteral("KDE")); w.doCompletion(w.text()); // popup appears QCOMPARE(w.text(), QString::fromLatin1("KDE")); // Selecting an item in the popup completion changes the lineedit text and emits all 3 signals @@ -203,13 +203,13 @@ void testCompletionBox() { KLineEdit w; - w.setText("/"); + w.setText(QStringLiteral("/")); w.setCompletionMode(KCompletion::CompletionPopup); KCompletion completion; completion.setSoundsEnabled(false); w.setCompletionObject(&completion); QStringList items; - items << "/home/" << "/hold/" << "/hole/"; + items << QStringLiteral("/home/") << QStringLiteral("/hold/") << QStringLiteral("/hole/"); completion.setItems(items); QTest::keyClick(&w, 'h'); QCOMPARE(w.text(), QString::fromLatin1("/h")); @@ -230,7 +230,7 @@ QCOMPARE(w.text(), items.at(0)); QStringList newItems; - newItems << "/home/kde"; + newItems << QStringLiteral("/home/kde"); completion.setItems(newItems); QTest::keyClick(&w, 'k'); QCOMPARE(w.text(), QString("/home/k")); @@ -243,10 +243,10 @@ void testPaste() { const QString origText = QApplication::clipboard()->text(); - const QString pastedText = "Test paste from klineedit_unittest"; + const QString pastedText = QStringLiteral("Test paste from klineedit_unittest"); QApplication::clipboard()->setText(pastedText); KLineEdit w; - w.setText("Hello world"); + w.setText(QStringLiteral("Hello world")); w.selectAll(); QTest::keyClick(&w, Qt::Key_V, Qt::ControlModifier); QCOMPARE(w.text(), pastedText); diff -Nru kcompletion-5.40.0/CMakeLists.txt kcompletion-5.41.0/CMakeLists.txt --- kcompletion-5.40.0/CMakeLists.txt 2017-11-05 08:25:41.000000000 +0000 +++ kcompletion-5.41.0/CMakeLists.txt 2017-12-06 10:15:37.000000000 +0000 @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.0) -set(KF5_VERSION "5.40.0") # handled by release scripts -set(KF5_DEP_VERSION "5.40.0") # handled by release scripts +set(KF5_VERSION "5.41.0") # handled by release scripts +set(KF5_DEP_VERSION "5.41.0") # handled by release scripts project(KCompletion VERSION ${KF5_VERSION}) # ECM setup include(FeatureSummary) -find_package(ECM 5.40.0 NO_MODULE) +find_package(ECM 5.41.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) diff -Nru kcompletion-5.40.0/debian/changelog kcompletion-5.41.0/debian/changelog --- kcompletion-5.40.0/debian/changelog 2017-11-24 17:15:19.000000000 +0000 +++ kcompletion-5.41.0/debian/changelog 2017-12-11 04:03:31.000000000 +0000 @@ -1,3 +1,9 @@ +kcompletion (5.41.0-0ubuntu1) bionic; urgency=low + + * New upstream release (5.41.0) + + -- Walter Lapchynski Sun, 10 Dec 2017 22:03:31 -0600 + kcompletion (5.40.0-0ubuntu1) bionic; urgency=medium * New upstream release (5.39.0) diff -Nru kcompletion-5.40.0/debian/control kcompletion-5.41.0/debian/control --- kcompletion-5.40.0/debian/control 2017-11-24 17:15:19.000000000 +0000 +++ kcompletion-5.41.0/debian/control 2017-12-11 04:03:31.000000000 +0000 @@ -5,9 +5,9 @@ Uploaders: Maximiliano Curia Build-Depends: cmake (>= 2.8.12), debhelper (>= 9), - extra-cmake-modules (>= 5.40.0~), - libkf5config-dev (>= 5.40.0~), - libkf5widgetsaddons-dev (>= 5.40.0~), + extra-cmake-modules (>= 5.41.0~), + libkf5config-dev (>= 5.41.0~), + libkf5widgetsaddons-dev (>= 5.41.0~), pkg-kde-tools (>= 0.15.15ubuntu1~), qtbase5-dev (>= 5.6.1~), qttools5-dev (>= 5.6.1~), @@ -33,8 +33,8 @@ Architecture: any Section: libdevel Depends: libkf5completion5 (= ${binary:Version}), - libkf5config-dev (>= 5.40.0~), - libkf5widgetsaddons-dev (>= 5.40.0~), + libkf5config-dev (>= 5.41.0~), + libkf5widgetsaddons-dev (>= 5.41.0~), ${misc:Depends} Description: development files for kcompletion KCompletion provides widgets with advanced completion support as well as a diff -Nru kcompletion-5.40.0/po/fr/kcompletion5_qt.po kcompletion-5.41.0/po/fr/kcompletion5_qt.po --- kcompletion-5.40.0/po/fr/kcompletion5_qt.po 2017-11-05 08:25:41.000000000 +0000 +++ kcompletion-5.41.0/po/fr/kcompletion5_qt.po 2017-12-06 10:15:37.000000000 +0000 @@ -24,10 +24,10 @@ "PO-Revision-Date: 2014-03-16 18:32+0100\n" "Last-Translator: Sebastien Renard \n" "Language-Team: French \n" +"Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" "X-Generator: Lokalize 1.5\n" "X-Environment: kde\n" diff -Nru kcompletion-5.40.0/src/kcombobox.cpp kcompletion-5.41.0/src/kcombobox.cpp --- kcompletion-5.40.0/src/kcombobox.cpp 2017-11-05 08:25:41.000000000 +0000 +++ kcompletion-5.41.0/src/kcombobox.cpp 2017-12-06 10:15:37.000000000 +0000 @@ -311,10 +311,18 @@ edit = kedit; } + // reuse an existing completion object, if it does not belong to the previous + // line edit and gets destroyed with it + QPointer completion = compObj(); + QComboBox::setLineEdit(edit); d->klineEdit = qobject_cast(edit); setDelegate(d->klineEdit); + if (completion && d->klineEdit) { + d->klineEdit->setCompletionObject(completion); + } + // Connect the returnPressed signal for both Q[K]LineEdits' if (edit) { connect(edit, SIGNAL(returnPressed()), SIGNAL(returnPressed())); @@ -382,6 +390,10 @@ void KComboBox::setEditable(bool editable) { + if (editable == isEditable()) { + return; + } + if (editable) { // Create a KLineEdit instead of a QLineEdit // Compared to QComboBox::setEditable, we might be missing the SH_ComboBox_Popup code though... diff -Nru kcompletion-5.40.0/src/kcombobox.h kcompletion-5.41.0/src/kcombobox.h --- kcompletion-5.40.0/src/kcombobox.h 2017-11-05 08:25:41.000000000 +0000 +++ kcompletion-5.41.0/src/kcombobox.h 2017-12-06 10:15:37.000000000 +0000 @@ -138,7 +138,7 @@ * combo->setKeyBinding(KCompletionBase::TextCompletion, Qt::End); * \endcode * - * \image html kcombobox.png "KDE Combo Boxes, one non-editable, one editable with KUrlCompletion" + * \image html kcombobox.png "KComboBox widgets, one non-editable, one editable with KUrlCompletion" * * @author Dawit Alemayehu */ diff -Nru kcompletion-5.40.0/src/khistorycombobox.h kcompletion-5.41.0/src/khistorycombobox.h --- kcompletion-5.40.0/src/khistorycombobox.h 2017-11-05 08:25:41.000000000 +0000 +++ kcompletion-5.41.0/src/khistorycombobox.h 2017-12-06 10:15:37.000000000 +0000 @@ -45,7 +45,7 @@ * duplicates will be disabled when HISTCONTROL is set to "ignoredups" or * "ignoreboth". Otherwise, duplicates are enabled by default. * - * \image html khistorycombobox.png "KDE History Combo Box" + * \image html khistorycombobox.png "KHistoryComboBox widget" * * @author Carsten Pfeiffer */ diff -Nru kcompletion-5.40.0/src/klineedit.h kcompletion-5.41.0/src/klineedit.h --- kcompletion-5.40.0/src/klineedit.h 2017-11-05 08:25:41.000000000 +0000 +++ kcompletion-5.41.0/src/klineedit.h 2017-12-06 10:15:37.000000000 +0000 @@ -145,7 +145,7 @@ * edit->useGlobalKeyBindings(); * \endcode * - * \image html klineedit.png "KDE Line Edit Widgets with clear-button" + * \image html klineedit.png "KLineEdit widgets with clear-button" * * @author Dawit Alemayehu */ diff -Nru kcompletion-5.40.0/tests/kcomboboxtest.cpp kcompletion-5.41.0/tests/kcomboboxtest.cpp --- kcompletion-5.40.0/tests/kcomboboxtest.cpp 2017-11-05 08:25:41.000000000 +0000 +++ kcompletion-5.41.0/tests/kcomboboxtest.cpp 2017-12-06 10:15:37.000000000 +0000 @@ -23,12 +23,12 @@ // Qt combobox QHBoxLayout *hbox = new QHBoxLayout(); - QLabel *lbl = new QLabel("&QCombobox:", this); + QLabel *lbl = new QLabel(QStringLiteral("&QCombobox:"), this); lbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); hbox->addWidget(lbl); m_qc = new QComboBox(this); - m_qc->setObjectName(QLatin1String("QtReadOnlyCombo")); + m_qc->setObjectName(QStringLiteral("QtReadOnlyCombo")); lbl->setBuddy(m_qc); connectComboSignals(m_qc); hbox->addWidget(m_qc); @@ -37,12 +37,12 @@ // Read-only combobox hbox = new QHBoxLayout(); - lbl = new QLabel("&Read-Only Combo:", this); + lbl = new QLabel(QStringLiteral("&Read-Only Combo:"), this); lbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); hbox->addWidget(lbl); m_ro = new KComboBox(this); - m_ro->setObjectName("ReadOnlyCombo"); + m_ro->setObjectName(QStringLiteral("ReadOnlyCombo")); lbl->setBuddy(m_ro); m_ro->setCompletionMode(KCompletion::CompletionAuto); connectComboSignals(m_ro); @@ -52,12 +52,12 @@ // Read-write combobox hbox = new QHBoxLayout(); - lbl = new QLabel("&Editable Combo:", this); + lbl = new QLabel(QStringLiteral("&Editable Combo:"), this); lbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); hbox->addWidget(lbl); m_rw = new KComboBox(true, this); - m_rw->setObjectName("ReadWriteCombo"); + m_rw->setObjectName(QStringLiteral("ReadWriteCombo")); lbl->setBuddy(m_rw); m_rw->setDuplicatesEnabled(true); m_rw->setInsertPolicy(QComboBox::NoInsert); @@ -68,12 +68,12 @@ // History combobox... hbox = new QHBoxLayout(); - lbl = new QLabel("&History Combo:", this); + lbl = new QLabel(QStringLiteral("&History Combo:"), this); lbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); hbox->addWidget(lbl); m_hc = new KHistoryComboBox(this); - m_hc->setObjectName("HistoryCombo"); + m_hc->setObjectName(QStringLiteral("HistoryCombo")); lbl->setBuddy(m_hc); m_hc->setDuplicatesEnabled(true); m_hc->setInsertPolicy(QComboBox::NoInsert); @@ -84,12 +84,12 @@ // Read-write combobox that is a replica of code in konqueror... hbox = new QHBoxLayout(); - lbl = new QLabel("&Konq's Combo:", this); + lbl = new QLabel(QStringLiteral("&Konq's Combo:"), this); lbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); hbox->addWidget(lbl); m_konqc = new KComboBox(true, this); - m_konqc->setObjectName("KonqyCombo"); + m_konqc->setObjectName(QStringLiteral("KonqyCombo")); lbl->setBuddy(m_konqc); m_konqc->setMaxCount(10); connectComboSignals(m_konqc); @@ -98,12 +98,12 @@ // Create an exit button hbox = new QHBoxLayout(); - m_btnExit = new QPushButton("E&xit", this); + m_btnExit = new QPushButton(QStringLiteral("E&xit"), this); QObject::connect(m_btnExit, &QAbstractButton::clicked, this, &KComboBoxTest::quitApp); hbox->addWidget(m_btnExit); // Create a disable button... - m_btnEnable = new QPushButton("Disa&ble", this); + m_btnEnable = new QPushButton(QStringLiteral("Disa&ble"), this); QObject::connect(m_btnEnable, &QAbstractButton::clicked, this, &KComboBoxTest::slotDisable); hbox->addWidget(m_btnEnable); @@ -111,8 +111,8 @@ // Popuplate the select-only list box QStringList list; - list << "Stone" << "Tree" << "Peables" << "Ocean" << "Sand" << "Chips" - << "Computer" << "Mankind"; + list << QStringLiteral("Stone") << QStringLiteral("Tree") << QStringLiteral("Peables") << QStringLiteral("Ocean") << QStringLiteral("Sand") << QStringLiteral("Chips") + << QStringLiteral("Computer") << QStringLiteral("Mankind"); list.sort(); // Setup the qcombobox @@ -128,10 +128,10 @@ // Setup history combo m_hc->addItems(list); - m_hc->completionObject()->setItems(list + QStringList() << "One" << "Two" << "Three"); + m_hc->completionObject()->setItems(list + QStringList() << QStringLiteral("One") << QStringLiteral("Two") << QStringLiteral("Three")); // Setup konq's combobox - KConfig historyConfig("konq_history", KConfig::SimpleConfig); + KConfig historyConfig(QStringLiteral("konq_history"), KConfig::SimpleConfig); KConfigGroup cg(&historyConfig, "Location Bar"); KCompletion *s_pCompletion = new KCompletion; s_pCompletion->setOrder(KCompletion::Weighted); @@ -141,7 +141,7 @@ QPixmap pix(16, 16); pix.fill(Qt::blue); - m_konqc->addItem(pix, "http://www.kde.org"); + m_konqc->addItem(pix, QStringLiteral("http://www.kde.org")); m_konqc->setCurrentIndex(m_konqc->count() - 1); m_timer = new QTimer(this); @@ -181,9 +181,9 @@ bool enabled = m_ro->isEnabled(); if (enabled) { - m_btnEnable->setText("Ena&ble"); + m_btnEnable->setText(QStringLiteral("Ena&ble")); } else { - m_btnEnable->setText("Disa&ble"); + m_btnEnable->setText(QStringLiteral("Disa&ble")); } m_qc->setEnabled(!enabled); @@ -232,7 +232,7 @@ int main(int argc, char **argv) { - QApplication::setApplicationName("kcomboboxtest"); + QApplication::setApplicationName(QStringLiteral("kcomboboxtest")); QApplication a(argc, argv); diff -Nru kcompletion-5.40.0/tests/klineedittest.cpp kcompletion-5.41.0/tests/klineedittest.cpp --- kcompletion-5.40.0/tests/klineedittest.cpp 2017-11-05 08:25:41.000000000 +0000 +++ kcompletion-5.41.0/tests/klineedittest.cpp 2017-12-06 10:15:37.000000000 +0000 @@ -18,13 +18,13 @@ QVBoxLayout *layout = new QVBoxLayout(this); QStringList list; - list << "Tree" << "Suuupa" << "Stroustrup" << "Stone" << "Slick" - << "Slashdot" << "Send" << "Peables" << "Mankind" << "Ocean" - << "Chips" << "Computer" << "Sandworm" << "Sandstorm" << "Chops"; + list << QStringLiteral("Tree") << QStringLiteral("Suuupa") << QStringLiteral("Stroustrup") << QStringLiteral("Stone") << QStringLiteral("Slick") + << QStringLiteral("Slashdot") << QStringLiteral("Send") << QStringLiteral("Peables") << QStringLiteral("Mankind") << QStringLiteral("Ocean") + << QStringLiteral("Chips") << QStringLiteral("Computer") << QStringLiteral("Sandworm") << QStringLiteral("Sandstorm") << QStringLiteral("Chops"); list.sort(); m_lineedit = new KLineEdit(this); - m_lineedit->setObjectName("klineedittest"); + m_lineedit->setObjectName(QStringLiteral("klineedittest")); m_lineedit->completionObject()->setItems(list); m_lineedit->setSqueezedTextEnabled(true); m_lineedit->setClearButtonShown(true); @@ -34,42 +34,42 @@ QHBoxLayout *restrictedHBox = new QHBoxLayout; m_restrictedLine = new KLineEdit(this); - QRegExp regex(QString::fromUtf8("[aeiouyé]*")); + QRegExp regex(QStringLiteral("[aeiouyé]*")); QRegExpValidator *validator = new QRegExpValidator(regex, m_restrictedLine); m_restrictedLine->setValidator(validator); //connect(m_restrictedLine, SIGNAL(invalidChar(int)), this, SLOT(slotInvalidChar(int))); connect(m_restrictedLine, SIGNAL(returnPressed()), SLOT(slotReturnPressed())); connect(m_restrictedLine, SIGNAL(returnPressed(QString)), SLOT(slotReturnPressed(QString))); - restrictedHBox->addWidget(new QLabel("Vowels only:", this)); + restrictedHBox->addWidget(new QLabel(QStringLiteral("Vowels only:"), this)); restrictedHBox->addWidget(m_restrictedLine); m_invalidCharLabel = new QLabel(this); restrictedHBox->addWidget(m_invalidCharLabel); // horizontal button layout - m_btnExit = new QPushButton("E&xit", this); + m_btnExit = new QPushButton(QStringLiteral("E&xit"), this); connect(m_btnExit, &QAbstractButton::clicked, this, &KLineEditTest::quitApp); - m_btnReadOnly = new QPushButton("&Read Only", this); + m_btnReadOnly = new QPushButton(QStringLiteral("&Read Only"), this); m_btnReadOnly->setCheckable(true); connect(m_btnReadOnly, &QAbstractButton::toggled, this, &KLineEditTest::slotReadOnly); - m_btnPassword = new QPushButton("&Password", this); + m_btnPassword = new QPushButton(QStringLiteral("&Password"), this); m_btnPassword->setCheckable(true); connect(m_btnPassword, &QAbstractButton::toggled, this, &KLineEditTest::slotPassword); - m_btnEnable = new QPushButton("Dis&able", this); + m_btnEnable = new QPushButton(QStringLiteral("Dis&able"), this); m_btnEnable->setCheckable(true); connect(m_btnEnable, &QAbstractButton::toggled, this, &KLineEditTest::slotEnable); - m_btnHide = new QPushButton("Hi&de", this); + m_btnHide = new QPushButton(QStringLiteral("Hi&de"), this); connect(m_btnHide, &QAbstractButton::clicked, this, &KLineEditTest::slotHide); - m_btnPlaceholderText = new QPushButton("Place Holder Text", this); + m_btnPlaceholderText = new QPushButton(QStringLiteral("Place Holder Text"), this); m_btnPlaceholderText->setCheckable(true); connect(m_btnPlaceholderText, &QAbstractButton::toggled, this, &KLineEditTest::slotPlaceholderText); - QPushButton *btnStyle = new QPushButton("Stylesheet", this); + QPushButton *btnStyle = new QPushButton(QStringLiteral("Stylesheet"), this); connect(btnStyle, &QAbstractButton::clicked, this, &KLineEditTest::slotSetStyleSheet); QHBoxLayout *buttonLayout = new QHBoxLayout(); @@ -84,7 +84,7 @@ layout->addWidget(m_lineedit); layout->addLayout(restrictedHBox); layout->addLayout(buttonLayout); - setWindowTitle("KLineEdit Unit Test"); + setWindowTitle(QStringLiteral("KLineEdit Unit Test")); } KLineEditTest::~KLineEditTest() @@ -98,7 +98,7 @@ void KLineEditTest::slotSetStyleSheet() { - m_lineedit->setStyleSheet("QLineEdit{ background-color:#baf9ce }"); + m_lineedit->setStyleSheet(QStringLiteral("QLineEdit{ background-color:#baf9ce }")); } void KLineEditTest::show() @@ -151,8 +151,8 @@ void KLineEditTest::slotPlaceholderText(bool click) { if (click) { - m_lineedit->setText(""); // Clear before to add message - m_lineedit->setPlaceholderText("Click in this lineedit"); + m_lineedit->setText(QLatin1String("")); // Clear before to add message + m_lineedit->setPlaceholderText(QStringLiteral("Click in this lineedit")); } } @@ -167,7 +167,7 @@ void KLineEditTest::slotInvalidChar(int key) { - m_invalidCharLabel->setText(QString("Invalid char: %1").arg(key)); + m_invalidCharLabel->setText(QStringLiteral("Invalid char: %1").arg(key)); } int main(int argc, char **argv)