Warning, file /office/calligra/libs/kross/KoScriptingDocker.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /***************************************************************************
0002  * KoScriptingDocker.h
0003  * This file is part of the KDE project
0004  * copyright (C) 2006-2007 Sebastian Sauer <mail@dipe.org>
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Library General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2 of the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Library General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Library General Public License
0017  * along with this program; see the file COPYING.  If not, write to
0018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020  ***************************************************************************/
0021 
0022 #ifndef KOKROSS_KOSCRIPTINGDOCKER_H
0023 #define KOKROSS_KOSCRIPTINGDOCKER_H
0024 
0025 #include <KoDockFactoryBase.h>
0026 
0027 #include <QDockWidget>
0028 #include <QPointer>
0029 #include <QMap>
0030 
0031 namespace Kross {
0032     class Action;
0033     class ActionCollectionView;
0034 }
0035 
0036 class KoScriptingModule;
0037 class QAction;
0038 
0039 /**
0040 * The KoScriptingDockerFactory class implements a factory to
0041 * create \a KoScriptingDocker instances.
0042 */
0043 class KoScriptingDockerFactory : public KoDockFactoryBase
0044 {
0045 public:
0046 
0047     /**
0048     * Constructor.
0049     *
0050     * \param parent The parent QWidget of the \a KoScriptingDocker .
0051     * \param module The optional \a KoScriptingModule instance.
0052     * \param action The optional action. If this is NULL we will use a
0053     * \a KoScriptingDocker class else a \a KoScriptingActionDocker is used.
0054     */
0055     explicit KoScriptingDockerFactory(QWidget *parent = 0, KoScriptingModule *module = 0, Kross::Action *action = 0);
0056 
0057     /**
0058     * \return the id the docker has. This will be always "Scripting".
0059     */
0060     QString id() const override;
0061 
0062     /**
0063     * \return the default docking area.
0064     */
0065     KoDockFactoryBase::DockPosition defaultDockPosition() const override;
0066 
0067     /**
0068     * \return a newly created \a KoScriptingDocker instance.
0069     */
0070     QDockWidget *createDockWidget() override;
0071 
0072 private:
0073     /// The parent QWidget instance.
0074     QPointer<QWidget> m_parent;
0075     /// The module, can be 0.
0076     KoScriptingModule *m_module;
0077     /// The action, can be 0.
0078     Kross::Action *m_action;
0079 };
0080 
0081 /**
0082 * The KoScriptingDocker class implements a docking widget that displays
0083 * the scripts using the \a Kross::ActionCollectionView widget.
0084 */
0085 class KoScriptingDocker : public QDockWidget
0086 {
0087     Q_OBJECT
0088 public:
0089     /**
0090     * Constructor.
0091     *
0092     * \param parent The parent QWidget of the \a KoScriptingDocker .
0093     */
0094     explicit KoScriptingDocker(QWidget *parent = 0);
0095 
0096 protected Q_SLOTS:
0097 
0098     /**
0099     * This slow got called if the "Script Manager" toolbar-button
0100     * got activated.
0101     */
0102     void slotShowScriptManager();
0103 
0104     /**
0105     * This slot got called if the enabled-state of the run or stop
0106     * actions the used \a Kross::ActionCollectionView provides us
0107     * changed.
0108     */
0109     void slotEnabledChanged(const QString&);
0110 
0111     /**
0112     * This slot got called on doubleclick on the used
0113     * \a Kross::ActionCollectionView instance and executes the
0114     * selected action.
0115     */
0116     void slotDoubleClicked();
0117 
0118 private:
0119     /// The view we are using to display the collections and there actions.
0120     Kross::ActionCollectionView *m_view;
0121     /// The map of actions we are using to display toolbar-buttons like "run" and "stop".
0122     QMap<QString, QAction*> m_actions;
0123 };
0124 
0125 /**
0126 * The KoScriptingActionDocker class implements a docking widget that displays
0127 * a docker and uses a \a Kross::Action instance to create optional widgets
0128 * in it using a scripting language.
0129 */
0130 class KoScriptingActionDocker : public QDockWidget
0131 {
0132     Q_OBJECT
0133 public:
0134 
0135     /**
0136     * Constructor.
0137     *
0138     * \param parent The parent QWidget of the \a KoScriptingDocker .
0139     * \param module The \a KoScriptingModule instance.
0140     * \param action The action the docker should decorate. This action
0141     * will be used to create the widgets, etc. in the docker using scripts.
0142     */
0143     KoScriptingActionDocker(KoScriptingModule *module, Kross::Action *action, QWidget *parent = 0);
0144 
0145     /**
0146     * Destructor.
0147     */
0148     ~KoScriptingActionDocker() override;
0149 
0150 public Q_SLOTS:
0151 
0152     /**
0153     * Returns the widget that should be displayed within this docker.
0154     */
0155     QWidget* widget();
0156 
0157     /**
0158     * Set the widget that should be displayed within this docker.
0159     */
0160     void setWidget(QWidget* widget);
0161 
0162 Q_SIGNALS:
0163     //void visibilityChanged(bool visible);
0164 
0165 private Q_SLOTS:
0166     void slotVisibilityChanged(bool visible);
0167 
0168 private:
0169     QPointer<KoScriptingModule> m_module;
0170     Kross::Action *m_action;
0171 };
0172 
0173 #endif