summaryrefslogtreecommitdiffstats
path: root/src/designer/src/lib/shared/formlayoutmenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/designer/src/lib/shared/formlayoutmenu.cpp')
-rw-r--r--src/designer/src/lib/shared/formlayoutmenu.cpp75
1 files changed, 23 insertions, 52 deletions
diff --git a/src/designer/src/lib/shared/formlayoutmenu.cpp b/src/designer/src/lib/shared/formlayoutmenu.cpp
index f4b9255ff..0c7313770 100644
--- a/src/designer/src/lib/shared/formlayoutmenu.cpp
+++ b/src/designer/src/lib/shared/formlayoutmenu.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Designer of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "formlayoutmenu_p.h"
#include "layoutinfo_p.h"
@@ -56,14 +31,16 @@
#include <QtCore/qhash.h>
#include <QtCore/qdebug.h>
-static const char *buddyPropertyC = "buddy";
+QT_BEGIN_NAMESPACE
+
+using namespace Qt::StringLiterals;
+
+static constexpr auto buddyPropertyC = "buddy"_L1;
static const char *fieldWidgetBaseClasses[] = {
"QLineEdit", "QComboBox", "QSpinBox", "QDoubleSpinBox", "QCheckBox",
"QDateEdit", "QTimeEdit", "QDateTimeEdit", "QDial", "QWidget"
};
-QT_BEGIN_NAMESPACE
-
namespace qdesigner_internal {
// Struct that describes a row of controls (descriptive label and control) to
@@ -118,7 +95,7 @@ private:
// Check for buddy marker in string
const QRegularExpression m_buddyMarkerRegexp;
- Ui::FormLayoutRowDialog m_ui;
+ QT_PREPEND_NAMESPACE(Ui)::FormLayoutRowDialog m_ui;
bool m_labelNameEdited;
bool m_fieldNameEdited;
bool m_buddyClicked;
@@ -127,19 +104,18 @@ private:
FormLayoutRowDialog::FormLayoutRowDialog(QDesignerFormEditorInterface *core,
QWidget *parent) :
QDialog(parent),
- m_buddyMarkerRegexp(QStringLiteral("\\&[^&]")),
+ m_buddyMarkerRegexp(u"\\&[^&]"_s),
m_labelNameEdited(false),
m_fieldNameEdited(false),
m_buddyClicked(false)
{
Q_ASSERT(m_buddyMarkerRegexp.isValid());
- setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setModal(true);
m_ui.setupUi(this);
connect(m_ui.labelTextLineEdit, &QLineEdit::textEdited, this, &FormLayoutRowDialog::labelTextEdited);
- QRegularExpressionValidator *nameValidator = new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^[a-zA-Z0-9_]+$")), this);
+ auto *nameValidator = new QRegularExpressionValidator(QRegularExpression(u"^[a-zA-Z0-9_]+$"_s), this);
Q_ASSERT(nameValidator->regularExpression().isValid());
m_ui.labelNameLineEdit->setValidator(nameValidator);
@@ -240,11 +216,11 @@ void FormLayoutRowDialog::labelTextEdited(const QString &text)
// "namespace::QLineEdit"->"LineEdit"
static inline QString postFixFromClassName(QString className)
{
- const int index = className.lastIndexOf(QStringLiteral("::"));
+ const int index = className.lastIndexOf("::"_L1);
if (index != -1)
className.remove(0, index + 2);
if (className.size() > 2)
- if (className.at(0) == QLatin1Char('Q') || className.at(0) == QLatin1Char('K'))
+ if (className.at(0) == u'Q' || className.at(0) == u'K')
if (className.at(1).isUpper())
className.remove(0, 1);
return className;
@@ -290,10 +266,8 @@ static inline PrefixCharacterKind prefixCharacterKind(const QChar &c)
static QString prefixFromLabel(const QString &prefix)
{
QString rc;
- const int length = prefix.size();
bool lastWasAcceptable = false;
- for (int i = 0 ; i < length; i++) {
- const QChar c = prefix.at(i);
+ for (const QChar &c : prefix) {
const PrefixCharacterKind kind = prefixCharacterKind(c);
const bool acceptable = kind != PC_Invalid;
if (acceptable) {
@@ -323,7 +297,7 @@ void FormLayoutRowDialog::updateObjectNames(bool updateLabel, bool updateField)
const QString prefix = prefixFromLabel(labelText());
// Set names
if (doUpdateLabel)
- m_ui.labelNameLineEdit->setText(prefix + QStringLiteral("Label"));
+ m_ui.labelNameLineEdit->setText(prefix + "Label"_L1);
if (doUpdateField)
m_ui.fieldNameLineEdit->setText(prefix + postFixFromClassName(fieldClass()));
}
@@ -356,19 +330,16 @@ void FormLayoutRowDialog::buddyClicked()
* from them ("QLineEdit", "CustomLineEdit", "QComboBox"...). */
QStringList FormLayoutRowDialog::fieldWidgetClasses(QDesignerFormEditorInterface *core)
{
- // Base class -> custom widgets map
- typedef QMultiHash<QString, QString> ClassMap;
-
static QStringList rc;
if (rc.isEmpty()) {
// Turn known base classes into list
QStringList baseClasses;
for (auto fw : fieldWidgetBaseClasses)
- baseClasses.append(QLatin1String(fw));
+ baseClasses.append(QLatin1StringView(fw));
// Scan for custom widgets that inherit them and store them in a
// multimap of base class->custom widgets unless we have a language
// extension installed which might do funny things with custom widgets.
- ClassMap customClassMap;
+ QMultiHash<QString, QString> customClassMap; // Base class -> custom widgets map
if (qt_extension<QDesignerLanguageExtension *>(core->extensionManager(), core) == nullptr) {
const QDesignerWidgetDataBaseInterface *wdb = core->widgetDataBase();
const int wdbCount = wdb->count();
@@ -405,23 +376,23 @@ static QFormLayout *managedFormLayout(const QDesignerFormEditorInterface *core,
// Create the widgets of a control row and apply text properties contained
// in the struct, called by addFormLayoutRow()
-static QPair<QWidget *,QWidget *>
+static std::pair<QWidget *,QWidget *>
createWidgets(const FormLayoutRow &row, QWidget *parent,
QDesignerFormWindowInterface *formWindow)
{
QDesignerFormEditorInterface *core = formWindow->core();
QDesignerWidgetFactoryInterface *wf = core->widgetFactory();
- QPair<QWidget *,QWidget *> rc = QPair<QWidget *,QWidget *>(wf->createWidget(QStringLiteral("QLabel"), parent),
- wf->createWidget(row.fieldClassName, parent));
+ std::pair<QWidget *,QWidget *> rc{wf->createWidget(u"QLabel"_s, parent),
+ wf->createWidget(row.fieldClassName, parent)};
// Set up properties of the label
- const QString objectNameProperty = QStringLiteral("objectName");
+ const QString objectNameProperty = u"objectName"_s;
QDesignerPropertySheetExtension *labelSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), rc.first);
int nameIndex = labelSheet->indexOf(objectNameProperty);
labelSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.labelName)));
labelSheet->setChanged(nameIndex, true);
formWindow->ensureUniqueObjectName(rc.first);
- const int textIndex = labelSheet->indexOf(QStringLiteral("text"));
+ const int textIndex = labelSheet->indexOf(u"text"_s);
labelSheet->setProperty(textIndex, QVariant::fromValue(PropertySheetStringValue(row.labelText)));
labelSheet->setChanged(textIndex, true);
// Set up properties of the control
@@ -445,7 +416,7 @@ static void addFormLayoutRow(const FormLayoutRow &formLayoutRow, int row, QWidge
undoStack->beginMacro(macroName);
// Create a list of widget insertion commands and pass them a cell position
- const QPair<QWidget *,QWidget *> widgetPair = createWidgets(formLayoutRow, w, formWindow);
+ const auto widgetPair = createWidgets(formLayoutRow, w, formWindow);
InsertWidgetCommand *labelCmd = new InsertWidgetCommand(formWindow);
labelCmd->init(widgetPair.first, false, row, 0);
@@ -455,7 +426,7 @@ static void addFormLayoutRow(const FormLayoutRow &formLayoutRow, int row, QWidge
undoStack->push(controlCmd);
if (formLayoutRow.buddy) {
SetPropertyCommand *buddyCommand = new SetPropertyCommand(formWindow);
- buddyCommand->init(widgetPair.first, QLatin1String(buddyPropertyC), widgetPair.second->objectName());
+ buddyCommand->init(widgetPair.first, buddyPropertyC, widgetPair.second->objectName());
undoStack->push(buddyCommand);
}
undoStack->endMacro();