[PC-BSD Commits] r771 - in pcbsd: branches/1.4/kcmPBMsource trunk/kcmPBMsource

svn at pcbsd.org svn at pcbsd.org
Mon Oct 1 06:46:35 PDT 2007


Author: tim
Date: 2007-10-01 06:46:35 -0700 (Mon, 01 Oct 2007)
New Revision: 771

Modified:
   pcbsd/branches/1.4/kcmPBMsource/kcm.cpp
   pcbsd/branches/1.4/kcmPBMsource/pbm.ui.h
   pcbsd/trunk/kcmPBMsource/kcm.cpp
   pcbsd/trunk/kcmPBMsource/pbm.ui.h
Log:
Improved efficiency of PBI manager list population.

Modified: pcbsd/branches/1.4/kcmPBMsource/kcm.cpp
===================================================================
--- pcbsd/branches/1.4/kcmPBMsource/kcm.cpp	2007-10-01 11:19:54 UTC (rev 770)
+++ pcbsd/branches/1.4/kcmPBMsource/kcm.cpp	2007-10-01 13:46:35 UTC (rev 771)
@@ -27,8 +27,8 @@
   KGlobal::locale()->insertCatalogue(LANG);
 
   PBM *pbmproc = new PBM(parent);
+  pbmproc->reparent(this, QPoint());
   pbmproc->ProgramInit();
-  pbmproc->reparent(this, QPoint());
   } else  {
       setButtons(KCModule::Help);
       NotRoot *nroot = new NotRoot(parent);

Modified: pcbsd/branches/1.4/kcmPBMsource/pbm.ui.h
===================================================================
--- pcbsd/branches/1.4/kcmPBMsource/pbm.ui.h	2007-10-01 11:19:54 UTC (rev 770)
+++ pcbsd/branches/1.4/kcmPBMsource/pbm.ui.h	2007-10-01 13:46:35 UTC (rev 771)
@@ -171,17 +171,15 @@
         file.close();
     }
     
-    for (int n=0; n<=i; n++)
+    i = 0;
+    SoftwareListBox->clear();
+    
+    while (! ProgName[i].isEmpty())
     {
-        if ( ProgName[n].isEmpty() )
-        {
-	 break;
-        }
-
-        tmp = ProgName[n];
+        tmp = ProgName[i];
         tmp.replace(" ", "");
         ProgDirName = tmp;
-        tmp = ProgVer[n];
+        tmp = ProgVer[i];
         tmp.replace(" ", "");
         ProgDirName = ProgDirName + tmp;
 
@@ -189,46 +187,27 @@
 	QDir d( "/Programs/" + ProgDirName );  
    	 if ( !d.exists() ) {
 	 // If the directory doesn't exist, remove the entry
-	 CleanPackageList(n);
+	 CleanPackageList(i);
 	 PopulateList();
 	 return;
 	}
 
-	qDebug("Working out path for: " + ProgName[n]);
-	QString progPath = "/Programs/" + ProgName[n] + ProgVer[n];
+	qDebug("Working out path for: " + ProgName[i]);
+	QString progPath = "/Programs/" + ProgName[i] + ProgVer[i];
 	progPath.remove(" ");
 	qDebug("Finding size of: " + progPath);
-	ProgSize[n] = getDirSize(progPath);
+	ProgSize[i] = getDirSize(progPath);
+        
+        if (ProgIcon[i].isEmpty()) ProgIcon[i] = "/Programs/.config/application.png";
+        else ProgIcon[i] = "/Programs/" + ProgDirName + "/" + ProgIcon[i];
+        //QImage *Icon = new QImage(ProgIcon[i]);
+        QPixmap PixmapIcon;
+        PixmapIcon.convertFromImage(QImage(ProgIcon[i]).smoothScale(40,40));
+        qDebug("Inserting " + ProgName[i] + " into ListBox");
+        SoftwareListBox->insertItem(PixmapIcon, ProgName[i] + " " + ProgVer[i] + " (" + bytesToHumanReadable(ProgSize[i]) + ")");
+        
+        i++;
     }
-    
-    i = 0;
-    QString IconPath;
-    SoftwareListBox->clear();
-    
-    while (! ProgName[i].isEmpty() )
-    {
-	
-        tmp = ProgName[i];
-        tmp.replace(" ", "");
-        ProgDirName = tmp;
-        tmp = ProgVer[i];
-        tmp.replace(" ", "");
-        ProgDirName = ProgDirName + tmp;
-
-	
-	if (ProgIcon[i].isEmpty() )
-	{
-	      IconPath="/Programs/.config/application.png";
-	} else {
-	      IconPath = "/Programs/" + ProgDirName + "/" + ProgIcon[i];
-	}
-	
-       QImage *Icon = new QImage(IconPath);
-       QPixmap PixmapIcon;
-       PixmapIcon.convertFromImage(Icon->smoothScale(40,40));
-       SoftwareListBox->insertItem(PixmapIcon, ProgName[i] + " " + ProgVer[i] + " (" + bytesToHumanReadable(ProgSize[i]) + ")");
-       i++;
-    }
 }
 
 
@@ -560,7 +539,7 @@
         d.setFilter( QDir::Dirs );
         d.setSorting( QDir::Name );
 	
-        for ( int i = 0; i < d.count(); i++ )
+        for ( uint i = 0; i < d.count(); i++ )
         {
 	    QFile file( "/PCBSD/Components/" + d[i] + "/component.cfg" );
 	    if ( file.open( IO_ReadOnly ) ) {

Modified: pcbsd/trunk/kcmPBMsource/kcm.cpp
===================================================================
--- pcbsd/trunk/kcmPBMsource/kcm.cpp	2007-10-01 11:19:54 UTC (rev 770)
+++ pcbsd/trunk/kcmPBMsource/kcm.cpp	2007-10-01 13:46:35 UTC (rev 771)
@@ -27,8 +27,8 @@
   KGlobal::locale()->insertCatalogue(LANG);
 
   PBM *pbmproc = new PBM(parent);
+  pbmproc->reparent(this, QPoint());
   pbmproc->ProgramInit();
-  pbmproc->reparent(this, QPoint());
   } else  {
       setButtons(KCModule::Help);
       NotRoot *nroot = new NotRoot(parent);

Modified: pcbsd/trunk/kcmPBMsource/pbm.ui.h
===================================================================
--- pcbsd/trunk/kcmPBMsource/pbm.ui.h	2007-10-01 11:19:54 UTC (rev 770)
+++ pcbsd/trunk/kcmPBMsource/pbm.ui.h	2007-10-01 13:46:35 UTC (rev 771)
@@ -171,17 +171,15 @@
         file.close();
     }
     
-    for (int n=0; n<=i; n++)
+    i = 0;
+    SoftwareListBox->clear();
+    
+    while (! ProgName[i].isEmpty())
     {
-        if ( ProgName[n].isEmpty() )
-        {
-	 break;
-        }
-
-        tmp = ProgName[n];
+        tmp = ProgName[i];
         tmp.replace(" ", "");
         ProgDirName = tmp;
-        tmp = ProgVer[n];
+        tmp = ProgVer[i];
         tmp.replace(" ", "");
         ProgDirName = ProgDirName + tmp;
 
@@ -189,46 +187,27 @@
 	QDir d( "/Programs/" + ProgDirName );  
    	 if ( !d.exists() ) {
 	 // If the directory doesn't exist, remove the entry
-	 CleanPackageList(n);
+	 CleanPackageList(i);
 	 PopulateList();
 	 return;
 	}
 
-	qDebug("Working out path for: " + ProgName[n]);
-	QString progPath = "/Programs/" + ProgName[n] + ProgVer[n];
+	qDebug("Working out path for: " + ProgName[i]);
+	QString progPath = "/Programs/" + ProgName[i] + ProgVer[i];
 	progPath.remove(" ");
 	qDebug("Finding size of: " + progPath);
-	ProgSize[n] = getDirSize(progPath);
+	ProgSize[i] = getDirSize(progPath);
+        
+        if (ProgIcon[i].isEmpty()) ProgIcon[i] = "/Programs/.config/application.png";
+        else ProgIcon[i] = "/Programs/" + ProgDirName + "/" + ProgIcon[i];
+        //QImage *Icon = new QImage(ProgIcon[i]);
+        QPixmap PixmapIcon;
+        PixmapIcon.convertFromImage(QImage(ProgIcon[i]).smoothScale(40,40));
+        qDebug("Inserting " + ProgName[i] + " into ListBox");
+        SoftwareListBox->insertItem(PixmapIcon, ProgName[i] + " " + ProgVer[i] + " (" + bytesToHumanReadable(ProgSize[i]) + ")");
+        
+        i++;
     }
-    
-    i = 0;
-    QString IconPath;
-    SoftwareListBox->clear();
-    
-    while (! ProgName[i].isEmpty() )
-    {
-	
-        tmp = ProgName[i];
-        tmp.replace(" ", "");
-        ProgDirName = tmp;
-        tmp = ProgVer[i];
-        tmp.replace(" ", "");
-        ProgDirName = ProgDirName + tmp;
-
-	
-	if (ProgIcon[i].isEmpty() )
-	{
-	      IconPath="/Programs/.config/application.png";
-	} else {
-	      IconPath = "/Programs/" + ProgDirName + "/" + ProgIcon[i];
-	}
-	
-       QImage *Icon = new QImage(IconPath);
-       QPixmap PixmapIcon;
-       PixmapIcon.convertFromImage(Icon->smoothScale(40,40));
-       SoftwareListBox->insertItem(PixmapIcon, ProgName[i] + " " + ProgVer[i] + " (" + bytesToHumanReadable(ProgSize[i]) + ")");
-       i++;
-    }
 }
 
 
@@ -560,7 +539,7 @@
         d.setFilter( QDir::Dirs );
         d.setSorting( QDir::Name );
 	
-        for ( int i = 0; i < d.count(); i++ )
+        for ( uint i = 0; i < d.count(); i++ )
         {
 	    QFile file( "/PCBSD/Components/" + d[i] + "/component.cfg" );
 	    if ( file.open( IO_ReadOnly ) ) {



More information about the Commits mailing list