[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/sysadmin/muon/installer/CategoryView
From:       Jonathan Michael Thomas <echidnaman () kubuntu ! org>
Date:       2010-11-15 20:40:36
Message-ID: 20101115204036.CAFC3AC8A2 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1197439 by jmthomas:

Add an "All" subcategory to categories with subcategories


 M  +16 -1     Category.cpp  
 M  +8 -1      Category.h  
 M  +0 -1      CategoryViewWidget.cpp  


--- trunk/extragear/sysadmin/muon/installer/CategoryView/Category.cpp #1197438:1197439
@@ -22,9 +22,12 @@
 
 #include <QtXml/QDomNode>
 
-Category::Category(const QDomNode &data)
+#include <KLocale>
+
+Category::Category(const QDomNode &data, CategoryChildPolicy policy)
         : m_iconString("applications-other")
         , m_hasSubCategories(false)
+        , m_policy(policy)
 {
     parseData(data);
 }
@@ -47,22 +50,34 @@
                 node = node.nextSibling();
                 continue;
             }
+
+            if (m_policy == CanHaveChildren) {
             m_name = tempElement.text();
+            } else {
+                m_name = i18nc("@label", "All");
+            }
         } else if (tempElement.tagName() == QLatin1String("Icon")) {
             if (!tempElement.text().isEmpty()) {
                 m_iconString = tempElement.text();
             }
         } else if (tempElement.tagName() == QLatin1String("Menu")) {
+            if (m_policy == CanHaveChildren) {
             Category *subCategory = new Category(node);
             m_subCategories << subCategory;
             m_hasSubCategories = true;
+            }
         } else if (tempElement.tagName() == QLatin1String("Include")) {
             parseIncludes(tempElement);
         }
 
         node = node.nextSibling();
     }
+
+    if (m_hasSubCategories) {
+        Category *allSubCategory = new Category(data, NoChildren);
+        m_subCategories << allSubCategory;
 }
+}
 
 QList<QPair<FilterType, QString> > Category::parseIncludes(const QDomNode &data)
 {
--- trunk/extragear/sysadmin/muon/installer/CategoryView/Category.h #1197438:1197439
@@ -35,10 +35,16 @@
     PkgNameFilter = 4
 };
 
+enum CategoryChildPolicy {
+    InvalidPolicy = 0,
+    CanHaveChildren = 1,
+    NoChildren = 2
+};
+
 class Category
 {
 public:
-    explicit Category(const QDomNode &node);
+    explicit Category(const QDomNode &node, CategoryChildPolicy type = CanHaveChildren);
     ~Category();
 
     QString name() const;
@@ -57,6 +63,7 @@
     QList<QPair<FilterType, QString> > m_notFilters;
     bool m_hasSubCategories;
     QList<Category *> m_subCategories;
+    CategoryChildPolicy m_policy;
 
     void parseData(const QDomNode &data);
     QList<QPair<FilterType, QString> > parseIncludes(const QDomNode &data);
--- trunk/extragear/sysadmin/muon/installer/CategoryView/CategoryViewWidget.cpp #1197438:1197439
@@ -87,7 +87,6 @@
     KCategorizedSortFilterProxyModel *proxy = new KCategorizedSortFilterProxyModel(this);
     proxy->setSourceModel(m_categoryModel);
     proxy->setCategorizedModel(true);
-    proxy->sort(0);
     m_categoryView->setModel(proxy);
 
     m_crumb->setText(rootName);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic