[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-23 18:06:12
Message-ID: 200803231906.12743.michel.ludwig () kdemail ! net
[Download RAW message or body]
On Wed 02 Jan 2008, Anders Lund wrote:
> But for any action that is not specified in an interface, you would not
> know.
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. The proposed interface extension adds two
functions "getAction(ActionType type)" and "getActions(ActionSetType type)",
which allow for retrieving the QAction objects associated to a given task.
The actions named in the attached file are the ones of immediate usefulness
for Kile; for example, we want to implement our own spell checking.
Any comments? :-)
Michel
["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 for allowing 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 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:
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