kexi

kexiactionproxy.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KEXIACTIONPROXY_H
00021 #define KEXIACTIONPROXY_H
00022 
00023 #include <qguardedptr.h>
00024 #include <qasciidict.h>
00025 #include <qobject.h>
00026 #include <qpair.h>
00027 #include <qptrlist.h>
00028 
00029 #include <kaction.h>
00030 
00031 #include "kexiproject.h"
00032 #include "kexisharedactionhost.h"
00033 
00034 class QSignal;
00035 class KAction;
00036 class KXMLGUIClient;
00037 class KAction_setEnabled_Helper;
00038 class KexiActionProxy;
00039 
00041 
00054 //TODO add method for setAvailable()
00055 class KEXICORE_EXPORT KexiSharedActionConnector
00056 {
00057     public:
00058         /* Connects shared actions offered by \a proxy to \a obj. */
00059         KexiSharedActionConnector(KexiActionProxy* proxy, QObject *obj);
00060         ~KexiSharedActionConnector();
00061 
00062     protected:
00063         void plugSharedAction(const char *action_name, const char *slot);
00064 
00065         void plugSharedActionToExternalGUI(const char *action_name, KXMLGUIClient *client);
00066 
00067         void plugSharedActionsToExternalGUI(
00068             const QValueList<QCString>& action_names, KXMLGUIClient *client);
00069 
00070         KexiActionProxy* m_proxy;
00071         QObject *m_object;
00072 };
00073 
00075 
00083 class KEXICORE_EXPORT KexiActionProxy
00084 {
00085     public:
00089         KexiActionProxy(QObject *receiver , KexiSharedActionHost *host = 0 );
00090         virtual ~KexiActionProxy();
00091 
00094         bool activateSharedAction(const char *action_name, bool alsoCheckInChildren = true);
00095 
00097         void setSharedActionHost(KexiSharedActionHost& host) { m_host = &host; }
00098 
00102         bool isAvailable(const char* action_name, bool alsoCheckInChildren = true) const;
00103 
00105         bool isSupported(const char* action_name) const;
00106 
00107     protected:
00110         void plugSharedAction(const char *action_name, QObject* receiver, const char *slot);
00111 
00112         void unplugSharedAction(const char *action_name);
00113 
00116         inline void plugSharedAction(const char *action_name, const char *slot) {
00117             plugSharedAction(action_name, m_receiver, slot);
00118         }
00119 
00126         int plugSharedAction(const char *action_name, QWidget* w);
00127 
00128         void plugSharedActionToExternalGUI(const char *action_name, KXMLGUIClient *client);
00129 
00130         void plugSharedActionsToExternalGUI(
00131             const QValueList<QCString>& action_names, KXMLGUIClient *client);
00132 
00135         void unplugSharedAction(const char *action_name, QWidget* w);
00136 
00142         KAction* plugSharedAction(const char *action_name, const QString& alternativeText, QWidget* w);
00143 
00145         virtual KAction* sharedAction(const char* action_name);
00146 
00147         inline QObject *receiver() const { return m_receiver; }
00148 
00149         virtual void setAvailable(const char* action_name, bool set);
00150 
00158         void addActionProxyChild( KexiActionProxy* child );
00159 
00160         void takeActionProxyChild( KexiActionProxy* child );
00161 
00162         KexiSharedActionHost *m_host;
00163         QGuardedPtr<QObject> m_receiver;
00164         QAsciiDict< QPair<QSignal*,bool> > m_signals;
00165 
00166         QPtrList<KexiActionProxy> m_sharedActionChildren;
00167 
00168         QPtrList<KAction> m_alternativeActions;
00169 
00170         KexiActionProxy* m_actionProxyParent;
00171 
00172         QObject m_signal_parent; 
00173 
00175         KAction_setEnabled_Helper *m_KAction_setEnabled_helper;
00176 
00177     public:
00179         void setActionProxyParent_internal( KexiActionProxy* parent );
00180 
00182         KexiActionProxy *m_focusedChild;
00183 
00184     friend class KexiSharedActionHost;
00185     friend class KAction_setEnabled_Helper;
00186     friend class KexiSharedActionConnector;
00187 };
00188 
00189 #endif
00190 
KDE Home | KDE Accessibility Home | Description of Access Keys