Kross
actioncollection.h
Go to the documentation of this file.
00001 /*************************************************************************** 00002 * actioncollection.h 00003 * This file is part of the KDE project 00004 * copyright (C)2004-2007 by Sebastian Sauer (mail@dipe.org) 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * This program 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 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; see the file COPYING. 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 KROSS_ACTIONCOLLECTION_H 00021 #define KROSS_ACTIONCOLLECTION_H 00022 00023 #include "krossconfig.h" 00024 #include "action.h" 00025 00026 #include <QtCore/QObject> 00027 #include <QtCore/QDir> 00028 00029 class QDomElement; 00030 class QIODevice; 00031 00032 namespace Kross { 00033 00045 class KROSSCORE_EXPORT ActionCollection : public QObject 00046 { 00047 Q_OBJECT 00048 00049 public: 00050 00061 explicit ActionCollection(const QString& name, ActionCollection* parent = 0); 00062 00066 virtual ~ActionCollection(); 00067 00071 QString name() const; 00072 00076 QString text() const; 00077 00081 void setText(const QString& text); 00082 00086 QString description() const; 00087 00091 void setDescription(const QString& description); 00092 00096 QString iconName() const; 00097 00101 void setIconName(const QString& iconname); 00102 00106 QIcon icon() const; 00107 00111 bool isEnabled() const; 00112 00116 void setEnabled(bool enabled); 00117 00123 ActionCollection* parentCollection() const; 00125 void setParentCollection( ActionCollection *parent ); 00130 bool hasCollection(const QString& name) const; 00131 00136 ActionCollection* collection(const QString& name) const; 00137 00142 QStringList collections() const; 00143 00144 QList<Action*> actions() const; 00145 00149 Action* action(const QString& name) const; 00150 void addAction(Action* action); 00151 void addAction(const QString& name, Action* action); 00152 void removeAction(const QString& name); 00153 void removeAction(Action* action); 00154 00165 bool readXml(const QDomElement& element, const QDir& directory = QDir()); 00166 bool readXml(const QDomElement& element, const QStringList& searchPath/* = QStringList()*/); 00167 00171 bool readXml(QIODevice* device, const QDir& directory = QDir()); 00172 bool readXml(QIODevice* device, const QStringList& searchPath/* = QStringList()*/); 00173 00180 bool readXmlFile(const QString& file); 00181 00186 QDomElement writeXml(); 00187 QDomElement writeXml(const QStringList& searchPath/* = QStringList()*/); 00188 00189 00194 bool writeXml(QIODevice* device, int indent = 2); 00195 bool writeXml(QIODevice* device, int indent/* = 2*/, const QStringList& searchPath/* = QStringList()*/); 00196 00197 00198 Q_SIGNALS: 00199 00204 void updated(); 00205 00207 void dataChanged(Action*); 00209 void dataChanged(ActionCollection*); 00210 00212 void collectionToBeInserted(ActionCollection* child, ActionCollection* parent); 00214 void collectionInserted(ActionCollection* child, ActionCollection* parent); 00216 void collectionToBeRemoved(ActionCollection* child, ActionCollection* parent); 00218 void collectionRemoved(ActionCollection* child, ActionCollection* parent); 00219 00221 void actionToBeInserted(Action* child, ActionCollection* parent); 00223 void actionInserted(Action* child, ActionCollection* parent); 00225 void actionToBeRemoved(Action* child, ActionCollection* parent); 00227 void actionRemoved(Action* child, ActionCollection* parent); 00228 00229 protected: 00230 void registerCollection(ActionCollection* collection); 00231 void unregisterCollection(const QString& name); 00232 void connectSignals(ActionCollection* collection, bool conn); 00233 void connectSignals(Action* collection, bool conn); 00234 00235 private Q_SLOTS: 00236 void emitUpdated(); 00237 00238 private: 00240 class Private; 00242 Private* const d; 00243 }; 00244 00245 } 00246 00247 #endif 00248
KDE 4.6 API Reference