KDEUI
kactioncollection.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef KACTIONCOLLECTION_H
00027 #define KACTIONCOLLECTION_H
00028
00029 #include <kdeui_export.h>
00030 #include <kstandardaction.h>
00031 #include <kcomponentdata.h>
00032
00033 #include <QtCore/QObject>
00034
00035 class QAction;
00036 class KXMLGUIClient;
00037
00038 class QActionGroup;
00039 class QString;
00040
00056 class KDEUI_EXPORT KActionCollection : public QObject
00057 {
00058 friend class KXMLGUIClient;
00059
00060 Q_OBJECT
00061
00062 Q_PROPERTY( QString configGroup READ configGroup WRITE setConfigGroup )
00063 Q_PROPERTY( bool configIsGlobal READ configIsGlobal WRITE setConfigGlobal )
00064
00065 public:
00070 explicit KActionCollection(QObject *parent, const KComponentData &cData = KComponentData());
00071
00075 virtual ~KActionCollection();
00076
00080 static const QList<KActionCollection*>& allCollections();
00081
00085 void clear();
00086
00094 void associateWidget(QWidget* widget) const;
00095
00104 void addAssociatedWidget(QWidget* widget);
00105
00110 void removeAssociatedWidget(QWidget* widget);
00111
00115 QList<QWidget*> associatedWidgets() const;
00116
00120 void clearAssociatedWidgets();
00121
00125 QString configGroup() const;
00126
00131 bool configIsGlobal() const;
00132
00136 void setConfigGroup( const QString& group );
00137
00142 void setConfigGlobal( bool global );
00143
00151 void readSettings( KConfigGroup* config = 0 );
00152
00160 void importGlobalShortcuts( KConfigGroup* config );
00161
00170 void exportGlobalShortcuts( KConfigGroup* config, bool writeDefaults = false ) const;
00171
00187 void writeSettings( KConfigGroup* config = 0, bool writeDefaults = false, QAction* oneAction = 0 ) const;
00188
00194 int count() const;
00195
00199 bool isEmpty() const;
00200
00206 QAction *action(int index) const;
00207
00215 QAction* action( const QString& name ) const;
00216
00223 QList<QAction*> actions() const;
00224
00228 const QList<QAction*> actionsWithoutGroup() const;
00229
00233 const QList<QActionGroup*> actionGroups() const;
00234
00244 void setComponentData(const KComponentData &componentData);
00245
00247 KComponentData componentData() const;
00248
00252 const KXMLGUIClient *parentGUIClient() const;
00253
00254 Q_SIGNALS:
00258 void inserted( QAction* action );
00259
00264 QT_MOC_COMPAT void removed( QAction* action );
00265
00270 QT_MOC_COMPAT void actionHighlighted(QAction* action);
00271
00275 void actionHovered(QAction* action);
00276
00280 void actionTriggered(QAction* action);
00281
00282 protected Q_SLOTS:
00284 virtual void connectNotify ( const char * signal );
00285
00286 virtual void slotActionTriggered();
00287
00292 QT_MOC_COMPAT virtual void slotActionHighlighted();
00293
00294 private Q_SLOTS:
00295 void slotActionHovered();
00296
00297
00298 public:
00312 QAction *addAction(const QString &name, QAction *action);
00313 KAction *addAction(const QString &name, KAction *action);
00314
00319 void removeAction(QAction *action);
00320
00325 QAction* takeAction(QAction *action);
00326
00334 KAction *addAction(KStandardAction::StandardAction actionType, const QObject *receiver = 0, const char *member = 0);
00341 KAction *addAction(KStandardAction::StandardAction actionType, const QString &name,
00342 const QObject *receiver = 0, const char *member = 0);
00343
00358 KAction *addAction(const QString &name, const QObject *receiver = 0, const char *member = 0);
00359
00376 template<class ActionType>
00377 ActionType *add(const QString &name, const QObject *receiver = 0, const char *member = 0)
00378 {
00379 ActionType *a = new ActionType(this);
00380 if (receiver && member)
00381 connect(a, SIGNAL(triggered(bool)), receiver, member);
00382 addAction(name, a);
00383 return a;
00384 }
00385
00386 private:
00387 Q_PRIVATE_SLOT(d, void _k_actionDestroyed(QObject *))
00388 Q_PRIVATE_SLOT(d, void _k_associatedWidgetDestroyed(QObject*))
00389
00390 KActionCollection( const KXMLGUIClient* parent );
00391
00392 friend class KActionCollectionPrivate;
00393 class KActionCollectionPrivate* const d;
00394 };
00395
00396 #endif