[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klfprogerr.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * file klfprogerr.cpp
3 * This file is part of the KLatexFormula Project.
4 * Copyright (C) 2014 by Philippe Faist
5 * philippe.faist at bluewin.ch
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
22/* $Id$ */
23
24#include <QRegExp>
25#include <QSizePolicy>
26
27#include "klfprogerr.h"
28
29#include "ui_klfprogerr.h"
30
31
32KLFProgErr::KLFProgErr(QWidget *parent, QString errtext)
33 : QDialog(parent, Qt::Sheet)
34{
35 u = new Ui::KLFProgErr;
36 u->setupUi(this);
37 setObjectName("KLFProgErr");
38
39 setWindowModality(Qt::WindowModal);
40 setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
41
42 u->txtError->setWordWrapMode(QTextOption::WrapAnywhere);
43 u->txtError->setText(errtext);
44}
45
47{
48 return u->txtError;
49}
50
51
53{
54 delete u;
55}
56
58{
59}
60
61void KLFProgErr::showError(QWidget *parent, QString errtext)
62{
63 KLFProgErr dlg(parent, errtext);
64 dlg.exec();
65}
66
67
68
69// ------------------------------------------------------------------------
70
71
73{
74 // if it was LaTeX, attempt to parse the error...
75 QRegExp latexerr("\\n(\\!.*)\\n\\n");
76 if (latexerr.indexIn(str)) {
77 QString s = latexerr.cap(1);
78 s.replace(QRegExp("^([^\\n]+)"), "<b>\\1</b>"); // make first line boldface
79 return "<pre>"+s+"</pre>";
80 }
81 return str;
82}
83
QTextEdit * textEditWidget()
Definition: klfprogerr.cpp:46
virtual void showEvent(QShowEvent *e)
Definition: klfprogerr.cpp:57
KLFProgErr(QWidget *parent, QString errtext)
Definition: klfprogerr.cpp:32
virtual ~KLFProgErr()
Definition: klfprogerr.cpp:52
static QString extractLatexError(const QString &str)
Definition: klfprogerr.cpp:72
static void showError(QWidget *parent, QString text)
Definition: klfprogerr.cpp:61
QString cap(int nth) const
int indexIn(const QString &str, int offset, CaretMode caretMode) const
QString & replace(int position, int n, QChar after)

Generated by doxygen 1.9.6