summaryrefslogtreecommitdiffstats
path: root/opensuse/tdelibs/clever-menu.diff
blob: e2ae876c5ec7803dea54266f7ab0e2319558f7ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
Index: kio/kio/kservice.cpp
===================================================================
--- kio/kio/kservice.cpp.orig
+++ kio/kio/kservice.cpp
@@ -725,6 +725,20 @@ QString KService::untranslatedGenericNam
   return v.isValid() ? v.toString() : QString::null;
 }
 
+bool KService::SuSEunimportant() const {
+  QMap<QString,QVariant>::ConstIterator it = m_mapProps.find( "X-SuSE-Unimportant" );
+  if ( (it == m_mapProps.end()) || (!it.data().isValid()))
+  {
+     return false;
+  }
+
+  QString aValue = it.data().toString();
+  if (aValue == "true" || aValue == "on" || aValue == "yes")
+     return true;
+  else
+     return false;
+}
+
 QString KService::parentApp() const {
   QMap<QString,QVariant>::ConstIterator it = m_mapProps.find( "X-KDE-ParentApp" );
   if ( (it == m_mapProps.end()) || (!it.data().isValid()))
Index: kio/kio/kservice.h
===================================================================
--- kio/kio/kservice.h.orig
+++ kio/kio/kservice.h
@@ -327,6 +327,10 @@ public:
    * @return true to suppress this service
    */
   bool noDisplay() const;
+  /**
+   * check if the application entry is important
+   */
+  bool SuSEunimportant() const;
 
   /**
    * Name of the application this service belongs to.
Index: kio/kio/kservicegroup.cpp
===================================================================
--- kio/kio/kservicegroup.cpp.orig
+++ kio/kio/kservicegroup.cpp
@@ -31,8 +31,10 @@
 class KServiceGroup::Private
 {
 public:
-    Private() { m_bNoDisplay = false; m_bShowEmptyMenu = false;m_bShowInlineHeader=false;m_bInlineAlias=false; m_bAllowInline = false;m_inlineValue = 4;}
+    Private() { m_bNoDisplay = false; m_bShowEmptyMenu = false;m_bShowInlineHeader=false;m_bInlineAlias=false; m_bAllowInline = false; m_inlineValue = 4; m_bShortMenu = false; m_bGeneralDescription = false;}
   bool m_bNoDisplay;
+    bool m_bShortMenu;
+    bool m_bGeneralDescription;
     bool m_bShowEmptyMenu;
     bool m_bShowInlineHeader;
     bool m_bInlineAlias;
@@ -73,6 +75,11 @@ KServiceGroup::KServiceGroup( const QStr
   m_strComment = config.readEntry( "Comment" );
   m_bDeleted = config.readBoolEntry( "Hidden", false );
   d->m_bNoDisplay = config.readBoolEntry( "NoDisplay", false );
+  if (d->directoryEntryPath.startsWith(QDir::homeDirPath()))
+    d->m_bShortMenu = false;
+  else
+    d->m_bShortMenu = config.readBoolEntry( "X-SuSE-AutoShortMenu", true );
+  d->m_bGeneralDescription = config.readBoolEntry( "X-SuSE-GeneralDescription", false );
   QStringList tmpList;
   if (config.hasKey("OnlyShowIn"))
   {
@@ -120,6 +127,10 @@ int KServiceGroup::childCount()
 {
   if (m_childCount == -1)
   {
+     KConfig global("kdeglobals");
+     global.setGroup("KDE");
+     bool showUnimportant = global.readBoolEntry("showUnimportant", false);
+
      m_childCount = 0;
 
      for( List::ConstIterator it = m_serviceList.begin();
@@ -130,7 +141,8 @@ int KServiceGroup::childCount()
         {
            KService *service = static_cast<KService *>(p);
            if (!service->noDisplay())
-              m_childCount++;
+             if ( showUnimportant || !service->SuSEunimportant() )
+               m_childCount++;
         }
         else if (p->isType(KST_KServiceGroup))
         {
@@ -203,6 +215,16 @@ QStringList KServiceGroup::suppressGener
   return d->suppressGenericNames;
 }
 
+bool KServiceGroup::SuSEgeneralDescription() const
+{
+    return d->m_bGeneralDescription;
+}
+
+bool KServiceGroup::SuSEshortMenu() const
+{
+    return d->m_bShortMenu;
+}
+
 void KServiceGroup::load( QDataStream& s )
 {
   QStringList groupList;
@@ -214,7 +236,8 @@ void KServiceGroup::load( QDataStream& s
   s >> m_strCaption >> m_strIcon >>
       m_strComment >> groupList >> m_strBaseGroupName >> m_childCount >>
       noDisplay >> d->suppressGenericNames >> d->directoryEntryPath >>
-      d->sortOrder >> _showEmptyMenu >> inlineHeader >> _inlineAlias >> _allowInline;
+      d->sortOrder >> _showEmptyMenu >> inlineHeader >> _inlineAlias >>
+      _allowInline >> d->m_bShortMenu >> d->m_bGeneralDescription;
 
   d->m_bNoDisplay = (noDisplay != 0);
   d->m_bShowEmptyMenu = ( _showEmptyMenu != 0 );
@@ -286,7 +309,8 @@ void KServiceGroup::save( QDataStream& s
   s << m_strCaption << m_strIcon <<
       m_strComment << groupList << m_strBaseGroupName << m_childCount <<
       noDisplay << d->suppressGenericNames << d->directoryEntryPath <<
-      d->sortOrder <<_showEmptyMenu <<inlineHeader<<_inlineAlias<<_allowInline;
+      d->sortOrder <<_showEmptyMenu <<inlineHeader<<_inlineAlias<<_allowInline << 
+      d->m_bShortMenu << d->m_bGeneralDescription;
 }
 
 KServiceGroup::List
@@ -312,6 +336,12 @@ static void addItem(KServiceGroup::List
 KServiceGroup::List
 KServiceGroup::entries(bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName)
 {
+   return SuSEentries(sort, excludeNoDisplay, allowSeparators, sortByGenericName);
+}
+
+KServiceGroup::List
+KServiceGroup::SuSEentries(bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName, bool excludeSuSEunimportant)
+{
     KServiceGroup *group = this;
 
     // If the entries haven't been loaded yet, we have to reload ourselves
@@ -338,11 +368,18 @@ KServiceGroup::entries(bool sort, bool e
     for (List::ConstIterator it(group->m_serviceList.begin()); it != group->m_serviceList.end(); ++it)
     {
         KSycocaEntry *p = (*it);
+        if( !p->isType(KST_KServiceGroup) && !p->isType(KST_KService))
+            continue;
 	bool noDisplay = p->isType(KST_KServiceGroup) ?
                                    static_cast<KServiceGroup *>(p)->noDisplay() :
                                    static_cast<KService *>(p)->noDisplay();
         if (excludeNoDisplay && noDisplay)
            continue;
+	bool SuSEunimportant = p->isType(KST_KService) &&
+                                   static_cast<KService *>(p)->SuSEunimportant();
+        if (excludeSuSEunimportant && SuSEunimportant)
+           continue;
+
         // Choose the right list
         KSortableValueList<SPtr,QCString> & list = p->isType(KST_KServiceGroup) ? glist : slist;
         QString name;
@@ -374,6 +411,15 @@ KServiceGroup::entries(bool sort, bool e
         }
         list.insert(key,SPtr(*it));
     }
+
+    return group->SuSEsortEntries( slist, glist, excludeNoDisplay, allowSeparators );
+}
+
+KServiceGroup::List
+KServiceGroup::SuSEsortEntries( KSortableValueList<SPtr,QCString> slist, KSortableValueList<SPtr,QCString> glist, bool excludeNoDisplay, bool allowSeparators )
+{
+    KServiceGroup *group = this;
+
     // Now sort
     slist.sort();
     glist.sort();
@@ -415,6 +461,8 @@ KServiceGroup::entries(bool sort, bool e
            // TODO: This prevents duplicates
           for(KSortableValueList<SPtr,QCString>::Iterator it2 = slist.begin(); it2 != slist.end(); ++it2)
           {
+            if (!(*it2).value()->isType(KST_KService))
+                continue;
              KService *service = (KService *)((KSycocaEntry *)((*it2).value()));
              if (service->menuId() == item)
              {
Index: kio/kio/kservicegroup.h
===================================================================
--- kio/kio/kservicegroup.h.orig
+++ kio/kio/kservicegroup.h
@@ -26,6 +26,7 @@
 #include <qvariant.h>
 
 #include <kdesktopfile.h>
+#include <ksortablevaluelist.h>
 
 #include "ksycocaentry.h"
 #include "ksycocatype.h"
@@ -201,6 +202,12 @@ public:
   void setLayoutInfo(const QStringList &layout);
 
   /**
+   * SuSE special, not part of KDE API
+   */
+  bool SuSEshortMenu() const;
+  bool SuSEgeneralDescription() const;
+
+  /**
    * @internal
    * Returns information related to the layout of services in this group.
    */
@@ -238,6 +245,12 @@ public:
    */
   virtual List entries(bool sorted = false);
 
+  /*
+   * UNOFFICIAL SuSE special
+   */
+  virtual List SuSEentries(bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName, bool excludeSuSEunimportant = true);
+  virtual List SuSEsortEntries( KSortableValueList<SPtr,QCString> slist, KSortableValueList<SPtr,QCString> glist, bool excludeNoDisplay, bool allowSeparators );
+
   /**
    * Returns a non-empty string if the group is a special base group.
    * By default, "Settings/" is the kcontrol base group ("settings")