Sophie

Sophie

distrib > Mandriva > 2006.0 > i586 > by-pkgid > ee5019e51831f214d532979b59ea2d61 > files > 39

kdelibs-3.4.2-31.4.20060mdk.src.rpm

--- ./kio/kio/kservicegroup.h.support_complet_freedesktop_menu	2005-02-24 11:57:56.000000000 +0100
+++ ./kio/kio/kservicegroup.h	2005-03-09 09:43:46.000000000 +0100
@@ -149,6 +149,33 @@ public:
    */
   bool noDisplay() const;
 
+  /** 
+   * Return true if we want to display empty menu entry
+   * @return true to show this service group as menu entry is empty, false to hide it
+   * @since 3.4
+   */
+  bool showEmptyMenu() const;
+
+  void setShowEmptyMenu( bool b);
+
+  /**
+   * @return true to show an inline header into menu
+   * @since 3.4
+   */
+  bool showInlineHeader() const;
+  void setShowInlineHeader(bool _b);
+
+
+  bool inlineAlias() const;
+  void setInlineAlias(bool _b);
+
+  bool allowInline() const;
+  void setAllowInline(bool _b);
+
+  int inlineValue() const;
+  void setInlineValue(int _val);
+
+
   /**
    * Returns a list of untranslated generic names that should be 
    * be supressed when showing this group.
@@ -250,6 +277,8 @@ public:
    */
   static Ptr childGroup(const QString &parent);
 
+  void parseAttribute( const QString &item ,  bool &showEmptyMenu, bool &showInline, bool &showInlineHeader, bool & showInlineAlias ,int &inlineValue );
+
 protected:
   /**
    * @internal
--- ./kio/kio/kservicegroup.cpp.support_complet_freedesktop_menu	2005-03-09 09:43:45.000000000 +0100
+++ ./kio/kio/kservicegroup.cpp	2005-03-09 16:32:23.124414248 +0100
@@ -33,11 +33,16 @@
 class KServiceGroup::Private
 {
 public:
-  Private() { m_bNoDisplay = false; }
+    Private() { m_bNoDisplay = false; m_bShowEmptyMenu = false;m_bShowInlineHeader=false;m_bInlineAlias=false; m_bAllowInline = false;m_inlineValue = 4;}
   bool m_bNoDisplay;
-  QStringList suppressGenericNames;
-  QString directoryEntryPath;
-  QStringList sortOrder;
+    bool m_bShowEmptyMenu;
+    bool m_bShowInlineHeader;
+    bool m_bInlineAlias;
+    bool m_bAllowInline;
+    int m_inlineValue;
+    QStringList suppressGenericNames;
+    QString directoryEntryPath;
+    QStringList sortOrder;
 };
 
 KServiceGroup::KServiceGroup( const QString & name )
@@ -79,7 +84,7 @@ KServiceGroup::KServiceGroup( const QStr
      if (config.readListEntry("NotShowIn", ';').contains("KDE"))
         d->m_bNoDisplay = true;
   }
-  
+
   m_strBaseGroupName = config.readEntry( "X-KDE-BaseGroup" );
   d->suppressGenericNames = config.readListEntry( "X-KDE-SuppressGenericNames" );
   d->sortOrder = config.readListEntry("SortOrder");
@@ -139,6 +144,56 @@ int KServiceGroup::childCount()
 }
 
 
+bool KServiceGroup::showInlineHeader() const
+{
+    return d->m_bShowInlineHeader;
+}
+
+bool KServiceGroup::showEmptyMenu() const
+{
+    return d->m_bShowEmptyMenu;
+}
+
+bool KServiceGroup::inlineAlias() const
+{
+    return d->m_bInlineAlias;
+}
+
+void KServiceGroup::setInlineAlias(bool _b)
+{
+    d->m_bInlineAlias = _b;
+}
+
+void KServiceGroup::setShowEmptyMenu(bool _b)
+{
+    d->m_bShowEmptyMenu=_b;
+}
+
+void KServiceGroup::setShowInlineHeader(bool _b)
+{
+    d->m_bShowInlineHeader=_b;
+}
+
+int KServiceGroup::inlineValue() const
+{
+    return d->m_inlineValue;
+}
+
+void KServiceGroup::setInlineValue(int _val)
+{
+    d->m_inlineValue = _val;
+}
+
+bool KServiceGroup::allowInline() const
+{
+    return d->m_bAllowInline;
+}
+
+void KServiceGroup::setAllowInline(bool _b)
+{
+    d->m_bAllowInline = _b;
+}
+
 bool KServiceGroup::noDisplay() const
 {
   return d->m_bNoDisplay || m_strCaption.startsWith(".");
@@ -153,12 +208,20 @@ void KServiceGroup::load( QDataStream& s
 {
   QStringList groupList;
   Q_INT8 noDisplay;
+  Q_INT8 _showEmptyMenu;
+  Q_INT8 inlineHeader;
+  Q_INT8 _inlineAlias;
+  Q_INT8 _allowInline;
   s >> m_strCaption >> m_strIcon >>
       m_strComment >> groupList >> m_strBaseGroupName >> m_childCount >>
       noDisplay >> d->suppressGenericNames >> d->directoryEntryPath >>
-      d->sortOrder;
+      d->sortOrder >> _showEmptyMenu >> inlineHeader >> _inlineAlias >> _allowInline;
 
   d->m_bNoDisplay = (noDisplay != 0);
+  d->m_bShowEmptyMenu = ( _showEmptyMenu != 0 );
+  d->m_bShowInlineHeader = ( inlineHeader != 0 );
+  d->m_bInlineAlias = ( _inlineAlias != 0 );
+  d->m_bAllowInline = ( _allowInline != 0 );
 
   if (m_bDeep)
   {
@@ -217,10 +280,14 @@ void KServiceGroup::save( QDataStream& s
   (void) childCount();
 
   Q_INT8 noDisplay = d->m_bNoDisplay ? 1 : 0;
+  Q_INT8 _showEmptyMenu = d->m_bShowEmptyMenu ? 1 : 0;
+  Q_INT8 inlineHeader = d->m_bShowInlineHeader ? 1 : 0;
+  Q_INT8 _inlineAlias = d->m_bInlineAlias ? 1 : 0;
+  Q_INT8 _allowInline = d->m_bAllowInline ? 1 : 0;
   s << m_strCaption << m_strIcon <<
       m_strComment << groupList << m_strBaseGroupName << m_childCount <<
       noDisplay << d->suppressGenericNames << d->directoryEntryPath <<
-      d->sortOrder;
+      d->sortOrder <<_showEmptyMenu <<inlineHeader<<_inlineAlias<<_allowInline;
 }
 
 KServiceGroup::List
@@ -286,7 +353,7 @@ KServiceGroup::entries(bool sort, bool e
           name = static_cast<KService *>(p)->genericName() + " " + p->name();
         else
           name = p->name() + " " + static_cast<KService *>(p)->genericName();
-                                                                      
+
         QCString key( name.length() * 4 + 1 );
         // strxfrm() crashes on Solaris
 #ifndef USE_SOLARIS
@@ -316,6 +383,7 @@ KServiceGroup::entries(bool sort, bool e
     {
        d->sortOrder << ":M";
        d->sortOrder << ":F";
+       d->sortOrder << ":OIH IL[4]"; //just inline header
     }
 
     QString rp = relPath();
@@ -375,6 +443,35 @@ KServiceGroup::entries(bool sort, bool e
              if (allowSeparators)
                 needSeparator = true;
           }
+          else if ( item.contains( ":O" ) )
+          {
+              //todo parse attribute:
+              QString tmp(  item );
+              tmp = tmp.remove(":O");
+              QStringList optionAttribute = QStringList::split(" ",tmp);
+              if( optionAttribute.count()==0)
+                  optionAttribute.append(tmp);
+              bool showEmptyMenu = false;
+              bool showInline = false;
+              bool showInlineHeader = true;
+              bool showInlineAlias = false;
+              int inlineValue = 4;
+
+              for ( QStringList::Iterator it3 = optionAttribute.begin(); it3 != optionAttribute.end(); ++it3 )
+              {
+                  parseAttribute( *it3,  showEmptyMenu, showInline, showInlineHeader, showInlineAlias, inlineValue );
+              }
+              for(KSortableValueList<SPtr,QCString>::Iterator it2 = glist.begin(); it2 != glist.end(); ++it2)
+              {
+                  KServiceGroup *group = (KServiceGroup *)((KSycocaEntry *)(*it2).value());
+                  group->setShowEmptyMenu(  showEmptyMenu  );
+                  group->setAllowInline( showInline );
+                  group->setShowInlineHeader( showInlineHeader );
+                  group->setInlineAlias( showInlineAlias );
+                  group->setInlineValue( inlineValue );
+              }
+
+          }
           else if (item == ":M")
           {
             // Add sorted list of sub-menus
@@ -396,14 +493,14 @@ KServiceGroup::entries(bool sort, bool e
             // Add sorted lists of services and submenus
             KSortableValueList<SPtr,QCString>::Iterator it_s = slist.begin();
             KSortableValueList<SPtr,QCString>::Iterator it_g = glist.begin();
-            
+
             while(true)
             {
                if (it_s == slist.end())
                {
                   if (it_g == glist.end())
                      break; // Done
-                     
+
                   // Insert remaining sub-menu
                   addItem(sorted, (*it_g).value(), needSeparator);
                   it_g++;
@@ -431,41 +528,104 @@ KServiceGroup::entries(bool sort, bool e
         }
         else if (item[0] == '/')
         {
-          QString groupPath = rp + item.mid(1) + "/";
+            QString groupPath = rp + item.mid(1) + "/";
 
-          for (List::ConstIterator it2(group->m_serviceList.begin()); it2 != group->m_serviceList.end(); ++it2)
-          {
-            if (!(*it2)->isType(KST_KServiceGroup))
-               continue;
-            KServiceGroup *group = (KServiceGroup *)((KSycocaEntry *)(*it2));
-            if (group->relPath() == groupPath)
+            for (List::ConstIterator it2(group->m_serviceList.begin()); it2 != group->m_serviceList.end(); ++it2)
             {
-               if (!excludeNoDisplay || !group->noDisplay())
-                  addItem(sorted, (*it2), needSeparator);
-               break;
+                if (!(*it2)->isType(KST_KServiceGroup))
+                    continue;
+                KServiceGroup *group = (KServiceGroup *)((KSycocaEntry *)(*it2));
+                if (group->relPath() == groupPath)
+                {
+                    if (!excludeNoDisplay || !group->noDisplay())
+                    {
+                        const QString &nextItem = *( ++it );
+                        if ( nextItem.startsWith( ":O" ) )
+                        {
+                            QString tmp(  nextItem );
+                            tmp = tmp.remove(":O");
+                            QStringList optionAttribute = QStringList::split(" ",tmp);
+                            if( optionAttribute.count()==0)
+	                               optionAttribute.append(tmp);
+                            bool bShowEmptyMenu = false;
+                            bool bShowInline = false;
+                            bool bShowInlineHeader = false;
+                            bool bShowInlineAlias = false;
+                            int inlineValue = -1;
+
+                            for ( QStringList::Iterator it3 = optionAttribute.begin(); it3 != optionAttribute.end(); ++it3 )
+                            {
+                                parseAttribute( *it3 , bShowEmptyMenu, bShowInline, bShowInlineHeader, bShowInlineAlias , inlineValue );
+                            }
+							group->setShowEmptyMenu( bShowEmptyMenu );
+                            group->setAllowInline( bShowInline );
+                            group->setShowInlineHeader( bShowInlineHeader );
+                            group->setInlineAlias( bShowInlineAlias );
+                            group->setInlineValue( inlineValue );
+
+                        }
+                        else
+                            it--;
+
+                        addItem(sorted, (group), needSeparator);
+                    }
+                    break;
+                }
             }
-          }
         }
         else
         {
-          for (List::ConstIterator it2(group->m_serviceList.begin()); it2 != group->m_serviceList.end(); ++it2)
-          {
-            if (!(*it2)->isType(KST_KService))
-               continue;
-            KService *service = (KService *)((KSycocaEntry *)(*it2));
-            if (service->menuId() == item)
+            for (List::ConstIterator it2(group->m_serviceList.begin()); it2 != group->m_serviceList.end(); ++it2)
             {
-               if (!excludeNoDisplay || !service->noDisplay())
-                  addItem(sorted, (*it2), needSeparator);
-               break;
+                if (!(*it2)->isType(KST_KService))
+                    continue;
+                KService *service = (KService *)((KSycocaEntry *)(*it2));
+                if (service->menuId() == item)
+                {
+                    if (!excludeNoDisplay || !service->noDisplay())
+                        addItem(sorted, (*it2), needSeparator);
+                    break;
+                }
             }
-          }
         }
     }
 
     return sorted;
 }
 
+void KServiceGroup::parseAttribute( const QString &item ,  bool &showEmptyMenu, bool &showInline, bool &showInlineHeader, bool & showInlineAlias , int &inlineValue )
+{
+    if( item == "ME") //menu empty
+        showEmptyMenu=true;
+    else if ( item == "NME") //menu empty
+        showEmptyMenu=false;
+    else if( item == "I") //inline !
+        showInline = true;
+    else if ( item == "NI") //inline !
+        showInline = false;
+    else if( item == "IH") //inline  header!
+        showInlineHeader= true;
+    else if ( item == "NIH") //inline  header!
+        showInlineHeader = false;
+    else if( item == "IA") //inline alias!
+        showInlineAlias = true;
+    else if (  item == "NIA") //inline alias!
+        showInlineAlias = false;
+    else if( ( item ).contains( "IL" )) //inline limite!
+    {
+        QString tmp( item );
+        tmp = tmp.remove( "IL[" );
+        tmp = tmp.remove( "]" );
+        bool ok;
+        int _inlineValue = tmp.toInt(&ok);
+        if ( !ok ) //error
+            _inlineValue = -1;
+        inlineValue =  _inlineValue;
+    }
+    else
+        kdDebug()<<" not supported !!!!!!!\n";
+}
+
 void KServiceGroup::setLayoutInfo(const QStringList &layout)
 {
     d->sortOrder = layout;
--- kded/vfolder_menu.cpp--	2005-04-04 09:16:51.905247047 -0400
+++ kded/vfolder_menu.cpp	2005-04-04 09:19:13.996780570 -0400
@@ -1405,9 +1405,75 @@ kdDebug(7021) << "Processing KDE Legacy 
    m_currentMenu = parentMenu;
 }
 
+static QString parseAttribute( const QDomElement &e)
+{
+    QString option;
+    if ( e.hasAttribute( "show_empty" ) )
+    {
+        QString str = e.attribute( "show_empty" );
+        if ( str=="true" )
+            option= "ME ";
+        else if ( str=="false" )
+            option= "NME ";
+        else
+            kdDebug()<<" Error in parsing show_empty attribute :"<<str<<endl;
+    }
+    if ( e.hasAttribute( "inline" ) )
+    {
+        QString str = e.attribute( "inline" );
+        if (  str=="true" )
+            option+="I ";
+        else if ( str=="false" )
+            option+="NI ";
+        else
+            kdDebug()<<" Error in parsing inlibe attribute :"<<str<<endl;
+    }
+    if ( e.hasAttribute( "inline_limit" ) )
+    {
+        bool ok;
+        int value = e.attribute( "inline_limit" ).toInt(&ok);
+        if ( ok )
+            option+=QString( "IL[%1] " ).arg( value );
+    }
+    if ( e.hasAttribute( "inline_header" ) )
+    {
+        QString str = e.attribute( "inline_header" );
+        if ( str=="true")
+            option+="IH ";
+        else if ( str == "false" )
+            option+="NIH ";
+        else
+            kdDebug()<<" Error in parsing of inline_header attribute :"<<str<<endl;
+
+    }
+    if ( e.hasAttribute( "inline_alias" ) && e.attribute( "inline_alias" )=="true")
+    {
+        QString str = e.attribute( "inline_alias" );
+        if ( str=="true" )
+            option+="IA";
+        else if ( str=="false" )
+            option+="NIA";
+        else
+            kdDebug()<<" Error in parsing inline_alias attribute :"<<str<<endl;
+    }
+    if( !option.isEmpty())
+    {
+        option = option.prepend(":O");
+    }
+    return option;
+
+}
+
+
 static QStringList parseLayoutNode(const QDomElement &docElem)
 {
    QStringList layout;
+   QString optionDefaultLayout;
+   if( docElem.tagName()=="DefaultLayout")
+       optionDefaultLayout =  parseAttribute( docElem);
+   if ( !optionDefaultLayout.isEmpty() )
+       layout.append( optionDefaultLayout );
+
    
    QDomNode n = docElem.firstChild();
    while( !n.isNull() ) {
@@ -1423,6 +1489,10 @@ static QStringList parseLayoutNode(const
       else if (e.tagName() == "Menuname")
       {
          layout.append("/"+e.text());
+         QString option = parseAttribute( e );
+         if( !option.isEmpty())
+             layout.append( option );
+
       }
       else if (e.tagName() == "Merge")
       {