From ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kig/misc/lists.h | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 kig/misc/lists.h (limited to 'kig/misc/lists.h') diff --git a/kig/misc/lists.h b/kig/misc/lists.h new file mode 100644 index 00000000..a3f97f1d --- /dev/null +++ b/kig/misc/lists.h @@ -0,0 +1,170 @@ +// Copyright (C) 2003 Dominique Devriese + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +// 02110-1301, USA. + +#ifndef KIG_MISC_LISTS_H +#define KIG_MISC_LISTS_H + +#include +#include + +class GUIAction; +class ObjectConstructor; +class MacroConstructor; +class KigDocument; +class KigPart; +class KigWidget; +class QString; +class QDomElement; +class ObjectCalcer; + +/** + * List of GUIActions for the parts to show. Note that the list owns + * the actions it receives.. + */ +class GUIActionList +{ +public: + typedef std::set avectype; + typedef std::set dvectype; +private: + avectype mactions; + dvectype mdocs; + GUIActionList(); + ~GUIActionList(); +public: + static GUIActionList* instance(); + const avectype& actions() const { return mactions; } + + /** + * register this document, so that it receives notifications for + * added and removed actions.. + */ + void regDoc( KigPart* d ); + void unregDoc( KigPart* d ); + + void add( GUIAction* a ); + void add( const std::vector& a ); + void remove( GUIAction* a ); + void remove( const std::vector& a ); +}; + +/** + * The list of object constructors for use in various places, e.g. RMB + * menu's. Note that the list owns the ctors it gets.. + */ +class ObjectConstructorList +{ +public: + typedef std::vector vectype; +private: + vectype mctors; + ObjectConstructorList(); + ~ObjectConstructorList(); +public: + static ObjectConstructorList* instance(); + void add( ObjectConstructor* a ); + void remove( ObjectConstructor* a ); + vectype ctorsThatWantArgs( const std::vector&, const KigDocument&, + const KigWidget&, bool completeOnly = false + ) const; + const vectype& constructors() const; +}; + +/** + * this is just a simple data struct. doesn't have any functionality + * of its own.. + */ +class Macro +{ +public: + GUIAction* action; + MacroConstructor* ctor; + Macro( GUIAction* a, MacroConstructor* c ); + ~Macro(); +}; + +/** + * a simply equality operator for Macro class. + */ +bool operator==( const Macro& l, const Macro& r ); + +/** + * This class keeps a list of all macro's, and allows them to be + * easily accessed, added etc. Macro objects are owned by this + * list.. + */ +class MacroList +{ +public: + typedef std::vector vectype; +private: + vectype mdata; + MacroList(); + ~MacroList(); +public: + /** + * MacroList is a singleton + */ + static MacroList* instance(); + + /** + * Add a Macro \p m . MacroList takes care of adding the action and + * ctor in the relevant places.. + */ + void add( Macro* m ); + /** + * Add the Macro's \p ms. MacroList takes care of adding the action + * and ctor in the relevant places.. + */ + void add( const vectype& ms ); + + /** + * Remove macro \p m . Macrolist takes care of deleting everything, and + * unregistering the action and ctor from the relevant places.. + */ + void remove( Macro* m ); + + /** + * Save macro \p m to file \p f .. + */ + bool save( Macro* m, const QString& f ); + /** + * Save macros \p ms to file \p f .. + */ + bool save( const vectype& ms, const QString& f ); + + /** + * load macro's from file \p f .. + * note that this just returns the loaded macro's, and doesn't add + * them to the various lists. Use add() if you want + * that behaviour.. + * The fact that this functions requires a KigPart argument is + * semantically incorrect, but i haven't been able to work around + * it.. + */ + bool load( const QString& f, vectype& ret, const KigPart& ); + + /** + * get access to the list of macro's.. + */ + const vectype& macros() const; + +private: + bool loadNew( const QDomElement& docelem, std::vector& ret, const KigPart& ); +}; + +#endif -- cgit v1.2.1