1 /* BEGIN_COMMON_COPYRIGHT_HEADER
2  * (c)LGPL2+
3  *
4  * LXQt - a lightweight, Qt based, desktop toolset
5  * https://lxqt.org
6  *
7  * Copyright: 2010-2011 Razor team
8  * Authors:
9  *   Alexander Sokoloff <sokoloff.a@gmail.com>
10  *
11  * This program or library is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20 
21  * You should have received a copy of the GNU Lesser General
22  * Public License along with this library; if not, write to the
23  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24  * Boston, MA 02110-1301 USA
25  *
26  * END_COMMON_COPYRIGHT_HEADER */
27 
28 #ifndef QTXDG_XDGMENULAYOUTPROCESSOR_H
29 #define QTXDG_XDGMENULAYOUTPROCESSOR_H
30 
31 #include <QtXml/QDomElement>
32 #include <QList>
33 
34 struct LayoutItem
35 {
36     enum Type{
37         Filename,
38         Menuname,
39         Separator,
40         MergeMenus,
41         MergeFiles,
42         MergeAll,
43     };
44 
45     Type type;
46     bool showEmpty;
47     bool isInline;
48     bool inlineLimit;
49     bool inlineHeader;
50     bool inlineAlias;
51     QString fileId;
52 };
53 
54 //class Layout: public QList<LayoutItem>
55 //{
56 //public:
57 /*    Layout() {}
58 
59 
60     bool showEmpty() { return mShowEmpty; }
61     void setShowEmpty(bool value) { mShowEmpty = value; }
62 
63     bool isInline() { return mInline; }
64     void setInline(bool value) { mInline = value; }
65 
66     int inlineLimit() { return mInlineLimit; }
67     void setInlineLimit(int value) { mInlineLimit = value; }
68 
69     bool inlineHeader() {return mInlineHeader; }
70     void setInlineHeader(bool value) { mInlineHeader = value; }
71 
72     bool inlineAlias() { return mInlineAlias; }
73     void setInlineAlias(bool value) { mInlineAlias = value; }
74 
75 
76 
77 private:
78 */
79 
80 struct LayoutParams
81 {
82     bool mShowEmpty;
83     bool mInline;
84     int mInlineLimit;
85     bool mInlineHeader;
86     bool mInlineAlias;
87 };
88 
89 
90 class XdgMenuLayoutProcessor
91 {
92 public:
93     XdgMenuLayoutProcessor(QDomElement& element);
94     void run();
95 
96 protected:
97     XdgMenuLayoutProcessor(QDomElement& element, XdgMenuLayoutProcessor *parent);
98 
99 private:
100     void setParams(QDomElement defaultLayout, LayoutParams *result);
101     QDomElement searchElement(const QString &tagName, const QString &attributeName, const QString &attributeValue) const;
102     void processFilenameTag(const QDomElement &element);
103     void processMenunameTag(const QDomElement &element);
104     void processSeparatorTag(const QDomElement &element);
105     void processMergeTag(const QDomElement &element);
106 
107     LayoutParams mDefaultParams;
108     QDomElement& mElement;
109     QDomElement mDefaultLayout;
110     QDomElement mLayout;
111     QDomElement mResult;
112 };
113 
114 #endif // QTXDG_XDGMENULAYOUTPROCESSOR_H
115