KDEUI
kactioncategory.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 00003 Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KACTIONCATEGORY_H 00022 #define KACTIONCATEGORY_H 00023 00024 #include <QtCore/QObject> 00025 #include <QtCore/QString> 00026 #include <QtCore/QList> 00027 00028 #include "kstandardaction.h" 00029 #include "kactioncollection.h" 00030 00031 00032 class KAction; 00033 struct KActionCategoryPrivate; 00034 00035 class QAction; 00036 00037 00038 00095 class KDEUI_EXPORT KActionCategory : public QObject 00096 { 00097 Q_OBJECT 00098 00099 Q_PROPERTY( QString text READ text WRITE setText ) 00100 00101 public: 00102 00106 explicit KActionCategory(const QString &text, KActionCollection *parent=NULL); 00107 00111 virtual ~KActionCategory(); 00112 00122 QAction * addAction(const QString &name, QAction *action); 00123 00124 KAction * addAction(const QString &name, KAction *action); 00125 00126 KAction * addAction( 00127 KStandardAction::StandardAction actionType, 00128 const QObject *receiver = NULL, 00129 const char *member = NULL); 00130 00131 KAction * addAction( 00132 KStandardAction::StandardAction actionType, 00133 const QString &name, 00134 const QObject *receiver = NULL, 00135 const char *member = NULL); 00136 00137 KAction *addAction( 00138 const QString &name, 00139 const QObject *receiver = NULL, 00140 const char *member = NULL); 00141 00142 template<class ActionType> 00143 ActionType *add( 00144 const QString &name, 00145 const QObject *receiver = NULL, 00146 const char *member = NULL) 00147 { 00148 ActionType *action = collection()->add<ActionType>(name, receiver, member); 00149 addAction(action); 00150 return action; 00151 } 00152 00154 00158 const QList<QAction*> actions() const; 00159 00163 KActionCollection * collection() const; 00164 00168 QString text() const; 00169 00173 void setText(const QString& text); 00174 00175 private: 00176 00180 void unlistAction(QAction *action); 00181 00185 void addAction(QAction *action); 00186 00188 friend class KActionCollectionPrivate; 00189 00191 KActionCategoryPrivate *const d; 00192 }; 00193 00194 00195 #endif /* #ifndef KACTIONCATEGORY_H */
KDE 4.6 API Reference