00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __menufile_h__
00020 #define __menufile_h__
00021
00022 #include <tqdom.h>
00023 #include <tqstring.h>
00024
00025 class MenuFile
00026 {
00027 public:
00028 MenuFile(const TQString &file);
00029 ~MenuFile();
00030
00031 bool load();
00032 bool save();
00033 void create();
00034 TQString error() { return m_error; }
00035
00036 enum ActionType {
00037 ADD_ENTRY = 0,
00038 REMOVE_ENTRY,
00039 ADD_MENU,
00040 REMOVE_MENU,
00041 MOVE_MENU
00042 };
00043
00044 struct ActionAtom
00045 {
00046 ActionType action;
00047 TQString arg1;
00048 TQString arg2;
00049 };
00050
00054 ActionAtom *pushAction(ActionType action, const TQString &arg1, const TQString &arg2);
00055
00060 void popAction(ActionAtom *atom);
00061
00065 void performAction(const ActionAtom *);
00066
00072 bool performAllActions();
00073
00077 bool dirty();
00078
00079 void addEntry(const TQString &menuName, const TQString &menuId);
00080 void removeEntry(const TQString &menuName, const TQString &menuId);
00081
00082 void addMenu(const TQString &menuName, const TQString &menuFile);
00083 void moveMenu(const TQString &oldMenu, const TQString &newMenu);
00084 void removeMenu(const TQString &menuName);
00085
00086 void setLayout(const TQString &menuName, const TQStringList &layout);
00087
00092 TQString uniqueMenuName(const TQString &menuName, const TQString &newMenu, const TQStringList &excludeList);
00093
00094 protected:
00100 TQDomElement findMenu(TQDomElement elem, const TQString &menuName, bool create);
00101
00102 private:
00103 TQString m_error;
00104 TQString m_fileName;
00105
00106 TQDomDocument m_doc;
00107 bool m_bDirty;
00108
00109 TQPtrList<ActionAtom> m_actionList;
00110 TQStringList m_removedEntries;
00111 };
00112
00113
00114 #endif