OSDN Git Service

Discontinue formal use of the build-aux submodule.
[mingw/mingw-get.git] / src / pkglist.cpp
index 450cc75..ed69aa0 100644 (file)
@@ -4,7 +4,7 @@
  * $Id$
  *
  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2012, MinGW Project
+ * Copyright (C) 2012, 2013, MinGW.org Project
  *
  *
  * Implementation of the methods for the pkgListViewMaker class, and
@@ -73,13 +73,12 @@ void AppWindowMaker::InitPackageListView()
   /* Initialise the table layout, and assign column headings.
    */
   LVCOLUMN table;
-  struct { int id; int width; char *text; } headings[] =
+  struct { int id; int width; const char *text; } headings[] =
   {
     /* Specify the column headings for the package list table.
      */
     { ID_PKGLIST_TABLE_HEADINGS,  20, ""  },
-    { ID_PKGNAME_COLUMN_HEADING, 150, "Package" },
-    { ID_PKGTYPE_COLUMN_HEADING,  48, "Class" },
+    { ID_PKGNAME_COLUMN_HEADING, 198, "Package" },
     { ID_INSTVER_COLUMN_HEADING, 125, "Installed Version" },
     { ID_REPOVER_COLUMN_HEADING, 125, "Repository Version" },
     { ID_PKGDESC_COLUMN_HEADING, 400, "Description" },
@@ -96,7 +95,7 @@ void AppWindowMaker::InitPackageListView()
      * (in pixels), and assigning the heading to each.
      */
     table.cx = headings[index].width;
-    table.pszText = headings[index].text;
+    table.pszText = (char *)(headings[index].text);
     ListView_InsertColumn( PackageListView, index, &table );
   }
   /* "Update" the package list, to initialise the list view.
@@ -113,8 +112,30 @@ void AppWindowMaker::UpdatePackageList()
   pkgDirectory *dir = pkgData->CatalogueAllPackages();
   dir->InOrder( &PackageList );
   delete dir;
+
+  /* Force a redraw of the application window, to ensure that the
+   * data pane content remains synchronised.
+   */
+  InvalidateRect( AppWindow, NULL, FALSE );
+  UpdateWindow( AppWindow );
 }
 
+inline bool pkgXmlNode::IsVisibleGroupMember()
+{
+  /* Hook invoked before adding a package reference to the package list,
+   * to ensure that it represents a member of the current package group.
+   */
+  return AppWindowMaker::IsPackageGroupAffiliate( this );
+}
+
+/* FIXME: Complementary check for component class visibility requires a
+ * future component class visibility control; for the time being, we may
+ * assume that any component package should be visible if it belongs to
+ * any visible package group, (including a component subset of such a
+ * group, which may comprise only itself).
+ */
+inline bool pkgXmlNode::IsVisibleClass(){ return IsVisibleGroupMember(); }
+
 static char *pkgGetTitle( pkgXmlNode *pkg, const pkgXmlNode *xml_root )
 {
   /* A private helper method, to retrieve the title attribute
@@ -390,9 +411,10 @@ void pkgListViewMaker::UpdateItem( char *class_name, bool new_entry )
      * ...and fill in the text for the package name, class name,
      * and package description columns...
      */
-    ListView_SetItemText( ListView, content.iItem, 1, package_name );
-    ListView_SetItemText( ListView, content.iItem, 2, class_name );
-    ListView_SetItemText( ListView, content.iItem, 5, pkgGetTitle( package ) );
+    char name[len]; const char *fmt = "%s-%s";
+    sprintf( name, *class_name ? fmt : fmt + 3, package_name, class_name );
+    ListView_SetItemText( ListView, content.iItem, 1, name );
+    ListView_SetItemText( ListView, content.iItem, 4, pkgGetTitle( package ) );
   }
   else
     /* ...otherwise, this is simply a request to update an
@@ -406,12 +428,12 @@ void pkgListViewMaker::UpdateItem( char *class_name, bool new_entry )
    * column which identifies the currently installed version,
    * if any, or clear it if the package is not installed.
    */
-  ListView_SetItemText( ListView, content.iItem, 3, buf );
+  ListView_SetItemText( ListView, content.iItem, 2, buf );
 
   /* Finally, fill in the text of the column which identifies
    * the latest available version of the package.
    */
-  ListView_SetItemText( ListView, content.iItem, 4, pkgVersionString( buf, &latest ) );
+  ListView_SetItemText( ListView, content.iItem, 3, pkgVersionString( buf, &latest ) );
 }
 
 void pkgListViewMaker::Dispatch( pkgXmlNode *package )
@@ -439,13 +461,14 @@ void pkgListViewMaker::Dispatch( pkgXmlNode *package )
       dir->InOrder( this );
       delete dir;
     }
-    else
-      /* ...otherwise, simply insert an unclassified list entry
+    else if( package->IsVisibleGroupMember() )
+      /*
+       * ...otherwise, simply insert an unclassified list entry
        * for the bare package name, omitting the component class.
        */
-      InsertItem( package, "" );
+      InsertItem( package, (char *)("") );
   }
-  else if( package->IsElementOfType( component_key ) )
+  else if( package->IsElementOfType( component_key ) && package->IsVisibleClass() )
   {
     /* Handle the recursive calls for the component sub-directory,
      * inheriting the package name entry from the original package