File indexing completed on 2024-04-28 11:20:48

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2009 Alexander Rieder <alexanderrieder@gmail.com>
0004 */
0005 
0006 #ifndef _SYNTAXHELPOBJECT_H
0007 #define _SYNTAXHELPOBJECT_H
0008 
0009 #include <QObject>
0010 #include "cantor_export.h"
0011 
0012 namespace Cantor{
0013 
0014 class SyntaxHelpObjectPrivate;
0015 class Session;
0016 
0017 /**
0018  * Object, used to display Syntax information to a given command
0019  * It is designed for asynchronous use. The Object emits done
0020  * as soon as fetching of the Help is finished
0021  *
0022  * @author Alexander Rieder
0023  **/
0024 class CANTOR_EXPORT SyntaxHelpObject : public QObject
0025 {
0026   Q_OBJECT
0027   public:
0028     /**
0029      * Construct a HelpObject, for the given command, belonging to the Session session.
0030      * @param command Command the help should be fetched for
0031      * @param session Session the HelpObject belongs to
0032      */
0033     SyntaxHelpObject( const QString& command, Session* session );
0034     /**
0035      * Destructor
0036      */
0037     ~SyntaxHelpObject() override;
0038 
0039     /**
0040      * Start fetching the syntax help, emitting done() when done.
0041      */
0042     void fetchSyntaxHelp();
0043 
0044     /**
0045      * Returns Html text of the Syntax Help
0046      */
0047     QString toHtml();
0048 
0049     /**
0050      * Returns the command, this SyntaxHelp is for
0051      * @return the command, this SyntaxHelp is for
0052      */
0053     QString command();
0054     /**
0055      * Returns the Session, this Object belongs to
0056      * @return the Session, this Object belongs to
0057      */
0058     Session* session();
0059 
0060   Q_SIGNALS:
0061     /**
0062      * The SyntaxHelpObject is done, fetching the Information.
0063      * The syntax help can be shown now
0064      */
0065     void done();
0066 
0067   protected Q_SLOTS:
0068     /**
0069      * This method should fetch the Syntax help information from the backend
0070      */
0071     virtual void fetchInformation() = 0;
0072 
0073   protected:
0074     /**
0075      * Set the html syntax help
0076      * @param result the html syntax help
0077      */
0078     void setHtml(const QString& result);
0079 
0080   private:
0081     SyntaxHelpObjectPrivate* d;
0082 
0083 };
0084 
0085 }
0086 #endif /* _SYNTAXHELPOBJECT_H */