Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
errorsview.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#include "errorsview.h"
5
6#include "messagemodel.h"
7
8#include <QtCore/QList>
9#include <QtCore/QString>
10#include <QtCore/QUrl>
11
12#include <QtGui/QStandardItem>
13#include <QtGui/QStandardItemModel>
14#include <QtWidgets/QListView>
15#include <QtWidgets/QTextEdit>
16#include <QtWidgets/QVBoxLayout>
17
19
20ErrorsView::ErrorsView(MultiDataModel *dataModel, QWidget *parent) :
22 m_dataModel(dataModel)
23{
24 m_list = new QStandardItemModel(this);
25 setModel(m_list);
26}
27
29{
30 m_list->clear();
31}
32
33void ErrorsView::addError(int model, const ErrorType type, const QString &arg)
34{
35 switch (type) {
36 case SuperfluousAccelerator:
37 addError(model, tr("Accelerator possibly superfluous in translation."));
38 break;
39 case MissingAccelerator:
40 addError(model, tr("Accelerator possibly missing in translation."));
41 break;
42 case SurroundingWhitespaceDiffers:
43 addError(model, tr("Translation does not have same leading and trailing whitespace as the source text."));
44 break;
45 case PunctuationDiffers:
46 addError(model, tr("Translation does not end with the same punctuation as the source text."));
47 break;
48 case IgnoredPhrasebook:
49 addError(model, tr("A phrase book suggestion for '%1' was ignored.").arg(arg));
50 break;
51 case PlaceMarkersDiffer:
52 addError(model, tr("Translation does not refer to the same place markers as in the source text."));
53 break;
54 case NumerusMarkerMissing:
55 addError(model, tr("Translation does not contain the necessary %n/%Ln place marker."));
56 break;
57 default:
58 addError(model, tr("Unknown error"));
59 break;
60 }
61}
62
64{
65 return (m_list->rowCount() == 0) ? QString() : m_list->item(0)->text();
66}
67
68void ErrorsView::addError(int model, const QString &error)
69{
70 // NOTE: Three statics instead of one just for GCC 3.3.5
71 static QLatin1String imageLocation(":/images/s_check_danger.png");
72 static QPixmap image(imageLocation);
73 static QIcon pxDanger(image);
74 QString lang;
75 if (m_dataModel->modelCount() > 1)
76 lang = m_dataModel->model(model)->localizedLanguage() + QLatin1String(": ");
77 QStandardItem *item = new QStandardItem(pxDanger, lang + error);
78 item->setEditable(false);
79 m_list->appendRow(QList<QStandardItem*>() << item);
80}
81
82QT_END_NAMESPACE
void addError(int model, const ErrorType type, const QString &arg=QString())
QString firstError()
void clear()
DataModel * model(int i)
int modelCount() const
QObject * parent
Definition qobject.h:73
Combined button and popup list for selecting options.