File indexing completed on 2024-04-21 15:55:42

0001 /*************************************************************************************
0002     Copyright (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net)
0003  *************************************************************************************/
0004 
0005 /***************************************************************************
0006  *                                                                         *
0007  *   This program is free software; you can redistribute it and/or modify  *
0008  *   it under the terms of the GNU General Public License as published by  *
0009  *   the Free Software Foundation; either version 2 of the License, or     *
0010  *   (at your option) any later version.                                   *
0011  *                                                                         *
0012  ***************************************************************************/
0013 
0014 #ifndef KILESTDTOOLS_H
0015 #define KILESTDTOOLS_H
0016 
0017 #include <QString>
0018 
0019 #include "kiledebug.h"
0020 #include "kiletool.h"
0021 #include "tool_utils.h"
0022 
0023 class KConfig;
0024 class KActionCollection;
0025 
0026 namespace KileTool
0027 {
0028 class View;
0029 class Compile;
0030 class Manager;
0031 
0032 class Factory
0033 {
0034     friend class Manager;
0035 
0036 public:
0037     Factory(Manager *mngr, KConfig *config, KActionCollection *actionCollection);
0038     ~Factory();
0039 
0040     void resetToolConfigurations();
0041     void installStandardLivePreviewTools();
0042 
0043 private:
0044     Manager            *m_manager;
0045     KConfig            *m_config;
0046     KActionCollection  *m_actionCollection;
0047     QString             m_standardToolConfigurationFileName;
0048 
0049     // only the 'Manager' is allowed to call this
0050     Base* create(const QString& tool, const QString& config, bool prepare = true);
0051 };
0052 
0053 class LaTeX : public Compile
0054 {
0055     Q_OBJECT
0056     friend class KileTool::Factory;
0057 
0058 protected:
0059     LaTeX(const QString& tool, Manager *mngr, bool prepare);
0060 public:
0061     virtual ~LaTeX();
0062 
0063     virtual void setupAsChildTool(KileTool::Base *child) override;
0064 
0065     LaTeXOutputHandler* latexOutputHandler();
0066     void setLaTeXOutputHandler(LaTeXOutputHandler *h);
0067 
0068 Q_SIGNALS:
0069     void jumpToFirstError();
0070 
0071 public Q_SLOTS:
0072     virtual bool finish(int) override;
0073 
0074 protected:
0075     LaTeXOutputHandler *m_latexOutputHandler;
0076 
0077     virtual bool determineSource() override;
0078 
0079     void checqCriticals();
0080     void checkAutoRun();
0081     virtual void latexOutputParserResultInstalled() override;
0082 
0083     virtual bool updateBibs(bool checkOnlyBibDependencies);
0084     virtual bool updateIndex();
0085     virtual bool updateAsy();
0086 
0087     virtual void configureLaTeX(KileTool::Base *tool, const QString& source);
0088     virtual void configureBibTeX(KileTool::Base *tool, const QString& source);
0089     virtual void configureMakeIndex(KileTool::Base *tool, const QString& source);
0090     virtual void configureAsymptote(KileTool::Base *tool, const QString& source);
0091 
0092     /**
0093      * @brief Determine the tool name and configuration for the bibliography backend
0094      *
0095      * If a backend has been set by the user, that one is returned. Otherwise,
0096      * an automatic detection of the backend is attempted. If an automatic detection
0097      * is not possible and no backend has been previously auto-detected, the
0098      * default tool (BibTex) is returned.
0099      * @returns Tool name that can be provided to @ref KileTool::Manager::create
0100      **/
0101     ToolConfigPair determineBibliographyBackend(const QString& hint);
0102 
0103     //FIXME: this is a little 'hackish'
0104     static int m_reRun;
0105 };
0106 
0107 class PreviewLaTeX : public LaTeX
0108 {
0109     Q_OBJECT
0110     friend class KileTool::Factory;
0111 
0112 protected:
0113     PreviewLaTeX(const QString& tool, Manager *mngr, bool prepare);
0114 
0115 public:
0116     void setPreviewInfo(const QString &filename, int selrow, int docrow);
0117 
0118 public Q_SLOTS:
0119     virtual bool finish(int) override;
0120 
0121 private:
0122     QString m_filename;
0123     int m_selrow;
0124     int m_docrow;
0125 };
0126 
0127 class LivePreviewLaTeX : public LaTeX
0128 {
0129     Q_OBJECT
0130     friend class KileTool::Factory;
0131 
0132 protected:
0133     LivePreviewLaTeX(const QString& tool, Manager *mngr, bool prepare);
0134 
0135 public:
0136 //          void setPreviewInfo(const QString &filename, int selrow, int docrow);
0137 
0138 public Q_SLOTS:
0139 //          bool finish(int);
0140 
0141 protected:
0142     virtual void configureLaTeX(KileTool::Base *tool, const QString& source) override;
0143     virtual void configureBibTeX(KileTool::Base *tool, const QString& source) override;
0144     virtual void configureMakeIndex(KileTool::Base *tool, const QString& source) override;
0145     virtual void configureAsymptote(KileTool::Base *tool, const QString& source) override;
0146 
0147 private:
0148     QString m_filename;
0149     int m_selrow;
0150     int m_docrow;
0151 };
0152 
0153 class ForwardDVI : public View
0154 {
0155     friend class KileTool::Factory;
0156 
0157 protected:
0158     ForwardDVI(const QString & tool, Manager *mngr, bool prepare = true);
0159 
0160     virtual bool determineTarget() override;
0161     virtual bool checkPrereqs() override;
0162 };
0163 
0164 class ViewBib : public View
0165 {
0166     friend class KileTool::Factory;
0167 
0168 protected:
0169     ViewBib(const QString& tool, Manager *mngr, bool prepare = true);
0170 
0171     virtual bool determineSource() override;
0172 };
0173 
0174 class ViewHTML : public View
0175 {
0176     Q_OBJECT
0177     friend class KileTool::Factory;
0178 
0179 protected:
0180     ViewHTML(const QString& tool, Manager *mngr, bool prepare = true);
0181 
0182     virtual bool determineTarget() override;
0183 
0184 Q_SIGNALS:
0185     void updateStatus(bool, bool);
0186 };
0187 
0188 class BibliographyCompile : public Compile
0189 {
0190     friend class KileTool::Factory;
0191 
0192 protected:
0193     BibliographyCompile(const QString& name, Manager* manager, bool prepare = true);
0194 public:
0195     static const QString ToolClass;
0196 };
0197 }
0198 
0199 #endif