author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt Designer of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "scripterrordialog_p.h" |
|
43 |
||
44 |
#include <QtGui/QTextEdit> |
|
45 |
#include <QtGui/QTextCursor> |
|
46 |
#include <QtGui/QVBoxLayout> |
|
47 |
#include <QtGui/QHBoxLayout> |
|
48 |
#include <QtGui/QDialogButtonBox> |
|
49 |
#include <QtGui/QPen> |
|
50 |
#include <QtCore/QCoreApplication> |
|
51 |
||
52 |
QT_BEGIN_NAMESPACE |
|
53 |
||
54 |
static void formatError(const QFormScriptRunner::Error &error, |
|
55 |
QTextCursor &cursor) |
|
56 |
{ |
|
57 |
const QTextCharFormat oldFormat = cursor.charFormat(); |
|
58 |
// Message |
|
59 |
cursor.insertText(QCoreApplication::translate("ScriptErrorDialog", "An error occurred while running the scripts for \"%1\":\n").arg(error.objectName)); |
|
60 |
||
61 |
QTextCharFormat format(oldFormat); |
|
62 |
||
63 |
// verbatim listing |
|
64 |
format.setFontFamily(QLatin1String("Courier")); |
|
65 |
cursor.insertText(error.script, format); |
|
66 |
||
67 |
const QString newLine(QLatin1Char('\n')); |
|
68 |
||
69 |
cursor.insertText(newLine); |
|
70 |
||
71 |
// red error |
|
72 |
format = oldFormat; |
|
73 |
format.setTextOutline(QPen(Qt::red)); |
|
74 |
cursor.insertText(error.errorMessage, format); |
|
75 |
cursor.insertText(newLine); |
|
76 |
cursor.setCharFormat (oldFormat); |
|
77 |
} |
|
78 |
||
79 |
namespace qdesigner_internal { |
|
80 |
||
81 |
// ScriptErrorDialog |
|
82 |
ScriptErrorDialog::ScriptErrorDialog(const Errors& errors, QWidget *parent) : |
|
83 |
QDialog(parent), |
|
84 |
m_textEdit(new QTextEdit) |
|
85 |
{ |
|
86 |
setWindowTitle(tr("Script errors")); |
|
87 |
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); |
|
88 |
setModal(true); |
|
89 |
||
90 |
QVBoxLayout *vboxLayout = new QVBoxLayout(this); |
|
91 |
||
92 |
m_textEdit->setReadOnly(true); |
|
93 |
m_textEdit->setMinimumSize(QSize(600, 400)); |
|
94 |
vboxLayout->addWidget(m_textEdit); |
|
95 |
// button box |
|
96 |
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); |
|
97 |
connect(buttonBox , SIGNAL(rejected()), this, SLOT(reject())); |
|
98 |
vboxLayout->addWidget(buttonBox); |
|
99 |
||
100 |
// Generate text |
|
101 |
QTextCursor cursor = m_textEdit->textCursor(); |
|
102 |
cursor.movePosition (QTextCursor::End); |
|
103 |
foreach (const QFormScriptRunner::Error error, errors) |
|
104 |
formatError(error, cursor); |
|
105 |
} |
|
106 |
} // namespace qdesigner_internal |
|
107 |
||
108 |
QT_END_NAMESPACE |