/* Klat - A LaTeX editor for KDE Copyright (C) 2002-2004 Jori Liesenborgs (jori@lumumba.luc.ac.be) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "klathtmlwidget.h" #include "klathtmlwidget.moc" #include #include #include #define IMGTOKILEPROT "imgtokile" #define IMGTOKLATPROT "imgtoklat" #define TXTTOKLATPROT "txttoklat" KlatHTMLWidget::KlatHTMLWidget(QWidget *parent) : KHTMLPart(parent) { connect(this,SIGNAL(onURL(const QString &)),this,SLOT(onURLslot(const QString &))); } KlatHTMLWidget::~KlatHTMLWidget() { } void KlatHTMLWidget::urlSelected(const QString &url, int button, int state,const QString &_target, KParts::URLArgs args) { KHTMLPart::urlSelected(url,button,state,_target,args); KURL cURL = completeURL(url); if (cURL.protocol() == IMGTOKLATPROT || cURL.protocol() == IMGTOKILEPROT || cURL.protocol() == TXTTOKLATPROT) { QString code=(cURL.url().remove(0,11)); int i,len,advance; bool found; len = code.length(); advance = len; if (code.left(6) == QString("\\begin")) { for (i = 6,found = false ; !found && i < len ; i++) { if (code[i] == '\\') { found = true; advance = i; } } } else { for (i = 0,found = false ; !found && i < len ; i++) { if (code[i] == '{') { found = true; advance = i+1; } } } emit signalSymbolCodeSelected(code,advance); } } void KlatHTMLWidget::openAppDataURL(const QString &relpath) { QString path,urlstr; path = locate("appdata",relpath); urlstr = "file:"; urlstr += path; KURL url(path); if (url.isValid()) openURL(url); } void KlatHTMLWidget::onURLslot(const QString& url) { KURL cURL = completeURL(url); if (cURL.protocol() == IMGTOKLATPROT || cURL.protocol() == IMGTOKILEPROT || cURL.protocol() == TXTTOKLATPROT) { QString code=(cURL.url().remove(0,11)); emit onURLcode(code); } }