KDevelop API Documentation

parts/texttools/texttoolspart.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2002 by Bernd Gehrmann * 00003 * bernd@kdevelop.org * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 ***************************************************************************/ 00011 00012 #include "texttoolspart.h" 00013 00014 #include <qwhatsthis.h> 00015 #include <kdebug.h> 00016 #include <klocale.h> 00017 #include <kdevgenericfactory.h> 00018 #include <ktexteditor/editinterface.h> 00019 00020 #include "kdevpartcontroller.h" 00021 #include "kdevmainwindow.h" 00022 00023 #include "texttoolswidget.h" 00024 00025 00026 typedef KDevGenericFactory<TextToolsPart> TextToolsFactory; 00027 static const KAboutData data("kdevtexttools", I18N_NOOP("Text Structure"), "1.0"); 00028 K_EXPORT_COMPONENT_FACTORY( libkdevtexttools, TextToolsFactory( &data ) ) 00029 00030 TextToolsPart::TextToolsPart(QObject *parent, const char *name, const QStringList &) 00031 : KDevPlugin("TextTools", "texttools", parent, name ? name : "TextToolsPart") 00032 { 00033 setInstance(TextToolsFactory::instance()); 00034 // setXMLFile("kdevfileview.rc"); 00035 00036 m_widget = 0; 00037 00038 connect( partController(), SIGNAL(activePartChanged(KParts::Part*)), 00039 this, SLOT(activePartChanged(KParts::Part*)) ); 00040 } 00041 00042 00043 TextToolsPart::~TextToolsPart() 00044 { 00045 if (m_widget) 00046 mainWindow()->removeView(m_widget); 00047 delete m_widget; 00048 } 00049 00050 00051 void TextToolsPart::createWidget() 00052 { 00053 if (m_widget) 00054 { 00055 // mainWindow()->embedSelectView(m_widget, i18n("Text Structure"), i18n("Text structure")); 00056 return; 00057 } 00058 00059 m_widget = new TextToolsWidget(this); 00060 m_widget->setCaption(i18n("Text Structure")); 00061 QWhatsThis::add(m_widget, i18n("<b>Text Structure</b><p>" 00062 "This browser shows the structure of the text.")); 00063 mainWindow()->embedSelectView(m_widget, i18n("Text Structure"), i18n("Text structure")); 00064 } 00065 00066 00067 void TextToolsPart::activePartChanged(KParts::Part *part) 00068 { 00069 if (m_widget) 00070 m_widget->stop(); 00071 00072 if (!part) 00073 return; 00074 KParts::ReadWritePart *rwpart = dynamic_cast<KParts::ReadWritePart*>(part); 00075 if (!rwpart) 00076 return; 00077 QString url = rwpart->url().url(); 00078 00079 if (url.endsWith(".html")) { 00080 kdDebug(9030) << "set mode html" << endl; 00081 createWidget(); 00082 m_widget->setMode(TextToolsWidget::HTML, rwpart); 00083 } else if (url.endsWith(".docbook")) { 00084 kdDebug(9030) << "set mode Docbook" << endl; 00085 createWidget(); 00086 m_widget->setMode(TextToolsWidget::Docbook, rwpart); 00087 } else if (url.endsWith(".tex")) { 00088 kdDebug(9030) << "set mode LaTeX" << endl; 00089 createWidget(); 00090 m_widget->setMode(TextToolsWidget::LaTeX, rwpart); 00091 } else if (m_widget) { 00092 // kdDebug(9030) << "hide output view" << endl; 00093 // mainWindow()->removeView(m_widget); 00094 m_widget->clear(); 00095 } 00096 } 00097 00098 #include "texttoolspart.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Oct 19 08:01:52 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003