summaryrefslogtreecommitdiffstats
path: root/kmenuedit/menufile.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kmenuedit/menufile.h
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
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/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmenuedit/menufile.h')
-rw-r--r--kmenuedit/menufile.h114
1 files changed, 114 insertions, 0 deletions
diff --git a/kmenuedit/menufile.h b/kmenuedit/menufile.h
new file mode 100644
index 000000000..61ca3a9f0
--- /dev/null
+++ b/kmenuedit/menufile.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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 __menufile_h__
+#define __menufile_h__
+
+#include <qdom.h>
+#include <qstring.h>
+
+class MenuFile
+{
+public:
+ MenuFile(const QString &file);
+ ~MenuFile();
+
+ bool load();
+ bool save();
+ void create();
+ QString error() { return m_error; } // Returns the last error message
+
+ enum ActionType {
+ ADD_ENTRY = 0,
+ REMOVE_ENTRY,
+ ADD_MENU,
+ REMOVE_MENU,
+ MOVE_MENU
+ };
+
+ struct ActionAtom
+ {
+ ActionType action;
+ QString arg1;
+ QString arg2;
+ };
+
+ /**
+ * Create action atom and push it on the stack
+ */
+ ActionAtom *pushAction(ActionType action, const QString &arg1, const QString &arg2);
+
+ /**
+ * Pop @p atom from the stack.
+ * @p atom must be last item on the stack
+ */
+ void popAction(ActionAtom *atom);
+
+ /**
+ * Perform the specified action
+ */
+ void performAction(const ActionAtom *);
+
+ /**
+ * Perform all actions currently on the stack, remove them from the stack and
+ * save result
+ * @return whether save was successful
+ */
+ bool performAllActions();
+
+ /**
+ * Returns whether the stack contains any actions
+ */
+ bool dirty();
+
+ void addEntry(const QString &menuName, const QString &menuId);
+ void removeEntry(const QString &menuName, const QString &menuId);
+
+ void addMenu(const QString &menuName, const QString &menuFile);
+ void moveMenu(const QString &oldMenu, const QString &newMenu);
+ void removeMenu(const QString &menuName);
+
+ void setLayout(const QString &menuName, const QStringList &layout);
+
+ /**
+ * Returns a unique menu-name for a new menu under @p menuName
+ * inspired by @p newMenu and not part of @p excludeList
+ */
+ QString uniqueMenuName(const QString &menuName, const QString &newMenu, const QStringList &excludeList);
+
+protected:
+ /**
+ * Finds menu @p menuName in @p elem.
+ * If @p create is true, the menu is created if it doesn't exist yet.
+ * @return The menu dom-node of @p menuName
+ */
+ QDomElement findMenu(QDomElement elem, const QString &menuName, bool create);
+
+private:
+ QString m_error;
+ QString m_fileName;
+
+ QDomDocument m_doc;
+ bool m_bDirty;
+
+ QPtrList<ActionAtom> m_actionList;
+ QStringList m_removedEntries;
+};
+
+
+#endif