[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ktexteditor-devel
Subject:    Re: Selective creation of KTextEditor::View actions
From:       Michel Ludwig <michel.ludwig () kdemail ! net>
Date:       2008-03-24 10:03:16
Message-ID: 200803241103.23768.michel.ludwig () kdemail ! net
[Download RAW message or body]

On Sun 23 Mar 2008, Michel Ludwig wrote:
> Attached is a proposal for a ActionAccessInterface: the underlying
> rationale is that applications may want more control over which actions a
> KTextEditor part is going to present.

Actually reconsidering, we would also need the possibility to specify which 
features a new view should *not* display once it is created. I propose 
a "FeatureControlInterface" for this purpose; a first draft is attached.


Thanks,

Michel

["featurecontrolinterface.h" (text/x-c++hdr)]

/* This file is part of the KDE libraries
   Copyright (C) 2008 Michel Ludwig <michel.ludwig@kdemail.net>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   This library 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef KDELIBS_KTEXTEDITOR_FEATURECONTROLINTERFACE_H
#define KDELIBS_KTEXTEDITOR_FEATURECONTROLINTERFACE_H

#include <ktexteditor/ktexteditor_export.h>

class KConfigGroup;

#include <QtCore/QObject>

namespace KTextEditor
{

/**
 * \brief Feature control interface options.
 */
namespace FeatureControl
{
  /**
   * \brief A type representing specific actions.
   *
   */
  enum ExludedFeaturesOptionsEnum
  {
    NoExclusion          = 0            ///< No feature should be excluded
    NoSpellchecking      = 1 << 0       ///< No spell checking features
  };

  Q_DECLARE_FLAGS(ExludedFeaturesOptions, ExludedFeaturesOptionsEnum)
  Q_DECLARE_OPERATORS_FOR_FLAGS(ExludedFeaturesOptions)
}

/**
 * \brief Feature control interface extension for the Document.
 *
 * \ingroup kte_group_doc_extensions
 *
 * \section featurecontrol_intro Introduction
 *
 * The FeatureControlInterface is an extension for Documents which allows features to be omitted
 * in newly created Views.
 *
 * \section featurecontrol_support Adding Feature Control Support
 *
 * To add support for feature control a KTextEditor implementation has to derive the
 * Document class from FeatureControlInterface and reimplement the purely virtual methods defined
 * in this interfaces.
 *
 * \section featurecontrol_access Accessing the FeatureControlInterface
 *
 * The FeatureControlInterface is supposed to be an extension interface for a Document, i.e. the
 * Document inherits the interface \e provided that it implements the interface. Use qobject_cast to
 * access the implementation:
 * \code
 * // object is of type KTextEditor::Document*
 * KTextEditor::FeatureControlInterface *iface =
 *     qobject_cast<KTextEditor::FeatureControlInterface*>( object );
 *
 * if( iface ) {
 *     // interface is supported
 *     // do stuff
 * }
 * \endcode
 *
 * \see KTextEditor::Document
 * \author Michel Ludwig \<michel.ludwig@kdemail.net\>
 */
class KTEXTEDITOR_EXPORT FeatureControlInterface
{
  public:
    /**
     * Constructor.
     */
    FeatureControlInterface();

    /**
     * Virtual destructor.
     */
    virtual ~FeatureControlInterface() {}

  public:
    /**
     * Create a new view which is attached to \p parent and which does not display the
     * features specified in \p options. Different values for \p options can be logically
     * ORed together.
     *
     * \param parent   Parent of the view returned
     * \param options  Features that should \e not be present in the view
     *                 returned
     * \return         A newly created view
     */
    virtual View* createView(QWidget *parent,
                             FeatureControl::ExludedFeaturesOptions options) = 0

  private:
    class FeatureControlInterfacePrivate* const d;
};

}

Q_DECLARE_INTERFACE(KTextEditor::FeatureControlInterface, "org.kde.KTextEditor.FeatureControlInterface")

#endif

// kate: space-indent on; indent-width 2; replace-tabs on;

["actionaccessinterface.h" (text/x-c++hdr)]

/* This file is part of the KDE libraries
   Copyright (C) 2008 Michel Ludwig <michel.ludwig@kdemail.net>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   This library 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef KDELIBS_KTEXTEDITOR_ACTIONACCESSINTERFACE_H
#define KDELIBS_KTEXTEDITOR_ACTIONACCESSINTERFACE_H

#include <ktexteditor/ktexteditor_export.h>

class KConfigGroup;

#include <QtCore/QObject>

namespace KTextEditor
{

/**
 * \brief Action types.
 */
namespace ActionAccess
{
  /**
   * \brief A type representing specific actions.
   *
   */
  enum ActionType
  {
    Save                = 0,      ///< "Save" action
    SaveAs              = 1 << 0  ///< "Save As" action
  };

  /**
   * \brief A type representing sets of actions.
   *
   */
  enum ActionSetType
  {
    Spellchecking       = 0        ///< All the actions related to spell checking
  };

}

/**
 * \brief Action access interface extension for the View.
 *
 * \ingroup kte_group_view_extensions
 *
 * \section actionaccess_intro Introduction
 *
 * The ActionAccessInterface is an extension for Views which allows access to the QAction objects
 * used by the View for specific tasks.
 *
 * \section actionaccess_support Adding Action Access Support
 *
 * To add support for action access a KTextEditor implementation has to derive the
 * View class from ActionAccessInterface and reimplement the purely virtual methods defined
 * in this interfaces.
 *
 * \section actionaccess_access Accessing the ActionAccessInterface
 *
 * The ActionAccessInterface is supposed to be an extension interface for a View, i.e. the
 * View inherits the interface \e provided that it implements the interface. Use qobject_cast to
 * access the implementation:
 * \code
 * // object is of type KTextEditor::View*
 * KTextEditor::ActionAccessInterface *iface =
 *     qobject_cast<KTextEditor::ActionAccessInterface*>( object );
 *
 * if( iface ) {
 *     // interface is supported
 *     // do stuff
 * }
 * \endcode
 *
 * \see KTextEditor::View, QAction
 * \author Michel Ludwig \<michel.ludwig@kdemail.net\>
 */
class KTEXTEDITOR_EXPORT ActionAccessInterface
{
  public:
    /**
     * Constructor.
     */
    ActionAccessInterface();

    /**
     * Virtual destructor.
     */
    virtual ~ActionAccessInterface() {}

  public:
    /**
     * Get the pointer to the QAction object associated to the task \p type.
     *
     * \param type  Considered action task
     * \return      Pointer to the QAction object representing \p type, or
     *              NULL if the task \p type is not implemented in the view
     */
    virtual QAction* getAction(ActionAccess::ActionType type) = 0;#

    /**
     * Get the list of pointers to the QAction objects associated to the
     * task \p type.
     *
     * \param type  Considered action task
     * \return      List of pointers to the QAction objects representing
     *              \p type, or an empty list if the task \p type is not
     *              implemented in the view
     */
    virtual QList<QAction*> getActions(ActionAccess::ActionSetType type) = 0;

  private:
    class ActionAccessInterfacePrivate* const d;
};

}

Q_DECLARE_INTERFACE(KTextEditor::ActionAccessInterface, "org.kde.KTextEditor.ActionAccessInterface")

#endif

// kate: space-indent on; indent-width 2; replace-tabs on;


_______________________________________________
KTextEditor-Devel mailing list
KTextEditor-Devel@kde.org
https://mail.kde.org/mailman/listinfo/ktexteditor-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic