[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
src/klftools/klfprogerr.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002  *   file klfprogerr.cpp
00003  *   This file is part of the KLatexFormula Project.
00004  *   Copyright (C) 2014 by Philippe Faist
00005  *   philippe.faist at bluewin.ch
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************/
00022 /* $Id$ */
00023 
00024 #include <QRegExp>
00025 #include <QSizePolicy>
00026 
00027 #include "klfprogerr.h"
00028 
00029 #include "ui_klfprogerr.h"
00030 
00031 
00032 KLFProgErr::KLFProgErr(QWidget *parent, QString errtext)
00033   : QDialog(parent, Qt::Sheet)
00034 {
00035   u = new Ui::KLFProgErr;
00036   u->setupUi(this);
00037   setObjectName("KLFProgErr");
00038 
00039   setWindowModality(Qt::WindowModal);
00040   setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
00041 
00042   u->txtError->setWordWrapMode(QTextOption::WrapAnywhere);
00043   u->txtError->setText(errtext);
00044 }
00045 
00046 QTextEdit * KLFProgErr::textEditWidget()
00047 {
00048   return u->txtError;
00049 }
00050 
00051 
00052 KLFProgErr::~KLFProgErr()
00053 {
00054   delete u;
00055 }
00056 
00057 void KLFProgErr::showEvent(QShowEvent */*e*/)
00058 {
00059 }
00060 
00061 void KLFProgErr::showError(QWidget *parent, QString errtext)
00062 {
00063   KLFProgErr dlg(parent, errtext);
00064   dlg.exec();
00065 }
00066 
00067 
00068 
00069 // ------------------------------------------------------------------------
00070 
00071 
00072 QString KLFProgErr::extractLatexError(const QString& str)
00073 {
00074   // if it was LaTeX, attempt to parse the error...
00075   QRegExp latexerr("\\n(\\!.*)\\n\\n");
00076   if (latexerr.indexIn(str)) {
00077     QString s = latexerr.cap(1);
00078     s.replace(QRegExp("^([^\\n]+)"), "<b>\\1</b>"); // make first line boldface
00079     return "<pre>"+s+"</pre>";
00080   }
00081   return str;
00082 }
00083 

Generated by doxygen 1.7.6.1. The KLatexFormula website is hosted on sourceforge.net