summaryrefslogtreecommitdiffstats
path: root/src/linguist/linguist/messageeditor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/linguist/linguist/messageeditor.cpp')
-rw-r--r--src/linguist/linguist/messageeditor.cpp79
1 files changed, 30 insertions, 49 deletions
diff --git a/src/linguist/linguist/messageeditor.cpp b/src/linguist/linguist/messageeditor.cpp
index 1a126da7a..ee4a5c70b 100644
--- a/src/linguist/linguist/messageeditor.cpp
+++ b/src/linguist/linguist/messageeditor.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 Linguist 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
/* TRANSLATOR MessageEditor
@@ -107,6 +82,12 @@ MessageEditor::MessageEditor(MultiDataModel *dataModel, QMainWindow *parent)
showNothing();
}
+MessageEditor::~MessageEditor()
+{
+ if (FormatTextEdit *fte = qobject_cast<FormatTextEdit *>(m_selectionHolder))
+ disconnect(fte, &FormatTextEdit::editorDestroyed, this, &MessageEditor::editorDestroyed);
+}
+
void MessageEditor::setupEditorPage()
{
QFrame *editorPage = new QFrame;
@@ -211,7 +192,7 @@ void MessageEditor::messageModelAppended()
void MessageEditor::allModelsDeleted()
{
- for (const MessageEditorData &med : qAsConst(m_editors))
+ for (const MessageEditorData &med : std::as_const(m_editors))
med.container->deleteLater();
m_editors.clear();
m_currentModel = -1;
@@ -255,7 +236,7 @@ void MessageEditor::addPluralForm(int model, const QString &label, bool writable
transEditor->setVisible(false);
transEditor->setMultiEnabled(m_lengthVariants);
static_cast<QBoxLayout *>(m_editors[model].container->layout())->insertWidget(
- m_editors[model].transTexts.count(), transEditor);
+ m_editors[model].transTexts.size(), transEditor);
connect(transEditor, &FormMultiWidget::selectionChanged,
this, &MessageEditor::selectionChanged);
@@ -312,7 +293,7 @@ void MessageEditor::fixTabOrder()
void MessageEditor::reallyFixTabOrder()
{
QWidget *prev = this;
- for (const MessageEditorData &med : qAsConst(m_editors)) {
+ for (const MessageEditorData &med : std::as_const(m_editors)) {
for (FormMultiWidget *fmw : med.transTexts)
for (QTextEdit *te : fmw->getEditors()) {
setTabOrder(prev, te);
@@ -334,7 +315,7 @@ void MessageEditor::reallyFixTabOrder()
QStringList MessageEditor::translations(int model) const
{
QStringList translations;
- for (int i = 0; i < m_editors[model].transTexts.count() &&
+ for (int i = 0; i < m_editors[model].transTexts.size() &&
m_editors[model].transTexts.at(i)->isVisible(); ++i)
translations << m_editors[model].transTexts[i]->getTranslation();
return translations;
@@ -386,7 +367,7 @@ void MessageEditor::resetSelection()
disconnect(fte, &FormatTextEdit::editorDestroyed,
this, &MessageEditor::editorDestroyed);
}
- m_selectionHolder = 0;
+ m_selectionHolder = nullptr;
#ifndef QT_NO_CLIPBOARD
updateCanCutCopy();
#endif
@@ -395,8 +376,8 @@ void MessageEditor::resetSelection()
void MessageEditor::activeModelAndNumerus(int *model, int *numerus) const
{
- for (int j = 0; j < m_editors.count(); ++j) {
- for (int i = 0; i < m_editors[j].transTexts.count(); ++i)
+ for (int j = 0; j < m_editors.size(); ++j) {
+ for (int i = 0; i < m_editors[j].transTexts.size(); ++i)
for (QTextEdit *te : m_editors[j].transTexts[i]->getEditors())
if (m_focusWidget == te) {
*model = j;
@@ -462,11 +443,11 @@ void MessageEditor::setTargetLanguage(int model)
{
const QStringList &numerusForms = m_dataModel->model(model)->numerusForms();
const QString &langLocalized = m_dataModel->model(model)->localizedLanguage();
- for (int i = 0; i < numerusForms.count(); ++i) {
+ for (int i = 0; i < numerusForms.size(); ++i) {
const QString &label = tr("Translation to %1 (%2)").arg(langLocalized, numerusForms[i]);
if (!i)
m_editors[model].firstForm = label;
- if (i >= m_editors[model].transTexts.count())
+ if (i >= m_editors[model].transTexts.size())
addPluralForm(model, label, m_dataModel->isModelWritable(model));
else
m_editors[model].transTexts[i]->setLabel(label);
@@ -475,7 +456,7 @@ void MessageEditor::setTargetLanguage(int model)
tr("This is where you can enter or modify"
" the translation of the above source text.") );
}
- for (int j = m_editors[model].transTexts.count() - numerusForms.count(); j > 0; --j)
+ for (int j = m_editors[model].transTexts.size() - numerusForms.size(); j > 0; --j)
delete m_editors[model].transTexts.takeLast();
m_editors[model].invariantForm = tr("Translation to %1").arg(langLocalized);
m_editors[model].transCommentText->setLabel(tr("Translator comments for %1").arg(langLocalized));
@@ -483,8 +464,8 @@ void MessageEditor::setTargetLanguage(int model)
MessageEditorData *MessageEditor::modelForWidget(const QObject *o)
{
- for (int j = 0; j < m_editors.count(); ++j) {
- for (int i = 0; i < m_editors[j].transTexts.count(); ++i)
+ for (int j = 0; j < m_editors.size(); ++j) {
+ for (int i = 0; i < m_editors[j].transTexts.size(); ++i)
for (QTextEdit *te : m_editors[j].transTexts[i]->getEditors())
if (te == o)
return &m_editors[j];
@@ -566,9 +547,9 @@ void MessageEditor::showNothing()
m_source->clearTranslation();
m_pluralSource->clearTranslation();
m_commentText->clearTranslation();
- for (int j = 0; j < m_editors.count(); ++j) {
+ for (int j = 0; j < m_editors.size(); ++j) {
setEditingEnabled(j, false);
- for (FormMultiWidget *widget : qAsConst(m_editors[j].transTexts))
+ for (FormMultiWidget *widget : std::as_const(m_editors[j].transTexts))
widget->clearTranslation();
m_editors[j].transCommentText->clearTranslation();
}
@@ -627,7 +608,7 @@ void MessageEditor::showMessage(const MultiDataIndex &index)
&& item->message().type() != TranslatorMessage::Vanished);
// Translation label
- ed.pluralEditMode = item->translations().count() > 1;
+ ed.pluralEditMode = item->translations().size() > 1;
ed.transTexts.first()->setLabel(ed.pluralEditMode ? ed.firstForm : ed.invariantForm);
// Translation forms
@@ -638,7 +619,7 @@ void MessageEditor::showMessage(const MultiDataIndex &index)
QStringList normalizedTranslations =
m_dataModel->model(j)->normalizedTranslations(*item);
for (int i = 0; i < ed.transTexts.size(); ++i) {
- bool shouldShow = (i < normalizedTranslations.count());
+ bool shouldShow = (i < normalizedTranslations.size());
if (shouldShow)
setNumerusTranslation(j, normalizedTranslations.at(i), i);
else
@@ -656,7 +637,7 @@ void MessageEditor::showMessage(const MultiDataIndex &index)
void MessageEditor::setNumerusTranslation(int model, const QString &translation, int numerus)
{
MessageEditorData &ed = m_editors[model];
- if (numerus >= ed.transTexts.count())
+ if (numerus >= ed.transTexts.size())
numerus = 0;
FormMultiWidget *transForm = ed.transTexts[numerus];
transForm->setTranslation(translation, false);
@@ -683,7 +664,7 @@ void MessageEditor::setTranslation(int latestModel, const QString &translation)
void MessageEditor::setEditingEnabled(int model, bool enabled)
{
MessageEditorData &ed = m_editors[model];
- for (FormMultiWidget *widget : qAsConst(ed.transTexts))
+ for (FormMultiWidget *widget : std::as_const(ed.transTexts))
widget->setEditingEnabled(enabled);
ed.transCommentText->setEditingEnabled(enabled);
@@ -695,7 +676,7 @@ void MessageEditor::setEditingEnabled(int model, bool enabled)
void MessageEditor::setLengthVariants(bool on)
{
m_lengthVariants = on;
- for (const MessageEditorData &ed : qAsConst(m_editors))
+ for (const MessageEditorData &ed : std::as_const(m_editors))
for (FormMultiWidget *widget : ed.transTexts)
widget->setMultiEnabled(on);
}
@@ -855,7 +836,7 @@ void MessageEditor::setEditorFocusForModel(int model)
bool MessageEditor::focusNextUnfinished(int start)
{
- for (int j = start; j < m_editors.count(); ++j)
+ for (int j = start; j < m_editors.size(); ++j)
if (m_dataModel->isModelWritable(j))
if (MessageItem *item = m_dataModel->messageItem(m_currentIndex, j))
if (item->type() == TranslatorMessage::Unfinished) {
@@ -882,7 +863,7 @@ void MessageEditor::setVisualizeWhitespace(bool value)
m_pluralSource->getEditor()->setVisualizeWhitespace(value);
m_commentText->getEditor()->setVisualizeWhitespace(value);
- for (const MessageEditorData &med : qAsConst(m_editors)) {
+ for (const MessageEditorData &med : std::as_const(m_editors)) {
med.transCommentText->getEditor()->setVisualizeWhitespace(value);
for (FormMultiWidget *widget : med.transTexts)
for (FormatTextEdit *te : widget->getEditors())
@@ -912,7 +893,7 @@ void MessageEditor::applyFontSize()
m_pluralSource->getEditor()->setFont(font);
m_commentText->getEditor()->setFont(font);
- for (const MessageEditorData &med : qAsConst(m_editors)) {
+ for (const MessageEditorData &med : std::as_const(m_editors)) {
for (FormMultiWidget *fmw : med.transTexts)
for (QTextEdit *te : fmw->getEditors())
te->setFont(font);